repo_name
string
path
string
copies
string
size
string
content
string
license
string
Arc-Team/android_kernel_htc_holiday
drivers/regulator/virtual.c
3955
9080
/* * reg-virtual-consumer.c * * Copyright 2008 Wolfson Microelectronics PLC. * * Author: Mark Brown <broonie@opensource.wolfsonmicro.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. */ #include <linux/err.h> #include <linux/mutex.h> #include <linux/platform_device.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> struct virtual_consumer_data { struct mutex lock; struct regulator *regulator; bool enabled; int min_uV; int max_uV; int min_uA; int max_uA; unsigned int mode; }; static void update_voltage_constraints(struct device *dev, struct virtual_consumer_data *data) { int ret; if (data->min_uV && data->max_uV && data->min_uV <= data->max_uV) { dev_dbg(dev, "Requesting %d-%duV\n", data->min_uV, data->max_uV); ret = regulator_set_voltage(data->regulator, data->min_uV, data->max_uV); if (ret != 0) { dev_err(dev, "regulator_set_voltage() failed: %d\n", ret); return; } } if (data->min_uV && data->max_uV && !data->enabled) { dev_dbg(dev, "Enabling regulator\n"); ret = regulator_enable(data->regulator); if (ret == 0) data->enabled = true; else dev_err(dev, "regulator_enable() failed: %d\n", ret); } if (!(data->min_uV && data->max_uV) && data->enabled) { dev_dbg(dev, "Disabling regulator\n"); ret = regulator_disable(data->regulator); if (ret == 0) data->enabled = false; else dev_err(dev, "regulator_disable() failed: %d\n", ret); } } static void update_current_limit_constraints(struct device *dev, struct virtual_consumer_data *data) { int ret; if (data->max_uA && data->min_uA <= data->max_uA) { dev_dbg(dev, "Requesting %d-%duA\n", data->min_uA, data->max_uA); ret = regulator_set_current_limit(data->regulator, data->min_uA, data->max_uA); if (ret != 0) { dev_err(dev, "regulator_set_current_limit() failed: %d\n", ret); return; } } if (data->max_uA && !data->enabled) { dev_dbg(dev, "Enabling regulator\n"); ret = regulator_enable(data->regulator); if (ret == 0) data->enabled = true; else dev_err(dev, "regulator_enable() failed: %d\n", ret); } if (!(data->min_uA && data->max_uA) && data->enabled) { dev_dbg(dev, "Disabling regulator\n"); ret = regulator_disable(data->regulator); if (ret == 0) data->enabled = false; else dev_err(dev, "regulator_disable() failed: %d\n", ret); } } static ssize_t show_min_uV(struct device *dev, struct device_attribute *attr, char *buf) { struct virtual_consumer_data *data = dev_get_drvdata(dev); return sprintf(buf, "%d\n", data->min_uV); } static ssize_t set_min_uV(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct virtual_consumer_data *data = dev_get_drvdata(dev); long val; if (strict_strtol(buf, 10, &val) != 0) return count; mutex_lock(&data->lock); data->min_uV = val; update_voltage_constraints(dev, data); mutex_unlock(&data->lock); return count; } static ssize_t show_max_uV(struct device *dev, struct device_attribute *attr, char *buf) { struct virtual_consumer_data *data = dev_get_drvdata(dev); return sprintf(buf, "%d\n", data->max_uV); } static ssize_t set_max_uV(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct virtual_consumer_data *data = dev_get_drvdata(dev); long val; if (strict_strtol(buf, 10, &val) != 0) return count; mutex_lock(&data->lock); data->max_uV = val; update_voltage_constraints(dev, data); mutex_unlock(&data->lock); return count; } static ssize_t show_min_uA(struct device *dev, struct device_attribute *attr, char *buf) { struct virtual_consumer_data *data = dev_get_drvdata(dev); return sprintf(buf, "%d\n", data->min_uA); } static ssize_t set_min_uA(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct virtual_consumer_data *data = dev_get_drvdata(dev); long val; if (strict_strtol(buf, 10, &val) != 0) return count; mutex_lock(&data->lock); data->min_uA = val; update_current_limit_constraints(dev, data); mutex_unlock(&data->lock); return count; } static ssize_t show_max_uA(struct device *dev, struct device_attribute *attr, char *buf) { struct virtual_consumer_data *data = dev_get_drvdata(dev); return sprintf(buf, "%d\n", data->max_uA); } static ssize_t set_max_uA(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct virtual_consumer_data *data = dev_get_drvdata(dev); long val; if (strict_strtol(buf, 10, &val) != 0) return count; mutex_lock(&data->lock); data->max_uA = val; update_current_limit_constraints(dev, data); mutex_unlock(&data->lock); return count; } static ssize_t show_mode(struct device *dev, struct device_attribute *attr, char *buf) { struct virtual_consumer_data *data = dev_get_drvdata(dev); switch (data->mode) { case REGULATOR_MODE_FAST: return sprintf(buf, "fast\n"); case REGULATOR_MODE_NORMAL: return sprintf(buf, "normal\n"); case REGULATOR_MODE_IDLE: return sprintf(buf, "idle\n"); case REGULATOR_MODE_STANDBY: return sprintf(buf, "standby\n"); default: return sprintf(buf, "unknown\n"); } } static ssize_t set_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct virtual_consumer_data *data = dev_get_drvdata(dev); unsigned int mode; int ret; /* * sysfs_streq() doesn't need the \n's, but we add them so the strings * will be shared with show_mode(), above. */ if (sysfs_streq(buf, "fast\n")) mode = REGULATOR_MODE_FAST; else if (sysfs_streq(buf, "normal\n")) mode = REGULATOR_MODE_NORMAL; else if (sysfs_streq(buf, "idle\n")) mode = REGULATOR_MODE_IDLE; else if (sysfs_streq(buf, "standby\n")) mode = REGULATOR_MODE_STANDBY; else { dev_err(dev, "Configuring invalid mode\n"); return count; } mutex_lock(&data->lock); ret = regulator_set_mode(data->regulator, mode); if (ret == 0) data->mode = mode; else dev_err(dev, "Failed to configure mode: %d\n", ret); mutex_unlock(&data->lock); return count; } static DEVICE_ATTR(min_microvolts, 0666, show_min_uV, set_min_uV); static DEVICE_ATTR(max_microvolts, 0666, show_max_uV, set_max_uV); static DEVICE_ATTR(min_microamps, 0666, show_min_uA, set_min_uA); static DEVICE_ATTR(max_microamps, 0666, show_max_uA, set_max_uA); static DEVICE_ATTR(mode, 0666, show_mode, set_mode); static struct attribute *regulator_virtual_attributes[] = { &dev_attr_min_microvolts.attr, &dev_attr_max_microvolts.attr, &dev_attr_min_microamps.attr, &dev_attr_max_microamps.attr, &dev_attr_mode.attr, NULL }; static const struct attribute_group regulator_virtual_attr_group = { .attrs = regulator_virtual_attributes, }; static int __devinit regulator_virtual_probe(struct platform_device *pdev) { char *reg_id = pdev->dev.platform_data; struct virtual_consumer_data *drvdata; int ret; drvdata = kzalloc(sizeof(struct virtual_consumer_data), GFP_KERNEL); if (drvdata == NULL) return -ENOMEM; mutex_init(&drvdata->lock); drvdata->regulator = regulator_get(&pdev->dev, reg_id); if (IS_ERR(drvdata->regulator)) { ret = PTR_ERR(drvdata->regulator); dev_err(&pdev->dev, "Failed to obtain supply '%s': %d\n", reg_id, ret); goto err; } ret = sysfs_create_group(&pdev->dev.kobj, &regulator_virtual_attr_group); if (ret != 0) { dev_err(&pdev->dev, "Failed to create attribute group: %d\n", ret); goto err_regulator; } drvdata->mode = regulator_get_mode(drvdata->regulator); platform_set_drvdata(pdev, drvdata); return 0; err_regulator: regulator_put(drvdata->regulator); err: kfree(drvdata); return ret; } static int __devexit regulator_virtual_remove(struct platform_device *pdev) { struct virtual_consumer_data *drvdata = platform_get_drvdata(pdev); sysfs_remove_group(&pdev->dev.kobj, &regulator_virtual_attr_group); if (drvdata->enabled) regulator_disable(drvdata->regulator); regulator_put(drvdata->regulator); kfree(drvdata); platform_set_drvdata(pdev, NULL); return 0; } static struct platform_driver regulator_virtual_consumer_driver = { .probe = regulator_virtual_probe, .remove = __devexit_p(regulator_virtual_remove), .driver = { .name = "reg-virt-consumer", .owner = THIS_MODULE, }, }; static int __init regulator_virtual_consumer_init(void) { return platform_driver_register(&regulator_virtual_consumer_driver); } module_init(regulator_virtual_consumer_init); static void __exit regulator_virtual_consumer_exit(void) { platform_driver_unregister(&regulator_virtual_consumer_driver); } module_exit(regulator_virtual_consumer_exit); MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); MODULE_DESCRIPTION("Virtual regulator consumer"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:reg-virt-consumer");
gpl-2.0
cuzz1369/android_kernel_lge_g3
fs/eventfd.c
4467
11232
/* * fs/eventfd.c * * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org> * */ #include <linux/file.h> #include <linux/poll.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/sched.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/list.h> #include <linux/spinlock.h> #include <linux/anon_inodes.h> #include <linux/syscalls.h> #include <linux/export.h> #include <linux/kref.h> #include <linux/eventfd.h> struct eventfd_ctx { struct kref kref; wait_queue_head_t wqh; /* * Every time that a write(2) is performed on an eventfd, the * value of the __u64 being written is added to "count" and a * wakeup is performed on "wqh". A read(2) will return the "count" * value to userspace, and will reset "count" to zero. The kernel * side eventfd_signal() also, adds to the "count" counter and * issue a wakeup. */ __u64 count; unsigned int flags; }; /** * eventfd_signal - Adds @n to the eventfd counter. * @ctx: [in] Pointer to the eventfd context. * @n: [in] Value of the counter to be added to the eventfd internal counter. * The value cannot be negative. * * This function is supposed to be called by the kernel in paths that do not * allow sleeping. In this function we allow the counter to reach the ULLONG_MAX * value, and we signal this as overflow condition by returining a POLLERR * to poll(2). * * Returns @n in case of success, a non-negative number lower than @n in case * of overflow, or the following error codes: * * -EINVAL : The value of @n is negative. */ int eventfd_signal(struct eventfd_ctx *ctx, int n) { unsigned long flags; if (n < 0) return -EINVAL; spin_lock_irqsave(&ctx->wqh.lock, flags); if (ULLONG_MAX - ctx->count < n) n = (int) (ULLONG_MAX - ctx->count); ctx->count += n; if (waitqueue_active(&ctx->wqh)) wake_up_locked_poll(&ctx->wqh, POLLIN); spin_unlock_irqrestore(&ctx->wqh.lock, flags); return n; } EXPORT_SYMBOL_GPL(eventfd_signal); static void eventfd_free_ctx(struct eventfd_ctx *ctx) { kfree(ctx); } static void eventfd_free(struct kref *kref) { struct eventfd_ctx *ctx = container_of(kref, struct eventfd_ctx, kref); eventfd_free_ctx(ctx); } /** * eventfd_ctx_get - Acquires a reference to the internal eventfd context. * @ctx: [in] Pointer to the eventfd context. * * Returns: In case of success, returns a pointer to the eventfd context. */ struct eventfd_ctx *eventfd_ctx_get(struct eventfd_ctx *ctx) { kref_get(&ctx->kref); return ctx; } EXPORT_SYMBOL_GPL(eventfd_ctx_get); /** * eventfd_ctx_put - Releases a reference to the internal eventfd context. * @ctx: [in] Pointer to eventfd context. * * The eventfd context reference must have been previously acquired either * with eventfd_ctx_get() or eventfd_ctx_fdget(). */ void eventfd_ctx_put(struct eventfd_ctx *ctx) { kref_put(&ctx->kref, eventfd_free); } EXPORT_SYMBOL_GPL(eventfd_ctx_put); static int eventfd_release(struct inode *inode, struct file *file) { struct eventfd_ctx *ctx = file->private_data; wake_up_poll(&ctx->wqh, POLLHUP); eventfd_ctx_put(ctx); return 0; } static unsigned int eventfd_poll(struct file *file, poll_table *wait) { struct eventfd_ctx *ctx = file->private_data; unsigned int events = 0; unsigned long flags; poll_wait(file, &ctx->wqh, wait); spin_lock_irqsave(&ctx->wqh.lock, flags); if (ctx->count > 0) events |= POLLIN; if (ctx->count == ULLONG_MAX) events |= POLLERR; if (ULLONG_MAX - 1 > ctx->count) events |= POLLOUT; spin_unlock_irqrestore(&ctx->wqh.lock, flags); return events; } static void eventfd_ctx_do_read(struct eventfd_ctx *ctx, __u64 *cnt) { *cnt = (ctx->flags & EFD_SEMAPHORE) ? 1 : ctx->count; ctx->count -= *cnt; } /** * eventfd_ctx_remove_wait_queue - Read the current counter and removes wait queue. * @ctx: [in] Pointer to eventfd context. * @wait: [in] Wait queue to be removed. * @cnt: [out] Pointer to the 64-bit counter value. * * Returns %0 if successful, or the following error codes: * * -EAGAIN : The operation would have blocked. * * This is used to atomically remove a wait queue entry from the eventfd wait * queue head, and read/reset the counter value. */ int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait, __u64 *cnt) { unsigned long flags; spin_lock_irqsave(&ctx->wqh.lock, flags); eventfd_ctx_do_read(ctx, cnt); __remove_wait_queue(&ctx->wqh, wait); if (*cnt != 0 && waitqueue_active(&ctx->wqh)) wake_up_locked_poll(&ctx->wqh, POLLOUT); spin_unlock_irqrestore(&ctx->wqh.lock, flags); return *cnt != 0 ? 0 : -EAGAIN; } EXPORT_SYMBOL_GPL(eventfd_ctx_remove_wait_queue); /** * eventfd_ctx_read - Reads the eventfd counter or wait if it is zero. * @ctx: [in] Pointer to eventfd context. * @no_wait: [in] Different from zero if the operation should not block. * @cnt: [out] Pointer to the 64-bit counter value. * * Returns %0 if successful, or the following error codes: * * -EAGAIN : The operation would have blocked but @no_wait was non-zero. * -ERESTARTSYS : A signal interrupted the wait operation. * * If @no_wait is zero, the function might sleep until the eventfd internal * counter becomes greater than zero. */ ssize_t eventfd_ctx_read(struct eventfd_ctx *ctx, int no_wait, __u64 *cnt) { ssize_t res; DECLARE_WAITQUEUE(wait, current); spin_lock_irq(&ctx->wqh.lock); *cnt = 0; res = -EAGAIN; if (ctx->count > 0) res = 0; else if (!no_wait) { __add_wait_queue(&ctx->wqh, &wait); for (;;) { set_current_state(TASK_INTERRUPTIBLE); if (ctx->count > 0) { res = 0; break; } if (signal_pending(current)) { res = -ERESTARTSYS; break; } spin_unlock_irq(&ctx->wqh.lock); schedule(); spin_lock_irq(&ctx->wqh.lock); } __remove_wait_queue(&ctx->wqh, &wait); __set_current_state(TASK_RUNNING); } if (likely(res == 0)) { eventfd_ctx_do_read(ctx, cnt); if (waitqueue_active(&ctx->wqh)) wake_up_locked_poll(&ctx->wqh, POLLOUT); } spin_unlock_irq(&ctx->wqh.lock); return res; } EXPORT_SYMBOL_GPL(eventfd_ctx_read); static ssize_t eventfd_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct eventfd_ctx *ctx = file->private_data; ssize_t res; __u64 cnt; if (count < sizeof(cnt)) return -EINVAL; res = eventfd_ctx_read(ctx, file->f_flags & O_NONBLOCK, &cnt); if (res < 0) return res; return put_user(cnt, (__u64 __user *) buf) ? -EFAULT : sizeof(cnt); } static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct eventfd_ctx *ctx = file->private_data; ssize_t res; __u64 ucnt; DECLARE_WAITQUEUE(wait, current); if (count < sizeof(ucnt)) return -EINVAL; if (copy_from_user(&ucnt, buf, sizeof(ucnt))) return -EFAULT; if (ucnt == ULLONG_MAX) return -EINVAL; spin_lock_irq(&ctx->wqh.lock); res = -EAGAIN; if (ULLONG_MAX - ctx->count > ucnt) res = sizeof(ucnt); else if (!(file->f_flags & O_NONBLOCK)) { __add_wait_queue(&ctx->wqh, &wait); for (res = 0;;) { set_current_state(TASK_INTERRUPTIBLE); if (ULLONG_MAX - ctx->count > ucnt) { res = sizeof(ucnt); break; } if (signal_pending(current)) { res = -ERESTARTSYS; break; } spin_unlock_irq(&ctx->wqh.lock); schedule(); spin_lock_irq(&ctx->wqh.lock); } __remove_wait_queue(&ctx->wqh, &wait); __set_current_state(TASK_RUNNING); } if (likely(res > 0)) { ctx->count += ucnt; if (waitqueue_active(&ctx->wqh)) wake_up_locked_poll(&ctx->wqh, POLLIN); } spin_unlock_irq(&ctx->wqh.lock); return res; } static const struct file_operations eventfd_fops = { .release = eventfd_release, .poll = eventfd_poll, .read = eventfd_read, .write = eventfd_write, .llseek = noop_llseek, }; /** * eventfd_fget - Acquire a reference of an eventfd file descriptor. * @fd: [in] Eventfd file descriptor. * * Returns a pointer to the eventfd file structure in case of success, or the * following error pointer: * * -EBADF : Invalid @fd file descriptor. * -EINVAL : The @fd file descriptor is not an eventfd file. */ struct file *eventfd_fget(int fd) { struct file *file; file = fget(fd); if (!file) return ERR_PTR(-EBADF); if (file->f_op != &eventfd_fops) { fput(file); return ERR_PTR(-EINVAL); } return file; } EXPORT_SYMBOL_GPL(eventfd_fget); /** * eventfd_ctx_fdget - Acquires a reference to the internal eventfd context. * @fd: [in] Eventfd file descriptor. * * Returns a pointer to the internal eventfd context, otherwise the error * pointers returned by the following functions: * * eventfd_fget */ struct eventfd_ctx *eventfd_ctx_fdget(int fd) { struct file *file; struct eventfd_ctx *ctx; file = eventfd_fget(fd); if (IS_ERR(file)) return (struct eventfd_ctx *) file; ctx = eventfd_ctx_get(file->private_data); fput(file); return ctx; } EXPORT_SYMBOL_GPL(eventfd_ctx_fdget); /** * eventfd_ctx_fileget - Acquires a reference to the internal eventfd context. * @file: [in] Eventfd file pointer. * * Returns a pointer to the internal eventfd context, otherwise the error * pointer: * * -EINVAL : The @fd file descriptor is not an eventfd file. */ struct eventfd_ctx *eventfd_ctx_fileget(struct file *file) { if (file->f_op != &eventfd_fops) return ERR_PTR(-EINVAL); return eventfd_ctx_get(file->private_data); } EXPORT_SYMBOL_GPL(eventfd_ctx_fileget); /** * eventfd_file_create - Creates an eventfd file pointer. * @count: Initial eventfd counter value. * @flags: Flags for the eventfd file. * * This function creates an eventfd file pointer, w/out installing it into * the fd table. This is useful when the eventfd file is used during the * initialization of data structures that require extra setup after the eventfd * creation. So the eventfd creation is split into the file pointer creation * phase, and the file descriptor installation phase. * In this way races with userspace closing the newly installed file descriptor * can be avoided. * Returns an eventfd file pointer, or a proper error pointer. */ struct file *eventfd_file_create(unsigned int count, int flags) { struct file *file; struct eventfd_ctx *ctx; /* Check the EFD_* constants for consistency. */ BUILD_BUG_ON(EFD_CLOEXEC != O_CLOEXEC); BUILD_BUG_ON(EFD_NONBLOCK != O_NONBLOCK); if (flags & ~EFD_FLAGS_SET) return ERR_PTR(-EINVAL); ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return ERR_PTR(-ENOMEM); kref_init(&ctx->kref); init_waitqueue_head(&ctx->wqh); ctx->count = count; ctx->flags = flags; file = anon_inode_getfile("[eventfd]", &eventfd_fops, ctx, O_RDWR | (flags & EFD_SHARED_FCNTL_FLAGS)); if (IS_ERR(file)) eventfd_free_ctx(ctx); return file; } SYSCALL_DEFINE2(eventfd2, unsigned int, count, int, flags) { int fd, error; struct file *file; error = get_unused_fd_flags(flags & EFD_SHARED_FCNTL_FLAGS); if (error < 0) return error; fd = error; file = eventfd_file_create(count, flags); if (IS_ERR(file)) { error = PTR_ERR(file); goto err_put_unused_fd; } fd_install(fd, file); return fd; err_put_unused_fd: put_unused_fd(fd); return error; } SYSCALL_DEFINE1(eventfd, unsigned int, count) { return sys_eventfd2(count, 0); }
gpl-2.0
TeamApexQ/android_kernel_samsung_d2
arch/arm/mach-ixp2000/ixdp2x01.c
4723
12747
/* * arch/arm/mach-ixp2000/ixdp2x01.c * * Code common to Intel IXDP2401 and IXDP2801 platforms * * Original Author: Andrzej Mialkowski <andrzej.mialkowski@intel.com> * Maintainer: Deepak Saxena <dsaxena@plexity.net> * * Copyright (C) 2002-2003 Intel Corp. * Copyright (C) 2003-2004 MontaVista Software, Inc. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/mm.h> #include <linux/sched.h> #include <linux/interrupt.h> #include <linux/bitops.h> #include <linux/pci.h> #include <linux/ioport.h> #include <linux/delay.h> #include <linux/serial.h> #include <linux/tty.h> #include <linux/serial_core.h> #include <linux/platform_device.h> #include <linux/serial_8250.h> #include <linux/io.h> #include <asm/irq.h> #include <asm/pgtable.h> #include <asm/page.h> #include <mach/hardware.h> #include <asm/mach-types.h> #include <asm/mach/pci.h> #include <asm/mach/map.h> #include <asm/mach/irq.h> #include <asm/mach/time.h> #include <asm/mach/arch.h> #include <asm/mach/flash.h> /************************************************************************* * IXDP2x01 IRQ Handling *************************************************************************/ static void ixdp2x01_irq_mask(struct irq_data *d) { ixp2000_reg_wrb(IXDP2X01_INT_MASK_SET_REG, IXP2000_BOARD_IRQ_MASK(d->irq)); } static void ixdp2x01_irq_unmask(struct irq_data *d) { ixp2000_reg_write(IXDP2X01_INT_MASK_CLR_REG, IXP2000_BOARD_IRQ_MASK(d->irq)); } static u32 valid_irq_mask; static void ixdp2x01_irq_handler(unsigned int irq, struct irq_desc *desc) { u32 ex_interrupt; int i; desc->irq_data.chip->irq_mask(&desc->irq_data); ex_interrupt = *IXDP2X01_INT_STAT_REG & valid_irq_mask; if (!ex_interrupt) { printk(KERN_ERR "Spurious IXDP2X01 CPLD interrupt!\n"); return; } for (i = 0; i < IXP2000_BOARD_IRQS; i++) { if (ex_interrupt & (1 << i)) { int cpld_irq = IXP2000_BOARD_IRQ(0) + i; generic_handle_irq(cpld_irq); } } desc->irq_data.chip->irq_unmask(&desc->irq_data); } static struct irq_chip ixdp2x01_irq_chip = { .irq_mask = ixdp2x01_irq_mask, .irq_ack = ixdp2x01_irq_mask, .irq_unmask = ixdp2x01_irq_unmask }; /* * We only do anything if we are the master NPU on the board. * The slave NPU only has the ethernet chip going directly to * the PCIB interrupt input. */ void __init ixdp2x01_init_irq(void) { int irq = 0; /* initialize chip specific interrupts */ ixp2000_init_irq(); if (machine_is_ixdp2401()) valid_irq_mask = IXDP2401_VALID_IRQ_MASK; else valid_irq_mask = IXDP2801_VALID_IRQ_MASK; /* Mask all interrupts from CPLD, disable simulation */ ixp2000_reg_write(IXDP2X01_INT_MASK_SET_REG, 0xffffffff); ixp2000_reg_wrb(IXDP2X01_INT_SIM_REG, 0); for (irq = NR_IXP2000_IRQS; irq < NR_IXDP2X01_IRQS; irq++) { if (irq & valid_irq_mask) { irq_set_chip_and_handler(irq, &ixdp2x01_irq_chip, handle_level_irq); set_irq_flags(irq, IRQF_VALID); } else { set_irq_flags(irq, 0); } } /* Hook into PCI interrupts */ irq_set_chained_handler(IRQ_IXP2000_PCIB, ixdp2x01_irq_handler); } /************************************************************************* * IXDP2x01 memory map *************************************************************************/ static struct map_desc ixdp2x01_io_desc __initdata = { .virtual = IXDP2X01_VIRT_CPLD_BASE, .pfn = __phys_to_pfn(IXDP2X01_PHYS_CPLD_BASE), .length = IXDP2X01_CPLD_REGION_SIZE, .type = MT_DEVICE }; static void __init ixdp2x01_map_io(void) { ixp2000_map_io(); iotable_init(&ixdp2x01_io_desc, 1); } /************************************************************************* * IXDP2x01 serial ports *************************************************************************/ static struct plat_serial8250_port ixdp2x01_serial_port1[] = { { .mapbase = (unsigned long)IXDP2X01_UART1_PHYS_BASE, .membase = (char *)IXDP2X01_UART1_VIRT_BASE, .irq = IRQ_IXDP2X01_UART1, .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, .iotype = UPIO_MEM32, .regshift = 2, .uartclk = IXDP2X01_UART_CLK, }, { } }; static struct resource ixdp2x01_uart_resource1 = { .start = IXDP2X01_UART1_PHYS_BASE, .end = IXDP2X01_UART1_PHYS_BASE + 0xffff, .flags = IORESOURCE_MEM, }; static struct platform_device ixdp2x01_serial_device1 = { .name = "serial8250", .id = PLAT8250_DEV_PLATFORM1, .dev = { .platform_data = ixdp2x01_serial_port1, }, .num_resources = 1, .resource = &ixdp2x01_uart_resource1, }; static struct plat_serial8250_port ixdp2x01_serial_port2[] = { { .mapbase = (unsigned long)IXDP2X01_UART2_PHYS_BASE, .membase = (char *)IXDP2X01_UART2_VIRT_BASE, .irq = IRQ_IXDP2X01_UART2, .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, .iotype = UPIO_MEM32, .regshift = 2, .uartclk = IXDP2X01_UART_CLK, }, { } }; static struct resource ixdp2x01_uart_resource2 = { .start = IXDP2X01_UART2_PHYS_BASE, .end = IXDP2X01_UART2_PHYS_BASE + 0xffff, .flags = IORESOURCE_MEM, }; static struct platform_device ixdp2x01_serial_device2 = { .name = "serial8250", .id = PLAT8250_DEV_PLATFORM2, .dev = { .platform_data = ixdp2x01_serial_port2, }, .num_resources = 1, .resource = &ixdp2x01_uart_resource2, }; static void ixdp2x01_uart_init(void) { platform_device_register(&ixdp2x01_serial_device1); platform_device_register(&ixdp2x01_serial_device2); } /************************************************************************* * IXDP2x01 timer tick configuration *************************************************************************/ static unsigned int ixdp2x01_clock; static int __init ixdp2x01_clock_setup(char *str) { ixdp2x01_clock = simple_strtoul(str, NULL, 10); return 1; } __setup("ixdp2x01_clock=", ixdp2x01_clock_setup); static void __init ixdp2x01_timer_init(void) { if (!ixdp2x01_clock) ixdp2x01_clock = 50000000; ixp2000_init_time(ixdp2x01_clock); } static struct sys_timer ixdp2x01_timer = { .init = ixdp2x01_timer_init, .offset = ixp2000_gettimeoffset, }; /************************************************************************* * IXDP2x01 PCI *************************************************************************/ void __init ixdp2x01_pci_preinit(void) { ixp2000_reg_write(IXP2000_PCI_ADDR_EXT, 0x00000000); ixp2000_pci_preinit(); pcibios_setup("firmware"); } #define DEVPIN(dev, pin) ((pin) | ((dev) << 3)) static int __init ixdp2x01_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { u8 bus = dev->bus->number; u32 devpin = DEVPIN(PCI_SLOT(dev->devfn), pin); struct pci_bus *tmp_bus = dev->bus; /* Primary bus, no interrupts here */ if (bus == 0) { return -1; } /* Lookup first leaf in bus tree */ while ((tmp_bus->parent != NULL) && (tmp_bus->parent->parent != NULL)) { tmp_bus = tmp_bus->parent; } /* Select between known bridges */ switch (tmp_bus->self->devfn | (tmp_bus->self->bus->number << 8)) { /* Device is located after first MB bridge */ case 0x0008: if (tmp_bus == dev->bus) { /* Device is located directly after first MB bridge */ switch (devpin) { case DEVPIN(1, 1): /* Onboard 82546 ch 0 */ if (machine_is_ixdp2401()) return IRQ_IXDP2401_INTA_82546; return -1; case DEVPIN(1, 2): /* Onboard 82546 ch 1 */ if (machine_is_ixdp2401()) return IRQ_IXDP2401_INTB_82546; return -1; case DEVPIN(0, 1): /* PMC INTA# */ return IRQ_IXDP2X01_SPCI_PMC_INTA; case DEVPIN(0, 2): /* PMC INTB# */ return IRQ_IXDP2X01_SPCI_PMC_INTB; case DEVPIN(0, 3): /* PMC INTC# */ return IRQ_IXDP2X01_SPCI_PMC_INTC; case DEVPIN(0, 4): /* PMC INTD# */ return IRQ_IXDP2X01_SPCI_PMC_INTD; } } break; case 0x0010: if (tmp_bus == dev->bus) { /* Device is located directly after second MB bridge */ /* Secondary bus of second bridge */ switch (devpin) { case DEVPIN(0, 1): /* DB#0 */ return IRQ_IXDP2X01_SPCI_DB_0; case DEVPIN(1, 1): /* DB#1 */ return IRQ_IXDP2X01_SPCI_DB_1; } } else { /* Device is located indirectly after second MB bridge */ /* Not supported now */ } break; } return -1; } static int ixdp2x01_pci_setup(int nr, struct pci_sys_data *sys) { sys->mem_offset = 0xe0000000; if (machine_is_ixdp2801() || machine_is_ixdp28x5()) sys->mem_offset -= ((*IXP2000_PCI_ADDR_EXT & 0xE000) << 16); return ixp2000_pci_setup(nr, sys); } struct hw_pci ixdp2x01_pci __initdata = { .nr_controllers = 1, .setup = ixdp2x01_pci_setup, .preinit = ixdp2x01_pci_preinit, .scan = ixp2000_pci_scan_bus, .map_irq = ixdp2x01_pci_map_irq, }; int __init ixdp2x01_pci_init(void) { if (machine_is_ixdp2401() || machine_is_ixdp2801() ||\ machine_is_ixdp28x5()) pci_common_init(&ixdp2x01_pci); return 0; } subsys_initcall(ixdp2x01_pci_init); /************************************************************************* * IXDP2x01 Machine Initialization *************************************************************************/ static struct flash_platform_data ixdp2x01_flash_platform_data = { .map_name = "cfi_probe", .width = 1, }; static unsigned long ixdp2x01_flash_bank_setup(unsigned long ofs) { ixp2000_reg_wrb(IXDP2X01_CPLD_FLASH_REG, ((ofs >> IXDP2X01_FLASH_WINDOW_BITS) | IXDP2X01_CPLD_FLASH_INTERN)); return (ofs & IXDP2X01_FLASH_WINDOW_MASK); } static struct ixp2000_flash_data ixdp2x01_flash_data = { .platform_data = &ixdp2x01_flash_platform_data, .bank_setup = ixdp2x01_flash_bank_setup }; static struct resource ixdp2x01_flash_resource = { .start = 0xc4000000, .end = 0xc4000000 + 0x01ffffff, .flags = IORESOURCE_MEM, }; static struct platform_device ixdp2x01_flash = { .name = "IXP2000-Flash", .id = 0, .dev = { .platform_data = &ixdp2x01_flash_data, }, .num_resources = 1, .resource = &ixdp2x01_flash_resource, }; static struct ixp2000_i2c_pins ixdp2x01_i2c_gpio_pins = { .sda_pin = IXDP2X01_GPIO_SDA, .scl_pin = IXDP2X01_GPIO_SCL, }; static struct platform_device ixdp2x01_i2c_controller = { .name = "IXP2000-I2C", .id = 0, .dev = { .platform_data = &ixdp2x01_i2c_gpio_pins, }, .num_resources = 0 }; static struct platform_device *ixdp2x01_devices[] __initdata = { &ixdp2x01_flash, &ixdp2x01_i2c_controller }; static void __init ixdp2x01_init_machine(void) { ixp2000_reg_wrb(IXDP2X01_CPLD_FLASH_REG, (IXDP2X01_CPLD_FLASH_BANK_MASK | IXDP2X01_CPLD_FLASH_INTERN)); ixdp2x01_flash_data.nr_banks = ((*IXDP2X01_CPLD_FLASH_REG & IXDP2X01_CPLD_FLASH_BANK_MASK) + 1); platform_add_devices(ixdp2x01_devices, ARRAY_SIZE(ixdp2x01_devices)); ixp2000_uart_init(); ixdp2x01_uart_init(); } static void ixdp2401_restart(char mode, const char *cmd) { /* * Reset flash banking register so that we are pointing at * RedBoot bank. */ ixp2000_reg_write(IXDP2X01_CPLD_FLASH_REG, ((0 >> IXDP2X01_FLASH_WINDOW_BITS) | IXDP2X01_CPLD_FLASH_INTERN)); ixp2000_reg_wrb(IXDP2X01_CPLD_RESET_REG, 0xffffffff); ixp2000_restart(mode, cmd); } static void ixdp280x_restart(char mode, const char *cmd) { /* * On IXDP2801 we need to write this magic sequence to the CPLD * to cause a complete reset of the CPU and all external devices * and move the flash bank register back to 0. */ unsigned long reset_reg = *IXDP2X01_CPLD_RESET_REG; reset_reg = 0x55AA0000 | (reset_reg & 0x0000FFFF); ixp2000_reg_write(IXDP2X01_CPLD_RESET_REG, reset_reg); ixp2000_reg_wrb(IXDP2X01_CPLD_RESET_REG, 0x80000000); ixp2000_restart(mode, cmd); } #ifdef CONFIG_ARCH_IXDP2401 MACHINE_START(IXDP2401, "Intel IXDP2401 Development Platform") /* Maintainer: MontaVista Software, Inc. */ .atag_offset = 0x100, .map_io = ixdp2x01_map_io, .init_irq = ixdp2x01_init_irq, .timer = &ixdp2x01_timer, .init_machine = ixdp2x01_init_machine, .restart = ixdp2401_restart, MACHINE_END #endif #ifdef CONFIG_ARCH_IXDP2801 MACHINE_START(IXDP2801, "Intel IXDP2801 Development Platform") /* Maintainer: MontaVista Software, Inc. */ .atag_offset = 0x100, .map_io = ixdp2x01_map_io, .init_irq = ixdp2x01_init_irq, .timer = &ixdp2x01_timer, .init_machine = ixdp2x01_init_machine, .restart = ixdp280x_restart, MACHINE_END /* * IXDP28x5 is basically an IXDP2801 with a different CPU but Intel * changed the machine ID in the bootloader */ MACHINE_START(IXDP28X5, "Intel IXDP2805/2855 Development Platform") /* Maintainer: MontaVista Software, Inc. */ .atag_offset = 0x100, .map_io = ixdp2x01_map_io, .init_irq = ixdp2x01_init_irq, .timer = &ixdp2x01_timer, .init_machine = ixdp2x01_init_machine, .restart = ixdp280x_restart, MACHINE_END #endif
gpl-2.0
ecostaalfaia/linux-sunxi-3.4_aufs_support
drivers/usb/gadget/net2280.c
4979
76768
/* * Driver for the PLX NET2280 USB device controller. * Specs and errata are available from <http://www.plxtech.com>. * * PLX Technology Inc. (formerly NetChip Technology) supported the * development of this driver. * * * CODE STATUS HIGHLIGHTS * * This driver should work well with most "gadget" drivers, including * the File Storage, Serial, and Ethernet/RNDIS gadget drivers * as well as Gadget Zero and Gadgetfs. * * DMA is enabled by default. Drivers using transfer queues might use * DMA chaining to remove IRQ latencies between transfers. (Except when * short OUT transfers happen.) Drivers can use the req->no_interrupt * hint to completely eliminate some IRQs, if a later IRQ is guaranteed * and DMA chaining is enabled. * * Note that almost all the errata workarounds here are only needed for * rev1 chips. Rev1a silicon (0110) fixes almost all of them. */ /* * Copyright (C) 2003 David Brownell * Copyright (C) 2003-2005 PLX Technology, Inc. * * Modified Seth Levy 2005 PLX Technology, Inc. to provide compatibility * with 2282 chip * * 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. */ #undef DEBUG /* messages on error and most fault paths */ #undef VERBOSE /* extra debug messages (success too) */ #include <linux/module.h> #include <linux/pci.h> #include <linux/dma-mapping.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/ioport.h> #include <linux/slab.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/timer.h> #include <linux/list.h> #include <linux/interrupt.h> #include <linux/moduleparam.h> #include <linux/device.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/prefetch.h> #include <asm/byteorder.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/unaligned.h> #define DRIVER_DESC "PLX NET228x USB Peripheral Controller" #define DRIVER_VERSION "2005 Sept 27" #define DMA_ADDR_INVALID (~(dma_addr_t)0) #define EP_DONTUSE 13 /* nonzero */ #define USE_RDK_LEDS /* GPIO pins control three LEDs */ static const char driver_name [] = "net2280"; static const char driver_desc [] = DRIVER_DESC; static const char ep0name [] = "ep0"; static const char *const ep_name [] = { ep0name, "ep-a", "ep-b", "ep-c", "ep-d", "ep-e", "ep-f", }; /* use_dma -- general goodness, fewer interrupts, less cpu load (vs PIO) * use_dma_chaining -- dma descriptor queueing gives even more irq reduction * * The net2280 DMA engines are not tightly integrated with their FIFOs; * not all cases are (yet) handled well in this driver or the silicon. * Some gadget drivers work better with the dma support here than others. * These two parameters let you use PIO or more aggressive DMA. */ static bool use_dma = 1; static bool use_dma_chaining = 0; /* "modprobe net2280 use_dma=n" etc */ module_param (use_dma, bool, S_IRUGO); module_param (use_dma_chaining, bool, S_IRUGO); /* mode 0 == ep-{a,b,c,d} 1K fifo each * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable */ static ushort fifo_mode = 0; /* "modprobe net2280 fifo_mode=1" etc */ module_param (fifo_mode, ushort, 0644); /* enable_suspend -- When enabled, the driver will respond to * USB suspend requests by powering down the NET2280. Otherwise, * USB suspend requests will be ignored. This is acceptable for * self-powered devices */ static bool enable_suspend = 0; /* "modprobe net2280 enable_suspend=1" etc */ module_param (enable_suspend, bool, S_IRUGO); #define DIR_STRING(bAddress) (((bAddress) & USB_DIR_IN) ? "in" : "out") #if defined(CONFIG_USB_GADGET_DEBUG_FILES) || defined (DEBUG) static char *type_string (u8 bmAttributes) { switch ((bmAttributes) & USB_ENDPOINT_XFERTYPE_MASK) { case USB_ENDPOINT_XFER_BULK: return "bulk"; case USB_ENDPOINT_XFER_ISOC: return "iso"; case USB_ENDPOINT_XFER_INT: return "intr"; }; return "control"; } #endif #include "net2280.h" #define valid_bit cpu_to_le32 (1 << VALID_BIT) #define dma_done_ie cpu_to_le32 (1 << DMA_DONE_INTERRUPT_ENABLE) /*-------------------------------------------------------------------------*/ static int net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) { struct net2280 *dev; struct net2280_ep *ep; u32 max, tmp; unsigned long flags; ep = container_of (_ep, struct net2280_ep, ep); if (!_ep || !desc || ep->desc || _ep->name == ep0name || desc->bDescriptorType != USB_DT_ENDPOINT) return -EINVAL; dev = ep->dev; if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) return -ESHUTDOWN; /* erratum 0119 workaround ties up an endpoint number */ if ((desc->bEndpointAddress & 0x0f) == EP_DONTUSE) return -EDOM; /* sanity check ep-e/ep-f since their fifos are small */ max = usb_endpoint_maxp (desc) & 0x1fff; if (ep->num > 4 && max > 64) return -ERANGE; spin_lock_irqsave (&dev->lock, flags); _ep->maxpacket = max & 0x7ff; ep->desc = desc; /* ep_reset() has already been called */ ep->stopped = 0; ep->wedged = 0; ep->out_overflow = 0; /* set speed-dependent max packet; may kick in high bandwidth */ set_idx_reg (dev->regs, REG_EP_MAXPKT (dev, ep->num), max); /* FIFO lines can't go to different packets. PIO is ok, so * use it instead of troublesome (non-bulk) multi-packet DMA. */ if (ep->dma && (max % 4) != 0 && use_dma_chaining) { DEBUG (ep->dev, "%s, no dma for maxpacket %d\n", ep->ep.name, ep->ep.maxpacket); ep->dma = NULL; } /* set type, direction, address; reset fifo counters */ writel ((1 << FIFO_FLUSH), &ep->regs->ep_stat); tmp = (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); if (tmp == USB_ENDPOINT_XFER_INT) { /* erratum 0105 workaround prevents hs NYET */ if (dev->chiprev == 0100 && dev->gadget.speed == USB_SPEED_HIGH && !(desc->bEndpointAddress & USB_DIR_IN)) writel ((1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp); } else if (tmp == USB_ENDPOINT_XFER_BULK) { /* catch some particularly blatant driver bugs */ if ((dev->gadget.speed == USB_SPEED_HIGH && max != 512) || (dev->gadget.speed == USB_SPEED_FULL && max > 64)) { spin_unlock_irqrestore (&dev->lock, flags); return -ERANGE; } } ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0; tmp <<= ENDPOINT_TYPE; tmp |= desc->bEndpointAddress; tmp |= (4 << ENDPOINT_BYTE_COUNT); /* default full fifo lines */ tmp |= 1 << ENDPOINT_ENABLE; wmb (); /* for OUT transfers, block the rx fifo until a read is posted */ ep->is_in = (tmp & USB_DIR_IN) != 0; if (!ep->is_in) writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp); else if (dev->pdev->device != 0x2280) { /* Added for 2282, Don't use nak packets on an in endpoint, * this was ignored on 2280 */ writel ((1 << CLEAR_NAK_OUT_PACKETS) | (1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp); } writel (tmp, &ep->regs->ep_cfg); /* enable irqs */ if (!ep->dma) { /* pio, per-packet */ tmp = (1 << ep->num) | readl (&dev->regs->pciirqenb0); writel (tmp, &dev->regs->pciirqenb0); tmp = (1 << DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE); if (dev->pdev->device == 0x2280) tmp |= readl (&ep->regs->ep_irqenb); writel (tmp, &ep->regs->ep_irqenb); } else { /* dma, per-request */ tmp = (1 << (8 + ep->num)); /* completion */ tmp |= readl (&dev->regs->pciirqenb1); writel (tmp, &dev->regs->pciirqenb1); /* for short OUT transfers, dma completions can't * advance the queue; do it pio-style, by hand. * NOTE erratum 0112 workaround #2 */ if ((desc->bEndpointAddress & USB_DIR_IN) == 0) { tmp = (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE); writel (tmp, &ep->regs->ep_irqenb); tmp = (1 << ep->num) | readl (&dev->regs->pciirqenb0); writel (tmp, &dev->regs->pciirqenb0); } } tmp = desc->bEndpointAddress; DEBUG (dev, "enabled %s (ep%d%s-%s) %s max %04x\n", _ep->name, tmp & 0x0f, DIR_STRING (tmp), type_string (desc->bmAttributes), ep->dma ? "dma" : "pio", max); /* pci writes may still be posted */ spin_unlock_irqrestore (&dev->lock, flags); return 0; } static int handshake (u32 __iomem *ptr, u32 mask, u32 done, int usec) { u32 result; do { result = readl (ptr); if (result == ~(u32)0) /* "device unplugged" */ return -ENODEV; result &= mask; if (result == done) return 0; udelay (1); usec--; } while (usec > 0); return -ETIMEDOUT; } static const struct usb_ep_ops net2280_ep_ops; static void ep_reset (struct net2280_regs __iomem *regs, struct net2280_ep *ep) { u32 tmp; ep->desc = NULL; INIT_LIST_HEAD (&ep->queue); ep->ep.maxpacket = ~0; ep->ep.ops = &net2280_ep_ops; /* disable the dma, irqs, endpoint... */ if (ep->dma) { writel (0, &ep->dma->dmactl); writel ( (1 << DMA_SCATTER_GATHER_DONE_INTERRUPT) | (1 << DMA_TRANSACTION_DONE_INTERRUPT) | (1 << DMA_ABORT) , &ep->dma->dmastat); tmp = readl (&regs->pciirqenb0); tmp &= ~(1 << ep->num); writel (tmp, &regs->pciirqenb0); } else { tmp = readl (&regs->pciirqenb1); tmp &= ~(1 << (8 + ep->num)); /* completion */ writel (tmp, &regs->pciirqenb1); } writel (0, &ep->regs->ep_irqenb); /* init to our chosen defaults, notably so that we NAK OUT * packets until the driver queues a read (+note erratum 0112) */ if (!ep->is_in || ep->dev->pdev->device == 0x2280) { tmp = (1 << SET_NAK_OUT_PACKETS_MODE) | (1 << SET_NAK_OUT_PACKETS) | (1 << CLEAR_EP_HIDE_STATUS_PHASE) | (1 << CLEAR_INTERRUPT_MODE); } else { /* added for 2282 */ tmp = (1 << CLEAR_NAK_OUT_PACKETS_MODE) | (1 << CLEAR_NAK_OUT_PACKETS) | (1 << CLEAR_EP_HIDE_STATUS_PHASE) | (1 << CLEAR_INTERRUPT_MODE); } if (ep->num != 0) { tmp |= (1 << CLEAR_ENDPOINT_TOGGLE) | (1 << CLEAR_ENDPOINT_HALT); } writel (tmp, &ep->regs->ep_rsp); /* scrub most status bits, and flush any fifo state */ if (ep->dev->pdev->device == 0x2280) tmp = (1 << FIFO_OVERFLOW) | (1 << FIFO_UNDERFLOW); else tmp = 0; writel (tmp | (1 << TIMEOUT) | (1 << USB_STALL_SENT) | (1 << USB_IN_NAK_SENT) | (1 << USB_IN_ACK_RCVD) | (1 << USB_OUT_PING_NAK_SENT) | (1 << USB_OUT_ACK_SENT) | (1 << FIFO_FLUSH) | (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) | (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) | (1 << DATA_PACKET_RECEIVED_INTERRUPT) | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) | (1 << DATA_OUT_PING_TOKEN_INTERRUPT) | (1 << DATA_IN_TOKEN_INTERRUPT) , &ep->regs->ep_stat); /* fifo size is handled separately */ } static void nuke (struct net2280_ep *); static int net2280_disable (struct usb_ep *_ep) { struct net2280_ep *ep; unsigned long flags; ep = container_of (_ep, struct net2280_ep, ep); if (!_ep || !ep->desc || _ep->name == ep0name) return -EINVAL; spin_lock_irqsave (&ep->dev->lock, flags); nuke (ep); ep_reset (ep->dev->regs, ep); VDEBUG (ep->dev, "disabled %s %s\n", ep->dma ? "dma" : "pio", _ep->name); /* synch memory views with the device */ (void) readl (&ep->regs->ep_cfg); if (use_dma && !ep->dma && ep->num >= 1 && ep->num <= 4) ep->dma = &ep->dev->dma [ep->num - 1]; spin_unlock_irqrestore (&ep->dev->lock, flags); return 0; } /*-------------------------------------------------------------------------*/ static struct usb_request * net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags) { struct net2280_ep *ep; struct net2280_request *req; if (!_ep) return NULL; ep = container_of (_ep, struct net2280_ep, ep); req = kzalloc(sizeof(*req), gfp_flags); if (!req) return NULL; req->req.dma = DMA_ADDR_INVALID; INIT_LIST_HEAD (&req->queue); /* this dma descriptor may be swapped with the previous dummy */ if (ep->dma) { struct net2280_dma *td; td = pci_pool_alloc (ep->dev->requests, gfp_flags, &req->td_dma); if (!td) { kfree (req); return NULL; } td->dmacount = 0; /* not VALID */ td->dmaaddr = cpu_to_le32 (DMA_ADDR_INVALID); td->dmadesc = td->dmaaddr; req->td = td; } return &req->req; } static void net2280_free_request (struct usb_ep *_ep, struct usb_request *_req) { struct net2280_ep *ep; struct net2280_request *req; ep = container_of (_ep, struct net2280_ep, ep); if (!_ep || !_req) return; req = container_of (_req, struct net2280_request, req); WARN_ON (!list_empty (&req->queue)); if (req->td) pci_pool_free (ep->dev->requests, req->td, req->td_dma); kfree (req); } /*-------------------------------------------------------------------------*/ /* load a packet into the fifo we use for usb IN transfers. * works for all endpoints. * * NOTE: pio with ep-a..ep-d could stuff multiple packets into the fifo * at a time, but this code is simpler because it knows it only writes * one packet. ep-a..ep-d should use dma instead. */ static void write_fifo (struct net2280_ep *ep, struct usb_request *req) { struct net2280_ep_regs __iomem *regs = ep->regs; u8 *buf; u32 tmp; unsigned count, total; /* INVARIANT: fifo is currently empty. (testable) */ if (req) { buf = req->buf + req->actual; prefetch (buf); total = req->length - req->actual; } else { total = 0; buf = NULL; } /* write just one packet at a time */ count = ep->ep.maxpacket; if (count > total) /* min() cannot be used on a bitfield */ count = total; VDEBUG (ep->dev, "write %s fifo (IN) %d bytes%s req %p\n", ep->ep.name, count, (count != ep->ep.maxpacket) ? " (short)" : "", req); while (count >= 4) { /* NOTE be careful if you try to align these. fifo lines * should normally be full (4 bytes) and successive partial * lines are ok only in certain cases. */ tmp = get_unaligned ((u32 *)buf); cpu_to_le32s (&tmp); writel (tmp, &regs->ep_data); buf += 4; count -= 4; } /* last fifo entry is "short" unless we wrote a full packet. * also explicitly validate last word in (periodic) transfers * when maxpacket is not a multiple of 4 bytes. */ if (count || total < ep->ep.maxpacket) { tmp = count ? get_unaligned ((u32 *)buf) : count; cpu_to_le32s (&tmp); set_fifo_bytecount (ep, count & 0x03); writel (tmp, &regs->ep_data); } /* pci writes may still be posted */ } /* work around erratum 0106: PCI and USB race over the OUT fifo. * caller guarantees chiprev 0100, out endpoint is NAKing, and * there's no real data in the fifo. * * NOTE: also used in cases where that erratum doesn't apply: * where the host wrote "too much" data to us. */ static void out_flush (struct net2280_ep *ep) { u32 __iomem *statp; u32 tmp; ASSERT_OUT_NAKING (ep); statp = &ep->regs->ep_stat; writel ( (1 << DATA_OUT_PING_TOKEN_INTERRUPT) | (1 << DATA_PACKET_RECEIVED_INTERRUPT) , statp); writel ((1 << FIFO_FLUSH), statp); mb (); tmp = readl (statp); if (tmp & (1 << DATA_OUT_PING_TOKEN_INTERRUPT) /* high speed did bulk NYET; fifo isn't filling */ && ep->dev->gadget.speed == USB_SPEED_FULL) { unsigned usec; usec = 50; /* 64 byte bulk/interrupt */ handshake (statp, (1 << USB_OUT_PING_NAK_SENT), (1 << USB_OUT_PING_NAK_SENT), usec); /* NAK done; now CLEAR_NAK_OUT_PACKETS is safe */ } } /* unload packet(s) from the fifo we use for usb OUT transfers. * returns true iff the request completed, because of short packet * or the request buffer having filled with full packets. * * for ep-a..ep-d this will read multiple packets out when they * have been accepted. */ static int read_fifo (struct net2280_ep *ep, struct net2280_request *req) { struct net2280_ep_regs __iomem *regs = ep->regs; u8 *buf = req->req.buf + req->req.actual; unsigned count, tmp, is_short; unsigned cleanup = 0, prevent = 0; /* erratum 0106 ... packets coming in during fifo reads might * be incompletely rejected. not all cases have workarounds. */ if (ep->dev->chiprev == 0x0100 && ep->dev->gadget.speed == USB_SPEED_FULL) { udelay (1); tmp = readl (&ep->regs->ep_stat); if ((tmp & (1 << NAK_OUT_PACKETS))) cleanup = 1; else if ((tmp & (1 << FIFO_FULL))) { start_out_naking (ep); prevent = 1; } /* else: hope we don't see the problem */ } /* never overflow the rx buffer. the fifo reads packets until * it sees a short one; we might not be ready for them all. */ prefetchw (buf); count = readl (&regs->ep_avail); if (unlikely (count == 0)) { udelay (1); tmp = readl (&ep->regs->ep_stat); count = readl (&regs->ep_avail); /* handled that data already? */ if (count == 0 && (tmp & (1 << NAK_OUT_PACKETS)) == 0) return 0; } tmp = req->req.length - req->req.actual; if (count > tmp) { /* as with DMA, data overflow gets flushed */ if ((tmp % ep->ep.maxpacket) != 0) { ERROR (ep->dev, "%s out fifo %d bytes, expected %d\n", ep->ep.name, count, tmp); req->req.status = -EOVERFLOW; cleanup = 1; /* NAK_OUT_PACKETS will be set, so flushing is safe; * the next read will start with the next packet */ } /* else it's a ZLP, no worries */ count = tmp; } req->req.actual += count; is_short = (count == 0) || ((count % ep->ep.maxpacket) != 0); VDEBUG (ep->dev, "read %s fifo (OUT) %d bytes%s%s%s req %p %d/%d\n", ep->ep.name, count, is_short ? " (short)" : "", cleanup ? " flush" : "", prevent ? " nak" : "", req, req->req.actual, req->req.length); while (count >= 4) { tmp = readl (&regs->ep_data); cpu_to_le32s (&tmp); put_unaligned (tmp, (u32 *)buf); buf += 4; count -= 4; } if (count) { tmp = readl (&regs->ep_data); /* LE conversion is implicit here: */ do { *buf++ = (u8) tmp; tmp >>= 8; } while (--count); } if (cleanup) out_flush (ep); if (prevent) { writel ((1 << CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp); (void) readl (&ep->regs->ep_rsp); } return is_short || ((req->req.actual == req->req.length) && !req->req.zero); } /* fill out dma descriptor to match a given request */ static void fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid) { struct net2280_dma *td = req->td; u32 dmacount = req->req.length; /* don't let DMA continue after a short OUT packet, * so overruns can't affect the next transfer. * in case of overruns on max-size packets, we can't * stop the fifo from filling but we can flush it. */ if (ep->is_in) dmacount |= (1 << DMA_DIRECTION); if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0) || ep->dev->pdev->device != 0x2280) dmacount |= (1 << END_OF_CHAIN); req->valid = valid; if (valid) dmacount |= (1 << VALID_BIT); if (likely(!req->req.no_interrupt || !use_dma_chaining)) dmacount |= (1 << DMA_DONE_INTERRUPT_ENABLE); /* td->dmadesc = previously set by caller */ td->dmaaddr = cpu_to_le32 (req->req.dma); /* 2280 may be polling VALID_BIT through ep->dma->dmadesc */ wmb (); td->dmacount = cpu_to_le32(dmacount); } static const u32 dmactl_default = (1 << DMA_SCATTER_GATHER_DONE_INTERRUPT) | (1 << DMA_CLEAR_COUNT_ENABLE) /* erratum 0116 workaround part 1 (use POLLING) */ | (POLL_100_USEC << DESCRIPTOR_POLLING_RATE) | (1 << DMA_VALID_BIT_POLLING_ENABLE) | (1 << DMA_VALID_BIT_ENABLE) | (1 << DMA_SCATTER_GATHER_ENABLE) /* erratum 0116 workaround part 2 (no AUTOSTART) */ | (1 << DMA_ENABLE); static inline void spin_stop_dma (struct net2280_dma_regs __iomem *dma) { handshake (&dma->dmactl, (1 << DMA_ENABLE), 0, 50); } static inline void stop_dma (struct net2280_dma_regs __iomem *dma) { writel (readl (&dma->dmactl) & ~(1 << DMA_ENABLE), &dma->dmactl); spin_stop_dma (dma); } static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma) { struct net2280_dma_regs __iomem *dma = ep->dma; unsigned int tmp = (1 << VALID_BIT) | (ep->is_in << DMA_DIRECTION); if (ep->dev->pdev->device != 0x2280) tmp |= (1 << END_OF_CHAIN); writel (tmp, &dma->dmacount); writel (readl (&dma->dmastat), &dma->dmastat); writel (td_dma, &dma->dmadesc); writel (dmactl, &dma->dmactl); /* erratum 0116 workaround part 3: pci arbiter away from net2280 */ (void) readl (&ep->dev->pci->pcimstctl); writel ((1 << DMA_START), &dma->dmastat); if (!ep->is_in) stop_out_naking (ep); } static void start_dma (struct net2280_ep *ep, struct net2280_request *req) { u32 tmp; struct net2280_dma_regs __iomem *dma = ep->dma; /* FIXME can't use DMA for ZLPs */ /* on this path we "know" there's no dma active (yet) */ WARN_ON (readl (&dma->dmactl) & (1 << DMA_ENABLE)); writel (0, &ep->dma->dmactl); /* previous OUT packet might have been short */ if (!ep->is_in && ((tmp = readl (&ep->regs->ep_stat)) & (1 << NAK_OUT_PACKETS)) != 0) { writel ((1 << SHORT_PACKET_TRANSFERRED_INTERRUPT), &ep->regs->ep_stat); tmp = readl (&ep->regs->ep_avail); if (tmp) { writel (readl (&dma->dmastat), &dma->dmastat); /* transfer all/some fifo data */ writel (req->req.dma, &dma->dmaaddr); tmp = min (tmp, req->req.length); /* dma irq, faking scatterlist status */ req->td->dmacount = cpu_to_le32 (req->req.length - tmp); writel ((1 << DMA_DONE_INTERRUPT_ENABLE) | tmp, &dma->dmacount); req->td->dmadesc = 0; req->valid = 1; writel ((1 << DMA_ENABLE), &dma->dmactl); writel ((1 << DMA_START), &dma->dmastat); return; } } tmp = dmactl_default; /* force packet boundaries between dma requests, but prevent the * controller from automagically writing a last "short" packet * (zero length) unless the driver explicitly said to do that. */ if (ep->is_in) { if (likely ((req->req.length % ep->ep.maxpacket) != 0 || req->req.zero)) { tmp |= (1 << DMA_FIFO_VALIDATE); ep->in_fifo_validate = 1; } else ep->in_fifo_validate = 0; } /* init req->td, pointing to the current dummy */ req->td->dmadesc = cpu_to_le32 (ep->td_dma); fill_dma_desc (ep, req, 1); if (!use_dma_chaining) req->td->dmacount |= cpu_to_le32 (1 << END_OF_CHAIN); start_queue (ep, tmp, req->td_dma); } static inline void queue_dma (struct net2280_ep *ep, struct net2280_request *req, int valid) { struct net2280_dma *end; dma_addr_t tmp; /* swap new dummy for old, link; fill and maybe activate */ end = ep->dummy; ep->dummy = req->td; req->td = end; tmp = ep->td_dma; ep->td_dma = req->td_dma; req->td_dma = tmp; end->dmadesc = cpu_to_le32 (ep->td_dma); fill_dma_desc (ep, req, valid); } static void done (struct net2280_ep *ep, struct net2280_request *req, int status) { struct net2280 *dev; unsigned stopped = ep->stopped; list_del_init (&req->queue); if (req->req.status == -EINPROGRESS) req->req.status = status; else status = req->req.status; dev = ep->dev; if (ep->dma) usb_gadget_unmap_request(&dev->gadget, &req->req, ep->is_in); if (status && status != -ESHUTDOWN) VDEBUG (dev, "complete %s req %p stat %d len %u/%u\n", ep->ep.name, &req->req, status, req->req.actual, req->req.length); /* don't modify queue heads during completion callback */ ep->stopped = 1; spin_unlock (&dev->lock); req->req.complete (&ep->ep, &req->req); spin_lock (&dev->lock); ep->stopped = stopped; } /*-------------------------------------------------------------------------*/ static int net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) { struct net2280_request *req; struct net2280_ep *ep; struct net2280 *dev; unsigned long flags; /* we always require a cpu-view buffer, so that we can * always use pio (as fallback or whatever). */ req = container_of (_req, struct net2280_request, req); if (!_req || !_req->complete || !_req->buf || !list_empty (&req->queue)) return -EINVAL; if (_req->length > (~0 & DMA_BYTE_COUNT_MASK)) return -EDOM; ep = container_of (_ep, struct net2280_ep, ep); if (!_ep || (!ep->desc && ep->num != 0)) return -EINVAL; dev = ep->dev; if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) return -ESHUTDOWN; /* FIXME implement PIO fallback for ZLPs with DMA */ if (ep->dma && _req->length == 0) return -EOPNOTSUPP; /* set up dma mapping in case the caller didn't */ if (ep->dma) { int ret; ret = usb_gadget_map_request(&dev->gadget, _req, ep->is_in); if (ret) return ret; } #if 0 VDEBUG (dev, "%s queue req %p, len %d buf %p\n", _ep->name, _req, _req->length, _req->buf); #endif spin_lock_irqsave (&dev->lock, flags); _req->status = -EINPROGRESS; _req->actual = 0; /* kickstart this i/o queue? */ if (list_empty (&ep->queue) && !ep->stopped) { /* use DMA if the endpoint supports it, else pio */ if (ep->dma) start_dma (ep, req); else { /* maybe there's no control data, just status ack */ if (ep->num == 0 && _req->length == 0) { allow_status (ep); done (ep, req, 0); VDEBUG (dev, "%s status ack\n", ep->ep.name); goto done; } /* PIO ... stuff the fifo, or unblock it. */ if (ep->is_in) write_fifo (ep, _req); else if (list_empty (&ep->queue)) { u32 s; /* OUT FIFO might have packet(s) buffered */ s = readl (&ep->regs->ep_stat); if ((s & (1 << FIFO_EMPTY)) == 0) { /* note: _req->short_not_ok is * ignored here since PIO _always_ * stops queue advance here, and * _req->status doesn't change for * short reads (only _req->actual) */ if (read_fifo (ep, req)) { done (ep, req, 0); if (ep->num == 0) allow_status (ep); /* don't queue it */ req = NULL; } else s = readl (&ep->regs->ep_stat); } /* don't NAK, let the fifo fill */ if (req && (s & (1 << NAK_OUT_PACKETS))) writel ((1 << CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp); } } } else if (ep->dma) { int valid = 1; if (ep->is_in) { int expect; /* preventing magic zlps is per-engine state, not * per-transfer; irq logic must recover hiccups. */ expect = likely (req->req.zero || (req->req.length % ep->ep.maxpacket) != 0); if (expect != ep->in_fifo_validate) valid = 0; } queue_dma (ep, req, valid); } /* else the irq handler advances the queue. */ ep->responded = 1; if (req) list_add_tail (&req->queue, &ep->queue); done: spin_unlock_irqrestore (&dev->lock, flags); /* pci writes may still be posted */ return 0; } static inline void dma_done ( struct net2280_ep *ep, struct net2280_request *req, u32 dmacount, int status ) { req->req.actual = req->req.length - (DMA_BYTE_COUNT_MASK & dmacount); done (ep, req, status); } static void restart_dma (struct net2280_ep *ep); static void scan_dma_completions (struct net2280_ep *ep) { /* only look at descriptors that were "naturally" retired, * so fifo and list head state won't matter */ while (!list_empty (&ep->queue)) { struct net2280_request *req; u32 tmp; req = list_entry (ep->queue.next, struct net2280_request, queue); if (!req->valid) break; rmb (); tmp = le32_to_cpup (&req->td->dmacount); if ((tmp & (1 << VALID_BIT)) != 0) break; /* SHORT_PACKET_TRANSFERRED_INTERRUPT handles "usb-short" * cases where DMA must be aborted; this code handles * all non-abort DMA completions. */ if (unlikely (req->td->dmadesc == 0)) { /* paranoia */ tmp = readl (&ep->dma->dmacount); if (tmp & DMA_BYTE_COUNT_MASK) break; /* single transfer mode */ dma_done (ep, req, tmp, 0); break; } else if (!ep->is_in && (req->req.length % ep->ep.maxpacket) != 0) { tmp = readl (&ep->regs->ep_stat); /* AVOID TROUBLE HERE by not issuing short reads from * your gadget driver. That helps avoids errata 0121, * 0122, and 0124; not all cases trigger the warning. */ if ((tmp & (1 << NAK_OUT_PACKETS)) == 0) { WARNING (ep->dev, "%s lost packet sync!\n", ep->ep.name); req->req.status = -EOVERFLOW; } else if ((tmp = readl (&ep->regs->ep_avail)) != 0) { /* fifo gets flushed later */ ep->out_overflow = 1; DEBUG (ep->dev, "%s dma, discard %d len %d\n", ep->ep.name, tmp, req->req.length); req->req.status = -EOVERFLOW; } } dma_done (ep, req, tmp, 0); } } static void restart_dma (struct net2280_ep *ep) { struct net2280_request *req; u32 dmactl = dmactl_default; if (ep->stopped) return; req = list_entry (ep->queue.next, struct net2280_request, queue); if (!use_dma_chaining) { start_dma (ep, req); return; } /* the 2280 will be processing the queue unless queue hiccups after * the previous transfer: * IN: wanted automagic zlp, head doesn't (or vice versa) * DMA_FIFO_VALIDATE doesn't init from dma descriptors. * OUT: was "usb-short", we must restart. */ if (ep->is_in && !req->valid) { struct net2280_request *entry, *prev = NULL; int reqmode, done = 0; DEBUG (ep->dev, "%s dma hiccup td %p\n", ep->ep.name, req->td); ep->in_fifo_validate = likely (req->req.zero || (req->req.length % ep->ep.maxpacket) != 0); if (ep->in_fifo_validate) dmactl |= (1 << DMA_FIFO_VALIDATE); list_for_each_entry (entry, &ep->queue, queue) { __le32 dmacount; if (entry == req) continue; dmacount = entry->td->dmacount; if (!done) { reqmode = likely (entry->req.zero || (entry->req.length % ep->ep.maxpacket) != 0); if (reqmode == ep->in_fifo_validate) { entry->valid = 1; dmacount |= valid_bit; entry->td->dmacount = dmacount; prev = entry; continue; } else { /* force a hiccup */ prev->td->dmacount |= dma_done_ie; done = 1; } } /* walk the rest of the queue so unlinks behave */ entry->valid = 0; dmacount &= ~valid_bit; entry->td->dmacount = dmacount; prev = entry; } } writel (0, &ep->dma->dmactl); start_queue (ep, dmactl, req->td_dma); } static void abort_dma (struct net2280_ep *ep) { /* abort the current transfer */ if (likely (!list_empty (&ep->queue))) { /* FIXME work around errata 0121, 0122, 0124 */ writel ((1 << DMA_ABORT), &ep->dma->dmastat); spin_stop_dma (ep->dma); } else stop_dma (ep->dma); scan_dma_completions (ep); } /* dequeue ALL requests */ static void nuke (struct net2280_ep *ep) { struct net2280_request *req; /* called with spinlock held */ ep->stopped = 1; if (ep->dma) abort_dma (ep); while (!list_empty (&ep->queue)) { req = list_entry (ep->queue.next, struct net2280_request, queue); done (ep, req, -ESHUTDOWN); } } /* dequeue JUST ONE request */ static int net2280_dequeue (struct usb_ep *_ep, struct usb_request *_req) { struct net2280_ep *ep; struct net2280_request *req; unsigned long flags; u32 dmactl; int stopped; ep = container_of (_ep, struct net2280_ep, ep); if (!_ep || (!ep->desc && ep->num != 0) || !_req) return -EINVAL; spin_lock_irqsave (&ep->dev->lock, flags); stopped = ep->stopped; /* quiesce dma while we patch the queue */ dmactl = 0; ep->stopped = 1; if (ep->dma) { dmactl = readl (&ep->dma->dmactl); /* WARNING erratum 0127 may kick in ... */ stop_dma (ep->dma); scan_dma_completions (ep); } /* make sure it's still queued on this endpoint */ list_for_each_entry (req, &ep->queue, queue) { if (&req->req == _req) break; } if (&req->req != _req) { spin_unlock_irqrestore (&ep->dev->lock, flags); return -EINVAL; } /* queue head may be partially complete. */ if (ep->queue.next == &req->queue) { if (ep->dma) { DEBUG (ep->dev, "unlink (%s) dma\n", _ep->name); _req->status = -ECONNRESET; abort_dma (ep); if (likely (ep->queue.next == &req->queue)) { // NOTE: misreports single-transfer mode req->td->dmacount = 0; /* invalidate */ dma_done (ep, req, readl (&ep->dma->dmacount), -ECONNRESET); } } else { DEBUG (ep->dev, "unlink (%s) pio\n", _ep->name); done (ep, req, -ECONNRESET); } req = NULL; /* patch up hardware chaining data */ } else if (ep->dma && use_dma_chaining) { if (req->queue.prev == ep->queue.next) { writel (le32_to_cpu (req->td->dmadesc), &ep->dma->dmadesc); if (req->td->dmacount & dma_done_ie) writel (readl (&ep->dma->dmacount) | le32_to_cpu(dma_done_ie), &ep->dma->dmacount); } else { struct net2280_request *prev; prev = list_entry (req->queue.prev, struct net2280_request, queue); prev->td->dmadesc = req->td->dmadesc; if (req->td->dmacount & dma_done_ie) prev->td->dmacount |= dma_done_ie; } } if (req) done (ep, req, -ECONNRESET); ep->stopped = stopped; if (ep->dma) { /* turn off dma on inactive queues */ if (list_empty (&ep->queue)) stop_dma (ep->dma); else if (!ep->stopped) { /* resume current request, or start new one */ if (req) writel (dmactl, &ep->dma->dmactl); else start_dma (ep, list_entry (ep->queue.next, struct net2280_request, queue)); } } spin_unlock_irqrestore (&ep->dev->lock, flags); return 0; } /*-------------------------------------------------------------------------*/ static int net2280_fifo_status (struct usb_ep *_ep); static int net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) { struct net2280_ep *ep; unsigned long flags; int retval = 0; ep = container_of (_ep, struct net2280_ep, ep); if (!_ep || (!ep->desc && ep->num != 0)) return -EINVAL; if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN) return -ESHUTDOWN; if (ep->desc /* not ep0 */ && (ep->desc->bmAttributes & 0x03) == USB_ENDPOINT_XFER_ISOC) return -EINVAL; spin_lock_irqsave (&ep->dev->lock, flags); if (!list_empty (&ep->queue)) retval = -EAGAIN; else if (ep->is_in && value && net2280_fifo_status (_ep) != 0) retval = -EAGAIN; else { VDEBUG (ep->dev, "%s %s %s\n", _ep->name, value ? "set" : "clear", wedged ? "wedge" : "halt"); /* set/clear, then synch memory views with the device */ if (value) { if (ep->num == 0) ep->dev->protocol_stall = 1; else set_halt (ep); if (wedged) ep->wedged = 1; } else { clear_halt (ep); ep->wedged = 0; } (void) readl (&ep->regs->ep_rsp); } spin_unlock_irqrestore (&ep->dev->lock, flags); return retval; } static int net2280_set_halt(struct usb_ep *_ep, int value) { return net2280_set_halt_and_wedge(_ep, value, 0); } static int net2280_set_wedge(struct usb_ep *_ep) { if (!_ep || _ep->name == ep0name) return -EINVAL; return net2280_set_halt_and_wedge(_ep, 1, 1); } static int net2280_fifo_status (struct usb_ep *_ep) { struct net2280_ep *ep; u32 avail; ep = container_of (_ep, struct net2280_ep, ep); if (!_ep || (!ep->desc && ep->num != 0)) return -ENODEV; if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN) return -ESHUTDOWN; avail = readl (&ep->regs->ep_avail) & ((1 << 12) - 1); if (avail > ep->fifo_size) return -EOVERFLOW; if (ep->is_in) avail = ep->fifo_size - avail; return avail; } static void net2280_fifo_flush (struct usb_ep *_ep) { struct net2280_ep *ep; ep = container_of (_ep, struct net2280_ep, ep); if (!_ep || (!ep->desc && ep->num != 0)) return; if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN) return; writel ((1 << FIFO_FLUSH), &ep->regs->ep_stat); (void) readl (&ep->regs->ep_rsp); } static const struct usb_ep_ops net2280_ep_ops = { .enable = net2280_enable, .disable = net2280_disable, .alloc_request = net2280_alloc_request, .free_request = net2280_free_request, .queue = net2280_queue, .dequeue = net2280_dequeue, .set_halt = net2280_set_halt, .set_wedge = net2280_set_wedge, .fifo_status = net2280_fifo_status, .fifo_flush = net2280_fifo_flush, }; /*-------------------------------------------------------------------------*/ static int net2280_get_frame (struct usb_gadget *_gadget) { struct net2280 *dev; unsigned long flags; u16 retval; if (!_gadget) return -ENODEV; dev = container_of (_gadget, struct net2280, gadget); spin_lock_irqsave (&dev->lock, flags); retval = get_idx_reg (dev->regs, REG_FRAME) & 0x03ff; spin_unlock_irqrestore (&dev->lock, flags); return retval; } static int net2280_wakeup (struct usb_gadget *_gadget) { struct net2280 *dev; u32 tmp; unsigned long flags; if (!_gadget) return 0; dev = container_of (_gadget, struct net2280, gadget); spin_lock_irqsave (&dev->lock, flags); tmp = readl (&dev->usb->usbctl); if (tmp & (1 << DEVICE_REMOTE_WAKEUP_ENABLE)) writel (1 << GENERATE_RESUME, &dev->usb->usbstat); spin_unlock_irqrestore (&dev->lock, flags); /* pci writes may still be posted */ return 0; } static int net2280_set_selfpowered (struct usb_gadget *_gadget, int value) { struct net2280 *dev; u32 tmp; unsigned long flags; if (!_gadget) return 0; dev = container_of (_gadget, struct net2280, gadget); spin_lock_irqsave (&dev->lock, flags); tmp = readl (&dev->usb->usbctl); if (value) tmp |= (1 << SELF_POWERED_STATUS); else tmp &= ~(1 << SELF_POWERED_STATUS); writel (tmp, &dev->usb->usbctl); spin_unlock_irqrestore (&dev->lock, flags); return 0; } static int net2280_pullup(struct usb_gadget *_gadget, int is_on) { struct net2280 *dev; u32 tmp; unsigned long flags; if (!_gadget) return -ENODEV; dev = container_of (_gadget, struct net2280, gadget); spin_lock_irqsave (&dev->lock, flags); tmp = readl (&dev->usb->usbctl); dev->softconnect = (is_on != 0); if (is_on) tmp |= (1 << USB_DETECT_ENABLE); else tmp &= ~(1 << USB_DETECT_ENABLE); writel (tmp, &dev->usb->usbctl); spin_unlock_irqrestore (&dev->lock, flags); return 0; } static int net2280_start(struct usb_gadget *_gadget, struct usb_gadget_driver *driver); static int net2280_stop(struct usb_gadget *_gadget, struct usb_gadget_driver *driver); static const struct usb_gadget_ops net2280_ops = { .get_frame = net2280_get_frame, .wakeup = net2280_wakeup, .set_selfpowered = net2280_set_selfpowered, .pullup = net2280_pullup, .udc_start = net2280_start, .udc_stop = net2280_stop, }; /*-------------------------------------------------------------------------*/ #ifdef CONFIG_USB_GADGET_DEBUG_FILES /* FIXME move these into procfs, and use seq_file. * Sysfs _still_ doesn't behave for arbitrarily sized files, * and also doesn't help products using this with 2.4 kernels. */ /* "function" sysfs attribute */ static ssize_t show_function (struct device *_dev, struct device_attribute *attr, char *buf) { struct net2280 *dev = dev_get_drvdata (_dev); if (!dev->driver || !dev->driver->function || strlen (dev->driver->function) > PAGE_SIZE) return 0; return scnprintf (buf, PAGE_SIZE, "%s\n", dev->driver->function); } static DEVICE_ATTR (function, S_IRUGO, show_function, NULL); static ssize_t net2280_show_registers(struct device *_dev, struct device_attribute *attr, char *buf) { struct net2280 *dev; char *next; unsigned size, t; unsigned long flags; int i; u32 t1, t2; const char *s; dev = dev_get_drvdata (_dev); next = buf; size = PAGE_SIZE; spin_lock_irqsave (&dev->lock, flags); if (dev->driver) s = dev->driver->driver.name; else s = "(none)"; /* Main Control Registers */ t = scnprintf (next, size, "%s version " DRIVER_VERSION ", chiprev %04x, dma %s\n\n" "devinit %03x fifoctl %08x gadget '%s'\n" "pci irqenb0 %02x irqenb1 %08x " "irqstat0 %04x irqstat1 %08x\n", driver_name, dev->chiprev, use_dma ? (use_dma_chaining ? "chaining" : "enabled") : "disabled", readl (&dev->regs->devinit), readl (&dev->regs->fifoctl), s, readl (&dev->regs->pciirqenb0), readl (&dev->regs->pciirqenb1), readl (&dev->regs->irqstat0), readl (&dev->regs->irqstat1)); size -= t; next += t; /* USB Control Registers */ t1 = readl (&dev->usb->usbctl); t2 = readl (&dev->usb->usbstat); if (t1 & (1 << VBUS_PIN)) { if (t2 & (1 << HIGH_SPEED)) s = "high speed"; else if (dev->gadget.speed == USB_SPEED_UNKNOWN) s = "powered"; else s = "full speed"; /* full speed bit (6) not working?? */ } else s = "not attached"; t = scnprintf (next, size, "stdrsp %08x usbctl %08x usbstat %08x " "addr 0x%02x (%s)\n", readl (&dev->usb->stdrsp), t1, t2, readl (&dev->usb->ouraddr), s); size -= t; next += t; /* PCI Master Control Registers */ /* DMA Control Registers */ /* Configurable EP Control Registers */ for (i = 0; i < 7; i++) { struct net2280_ep *ep; ep = &dev->ep [i]; if (i && !ep->desc) continue; t1 = readl (&ep->regs->ep_cfg); t2 = readl (&ep->regs->ep_rsp) & 0xff; t = scnprintf (next, size, "\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s" "irqenb %02x\n", ep->ep.name, t1, t2, (t2 & (1 << CLEAR_NAK_OUT_PACKETS)) ? "NAK " : "", (t2 & (1 << CLEAR_EP_HIDE_STATUS_PHASE)) ? "hide " : "", (t2 & (1 << CLEAR_EP_FORCE_CRC_ERROR)) ? "CRC " : "", (t2 & (1 << CLEAR_INTERRUPT_MODE)) ? "interrupt " : "", (t2 & (1<<CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)) ? "status " : "", (t2 & (1 << CLEAR_NAK_OUT_PACKETS_MODE)) ? "NAKmode " : "", (t2 & (1 << CLEAR_ENDPOINT_TOGGLE)) ? "DATA1 " : "DATA0 ", (t2 & (1 << CLEAR_ENDPOINT_HALT)) ? "HALT " : "", readl (&ep->regs->ep_irqenb)); size -= t; next += t; t = scnprintf (next, size, "\tstat %08x avail %04x " "(ep%d%s-%s)%s\n", readl (&ep->regs->ep_stat), readl (&ep->regs->ep_avail), t1 & 0x0f, DIR_STRING (t1), type_string (t1 >> 8), ep->stopped ? "*" : ""); size -= t; next += t; if (!ep->dma) continue; t = scnprintf (next, size, " dma\tctl %08x stat %08x count %08x\n" "\taddr %08x desc %08x\n", readl (&ep->dma->dmactl), readl (&ep->dma->dmastat), readl (&ep->dma->dmacount), readl (&ep->dma->dmaaddr), readl (&ep->dma->dmadesc)); size -= t; next += t; } /* Indexed Registers */ // none yet /* Statistics */ t = scnprintf (next, size, "\nirqs: "); size -= t; next += t; for (i = 0; i < 7; i++) { struct net2280_ep *ep; ep = &dev->ep [i]; if (i && !ep->irqs) continue; t = scnprintf (next, size, " %s/%lu", ep->ep.name, ep->irqs); size -= t; next += t; } t = scnprintf (next, size, "\n"); size -= t; next += t; spin_unlock_irqrestore (&dev->lock, flags); return PAGE_SIZE - size; } static DEVICE_ATTR(registers, S_IRUGO, net2280_show_registers, NULL); static ssize_t show_queues (struct device *_dev, struct device_attribute *attr, char *buf) { struct net2280 *dev; char *next; unsigned size; unsigned long flags; int i; dev = dev_get_drvdata (_dev); next = buf; size = PAGE_SIZE; spin_lock_irqsave (&dev->lock, flags); for (i = 0; i < 7; i++) { struct net2280_ep *ep = &dev->ep [i]; struct net2280_request *req; int t; if (i != 0) { const struct usb_endpoint_descriptor *d; d = ep->desc; if (!d) continue; t = d->bEndpointAddress; t = scnprintf (next, size, "\n%s (ep%d%s-%s) max %04x %s fifo %d\n", ep->ep.name, t & USB_ENDPOINT_NUMBER_MASK, (t & USB_DIR_IN) ? "in" : "out", ({ char *val; switch (d->bmAttributes & 0x03) { case USB_ENDPOINT_XFER_BULK: val = "bulk"; break; case USB_ENDPOINT_XFER_INT: val = "intr"; break; default: val = "iso"; break; }; val; }), usb_endpoint_maxp (d) & 0x1fff, ep->dma ? "dma" : "pio", ep->fifo_size ); } else /* ep0 should only have one transfer queued */ t = scnprintf (next, size, "ep0 max 64 pio %s\n", ep->is_in ? "in" : "out"); if (t <= 0 || t > size) goto done; size -= t; next += t; if (list_empty (&ep->queue)) { t = scnprintf (next, size, "\t(nothing queued)\n"); if (t <= 0 || t > size) goto done; size -= t; next += t; continue; } list_for_each_entry (req, &ep->queue, queue) { if (ep->dma && req->td_dma == readl (&ep->dma->dmadesc)) t = scnprintf (next, size, "\treq %p len %d/%d " "buf %p (dmacount %08x)\n", &req->req, req->req.actual, req->req.length, req->req.buf, readl (&ep->dma->dmacount)); else t = scnprintf (next, size, "\treq %p len %d/%d buf %p\n", &req->req, req->req.actual, req->req.length, req->req.buf); if (t <= 0 || t > size) goto done; size -= t; next += t; if (ep->dma) { struct net2280_dma *td; td = req->td; t = scnprintf (next, size, "\t td %08x " " count %08x buf %08x desc %08x\n", (u32) req->td_dma, le32_to_cpu (td->dmacount), le32_to_cpu (td->dmaaddr), le32_to_cpu (td->dmadesc)); if (t <= 0 || t > size) goto done; size -= t; next += t; } } } done: spin_unlock_irqrestore (&dev->lock, flags); return PAGE_SIZE - size; } static DEVICE_ATTR (queues, S_IRUGO, show_queues, NULL); #else #define device_create_file(a,b) (0) #define device_remove_file(a,b) do { } while (0) #endif /*-------------------------------------------------------------------------*/ /* another driver-specific mode might be a request type doing dma * to/from another device fifo instead of to/from memory. */ static void set_fifo_mode (struct net2280 *dev, int mode) { /* keeping high bits preserves BAR2 */ writel ((0xffff << PCI_BASE2_RANGE) | mode, &dev->regs->fifoctl); /* always ep-{a,b,e,f} ... maybe not ep-c or ep-d */ INIT_LIST_HEAD (&dev->gadget.ep_list); list_add_tail (&dev->ep [1].ep.ep_list, &dev->gadget.ep_list); list_add_tail (&dev->ep [2].ep.ep_list, &dev->gadget.ep_list); switch (mode) { case 0: list_add_tail (&dev->ep [3].ep.ep_list, &dev->gadget.ep_list); list_add_tail (&dev->ep [4].ep.ep_list, &dev->gadget.ep_list); dev->ep [1].fifo_size = dev->ep [2].fifo_size = 1024; break; case 1: dev->ep [1].fifo_size = dev->ep [2].fifo_size = 2048; break; case 2: list_add_tail (&dev->ep [3].ep.ep_list, &dev->gadget.ep_list); dev->ep [1].fifo_size = 2048; dev->ep [2].fifo_size = 1024; break; } /* fifo sizes for ep0, ep-c, ep-d, ep-e, and ep-f never change */ list_add_tail (&dev->ep [5].ep.ep_list, &dev->gadget.ep_list); list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list); } /* keeping it simple: * - one bus driver, initted first; * - one function driver, initted second * * most of the work to support multiple net2280 controllers would * be to associate this gadget driver (yes?) with all of them, or * perhaps to bind specific drivers to specific devices. */ static void usb_reset (struct net2280 *dev) { u32 tmp; dev->gadget.speed = USB_SPEED_UNKNOWN; (void) readl (&dev->usb->usbctl); net2280_led_init (dev); /* disable automatic responses, and irqs */ writel (0, &dev->usb->stdrsp); writel (0, &dev->regs->pciirqenb0); writel (0, &dev->regs->pciirqenb1); /* clear old dma and irq state */ for (tmp = 0; tmp < 4; tmp++) { struct net2280_ep *ep = &dev->ep [tmp + 1]; if (ep->dma) abort_dma (ep); } writel (~0, &dev->regs->irqstat0), writel (~(1 << SUSPEND_REQUEST_INTERRUPT), &dev->regs->irqstat1), /* reset, and enable pci */ tmp = readl (&dev->regs->devinit) | (1 << PCI_ENABLE) | (1 << FIFO_SOFT_RESET) | (1 << USB_SOFT_RESET) | (1 << M8051_RESET); writel (tmp, &dev->regs->devinit); /* standard fifo and endpoint allocations */ set_fifo_mode (dev, (fifo_mode <= 2) ? fifo_mode : 0); } static void usb_reinit (struct net2280 *dev) { u32 tmp; int init_dma; /* use_dma changes are ignored till next device re-init */ init_dma = use_dma; /* basic endpoint init */ for (tmp = 0; tmp < 7; tmp++) { struct net2280_ep *ep = &dev->ep [tmp]; ep->ep.name = ep_name [tmp]; ep->dev = dev; ep->num = tmp; if (tmp > 0 && tmp <= 4) { ep->fifo_size = 1024; if (init_dma) ep->dma = &dev->dma [tmp - 1]; } else ep->fifo_size = 64; ep->regs = &dev->epregs [tmp]; ep_reset (dev->regs, ep); } dev->ep [0].ep.maxpacket = 64; dev->ep [5].ep.maxpacket = 64; dev->ep [6].ep.maxpacket = 64; dev->gadget.ep0 = &dev->ep [0].ep; dev->ep [0].stopped = 0; INIT_LIST_HEAD (&dev->gadget.ep0->ep_list); /* we want to prevent lowlevel/insecure access from the USB host, * but erratum 0119 means this enable bit is ignored */ for (tmp = 0; tmp < 5; tmp++) writel (EP_DONTUSE, &dev->dep [tmp].dep_cfg); } static void ep0_start (struct net2280 *dev) { writel ( (1 << CLEAR_EP_HIDE_STATUS_PHASE) | (1 << CLEAR_NAK_OUT_PACKETS) | (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) , &dev->epregs [0].ep_rsp); /* * hardware optionally handles a bunch of standard requests * that the API hides from drivers anyway. have it do so. * endpoint status/features are handled in software, to * help pass tests for some dubious behavior. */ writel ( (1 << SET_TEST_MODE) | (1 << SET_ADDRESS) | (1 << DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP) | (1 << GET_DEVICE_STATUS) | (1 << GET_INTERFACE_STATUS) , &dev->usb->stdrsp); writel ( (1 << USB_ROOT_PORT_WAKEUP_ENABLE) | (1 << SELF_POWERED_USB_DEVICE) | (1 << REMOTE_WAKEUP_SUPPORT) | (dev->softconnect << USB_DETECT_ENABLE) | (1 << SELF_POWERED_STATUS) , &dev->usb->usbctl); /* enable irqs so we can see ep0 and general operation */ writel ( (1 << SETUP_PACKET_INTERRUPT_ENABLE) | (1 << ENDPOINT_0_INTERRUPT_ENABLE) , &dev->regs->pciirqenb0); writel ( (1 << PCI_INTERRUPT_ENABLE) | (1 << PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE) | (1 << PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE) | (1 << PCI_RETRY_ABORT_INTERRUPT_ENABLE) | (1 << VBUS_INTERRUPT_ENABLE) | (1 << ROOT_PORT_RESET_INTERRUPT_ENABLE) | (1 << SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE) , &dev->regs->pciirqenb1); /* don't leave any writes posted */ (void) readl (&dev->usb->usbctl); } /* when a driver is successfully registered, it will receive * control requests including set_configuration(), which enables * non-control requests. then usb traffic follows until a * disconnect is reported. then a host may connect again, or * the driver might get unbound. */ static int net2280_start(struct usb_gadget *_gadget, struct usb_gadget_driver *driver) { struct net2280 *dev; int retval; unsigned i; /* insist on high speed support from the driver, since * (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE) * "must not be used in normal operation" */ if (!driver || driver->max_speed < USB_SPEED_HIGH || !driver->setup) return -EINVAL; dev = container_of (_gadget, struct net2280, gadget); for (i = 0; i < 7; i++) dev->ep [i].irqs = 0; /* hook up the driver ... */ dev->softconnect = 1; driver->driver.bus = NULL; dev->driver = driver; dev->gadget.dev.driver = &driver->driver; retval = device_create_file (&dev->pdev->dev, &dev_attr_function); if (retval) goto err_unbind; retval = device_create_file (&dev->pdev->dev, &dev_attr_queues); if (retval) goto err_func; /* ... then enable host detection and ep0; and we're ready * for set_configuration as well as eventual disconnect. */ net2280_led_active (dev, 1); ep0_start (dev); DEBUG (dev, "%s ready, usbctl %08x stdrsp %08x\n", driver->driver.name, readl (&dev->usb->usbctl), readl (&dev->usb->stdrsp)); /* pci writes may still be posted */ return 0; err_func: device_remove_file (&dev->pdev->dev, &dev_attr_function); err_unbind: driver->unbind (&dev->gadget); dev->gadget.dev.driver = NULL; dev->driver = NULL; return retval; } static void stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver) { int i; /* don't disconnect if it's not connected */ if (dev->gadget.speed == USB_SPEED_UNKNOWN) driver = NULL; /* stop hardware; prevent new request submissions; * and kill any outstanding requests. */ usb_reset (dev); for (i = 0; i < 7; i++) nuke (&dev->ep [i]); usb_reinit (dev); } static int net2280_stop(struct usb_gadget *_gadget, struct usb_gadget_driver *driver) { struct net2280 *dev; unsigned long flags; dev = container_of (_gadget, struct net2280, gadget); spin_lock_irqsave (&dev->lock, flags); stop_activity (dev, driver); spin_unlock_irqrestore (&dev->lock, flags); dev->gadget.dev.driver = NULL; dev->driver = NULL; net2280_led_active (dev, 0); device_remove_file (&dev->pdev->dev, &dev_attr_function); device_remove_file (&dev->pdev->dev, &dev_attr_queues); DEBUG (dev, "unregistered driver '%s'\n", driver->driver.name); return 0; } /*-------------------------------------------------------------------------*/ /* handle ep0, ep-e, ep-f with 64 byte packets: packet per irq. * also works for dma-capable endpoints, in pio mode or just * to manually advance the queue after short OUT transfers. */ static void handle_ep_small (struct net2280_ep *ep) { struct net2280_request *req; u32 t; /* 0 error, 1 mid-data, 2 done */ int mode = 1; if (!list_empty (&ep->queue)) req = list_entry (ep->queue.next, struct net2280_request, queue); else req = NULL; /* ack all, and handle what we care about */ t = readl (&ep->regs->ep_stat); ep->irqs++; #if 0 VDEBUG (ep->dev, "%s ack ep_stat %08x, req %p\n", ep->ep.name, t, req ? &req->req : 0); #endif if (!ep->is_in || ep->dev->pdev->device == 0x2280) writel (t & ~(1 << NAK_OUT_PACKETS), &ep->regs->ep_stat); else /* Added for 2282 */ writel (t, &ep->regs->ep_stat); /* for ep0, monitor token irqs to catch data stage length errors * and to synchronize on status. * * also, to defer reporting of protocol stalls ... here's where * data or status first appears, handling stalls here should never * cause trouble on the host side.. * * control requests could be slightly faster without token synch for * status, but status can jam up that way. */ if (unlikely (ep->num == 0)) { if (ep->is_in) { /* status; stop NAKing */ if (t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT)) { if (ep->dev->protocol_stall) { ep->stopped = 1; set_halt (ep); } if (!req) allow_status (ep); mode = 2; /* reply to extra IN data tokens with a zlp */ } else if (t & (1 << DATA_IN_TOKEN_INTERRUPT)) { if (ep->dev->protocol_stall) { ep->stopped = 1; set_halt (ep); mode = 2; } else if (ep->responded && !req && !ep->stopped) write_fifo (ep, NULL); } } else { /* status; stop NAKing */ if (t & (1 << DATA_IN_TOKEN_INTERRUPT)) { if (ep->dev->protocol_stall) { ep->stopped = 1; set_halt (ep); } mode = 2; /* an extra OUT token is an error */ } else if (((t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT)) && req && req->req.actual == req->req.length) || (ep->responded && !req)) { ep->dev->protocol_stall = 1; set_halt (ep); ep->stopped = 1; if (req) done (ep, req, -EOVERFLOW); req = NULL; } } } if (unlikely (!req)) return; /* manual DMA queue advance after short OUT */ if (likely (ep->dma != 0)) { if (t & (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT)) { u32 count; int stopped = ep->stopped; /* TRANSFERRED works around OUT_DONE erratum 0112. * we expect (N <= maxpacket) bytes; host wrote M. * iff (M < N) we won't ever see a DMA interrupt. */ ep->stopped = 1; for (count = 0; ; t = readl (&ep->regs->ep_stat)) { /* any preceding dma transfers must finish. * dma handles (M >= N), may empty the queue */ scan_dma_completions (ep); if (unlikely (list_empty (&ep->queue) || ep->out_overflow)) { req = NULL; break; } req = list_entry (ep->queue.next, struct net2280_request, queue); /* here either (M < N), a "real" short rx; * or (M == N) and the queue didn't empty */ if (likely (t & (1 << FIFO_EMPTY))) { count = readl (&ep->dma->dmacount); count &= DMA_BYTE_COUNT_MASK; if (readl (&ep->dma->dmadesc) != req->td_dma) req = NULL; break; } udelay(1); } /* stop DMA, leave ep NAKing */ writel ((1 << DMA_ABORT), &ep->dma->dmastat); spin_stop_dma (ep->dma); if (likely (req)) { req->td->dmacount = 0; t = readl (&ep->regs->ep_avail); dma_done (ep, req, count, (ep->out_overflow || t) ? -EOVERFLOW : 0); } /* also flush to prevent erratum 0106 trouble */ if (unlikely (ep->out_overflow || (ep->dev->chiprev == 0x0100 && ep->dev->gadget.speed == USB_SPEED_FULL))) { out_flush (ep); ep->out_overflow = 0; } /* (re)start dma if needed, stop NAKing */ ep->stopped = stopped; if (!list_empty (&ep->queue)) restart_dma (ep); } else DEBUG (ep->dev, "%s dma ep_stat %08x ??\n", ep->ep.name, t); return; /* data packet(s) received (in the fifo, OUT) */ } else if (t & (1 << DATA_PACKET_RECEIVED_INTERRUPT)) { if (read_fifo (ep, req) && ep->num != 0) mode = 2; /* data packet(s) transmitted (IN) */ } else if (t & (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)) { unsigned len; len = req->req.length - req->req.actual; if (len > ep->ep.maxpacket) len = ep->ep.maxpacket; req->req.actual += len; /* if we wrote it all, we're usually done */ if (req->req.actual == req->req.length) { if (ep->num == 0) { /* send zlps until the status stage */ } else if (!req->req.zero || len != ep->ep.maxpacket) mode = 2; } /* there was nothing to do ... */ } else if (mode == 1) return; /* done */ if (mode == 2) { /* stream endpoints often resubmit/unlink in completion */ done (ep, req, 0); /* maybe advance queue to next request */ if (ep->num == 0) { /* NOTE: net2280 could let gadget driver start the * status stage later. since not all controllers let * them control that, the api doesn't (yet) allow it. */ if (!ep->stopped) allow_status (ep); req = NULL; } else { if (!list_empty (&ep->queue) && !ep->stopped) req = list_entry (ep->queue.next, struct net2280_request, queue); else req = NULL; if (req && !ep->is_in) stop_out_naking (ep); } } /* is there a buffer for the next packet? * for best streaming performance, make sure there is one. */ if (req && !ep->stopped) { /* load IN fifo with next packet (may be zlp) */ if (t & (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)) write_fifo (ep, &req->req); } } static struct net2280_ep * get_ep_by_addr (struct net2280 *dev, u16 wIndex) { struct net2280_ep *ep; if ((wIndex & USB_ENDPOINT_NUMBER_MASK) == 0) return &dev->ep [0]; list_for_each_entry (ep, &dev->gadget.ep_list, ep.ep_list) { u8 bEndpointAddress; if (!ep->desc) continue; bEndpointAddress = ep->desc->bEndpointAddress; if ((wIndex ^ bEndpointAddress) & USB_DIR_IN) continue; if ((wIndex & 0x0f) == (bEndpointAddress & 0x0f)) return ep; } return NULL; } static void handle_stat0_irqs (struct net2280 *dev, u32 stat) { struct net2280_ep *ep; u32 num, scratch; /* most of these don't need individual acks */ stat &= ~(1 << INTA_ASSERTED); if (!stat) return; // DEBUG (dev, "irqstat0 %04x\n", stat); /* starting a control request? */ if (unlikely (stat & (1 << SETUP_PACKET_INTERRUPT))) { union { u32 raw [2]; struct usb_ctrlrequest r; } u; int tmp; struct net2280_request *req; if (dev->gadget.speed == USB_SPEED_UNKNOWN) { if (readl (&dev->usb->usbstat) & (1 << HIGH_SPEED)) dev->gadget.speed = USB_SPEED_HIGH; else dev->gadget.speed = USB_SPEED_FULL; net2280_led_speed (dev, dev->gadget.speed); DEBUG(dev, "%s\n", usb_speed_string(dev->gadget.speed)); } ep = &dev->ep [0]; ep->irqs++; /* make sure any leftover request state is cleared */ stat &= ~(1 << ENDPOINT_0_INTERRUPT); while (!list_empty (&ep->queue)) { req = list_entry (ep->queue.next, struct net2280_request, queue); done (ep, req, (req->req.actual == req->req.length) ? 0 : -EPROTO); } ep->stopped = 0; dev->protocol_stall = 0; if (ep->dev->pdev->device == 0x2280) tmp = (1 << FIFO_OVERFLOW) | (1 << FIFO_UNDERFLOW); else tmp = 0; writel (tmp | (1 << TIMEOUT) | (1 << USB_STALL_SENT) | (1 << USB_IN_NAK_SENT) | (1 << USB_IN_ACK_RCVD) | (1 << USB_OUT_PING_NAK_SENT) | (1 << USB_OUT_ACK_SENT) | (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) | (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) | (1 << DATA_PACKET_RECEIVED_INTERRUPT) | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) | (1 << DATA_OUT_PING_TOKEN_INTERRUPT) | (1 << DATA_IN_TOKEN_INTERRUPT) , &ep->regs->ep_stat); u.raw [0] = readl (&dev->usb->setup0123); u.raw [1] = readl (&dev->usb->setup4567); cpu_to_le32s (&u.raw [0]); cpu_to_le32s (&u.raw [1]); tmp = 0; #define w_value le16_to_cpu(u.r.wValue) #define w_index le16_to_cpu(u.r.wIndex) #define w_length le16_to_cpu(u.r.wLength) /* ack the irq */ writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0); stat ^= (1 << SETUP_PACKET_INTERRUPT); /* watch control traffic at the token level, and force * synchronization before letting the status stage happen. * FIXME ignore tokens we'll NAK, until driver responds. * that'll mean a lot less irqs for some drivers. */ ep->is_in = (u.r.bRequestType & USB_DIR_IN) != 0; if (ep->is_in) { scratch = (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) | (1 << DATA_OUT_PING_TOKEN_INTERRUPT) | (1 << DATA_IN_TOKEN_INTERRUPT); stop_out_naking (ep); } else scratch = (1 << DATA_PACKET_RECEIVED_INTERRUPT) | (1 << DATA_OUT_PING_TOKEN_INTERRUPT) | (1 << DATA_IN_TOKEN_INTERRUPT); writel (scratch, &dev->epregs [0].ep_irqenb); /* we made the hardware handle most lowlevel requests; * everything else goes uplevel to the gadget code. */ ep->responded = 1; switch (u.r.bRequest) { case USB_REQ_GET_STATUS: { struct net2280_ep *e; __le32 status; /* hw handles device and interface status */ if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT)) goto delegate; if ((e = get_ep_by_addr (dev, w_index)) == 0 || w_length > 2) goto do_stall; if (readl (&e->regs->ep_rsp) & (1 << SET_ENDPOINT_HALT)) status = cpu_to_le32 (1); else status = cpu_to_le32 (0); /* don't bother with a request object! */ writel (0, &dev->epregs [0].ep_irqenb); set_fifo_bytecount (ep, w_length); writel ((__force u32)status, &dev->epregs [0].ep_data); allow_status (ep); VDEBUG (dev, "%s stat %02x\n", ep->ep.name, status); goto next_endpoints; } break; case USB_REQ_CLEAR_FEATURE: { struct net2280_ep *e; /* hw handles device features */ if (u.r.bRequestType != USB_RECIP_ENDPOINT) goto delegate; if (w_value != USB_ENDPOINT_HALT || w_length != 0) goto do_stall; if ((e = get_ep_by_addr (dev, w_index)) == 0) goto do_stall; if (e->wedged) { VDEBUG(dev, "%s wedged, halt not cleared\n", ep->ep.name); } else { VDEBUG(dev, "%s clear halt\n", ep->ep.name); clear_halt(e); } allow_status (ep); goto next_endpoints; } break; case USB_REQ_SET_FEATURE: { struct net2280_ep *e; /* hw handles device features */ if (u.r.bRequestType != USB_RECIP_ENDPOINT) goto delegate; if (w_value != USB_ENDPOINT_HALT || w_length != 0) goto do_stall; if ((e = get_ep_by_addr (dev, w_index)) == 0) goto do_stall; if (e->ep.name == ep0name) goto do_stall; set_halt (e); allow_status (ep); VDEBUG (dev, "%s set halt\n", ep->ep.name); goto next_endpoints; } break; default: delegate: VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x " "ep_cfg %08x\n", u.r.bRequestType, u.r.bRequest, w_value, w_index, w_length, readl (&ep->regs->ep_cfg)); ep->responded = 0; spin_unlock (&dev->lock); tmp = dev->driver->setup (&dev->gadget, &u.r); spin_lock (&dev->lock); } /* stall ep0 on error */ if (tmp < 0) { do_stall: VDEBUG (dev, "req %02x.%02x protocol STALL; stat %d\n", u.r.bRequestType, u.r.bRequest, tmp); dev->protocol_stall = 1; } /* some in/out token irq should follow; maybe stall then. * driver must queue a request (even zlp) or halt ep0 * before the host times out. */ } #undef w_value #undef w_index #undef w_length next_endpoints: /* endpoint data irq ? */ scratch = stat & 0x7f; stat &= ~0x7f; for (num = 0; scratch; num++) { u32 t; /* do this endpoint's FIFO and queue need tending? */ t = 1 << num; if ((scratch & t) == 0) continue; scratch ^= t; ep = &dev->ep [num]; handle_ep_small (ep); } if (stat) DEBUG (dev, "unhandled irqstat0 %08x\n", stat); } #define DMA_INTERRUPTS ( \ (1 << DMA_D_INTERRUPT) \ | (1 << DMA_C_INTERRUPT) \ | (1 << DMA_B_INTERRUPT) \ | (1 << DMA_A_INTERRUPT)) #define PCI_ERROR_INTERRUPTS ( \ (1 << PCI_MASTER_ABORT_RECEIVED_INTERRUPT) \ | (1 << PCI_TARGET_ABORT_RECEIVED_INTERRUPT) \ | (1 << PCI_RETRY_ABORT_INTERRUPT)) static void handle_stat1_irqs (struct net2280 *dev, u32 stat) { struct net2280_ep *ep; u32 tmp, num, mask, scratch; /* after disconnect there's nothing else to do! */ tmp = (1 << VBUS_INTERRUPT) | (1 << ROOT_PORT_RESET_INTERRUPT); mask = (1 << HIGH_SPEED) | (1 << FULL_SPEED); /* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set. * Root Port Reset is indicated by ROOT_PORT_RESET_INTERRUPT set and * both HIGH_SPEED and FULL_SPEED clear (as ROOT_PORT_RESET_INTERRUPT * only indicates a change in the reset state). */ if (stat & tmp) { writel (tmp, &dev->regs->irqstat1); if ((((stat & (1 << ROOT_PORT_RESET_INTERRUPT)) && ((readl (&dev->usb->usbstat) & mask) == 0)) || ((readl (&dev->usb->usbctl) & (1 << VBUS_PIN)) == 0) ) && ( dev->gadget.speed != USB_SPEED_UNKNOWN)) { DEBUG (dev, "disconnect %s\n", dev->driver->driver.name); stop_activity (dev, dev->driver); ep0_start (dev); return; } stat &= ~tmp; /* vBUS can bounce ... one of many reasons to ignore the * notion of hotplug events on bus connect/disconnect! */ if (!stat) return; } /* NOTE: chip stays in PCI D0 state for now, but it could * enter D1 to save more power */ tmp = (1 << SUSPEND_REQUEST_CHANGE_INTERRUPT); if (stat & tmp) { writel (tmp, &dev->regs->irqstat1); if (stat & (1 << SUSPEND_REQUEST_INTERRUPT)) { if (dev->driver->suspend) dev->driver->suspend (&dev->gadget); if (!enable_suspend) stat &= ~(1 << SUSPEND_REQUEST_INTERRUPT); } else { if (dev->driver->resume) dev->driver->resume (&dev->gadget); /* at high speed, note erratum 0133 */ } stat &= ~tmp; } /* clear any other status/irqs */ if (stat) writel (stat, &dev->regs->irqstat1); /* some status we can just ignore */ if (dev->pdev->device == 0x2280) stat &= ~((1 << CONTROL_STATUS_INTERRUPT) | (1 << SUSPEND_REQUEST_INTERRUPT) | (1 << RESUME_INTERRUPT) | (1 << SOF_INTERRUPT)); else stat &= ~((1 << CONTROL_STATUS_INTERRUPT) | (1 << RESUME_INTERRUPT) | (1 << SOF_DOWN_INTERRUPT) | (1 << SOF_INTERRUPT)); if (!stat) return; // DEBUG (dev, "irqstat1 %08x\n", stat); /* DMA status, for ep-{a,b,c,d} */ scratch = stat & DMA_INTERRUPTS; stat &= ~DMA_INTERRUPTS; scratch >>= 9; for (num = 0; scratch; num++) { struct net2280_dma_regs __iomem *dma; tmp = 1 << num; if ((tmp & scratch) == 0) continue; scratch ^= tmp; ep = &dev->ep [num + 1]; dma = ep->dma; if (!dma) continue; /* clear ep's dma status */ tmp = readl (&dma->dmastat); writel (tmp, &dma->dmastat); /* chaining should stop on abort, short OUT from fifo, * or (stat0 codepath) short OUT transfer. */ if (!use_dma_chaining) { if ((tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT)) == 0) { DEBUG (ep->dev, "%s no xact done? %08x\n", ep->ep.name, tmp); continue; } stop_dma (ep->dma); } /* OUT transfers terminate when the data from the * host is in our memory. Process whatever's done. * On this path, we know transfer's last packet wasn't * less than req->length. NAK_OUT_PACKETS may be set, * or the FIFO may already be holding new packets. * * IN transfers can linger in the FIFO for a very * long time ... we ignore that for now, accounting * precisely (like PIO does) needs per-packet irqs */ scan_dma_completions (ep); /* disable dma on inactive queues; else maybe restart */ if (list_empty (&ep->queue)) { if (use_dma_chaining) stop_dma (ep->dma); } else { tmp = readl (&dma->dmactl); if (!use_dma_chaining || (tmp & (1 << DMA_ENABLE)) == 0) restart_dma (ep); else if (ep->is_in && use_dma_chaining) { struct net2280_request *req; __le32 dmacount; /* the descriptor at the head of the chain * may still have VALID_BIT clear; that's * used to trigger changing DMA_FIFO_VALIDATE * (affects automagic zlp writes). */ req = list_entry (ep->queue.next, struct net2280_request, queue); dmacount = req->td->dmacount; dmacount &= cpu_to_le32 ( (1 << VALID_BIT) | DMA_BYTE_COUNT_MASK); if (dmacount && (dmacount & valid_bit) == 0) restart_dma (ep); } } ep->irqs++; } /* NOTE: there are other PCI errors we might usefully notice. * if they appear very often, here's where to try recovering. */ if (stat & PCI_ERROR_INTERRUPTS) { ERROR (dev, "pci dma error; stat %08x\n", stat); stat &= ~PCI_ERROR_INTERRUPTS; /* these are fatal errors, but "maybe" they won't * happen again ... */ stop_activity (dev, dev->driver); ep0_start (dev); stat = 0; } if (stat) DEBUG (dev, "unhandled irqstat1 %08x\n", stat); } static irqreturn_t net2280_irq (int irq, void *_dev) { struct net2280 *dev = _dev; /* shared interrupt, not ours */ if (!(readl(&dev->regs->irqstat0) & (1 << INTA_ASSERTED))) return IRQ_NONE; spin_lock (&dev->lock); /* handle disconnect, dma, and more */ handle_stat1_irqs (dev, readl (&dev->regs->irqstat1)); /* control requests and PIO */ handle_stat0_irqs (dev, readl (&dev->regs->irqstat0)); spin_unlock (&dev->lock); return IRQ_HANDLED; } /*-------------------------------------------------------------------------*/ static void gadget_release (struct device *_dev) { struct net2280 *dev = dev_get_drvdata (_dev); kfree (dev); } /* tear down the binding between this driver and the pci device */ static void net2280_remove (struct pci_dev *pdev) { struct net2280 *dev = pci_get_drvdata (pdev); usb_del_gadget_udc(&dev->gadget); BUG_ON(dev->driver); /* then clean up the resources we allocated during probe() */ net2280_led_shutdown (dev); if (dev->requests) { int i; for (i = 1; i < 5; i++) { if (!dev->ep [i].dummy) continue; pci_pool_free (dev->requests, dev->ep [i].dummy, dev->ep [i].td_dma); } pci_pool_destroy (dev->requests); } if (dev->got_irq) free_irq (pdev->irq, dev); if (dev->regs) iounmap (dev->regs); if (dev->region) release_mem_region (pci_resource_start (pdev, 0), pci_resource_len (pdev, 0)); if (dev->enabled) pci_disable_device (pdev); device_unregister (&dev->gadget.dev); device_remove_file (&pdev->dev, &dev_attr_registers); pci_set_drvdata (pdev, NULL); INFO (dev, "unbind\n"); } /* wrap this driver around the specified device, but * don't respond over USB until a gadget driver binds to us. */ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) { struct net2280 *dev; unsigned long resource, len; void __iomem *base = NULL; int retval, i; /* alloc, and start init */ dev = kzalloc (sizeof *dev, GFP_KERNEL); if (dev == NULL){ retval = -ENOMEM; goto done; } pci_set_drvdata (pdev, dev); spin_lock_init (&dev->lock); dev->pdev = pdev; dev->gadget.ops = &net2280_ops; dev->gadget.max_speed = USB_SPEED_HIGH; /* the "gadget" abstracts/virtualizes the controller */ dev_set_name(&dev->gadget.dev, "gadget"); dev->gadget.dev.parent = &pdev->dev; dev->gadget.dev.dma_mask = pdev->dev.dma_mask; dev->gadget.dev.release = gadget_release; dev->gadget.name = driver_name; /* now all the pci goodies ... */ if (pci_enable_device (pdev) < 0) { retval = -ENODEV; goto done; } dev->enabled = 1; /* BAR 0 holds all the registers * BAR 1 is 8051 memory; unused here (note erratum 0103) * BAR 2 is fifo memory; unused here */ resource = pci_resource_start (pdev, 0); len = pci_resource_len (pdev, 0); if (!request_mem_region (resource, len, driver_name)) { DEBUG (dev, "controller already in use\n"); retval = -EBUSY; goto done; } dev->region = 1; /* FIXME provide firmware download interface to put * 8051 code into the chip, e.g. to turn on PCI PM. */ base = ioremap_nocache (resource, len); if (base == NULL) { DEBUG (dev, "can't map memory\n"); retval = -EFAULT; goto done; } dev->regs = (struct net2280_regs __iomem *) base; dev->usb = (struct net2280_usb_regs __iomem *) (base + 0x0080); dev->pci = (struct net2280_pci_regs __iomem *) (base + 0x0100); dev->dma = (struct net2280_dma_regs __iomem *) (base + 0x0180); dev->dep = (struct net2280_dep_regs __iomem *) (base + 0x0200); dev->epregs = (struct net2280_ep_regs __iomem *) (base + 0x0300); /* put into initial config, link up all endpoints */ writel (0, &dev->usb->usbctl); usb_reset (dev); usb_reinit (dev); /* irq setup after old hardware is cleaned up */ if (!pdev->irq) { ERROR (dev, "No IRQ. Check PCI setup!\n"); retval = -ENODEV; goto done; } if (request_irq (pdev->irq, net2280_irq, IRQF_SHARED, driver_name, dev) != 0) { ERROR (dev, "request interrupt %d failed\n", pdev->irq); retval = -EBUSY; goto done; } dev->got_irq = 1; /* DMA setup */ /* NOTE: we know only the 32 LSBs of dma addresses may be nonzero */ dev->requests = pci_pool_create ("requests", pdev, sizeof (struct net2280_dma), 0 /* no alignment requirements */, 0 /* or page-crossing issues */); if (!dev->requests) { DEBUG (dev, "can't get request pool\n"); retval = -ENOMEM; goto done; } for (i = 1; i < 5; i++) { struct net2280_dma *td; td = pci_pool_alloc (dev->requests, GFP_KERNEL, &dev->ep [i].td_dma); if (!td) { DEBUG (dev, "can't get dummy %d\n", i); retval = -ENOMEM; goto done; } td->dmacount = 0; /* not VALID */ td->dmaaddr = cpu_to_le32 (DMA_ADDR_INVALID); td->dmadesc = td->dmaaddr; dev->ep [i].dummy = td; } /* enable lower-overhead pci memory bursts during DMA */ writel ( (1 << DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE) // 256 write retries may not be enough... // | (1 << PCI_RETRY_ABORT_ENABLE) | (1 << DMA_READ_MULTIPLE_ENABLE) | (1 << DMA_READ_LINE_ENABLE) , &dev->pci->pcimstctl); /* erratum 0115 shouldn't appear: Linux inits PCI_LATENCY_TIMER */ pci_set_master (pdev); pci_try_set_mwi (pdev); /* ... also flushes any posted pci writes */ dev->chiprev = get_idx_reg (dev->regs, REG_CHIPREV) & 0xffff; /* done */ INFO (dev, "%s\n", driver_desc); INFO (dev, "irq %d, pci mem %p, chip rev %04x\n", pdev->irq, base, dev->chiprev); INFO (dev, "version: " DRIVER_VERSION "; dma %s\n", use_dma ? (use_dma_chaining ? "chaining" : "enabled") : "disabled"); retval = device_register (&dev->gadget.dev); if (retval) goto done; retval = device_create_file (&pdev->dev, &dev_attr_registers); if (retval) goto done; retval = usb_add_gadget_udc(&pdev->dev, &dev->gadget); if (retval) goto done; return 0; done: if (dev) net2280_remove (pdev); return retval; } /* make sure the board is quiescent; otherwise it will continue * generating IRQs across the upcoming reboot. */ static void net2280_shutdown (struct pci_dev *pdev) { struct net2280 *dev = pci_get_drvdata (pdev); /* disable IRQs */ writel (0, &dev->regs->pciirqenb0); writel (0, &dev->regs->pciirqenb1); /* disable the pullup so the host will think we're gone */ writel (0, &dev->usb->usbctl); } /*-------------------------------------------------------------------------*/ static const struct pci_device_id pci_ids [] = { { .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), .class_mask = ~0, .vendor = 0x17cc, .device = 0x2280, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, }, { .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), .class_mask = ~0, .vendor = 0x17cc, .device = 0x2282, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, }, { /* end: all zeroes */ } }; MODULE_DEVICE_TABLE (pci, pci_ids); /* pci driver glue; this is a "new style" PCI driver module */ static struct pci_driver net2280_pci_driver = { .name = (char *) driver_name, .id_table = pci_ids, .probe = net2280_probe, .remove = net2280_remove, .shutdown = net2280_shutdown, /* FIXME add power management support */ }; MODULE_DESCRIPTION (DRIVER_DESC); MODULE_AUTHOR ("David Brownell"); MODULE_LICENSE ("GPL"); static int __init init (void) { if (!use_dma) use_dma_chaining = 0; return pci_register_driver (&net2280_pci_driver); } module_init (init); static void __exit cleanup (void) { pci_unregister_driver (&net2280_pci_driver); } module_exit (cleanup);
gpl-2.0
elliott-wen/S7270-Kernel
drivers/watchdog/pcwd.c
4979
26915
/* * PC Watchdog Driver * by Ken Hollis (khollis@bitgate.com) * * Permission granted from Simon Machell (smachell@berkprod.com) * Written for the Linux Kernel, and GPLed by Ken Hollis * * 960107 Added request_region routines, modulized the whole thing. * 960108 Fixed end-of-file pointer (Thanks to Dan Hollis), added * WD_TIMEOUT define. * 960216 Added eof marker on the file, and changed verbose messages. * 960716 Made functional and cosmetic changes to the source for * inclusion in Linux 2.0.x kernels, thanks to Alan Cox. * 960717 Removed read/seek routines, replaced with ioctl. Also, added * check_region command due to Alan's suggestion. * 960821 Made changes to compile in newer 2.0.x kernels. Added * "cold reboot sense" entry. * 960825 Made a few changes to code, deleted some defines and made * typedefs to replace them. Made heartbeat reset only available * via ioctl, and removed the write routine. * 960828 Added new items for PC Watchdog Rev.C card. * 960829 Changed around all of the IOCTLs, added new features, * added watchdog disable/re-enable routines. Added firmware * version reporting. Added read routine for temperature. * Removed some extra defines, added an autodetect Revision * routine. * 961006 Revised some documentation, fixed some cosmetic bugs. Made * drivers to panic the system if it's overheating at bootup. * 961118 Changed some verbiage on some of the output, tidied up * code bits, and added compatibility to 2.1.x. * 970912 Enabled board on open and disable on close. * 971107 Took account of recent VFS changes (broke read). * 971210 Disable board on initialisation in case board already ticking. * 971222 Changed open/close for temperature handling * Michael Meskes <meskes@debian.org>. * 980112 Used minor numbers from include/linux/miscdevice.h * 990403 Clear reset status after reading control status register in * pcwd_showprevstate(). [Marc Boucher <marc@mbsi.ca>] * 990605 Made changes to code to support Firmware 1.22a, added * fairly useless proc entry. * 990610 removed said useless proc code for the merge <alan> * 000403 Removed last traces of proc code. <davej> * 011214 Added nowayout module option to override * CONFIG_WATCHDOG_NOWAYOUT <Matt_Domsch@dell.com> * Added timeout module option to override default */ /* * A bells and whistles driver is available from http://www.pcwd.de/ * More info available at http://www.berkprod.com/ or * http://www.pcwatchdog.com/ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> /* For module specific items */ #include <linux/moduleparam.h> /* For new moduleparam's */ #include <linux/types.h> /* For standard types (like size_t) */ #include <linux/errno.h> /* For the -ENODEV/... values */ #include <linux/kernel.h> /* For printk/panic/... */ #include <linux/delay.h> /* For mdelay function */ #include <linux/timer.h> /* For timer related operations */ #include <linux/jiffies.h> /* For jiffies stuff */ #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ #include <linux/watchdog.h> /* For the watchdog specific items */ #include <linux/reboot.h> /* For kernel_power_off() */ #include <linux/init.h> /* For __init/__exit/... */ #include <linux/fs.h> /* For file operations */ #include <linux/isa.h> /* For isa devices */ #include <linux/ioport.h> /* For io-port access */ #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ #include <linux/uaccess.h> /* For copy_to_user/put_user/... */ #include <linux/io.h> /* For inb/outb/... */ /* Module and version information */ #define WATCHDOG_VERSION "1.20" #define WATCHDOG_DATE "18 Feb 2007" #define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog" #define WATCHDOG_NAME "pcwd" #define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION "\n" /* * It should be noted that PCWD_REVISION_B was removed because A and B * are essentially the same types of card, with the exception that B * has temperature reporting. Since I didn't receive a Rev.B card, * the Rev.B card is not supported. (It's a good thing too, as they * are no longer in production.) */ #define PCWD_REVISION_A 1 #define PCWD_REVISION_C 2 /* * These are the auto-probe addresses available. * * Revision A only uses ports 0x270 and 0x370. Revision C introduced 0x350. * Revision A has an address range of 2 addresses, while Revision C has 4. */ #define PCWD_ISA_NR_CARDS 3 static int pcwd_ioports[] = { 0x270, 0x350, 0x370, 0x000 }; /* * These are the defines that describe the control status bits for the * PCI-PC Watchdog card. */ /* Port 1 : Control Status #1 for the PC Watchdog card, revision A. */ #define WD_WDRST 0x01 /* Previously reset state */ #define WD_T110 0x02 /* Temperature overheat sense */ #define WD_HRTBT 0x04 /* Heartbeat sense */ #define WD_RLY2 0x08 /* External relay triggered */ #define WD_SRLY2 0x80 /* Software external relay triggered */ /* Port 1 : Control Status #1 for the PC Watchdog card, revision C. */ #define WD_REVC_WTRP 0x01 /* Watchdog Trip status */ #define WD_REVC_HRBT 0x02 /* Watchdog Heartbeat */ #define WD_REVC_TTRP 0x04 /* Temperature Trip status */ #define WD_REVC_RL2A 0x08 /* Relay 2 activated by on-board processor */ #define WD_REVC_RL1A 0x10 /* Relay 1 active */ #define WD_REVC_R2DS 0x40 /* Relay 2 disable */ #define WD_REVC_RLY2 0x80 /* Relay 2 activated? */ /* Port 2 : Control Status #2 */ #define WD_WDIS 0x10 /* Watchdog Disabled */ #define WD_ENTP 0x20 /* Watchdog Enable Temperature Trip */ #define WD_SSEL 0x40 /* Watchdog Switch Select (1:SW1 <-> 0:SW2) */ #define WD_WCMD 0x80 /* Watchdog Command Mode */ /* max. time we give an ISA watchdog card to process a command */ /* 500ms for each 4 bit response (according to spec.) */ #define ISA_COMMAND_TIMEOUT 1000 /* Watchdog's internal commands */ #define CMD_ISA_IDLE 0x00 #define CMD_ISA_VERSION_INTEGER 0x01 #define CMD_ISA_VERSION_TENTH 0x02 #define CMD_ISA_VERSION_HUNDRETH 0x03 #define CMD_ISA_VERSION_MINOR 0x04 #define CMD_ISA_SWITCH_SETTINGS 0x05 #define CMD_ISA_RESET_PC 0x06 #define CMD_ISA_ARM_0 0x07 #define CMD_ISA_ARM_30 0x08 #define CMD_ISA_ARM_60 0x09 #define CMD_ISA_DELAY_TIME_2SECS 0x0A #define CMD_ISA_DELAY_TIME_4SECS 0x0B #define CMD_ISA_DELAY_TIME_8SECS 0x0C #define CMD_ISA_RESET_RELAYS 0x0D /* Watchdog's Dip Switch heartbeat values */ static const int heartbeat_tbl[] = { 20, /* OFF-OFF-OFF = 20 Sec */ 40, /* OFF-OFF-ON = 40 Sec */ 60, /* OFF-ON-OFF = 1 Min */ 300, /* OFF-ON-ON = 5 Min */ 600, /* ON-OFF-OFF = 10 Min */ 1800, /* ON-OFF-ON = 30 Min */ 3600, /* ON-ON-OFF = 1 Hour */ 7200, /* ON-ON-ON = 2 hour */ }; /* * We are using an kernel timer to do the pinging of the watchdog * every ~500ms. We try to set the internal heartbeat of the * watchdog to 2 ms. */ #define WDT_INTERVAL (HZ/2+1) /* We can only use 1 card due to the /dev/watchdog restriction */ static int cards_found; /* internal variables */ static unsigned long open_allowed; static char expect_close; static int temp_panic; /* this is private data for each ISA-PC watchdog card */ static struct { char fw_ver_str[6]; /* The cards firmware version */ int revision; /* The card's revision */ int supports_temp; /* Whether or not the card has a temperature device */ int command_mode; /* Whether or not the card is in command mode */ int boot_status; /* The card's boot status */ int io_addr; /* The cards I/O address */ spinlock_t io_lock; /* the lock for io operations */ struct timer_list timer; /* The timer that pings the watchdog */ unsigned long next_heartbeat; /* the next_heartbeat for the timer */ } pcwd_private; /* module parameters */ #define QUIET 0 /* Default */ #define VERBOSE 1 /* Verbose */ #define DEBUG 2 /* print fancy stuff too */ static int debug = QUIET; module_param(debug, int, 0); MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); /* default heartbeat = delay-time from dip-switches */ #define WATCHDOG_HEARTBEAT 0 static int heartbeat = WATCHDOG_HEARTBEAT; module_param(heartbeat, int, 0); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. " "(2 <= heartbeat <= 7200 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); /* * Internal functions */ static int send_isa_command(int cmd) { int i; int control_status; int port0, last_port0; /* Double read for stabilising */ if (debug >= DEBUG) pr_debug("sending following data cmd=0x%02x\n", cmd); /* The WCMD bit must be 1 and the command is only 4 bits in size */ control_status = (cmd & 0x0F) | WD_WCMD; outb_p(control_status, pcwd_private.io_addr + 2); udelay(ISA_COMMAND_TIMEOUT); port0 = inb_p(pcwd_private.io_addr); for (i = 0; i < 25; ++i) { last_port0 = port0; port0 = inb_p(pcwd_private.io_addr); if (port0 == last_port0) break; /* Data is stable */ udelay(250); } if (debug >= DEBUG) pr_debug("received following data for cmd=0x%02x: port0=0x%02x last_port0=0x%02x\n", cmd, port0, last_port0); return port0; } static int set_command_mode(void) { int i, found = 0, count = 0; /* Set the card into command mode */ spin_lock(&pcwd_private.io_lock); while ((!found) && (count < 3)) { i = send_isa_command(CMD_ISA_IDLE); if (i == 0x00) found = 1; else if (i == 0xF3) { /* Card does not like what we've done to it */ outb_p(0x00, pcwd_private.io_addr + 2); udelay(1200); /* Spec says wait 1ms */ outb_p(0x00, pcwd_private.io_addr + 2); udelay(ISA_COMMAND_TIMEOUT); } count++; } spin_unlock(&pcwd_private.io_lock); pcwd_private.command_mode = found; if (debug >= DEBUG) pr_debug("command_mode=%d\n", pcwd_private.command_mode); return found; } static void unset_command_mode(void) { /* Set the card into normal mode */ spin_lock(&pcwd_private.io_lock); outb_p(0x00, pcwd_private.io_addr + 2); udelay(ISA_COMMAND_TIMEOUT); spin_unlock(&pcwd_private.io_lock); pcwd_private.command_mode = 0; if (debug >= DEBUG) pr_debug("command_mode=%d\n", pcwd_private.command_mode); } static inline void pcwd_check_temperature_support(void) { if (inb(pcwd_private.io_addr) != 0xF0) pcwd_private.supports_temp = 1; } static inline void pcwd_get_firmware(void) { int one, ten, hund, minor; strcpy(pcwd_private.fw_ver_str, "ERROR"); if (set_command_mode()) { one = send_isa_command(CMD_ISA_VERSION_INTEGER); ten = send_isa_command(CMD_ISA_VERSION_TENTH); hund = send_isa_command(CMD_ISA_VERSION_HUNDRETH); minor = send_isa_command(CMD_ISA_VERSION_MINOR); sprintf(pcwd_private.fw_ver_str, "%c.%c%c%c", one, ten, hund, minor); } unset_command_mode(); return; } static inline int pcwd_get_option_switches(void) { int option_switches = 0; if (set_command_mode()) { /* Get switch settings */ option_switches = send_isa_command(CMD_ISA_SWITCH_SETTINGS); } unset_command_mode(); return option_switches; } static void pcwd_show_card_info(void) { int option_switches; /* Get some extra info from the hardware (in command/debug/diag mode) */ if (pcwd_private.revision == PCWD_REVISION_A) pr_info("ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", pcwd_private.io_addr); else if (pcwd_private.revision == PCWD_REVISION_C) { pcwd_get_firmware(); pr_info("ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n", pcwd_private.io_addr, pcwd_private.fw_ver_str); option_switches = pcwd_get_option_switches(); pr_info("Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", option_switches, ((option_switches & 0x10) ? "ON" : "OFF"), ((option_switches & 0x08) ? "ON" : "OFF")); /* Reprogram internal heartbeat to 2 seconds */ if (set_command_mode()) { send_isa_command(CMD_ISA_DELAY_TIME_2SECS); unset_command_mode(); } } if (pcwd_private.supports_temp) pr_info("Temperature Option Detected\n"); if (pcwd_private.boot_status & WDIOF_CARDRESET) pr_info("Previous reboot was caused by the card\n"); if (pcwd_private.boot_status & WDIOF_OVERHEAT) { pr_emerg("Card senses a CPU Overheat. Panicking!\n"); pr_emerg("CPU Overheat\n"); } if (pcwd_private.boot_status == 0) pr_info("No previous trip detected - Cold boot or reset\n"); } static void pcwd_timer_ping(unsigned long data) { int wdrst_stat; /* If we got a heartbeat pulse within the WDT_INTERVAL * we agree to ping the WDT */ if (time_before(jiffies, pcwd_private.next_heartbeat)) { /* Ping the watchdog */ spin_lock(&pcwd_private.io_lock); if (pcwd_private.revision == PCWD_REVISION_A) { /* Rev A cards are reset by setting the WD_WDRST bit in register 1 */ wdrst_stat = inb_p(pcwd_private.io_addr); wdrst_stat &= 0x0F; wdrst_stat |= WD_WDRST; outb_p(wdrst_stat, pcwd_private.io_addr + 1); } else { /* Re-trigger watchdog by writing to port 0 */ outb_p(0x00, pcwd_private.io_addr); } /* Re-set the timer interval */ mod_timer(&pcwd_private.timer, jiffies + WDT_INTERVAL); spin_unlock(&pcwd_private.io_lock); } else { pr_warn("Heartbeat lost! Will not ping the watchdog\n"); } } static int pcwd_start(void) { int stat_reg; pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ); /* Start the timer */ mod_timer(&pcwd_private.timer, jiffies + WDT_INTERVAL); /* Enable the port */ if (pcwd_private.revision == PCWD_REVISION_C) { spin_lock(&pcwd_private.io_lock); outb_p(0x00, pcwd_private.io_addr + 3); udelay(ISA_COMMAND_TIMEOUT); stat_reg = inb_p(pcwd_private.io_addr + 2); spin_unlock(&pcwd_private.io_lock); if (stat_reg & WD_WDIS) { pr_info("Could not start watchdog\n"); return -EIO; } } if (debug >= VERBOSE) pr_debug("Watchdog started\n"); return 0; } static int pcwd_stop(void) { int stat_reg; /* Stop the timer */ del_timer(&pcwd_private.timer); /* Disable the board */ if (pcwd_private.revision == PCWD_REVISION_C) { spin_lock(&pcwd_private.io_lock); outb_p(0xA5, pcwd_private.io_addr + 3); udelay(ISA_COMMAND_TIMEOUT); outb_p(0xA5, pcwd_private.io_addr + 3); udelay(ISA_COMMAND_TIMEOUT); stat_reg = inb_p(pcwd_private.io_addr + 2); spin_unlock(&pcwd_private.io_lock); if ((stat_reg & WD_WDIS) == 0) { pr_info("Could not stop watchdog\n"); return -EIO; } } if (debug >= VERBOSE) pr_debug("Watchdog stopped\n"); return 0; } static int pcwd_keepalive(void) { /* user land ping */ pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ); if (debug >= DEBUG) pr_debug("Watchdog keepalive signal send\n"); return 0; } static int pcwd_set_heartbeat(int t) { if (t < 2 || t > 7200) /* arbitrary upper limit */ return -EINVAL; heartbeat = t; if (debug >= VERBOSE) pr_debug("New heartbeat: %d\n", heartbeat); return 0; } static int pcwd_get_status(int *status) { int control_status; *status = 0; spin_lock(&pcwd_private.io_lock); if (pcwd_private.revision == PCWD_REVISION_A) /* Rev A cards return status information from * the base register, which is used for the * temperature in other cards. */ control_status = inb(pcwd_private.io_addr); else { /* Rev C cards return card status in the base * address + 1 register. And use different bits * to indicate a card initiated reset, and an * over-temperature condition. And the reboot * status can be reset. */ control_status = inb(pcwd_private.io_addr + 1); } spin_unlock(&pcwd_private.io_lock); if (pcwd_private.revision == PCWD_REVISION_A) { if (control_status & WD_WDRST) *status |= WDIOF_CARDRESET; if (control_status & WD_T110) { *status |= WDIOF_OVERHEAT; if (temp_panic) { pr_info("Temperature overheat trip!\n"); kernel_power_off(); } } } else { if (control_status & WD_REVC_WTRP) *status |= WDIOF_CARDRESET; if (control_status & WD_REVC_TTRP) { *status |= WDIOF_OVERHEAT; if (temp_panic) { pr_info("Temperature overheat trip!\n"); kernel_power_off(); } } } return 0; } static int pcwd_clear_status(void) { int control_status; if (pcwd_private.revision == PCWD_REVISION_C) { spin_lock(&pcwd_private.io_lock); if (debug >= VERBOSE) pr_info("clearing watchdog trip status\n"); control_status = inb_p(pcwd_private.io_addr + 1); if (debug >= DEBUG) { pr_debug("status was: 0x%02x\n", control_status); pr_debug("sending: 0x%02x\n", (control_status & WD_REVC_R2DS)); } /* clear reset status & Keep Relay 2 disable state as it is */ outb_p((control_status & WD_REVC_R2DS), pcwd_private.io_addr + 1); spin_unlock(&pcwd_private.io_lock); } return 0; } static int pcwd_get_temperature(int *temperature) { /* check that port 0 gives temperature info and no command results */ if (pcwd_private.command_mode) return -1; *temperature = 0; if (!pcwd_private.supports_temp) return -ENODEV; /* * Convert celsius to fahrenheit, since this was * the decided 'standard' for this return value. */ spin_lock(&pcwd_private.io_lock); *temperature = ((inb(pcwd_private.io_addr)) * 9 / 5) + 32; spin_unlock(&pcwd_private.io_lock); if (debug >= DEBUG) { pr_debug("temperature is: %d F\n", *temperature); } return 0; } /* * /dev/watchdog handling */ static long pcwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int rv; int status; int temperature; int new_heartbeat; int __user *argp = (int __user *)arg; static const struct watchdog_info ident = { .options = WDIOF_OVERHEAT | WDIOF_CARDRESET | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, .firmware_version = 1, .identity = "PCWD", }; switch (cmd) { case WDIOC_GETSUPPORT: if (copy_to_user(argp, &ident, sizeof(ident))) return -EFAULT; return 0; case WDIOC_GETSTATUS: pcwd_get_status(&status); return put_user(status, argp); case WDIOC_GETBOOTSTATUS: return put_user(pcwd_private.boot_status, argp); case WDIOC_GETTEMP: if (pcwd_get_temperature(&temperature)) return -EFAULT; return put_user(temperature, argp); case WDIOC_SETOPTIONS: if (pcwd_private.revision == PCWD_REVISION_C) { if (get_user(rv, argp)) return -EFAULT; if (rv & WDIOS_DISABLECARD) { status = pcwd_stop(); if (status < 0) return status; } if (rv & WDIOS_ENABLECARD) { status = pcwd_start(); if (status < 0) return status; } if (rv & WDIOS_TEMPPANIC) temp_panic = 1; } return -EINVAL; case WDIOC_KEEPALIVE: pcwd_keepalive(); return 0; case WDIOC_SETTIMEOUT: if (get_user(new_heartbeat, argp)) return -EFAULT; if (pcwd_set_heartbeat(new_heartbeat)) return -EINVAL; pcwd_keepalive(); /* Fall */ case WDIOC_GETTIMEOUT: return put_user(heartbeat, argp); default: return -ENOTTY; } return 0; } static ssize_t pcwd_write(struct file *file, const char __user *buf, size_t len, loff_t *ppos) { if (len) { if (!nowayout) { size_t i; /* In case it was set long ago */ expect_close = 0; for (i = 0; i != len; i++) { char c; if (get_user(c, buf + i)) return -EFAULT; if (c == 'V') expect_close = 42; } } pcwd_keepalive(); } return len; } static int pcwd_open(struct inode *inode, struct file *file) { if (test_and_set_bit(0, &open_allowed)) return -EBUSY; if (nowayout) __module_get(THIS_MODULE); /* Activate */ pcwd_start(); pcwd_keepalive(); return nonseekable_open(inode, file); } static int pcwd_close(struct inode *inode, struct file *file) { if (expect_close == 42) pcwd_stop(); else { pr_crit("Unexpected close, not stopping watchdog!\n"); pcwd_keepalive(); } expect_close = 0; clear_bit(0, &open_allowed); return 0; } /* * /dev/temperature handling */ static ssize_t pcwd_temp_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { int temperature; if (pcwd_get_temperature(&temperature)) return -EFAULT; if (copy_to_user(buf, &temperature, 1)) return -EFAULT; return 1; } static int pcwd_temp_open(struct inode *inode, struct file *file) { if (!pcwd_private.supports_temp) return -ENODEV; return nonseekable_open(inode, file); } static int pcwd_temp_close(struct inode *inode, struct file *file) { return 0; } /* * Kernel Interfaces */ static const struct file_operations pcwd_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = pcwd_write, .unlocked_ioctl = pcwd_ioctl, .open = pcwd_open, .release = pcwd_close, }; static struct miscdevice pcwd_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", .fops = &pcwd_fops, }; static const struct file_operations pcwd_temp_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .read = pcwd_temp_read, .open = pcwd_temp_open, .release = pcwd_temp_close, }; static struct miscdevice temp_miscdev = { .minor = TEMP_MINOR, .name = "temperature", .fops = &pcwd_temp_fops, }; /* * Init & exit routines */ static inline int get_revision(void) { int r = PCWD_REVISION_C; spin_lock(&pcwd_private.io_lock); /* REV A cards use only 2 io ports; test * presumes a floating bus reads as 0xff. */ if ((inb(pcwd_private.io_addr + 2) == 0xFF) || (inb(pcwd_private.io_addr + 3) == 0xFF)) r = PCWD_REVISION_A; spin_unlock(&pcwd_private.io_lock); return r; } /* * The ISA cards have a heartbeat bit in one of the registers, which * register is card dependent. The heartbeat bit is monitored, and if * found, is considered proof that a Berkshire card has been found. * The initial rate is once per second at board start up, then twice * per second for normal operation. */ static int __devinit pcwd_isa_match(struct device *dev, unsigned int id) { int base_addr = pcwd_ioports[id]; int port0, last_port0; /* Reg 0, in case it's REV A */ int port1, last_port1; /* Register 1 for REV C cards */ int i; int retval; if (debug >= DEBUG) pr_debug("pcwd_isa_match id=%d\n", id); if (!request_region(base_addr, 4, "PCWD")) { pr_info("Port 0x%04x unavailable\n", base_addr); return 0; } retval = 0; port0 = inb_p(base_addr); /* For REV A boards */ port1 = inb_p(base_addr + 1); /* For REV C boards */ if (port0 != 0xff || port1 != 0xff) { /* Not an 'ff' from a floating bus, so must be a card! */ for (i = 0; i < 4; ++i) { msleep(500); last_port0 = port0; last_port1 = port1; port0 = inb_p(base_addr); port1 = inb_p(base_addr + 1); /* Has either hearbeat bit changed? */ if ((port0 ^ last_port0) & WD_HRTBT || (port1 ^ last_port1) & WD_REVC_HRBT) { retval = 1; break; } } } release_region(base_addr, 4); return retval; } static int __devinit pcwd_isa_probe(struct device *dev, unsigned int id) { int ret; if (debug >= DEBUG) pr_debug("pcwd_isa_probe id=%d\n", id); cards_found++; if (cards_found == 1) pr_info("v%s Ken Hollis (kenji@bitgate.com)\n", WATCHDOG_VERSION); if (cards_found > 1) { pr_err("This driver only supports 1 device\n"); return -ENODEV; } if (pcwd_ioports[id] == 0x0000) { pr_err("No I/O-Address for card detected\n"); return -ENODEV; } pcwd_private.io_addr = pcwd_ioports[id]; spin_lock_init(&pcwd_private.io_lock); /* Check card's revision */ pcwd_private.revision = get_revision(); if (!request_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4, "PCWD")) { pr_err("I/O address 0x%04x already in use\n", pcwd_private.io_addr); ret = -EIO; goto error_request_region; } /* Initial variables */ pcwd_private.supports_temp = 0; temp_panic = 0; pcwd_private.boot_status = 0x0000; /* get the boot_status */ pcwd_get_status(&pcwd_private.boot_status); /* clear the "card caused reboot" flag */ pcwd_clear_status(); setup_timer(&pcwd_private.timer, pcwd_timer_ping, 0); /* Disable the board */ pcwd_stop(); /* Check whether or not the card supports the temperature device */ pcwd_check_temperature_support(); /* Show info about the card itself */ pcwd_show_card_info(); /* If heartbeat = 0 then we use the heartbeat from the dip-switches */ if (heartbeat == 0) heartbeat = heartbeat_tbl[(pcwd_get_option_switches() & 0x07)]; /* Check that the heartbeat value is within it's range; if not reset to the default */ if (pcwd_set_heartbeat(heartbeat)) { pcwd_set_heartbeat(WATCHDOG_HEARTBEAT); pr_info("heartbeat value must be 2 <= heartbeat <= 7200, using %d\n", WATCHDOG_HEARTBEAT); } if (pcwd_private.supports_temp) { ret = misc_register(&temp_miscdev); if (ret) { pr_err("cannot register miscdev on minor=%d (err=%d)\n", TEMP_MINOR, ret); goto error_misc_register_temp; } } ret = misc_register(&pcwd_miscdev); if (ret) { pr_err("cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret); goto error_misc_register_watchdog; } pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n", heartbeat, nowayout); return 0; error_misc_register_watchdog: if (pcwd_private.supports_temp) misc_deregister(&temp_miscdev); error_misc_register_temp: release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); error_request_region: pcwd_private.io_addr = 0x0000; cards_found--; return ret; } static int __devexit pcwd_isa_remove(struct device *dev, unsigned int id) { if (debug >= DEBUG) pr_debug("pcwd_isa_remove id=%d\n", id); if (!pcwd_private.io_addr) return 1; /* Disable the board */ if (!nowayout) pcwd_stop(); /* Deregister */ misc_deregister(&pcwd_miscdev); if (pcwd_private.supports_temp) misc_deregister(&temp_miscdev); release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); pcwd_private.io_addr = 0x0000; cards_found--; return 0; } static void pcwd_isa_shutdown(struct device *dev, unsigned int id) { if (debug >= DEBUG) pr_debug("pcwd_isa_shutdown id=%d\n", id); pcwd_stop(); } static struct isa_driver pcwd_isa_driver = { .match = pcwd_isa_match, .probe = pcwd_isa_probe, .remove = __devexit_p(pcwd_isa_remove), .shutdown = pcwd_isa_shutdown, .driver = { .owner = THIS_MODULE, .name = WATCHDOG_NAME, }, }; static int __init pcwd_init_module(void) { return isa_register_driver(&pcwd_isa_driver, PCWD_ISA_NR_CARDS); } static void __exit pcwd_cleanup_module(void) { isa_unregister_driver(&pcwd_isa_driver); pr_info("Watchdog Module Unloaded\n"); } module_init(pcwd_init_module); module_exit(pcwd_cleanup_module); MODULE_AUTHOR("Ken Hollis <kenji@bitgate.com>, " "Wim Van Sebroeck <wim@iguana.be>"); MODULE_DESCRIPTION("Berkshire ISA-PC Watchdog driver"); MODULE_VERSION(WATCHDOG_VERSION); MODULE_LICENSE("GPL"); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); MODULE_ALIAS_MISCDEV(TEMP_MINOR);
gpl-2.0
a1d3s/linux-bpi
net/netfilter/xt_mac.c
4979
1784
/* Kernel module to match MAC address parameters. */ /* (C) 1999-2001 Paul `Rusty' Russell * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/module.h> #include <linux/skbuff.h> #include <linux/if_arp.h> #include <linux/if_ether.h> #include <linux/etherdevice.h> #include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv6.h> #include <linux/netfilter/xt_mac.h> #include <linux/netfilter/x_tables.h> MODULE_LICENSE("GPL"); MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>"); MODULE_DESCRIPTION("Xtables: MAC address match"); MODULE_ALIAS("ipt_mac"); MODULE_ALIAS("ip6t_mac"); static bool mac_mt(const struct sk_buff *skb, struct xt_action_param *par) { const struct xt_mac_info *info = par->matchinfo; bool ret; if (skb->dev == NULL || skb->dev->type != ARPHRD_ETHER) return false; if (skb_mac_header(skb) < skb->head) return false; if (skb_mac_header(skb) + ETH_HLEN > skb->data) return false; ret = ether_addr_equal(eth_hdr(skb)->h_source, info->srcaddr); ret ^= info->invert; return ret; } static struct xt_match mac_mt_reg __read_mostly = { .name = "mac", .revision = 0, .family = NFPROTO_UNSPEC, .match = mac_mt, .matchsize = sizeof(struct xt_mac_info), .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_IN) | (1 << NF_INET_FORWARD), .me = THIS_MODULE, }; static int __init mac_mt_init(void) { return xt_register_match(&mac_mt_reg); } static void __exit mac_mt_exit(void) { xt_unregister_match(&mac_mt_reg); } module_init(mac_mt_init); module_exit(mac_mt_exit);
gpl-2.0
figue/jolie-mako
drivers/gpio/gpio-pl061.c
4979
9484
/* * Copyright (C) 2008, 2009 Provigent Ltd. * * 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. * * Driver for the ARM PrimeCell(tm) General Purpose Input/Output (PL061) * * Data sheet: ARM DDI 0190B, September 2000 */ #include <linux/spinlock.h> #include <linux/errno.h> #include <linux/module.h> #include <linux/io.h> #include <linux/ioport.h> #include <linux/irq.h> #include <linux/bitops.h> #include <linux/workqueue.h> #include <linux/gpio.h> #include <linux/device.h> #include <linux/amba/bus.h> #include <linux/amba/pl061.h> #include <linux/slab.h> #include <linux/pm.h> #include <asm/mach/irq.h> #define GPIODIR 0x400 #define GPIOIS 0x404 #define GPIOIBE 0x408 #define GPIOIEV 0x40C #define GPIOIE 0x410 #define GPIORIS 0x414 #define GPIOMIS 0x418 #define GPIOIC 0x41C #define PL061_GPIO_NR 8 #ifdef CONFIG_PM struct pl061_context_save_regs { u8 gpio_data; u8 gpio_dir; u8 gpio_is; u8 gpio_ibe; u8 gpio_iev; u8 gpio_ie; }; #endif struct pl061_gpio { /* Each of the two spinlocks protects a different set of hardware * regiters and data structurs. This decouples the code of the IRQ from * the GPIO code. This also makes the case of a GPIO routine call from * the IRQ code simpler. */ spinlock_t lock; /* GPIO registers */ void __iomem *base; int irq_base; struct irq_chip_generic *irq_gc; struct gpio_chip gc; #ifdef CONFIG_PM struct pl061_context_save_regs csave_regs; #endif }; static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) { struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); unsigned long flags; unsigned char gpiodir; if (offset >= gc->ngpio) return -EINVAL; spin_lock_irqsave(&chip->lock, flags); gpiodir = readb(chip->base + GPIODIR); gpiodir &= ~(1 << offset); writeb(gpiodir, chip->base + GPIODIR); spin_unlock_irqrestore(&chip->lock, flags); return 0; } static int pl061_direction_output(struct gpio_chip *gc, unsigned offset, int value) { struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); unsigned long flags; unsigned char gpiodir; if (offset >= gc->ngpio) return -EINVAL; spin_lock_irqsave(&chip->lock, flags); writeb(!!value << offset, chip->base + (1 << (offset + 2))); gpiodir = readb(chip->base + GPIODIR); gpiodir |= 1 << offset; writeb(gpiodir, chip->base + GPIODIR); /* * gpio value is set again, because pl061 doesn't allow to set value of * a gpio pin before configuring it in OUT mode. */ writeb(!!value << offset, chip->base + (1 << (offset + 2))); spin_unlock_irqrestore(&chip->lock, flags); return 0; } static int pl061_get_value(struct gpio_chip *gc, unsigned offset) { struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); return !!readb(chip->base + (1 << (offset + 2))); } static void pl061_set_value(struct gpio_chip *gc, unsigned offset, int value) { struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); writeb(!!value << offset, chip->base + (1 << (offset + 2))); } static int pl061_to_irq(struct gpio_chip *gc, unsigned offset) { struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); if (chip->irq_base <= 0) return -EINVAL; return chip->irq_base + offset; } static int pl061_irq_type(struct irq_data *d, unsigned trigger) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); struct pl061_gpio *chip = gc->private; int offset = d->irq - chip->irq_base; unsigned long flags; u8 gpiois, gpioibe, gpioiev; if (offset < 0 || offset >= PL061_GPIO_NR) return -EINVAL; raw_spin_lock_irqsave(&gc->lock, flags); gpioiev = readb(chip->base + GPIOIEV); gpiois = readb(chip->base + GPIOIS); if (trigger & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) { gpiois |= 1 << offset; if (trigger & IRQ_TYPE_LEVEL_HIGH) gpioiev |= 1 << offset; else gpioiev &= ~(1 << offset); } else gpiois &= ~(1 << offset); writeb(gpiois, chip->base + GPIOIS); gpioibe = readb(chip->base + GPIOIBE); if ((trigger & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) gpioibe |= 1 << offset; else { gpioibe &= ~(1 << offset); if (trigger & IRQ_TYPE_EDGE_RISING) gpioiev |= 1 << offset; else if (trigger & IRQ_TYPE_EDGE_FALLING) gpioiev &= ~(1 << offset); } writeb(gpioibe, chip->base + GPIOIBE); writeb(gpioiev, chip->base + GPIOIEV); raw_spin_unlock_irqrestore(&gc->lock, flags); return 0; } static void pl061_irq_handler(unsigned irq, struct irq_desc *desc) { unsigned long pending; int offset; struct pl061_gpio *chip = irq_desc_get_handler_data(desc); struct irq_chip *irqchip = irq_desc_get_chip(desc); chained_irq_enter(irqchip, desc); pending = readb(chip->base + GPIOMIS); writeb(pending, chip->base + GPIOIC); if (pending) { for_each_set_bit(offset, &pending, PL061_GPIO_NR) generic_handle_irq(pl061_to_irq(&chip->gc, offset)); } chained_irq_exit(irqchip, desc); } static void __init pl061_init_gc(struct pl061_gpio *chip, int irq_base) { struct irq_chip_type *ct; chip->irq_gc = irq_alloc_generic_chip("gpio-pl061", 1, irq_base, chip->base, handle_simple_irq); chip->irq_gc->private = chip; ct = chip->irq_gc->chip_types; ct->chip.irq_mask = irq_gc_mask_clr_bit; ct->chip.irq_unmask = irq_gc_mask_set_bit; ct->chip.irq_set_type = pl061_irq_type; ct->chip.irq_set_wake = irq_gc_set_wake; ct->regs.mask = GPIOIE; irq_setup_generic_chip(chip->irq_gc, IRQ_MSK(PL061_GPIO_NR), IRQ_GC_INIT_NESTED_LOCK, IRQ_NOREQUEST, 0); } static int pl061_probe(struct amba_device *dev, const struct amba_id *id) { struct pl061_platform_data *pdata; struct pl061_gpio *chip; int ret, irq, i; chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; pdata = dev->dev.platform_data; if (pdata) { chip->gc.base = pdata->gpio_base; chip->irq_base = pdata->irq_base; } else if (dev->dev.of_node) { chip->gc.base = -1; chip->irq_base = 0; } else { ret = -ENODEV; goto free_mem; } if (!request_mem_region(dev->res.start, resource_size(&dev->res), "pl061")) { ret = -EBUSY; goto free_mem; } chip->base = ioremap(dev->res.start, resource_size(&dev->res)); if (chip->base == NULL) { ret = -ENOMEM; goto release_region; } spin_lock_init(&chip->lock); chip->gc.direction_input = pl061_direction_input; chip->gc.direction_output = pl061_direction_output; chip->gc.get = pl061_get_value; chip->gc.set = pl061_set_value; chip->gc.to_irq = pl061_to_irq; chip->gc.ngpio = PL061_GPIO_NR; chip->gc.label = dev_name(&dev->dev); chip->gc.dev = &dev->dev; chip->gc.owner = THIS_MODULE; ret = gpiochip_add(&chip->gc); if (ret) goto iounmap; /* * irq_chip support */ if (chip->irq_base <= 0) return 0; pl061_init_gc(chip, chip->irq_base); writeb(0, chip->base + GPIOIE); /* disable irqs */ irq = dev->irq[0]; if (irq < 0) { ret = -ENODEV; goto iounmap; } irq_set_chained_handler(irq, pl061_irq_handler); irq_set_handler_data(irq, chip); for (i = 0; i < PL061_GPIO_NR; i++) { if (pdata) { if (pdata->directions & (1 << i)) pl061_direction_output(&chip->gc, i, pdata->values & (1 << i)); else pl061_direction_input(&chip->gc, i); } } amba_set_drvdata(dev, chip); return 0; iounmap: iounmap(chip->base); release_region: release_mem_region(dev->res.start, resource_size(&dev->res)); free_mem: kfree(chip); return ret; } #ifdef CONFIG_PM static int pl061_suspend(struct device *dev) { struct pl061_gpio *chip = dev_get_drvdata(dev); int offset; chip->csave_regs.gpio_data = 0; chip->csave_regs.gpio_dir = readb(chip->base + GPIODIR); chip->csave_regs.gpio_is = readb(chip->base + GPIOIS); chip->csave_regs.gpio_ibe = readb(chip->base + GPIOIBE); chip->csave_regs.gpio_iev = readb(chip->base + GPIOIEV); chip->csave_regs.gpio_ie = readb(chip->base + GPIOIE); for (offset = 0; offset < PL061_GPIO_NR; offset++) { if (chip->csave_regs.gpio_dir & (1 << offset)) chip->csave_regs.gpio_data |= pl061_get_value(&chip->gc, offset) << offset; } return 0; } static int pl061_resume(struct device *dev) { struct pl061_gpio *chip = dev_get_drvdata(dev); int offset; for (offset = 0; offset < PL061_GPIO_NR; offset++) { if (chip->csave_regs.gpio_dir & (1 << offset)) pl061_direction_output(&chip->gc, offset, chip->csave_regs.gpio_data & (1 << offset)); else pl061_direction_input(&chip->gc, offset); } writeb(chip->csave_regs.gpio_is, chip->base + GPIOIS); writeb(chip->csave_regs.gpio_ibe, chip->base + GPIOIBE); writeb(chip->csave_regs.gpio_iev, chip->base + GPIOIEV); writeb(chip->csave_regs.gpio_ie, chip->base + GPIOIE); return 0; } static const struct dev_pm_ops pl061_dev_pm_ops = { .suspend = pl061_suspend, .resume = pl061_resume, .freeze = pl061_suspend, .restore = pl061_resume, }; #endif static struct amba_id pl061_ids[] = { { .id = 0x00041061, .mask = 0x000fffff, }, { 0, 0 }, }; MODULE_DEVICE_TABLE(amba, pl061_ids); static struct amba_driver pl061_gpio_driver = { .drv = { .name = "pl061_gpio", #ifdef CONFIG_PM .pm = &pl061_dev_pm_ops, #endif }, .id_table = pl061_ids, .probe = pl061_probe, }; static int __init pl061_gpio_init(void) { return amba_driver_register(&pl061_gpio_driver); } subsys_initcall(pl061_gpio_init); MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); MODULE_DESCRIPTION("PL061 GPIO driver"); MODULE_LICENSE("GPL");
gpl-2.0
Supervenom/linux-mod_sys_call
net/netfilter/xt_mac.c
4979
1784
/* Kernel module to match MAC address parameters. */ /* (C) 1999-2001 Paul `Rusty' Russell * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/module.h> #include <linux/skbuff.h> #include <linux/if_arp.h> #include <linux/if_ether.h> #include <linux/etherdevice.h> #include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv6.h> #include <linux/netfilter/xt_mac.h> #include <linux/netfilter/x_tables.h> MODULE_LICENSE("GPL"); MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>"); MODULE_DESCRIPTION("Xtables: MAC address match"); MODULE_ALIAS("ipt_mac"); MODULE_ALIAS("ip6t_mac"); static bool mac_mt(const struct sk_buff *skb, struct xt_action_param *par) { const struct xt_mac_info *info = par->matchinfo; bool ret; if (skb->dev == NULL || skb->dev->type != ARPHRD_ETHER) return false; if (skb_mac_header(skb) < skb->head) return false; if (skb_mac_header(skb) + ETH_HLEN > skb->data) return false; ret = ether_addr_equal(eth_hdr(skb)->h_source, info->srcaddr); ret ^= info->invert; return ret; } static struct xt_match mac_mt_reg __read_mostly = { .name = "mac", .revision = 0, .family = NFPROTO_UNSPEC, .match = mac_mt, .matchsize = sizeof(struct xt_mac_info), .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_IN) | (1 << NF_INET_FORWARD), .me = THIS_MODULE, }; static int __init mac_mt_init(void) { return xt_register_match(&mac_mt_reg); } static void __exit mac_mt_exit(void) { xt_unregister_match(&mac_mt_reg); } module_init(mac_mt_init); module_exit(mac_mt_exit);
gpl-2.0
kashifmin/BLU_LIFE_ONE
drivers/pcmcia/bcm63xx_pcmcia.c
4979
13726
/* * 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. * * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/ioport.h> #include <linux/timer.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/pci.h> #include <linux/gpio.h> #include <bcm63xx_regs.h> #include <bcm63xx_io.h> #include "bcm63xx_pcmcia.h" #define PFX "bcm63xx_pcmcia: " #ifdef CONFIG_CARDBUS /* if cardbus is used, platform device needs reference to actual pci * device */ static struct pci_dev *bcm63xx_cb_dev; #endif /* * read/write helper for pcmcia regs */ static inline u32 pcmcia_readl(struct bcm63xx_pcmcia_socket *skt, u32 off) { return bcm_readl(skt->base + off); } static inline void pcmcia_writel(struct bcm63xx_pcmcia_socket *skt, u32 val, u32 off) { bcm_writel(val, skt->base + off); } /* * This callback should (re-)initialise the socket, turn on status * interrupts and PCMCIA bus, and wait for power to stabilise so that * the card status signals report correctly. * * Hardware cannot do that. */ static int bcm63xx_pcmcia_sock_init(struct pcmcia_socket *sock) { return 0; } /* * This callback should remove power on the socket, disable IRQs from * the card, turn off status interrupts, and disable the PCMCIA bus. * * Hardware cannot do that. */ static int bcm63xx_pcmcia_suspend(struct pcmcia_socket *sock) { return 0; } /* * Implements the set_socket() operation for the in-kernel PCMCIA * service (formerly SS_SetSocket in Card Services). We more or * less punt all of this work and let the kernel handle the details * of power configuration, reset, &c. We also record the value of * `state' in order to regurgitate it to the PCMCIA core later. */ static int bcm63xx_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state) { struct bcm63xx_pcmcia_socket *skt; unsigned long flags; u32 val; skt = sock->driver_data; spin_lock_irqsave(&skt->lock, flags); /* note: hardware cannot control socket power, so we will * always report SS_POWERON */ /* apply socket reset */ val = pcmcia_readl(skt, PCMCIA_C1_REG); if (state->flags & SS_RESET) val |= PCMCIA_C1_RESET_MASK; else val &= ~PCMCIA_C1_RESET_MASK; /* reverse reset logic for cardbus card */ if (skt->card_detected && (skt->card_type & CARD_CARDBUS)) val ^= PCMCIA_C1_RESET_MASK; pcmcia_writel(skt, val, PCMCIA_C1_REG); /* keep requested state for event reporting */ skt->requested_state = *state; spin_unlock_irqrestore(&skt->lock, flags); return 0; } /* * identity cardtype from VS[12] input, CD[12] input while only VS2 is * floating, and CD[12] input while only VS1 is floating */ enum { IN_VS1 = (1 << 0), IN_VS2 = (1 << 1), IN_CD1_VS2H = (1 << 2), IN_CD2_VS2H = (1 << 3), IN_CD1_VS1H = (1 << 4), IN_CD2_VS1H = (1 << 5), }; static const u8 vscd_to_cardtype[] = { /* VS1 float, VS2 float */ [IN_VS1 | IN_VS2] = (CARD_PCCARD | CARD_5V), /* VS1 grounded, VS2 float */ [IN_VS2] = (CARD_PCCARD | CARD_5V | CARD_3V), /* VS1 grounded, VS2 grounded */ [0] = (CARD_PCCARD | CARD_5V | CARD_3V | CARD_XV), /* VS1 tied to CD1, VS2 float */ [IN_VS1 | IN_VS2 | IN_CD1_VS1H] = (CARD_CARDBUS | CARD_3V), /* VS1 grounded, VS2 tied to CD2 */ [IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V | CARD_XV), /* VS1 tied to CD2, VS2 grounded */ [IN_VS1 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_3V | CARD_XV | CARD_YV), /* VS1 float, VS2 grounded */ [IN_VS1] = (CARD_PCCARD | CARD_XV), /* VS1 float, VS2 tied to CD2 */ [IN_VS1 | IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V), /* VS1 float, VS2 tied to CD1 */ [IN_VS1 | IN_VS2 | IN_CD1_VS2H] = (CARD_CARDBUS | CARD_XV | CARD_YV), /* VS1 tied to CD2, VS2 float */ [IN_VS1 | IN_VS2 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_YV), /* VS2 grounded, VS1 is tied to CD1, CD2 is grounded */ [IN_VS1 | IN_CD1_VS1H] = 0, /* ignore cardbay */ }; /* * poll hardware to check card insertion status */ static unsigned int __get_socket_status(struct bcm63xx_pcmcia_socket *skt) { unsigned int stat; u32 val; stat = 0; /* check CD for card presence */ val = pcmcia_readl(skt, PCMCIA_C1_REG); if (!(val & PCMCIA_C1_CD1_MASK) && !(val & PCMCIA_C1_CD2_MASK)) stat |= SS_DETECT; /* if new insertion, detect cardtype */ if ((stat & SS_DETECT) && !skt->card_detected) { unsigned int stat = 0; /* float VS1, float VS2 */ val |= PCMCIA_C1_VS1OE_MASK; val |= PCMCIA_C1_VS2OE_MASK; pcmcia_writel(skt, val, PCMCIA_C1_REG); /* wait for output to stabilize and read VS[12] */ udelay(10); val = pcmcia_readl(skt, PCMCIA_C1_REG); stat |= (val & PCMCIA_C1_VS1_MASK) ? IN_VS1 : 0; stat |= (val & PCMCIA_C1_VS2_MASK) ? IN_VS2 : 0; /* drive VS1 low, float VS2 */ val &= ~PCMCIA_C1_VS1OE_MASK; val |= PCMCIA_C1_VS2OE_MASK; pcmcia_writel(skt, val, PCMCIA_C1_REG); /* wait for output to stabilize and read CD[12] */ udelay(10); val = pcmcia_readl(skt, PCMCIA_C1_REG); stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS2H : 0; stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS2H : 0; /* float VS1, drive VS2 low */ val |= PCMCIA_C1_VS1OE_MASK; val &= ~PCMCIA_C1_VS2OE_MASK; pcmcia_writel(skt, val, PCMCIA_C1_REG); /* wait for output to stabilize and read CD[12] */ udelay(10); val = pcmcia_readl(skt, PCMCIA_C1_REG); stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS1H : 0; stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS1H : 0; /* guess cardtype from all this */ skt->card_type = vscd_to_cardtype[stat]; if (!skt->card_type) dev_err(&skt->socket.dev, "unsupported card type\n"); /* drive both VS pin to 0 again */ val &= ~(PCMCIA_C1_VS1OE_MASK | PCMCIA_C1_VS2OE_MASK); /* enable correct logic */ val &= ~(PCMCIA_C1_EN_PCMCIA_MASK | PCMCIA_C1_EN_CARDBUS_MASK); if (skt->card_type & CARD_PCCARD) val |= PCMCIA_C1_EN_PCMCIA_MASK; else val |= PCMCIA_C1_EN_CARDBUS_MASK; pcmcia_writel(skt, val, PCMCIA_C1_REG); } skt->card_detected = (stat & SS_DETECT) ? 1 : 0; /* report card type/voltage */ if (skt->card_type & CARD_CARDBUS) stat |= SS_CARDBUS; if (skt->card_type & CARD_3V) stat |= SS_3VCARD; if (skt->card_type & CARD_XV) stat |= SS_XVCARD; stat |= SS_POWERON; if (gpio_get_value(skt->pd->ready_gpio)) stat |= SS_READY; return stat; } /* * core request to get current socket status */ static int bcm63xx_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status) { struct bcm63xx_pcmcia_socket *skt; skt = sock->driver_data; spin_lock_bh(&skt->lock); *status = __get_socket_status(skt); spin_unlock_bh(&skt->lock); return 0; } /* * socket polling timer callback */ static void bcm63xx_pcmcia_poll(unsigned long data) { struct bcm63xx_pcmcia_socket *skt; unsigned int stat, events; skt = (struct bcm63xx_pcmcia_socket *)data; spin_lock_bh(&skt->lock); stat = __get_socket_status(skt); /* keep only changed bits, and mask with required one from the * core */ events = (stat ^ skt->old_status) & skt->requested_state.csc_mask; skt->old_status = stat; spin_unlock_bh(&skt->lock); if (events) pcmcia_parse_events(&skt->socket, events); mod_timer(&skt->timer, jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE)); } static int bcm63xx_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map) { /* this doesn't seem to be called by pcmcia layer if static * mapping is used */ return 0; } static int bcm63xx_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map) { struct bcm63xx_pcmcia_socket *skt; struct resource *res; skt = sock->driver_data; if (map->flags & MAP_ATTRIB) res = skt->attr_res; else res = skt->common_res; map->static_start = res->start + map->card_start; return 0; } static struct pccard_operations bcm63xx_pcmcia_operations = { .init = bcm63xx_pcmcia_sock_init, .suspend = bcm63xx_pcmcia_suspend, .get_status = bcm63xx_pcmcia_get_status, .set_socket = bcm63xx_pcmcia_set_socket, .set_io_map = bcm63xx_pcmcia_set_io_map, .set_mem_map = bcm63xx_pcmcia_set_mem_map, }; /* * register pcmcia socket to core */ static int __devinit bcm63xx_drv_pcmcia_probe(struct platform_device *pdev) { struct bcm63xx_pcmcia_socket *skt; struct pcmcia_socket *sock; struct resource *res, *irq_res; unsigned int regmem_size = 0, iomem_size = 0; u32 val; int ret; skt = kzalloc(sizeof(*skt), GFP_KERNEL); if (!skt) return -ENOMEM; spin_lock_init(&skt->lock); sock = &skt->socket; sock->driver_data = skt; /* make sure we have all resources we need */ skt->common_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); skt->attr_res = platform_get_resource(pdev, IORESOURCE_MEM, 2); irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); skt->pd = pdev->dev.platform_data; if (!skt->common_res || !skt->attr_res || !irq_res || !skt->pd) { ret = -EINVAL; goto err; } /* remap pcmcia registers */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); regmem_size = resource_size(res); if (!request_mem_region(res->start, regmem_size, "bcm63xx_pcmcia")) { ret = -EINVAL; goto err; } skt->reg_res = res; skt->base = ioremap(res->start, regmem_size); if (!skt->base) { ret = -ENOMEM; goto err; } /* remap io registers */ res = platform_get_resource(pdev, IORESOURCE_MEM, 3); iomem_size = resource_size(res); skt->io_base = ioremap(res->start, iomem_size); if (!skt->io_base) { ret = -ENOMEM; goto err; } /* resources are static */ sock->resource_ops = &pccard_static_ops; sock->ops = &bcm63xx_pcmcia_operations; sock->owner = THIS_MODULE; sock->dev.parent = &pdev->dev; sock->features = SS_CAP_STATIC_MAP | SS_CAP_PCCARD; sock->io_offset = (unsigned long)skt->io_base; sock->pci_irq = irq_res->start; #ifdef CONFIG_CARDBUS sock->cb_dev = bcm63xx_cb_dev; if (bcm63xx_cb_dev) sock->features |= SS_CAP_CARDBUS; #endif /* assume common & attribute memory have the same size */ sock->map_size = resource_size(skt->common_res); /* initialize polling timer */ setup_timer(&skt->timer, bcm63xx_pcmcia_poll, (unsigned long)skt); /* initialize pcmcia control register, drive VS[12] to 0, * leave CB IDSEL to the old value since it is set by the PCI * layer */ val = pcmcia_readl(skt, PCMCIA_C1_REG); val &= PCMCIA_C1_CBIDSEL_MASK; val |= PCMCIA_C1_EN_PCMCIA_GPIO_MASK; pcmcia_writel(skt, val, PCMCIA_C1_REG); /* * Hardware has only one set of timings registers, not one for * each memory access type, so we configure them for the * slowest one: attribute memory. */ val = PCMCIA_C2_DATA16_MASK; val |= 10 << PCMCIA_C2_RWCOUNT_SHIFT; val |= 6 << PCMCIA_C2_INACTIVE_SHIFT; val |= 3 << PCMCIA_C2_SETUP_SHIFT; val |= 3 << PCMCIA_C2_HOLD_SHIFT; pcmcia_writel(skt, val, PCMCIA_C2_REG); ret = pcmcia_register_socket(sock); if (ret) goto err; /* start polling socket */ mod_timer(&skt->timer, jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE)); platform_set_drvdata(pdev, skt); return 0; err: if (skt->io_base) iounmap(skt->io_base); if (skt->base) iounmap(skt->base); if (skt->reg_res) release_mem_region(skt->reg_res->start, regmem_size); kfree(skt); return ret; } static int __devexit bcm63xx_drv_pcmcia_remove(struct platform_device *pdev) { struct bcm63xx_pcmcia_socket *skt; struct resource *res; skt = platform_get_drvdata(pdev); del_timer_sync(&skt->timer); iounmap(skt->base); iounmap(skt->io_base); res = skt->reg_res; release_mem_region(res->start, resource_size(res)); kfree(skt); return 0; } struct platform_driver bcm63xx_pcmcia_driver = { .probe = bcm63xx_drv_pcmcia_probe, .remove = __devexit_p(bcm63xx_drv_pcmcia_remove), .driver = { .name = "bcm63xx_pcmcia", .owner = THIS_MODULE, }, }; #ifdef CONFIG_CARDBUS static int __devinit bcm63xx_cb_probe(struct pci_dev *dev, const struct pci_device_id *id) { /* keep pci device */ bcm63xx_cb_dev = dev; return platform_driver_register(&bcm63xx_pcmcia_driver); } static void __devexit bcm63xx_cb_exit(struct pci_dev *dev) { platform_driver_unregister(&bcm63xx_pcmcia_driver); bcm63xx_cb_dev = NULL; } static DEFINE_PCI_DEVICE_TABLE(bcm63xx_cb_table) = { { .vendor = PCI_VENDOR_ID_BROADCOM, .device = BCM6348_CPU_ID, .subvendor = PCI_VENDOR_ID_BROADCOM, .subdevice = PCI_ANY_ID, .class = PCI_CLASS_BRIDGE_CARDBUS << 8, .class_mask = ~0, }, { .vendor = PCI_VENDOR_ID_BROADCOM, .device = BCM6358_CPU_ID, .subvendor = PCI_VENDOR_ID_BROADCOM, .subdevice = PCI_ANY_ID, .class = PCI_CLASS_BRIDGE_CARDBUS << 8, .class_mask = ~0, }, { }, }; MODULE_DEVICE_TABLE(pci, bcm63xx_cb_table); static struct pci_driver bcm63xx_cardbus_driver = { .name = "bcm63xx_cardbus", .id_table = bcm63xx_cb_table, .probe = bcm63xx_cb_probe, .remove = __devexit_p(bcm63xx_cb_exit), }; #endif /* * if cardbus support is enabled, register our platform device after * our fake cardbus bridge has been registered */ static int __init bcm63xx_pcmcia_init(void) { #ifdef CONFIG_CARDBUS return pci_register_driver(&bcm63xx_cardbus_driver); #else return platform_driver_register(&bcm63xx_pcmcia_driver); #endif } static void __exit bcm63xx_pcmcia_exit(void) { #ifdef CONFIG_CARDBUS return pci_unregister_driver(&bcm63xx_cardbus_driver); #else platform_driver_unregister(&bcm63xx_pcmcia_driver); #endif } module_init(bcm63xx_pcmcia_init); module_exit(bcm63xx_pcmcia_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>"); MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm63xx Socket Controller");
gpl-2.0
HackLinux/kernel-pandaboard-ES-RevB3
drivers/watchdog/ath79_wdt.c
4979
7032
/* * Atheros AR71XX/AR724X/AR913X built-in hardware watchdog timer. * * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> * * This driver was based on: drivers/watchdog/ixp4xx_wdt.c * Author: Deepak Saxena <dsaxena@plexity.net> * Copyright 2004 (c) MontaVista, Software, Inc. * * which again was based on sa1100 driver, * Copyright (C) 2000 Oleg Drokin <green@crimea.edu> * * 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. * */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/bitops.h> #include <linux/errno.h> #include <linux/fs.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/miscdevice.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/platform_device.h> #include <linux/types.h> #include <linux/watchdog.h> #include <linux/clk.h> #include <linux/err.h> #include <asm/mach-ath79/ath79.h> #include <asm/mach-ath79/ar71xx_regs.h> #define DRIVER_NAME "ath79-wdt" #define WDT_TIMEOUT 15 /* seconds */ #define WDOG_CTRL_LAST_RESET BIT(31) #define WDOG_CTRL_ACTION_MASK 3 #define WDOG_CTRL_ACTION_NONE 0 /* no action */ #define WDOG_CTRL_ACTION_GPI 1 /* general purpose interrupt */ #define WDOG_CTRL_ACTION_NMI 2 /* NMI */ #define WDOG_CTRL_ACTION_FCR 3 /* full chip reset */ static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); static int timeout = WDT_TIMEOUT; module_param(timeout, int, 0); MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds " "(default=" __MODULE_STRING(WDT_TIMEOUT) "s)"); static unsigned long wdt_flags; #define WDT_FLAGS_BUSY 0 #define WDT_FLAGS_EXPECT_CLOSE 1 static struct clk *wdt_clk; static unsigned long wdt_freq; static int boot_status; static int max_timeout; static inline void ath79_wdt_keepalive(void) { ath79_reset_wr(AR71XX_RESET_REG_WDOG, wdt_freq * timeout); /* flush write */ ath79_reset_rr(AR71XX_RESET_REG_WDOG); } static inline void ath79_wdt_enable(void) { ath79_wdt_keepalive(); ath79_reset_wr(AR71XX_RESET_REG_WDOG_CTRL, WDOG_CTRL_ACTION_FCR); /* flush write */ ath79_reset_rr(AR71XX_RESET_REG_WDOG_CTRL); } static inline void ath79_wdt_disable(void) { ath79_reset_wr(AR71XX_RESET_REG_WDOG_CTRL, WDOG_CTRL_ACTION_NONE); /* flush write */ ath79_reset_rr(AR71XX_RESET_REG_WDOG_CTRL); } static int ath79_wdt_set_timeout(int val) { if (val < 1 || val > max_timeout) return -EINVAL; timeout = val; ath79_wdt_keepalive(); return 0; } static int ath79_wdt_open(struct inode *inode, struct file *file) { if (test_and_set_bit(WDT_FLAGS_BUSY, &wdt_flags)) return -EBUSY; clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags); ath79_wdt_enable(); return nonseekable_open(inode, file); } static int ath79_wdt_release(struct inode *inode, struct file *file) { if (test_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags)) ath79_wdt_disable(); else { pr_crit("device closed unexpectedly, watchdog timer will not stop!\n"); ath79_wdt_keepalive(); } clear_bit(WDT_FLAGS_BUSY, &wdt_flags); clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags); return 0; } static ssize_t ath79_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos) { if (len) { if (!nowayout) { size_t i; clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags); for (i = 0; i != len; i++) { char c; if (get_user(c, data + i)) return -EFAULT; if (c == 'V') set_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags); } } ath79_wdt_keepalive(); } return len; } static const struct watchdog_info ath79_wdt_info = { .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE | WDIOF_CARDRESET, .firmware_version = 0, .identity = "ATH79 watchdog", }; static long ath79_wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; int __user *p = argp; int err; int t; switch (cmd) { case WDIOC_GETSUPPORT: err = copy_to_user(argp, &ath79_wdt_info, sizeof(ath79_wdt_info)) ? -EFAULT : 0; break; case WDIOC_GETSTATUS: err = put_user(0, p); break; case WDIOC_GETBOOTSTATUS: err = put_user(boot_status, p); break; case WDIOC_KEEPALIVE: ath79_wdt_keepalive(); err = 0; break; case WDIOC_SETTIMEOUT: err = get_user(t, p); if (err) break; err = ath79_wdt_set_timeout(t); if (err) break; /* fallthrough */ case WDIOC_GETTIMEOUT: err = put_user(timeout, p); break; default: err = -ENOTTY; break; } return err; } static const struct file_operations ath79_wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = ath79_wdt_write, .unlocked_ioctl = ath79_wdt_ioctl, .open = ath79_wdt_open, .release = ath79_wdt_release, }; static struct miscdevice ath79_wdt_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", .fops = &ath79_wdt_fops, }; static int __devinit ath79_wdt_probe(struct platform_device *pdev) { u32 ctrl; int err; wdt_clk = clk_get(&pdev->dev, "wdt"); if (IS_ERR(wdt_clk)) return PTR_ERR(wdt_clk); err = clk_enable(wdt_clk); if (err) goto err_clk_put; wdt_freq = clk_get_rate(wdt_clk); if (!wdt_freq) { err = -EINVAL; goto err_clk_disable; } max_timeout = (0xfffffffful / wdt_freq); if (timeout < 1 || timeout > max_timeout) { timeout = max_timeout; dev_info(&pdev->dev, "timeout value must be 0 < timeout < %d, using %d\n", max_timeout, timeout); } ctrl = ath79_reset_rr(AR71XX_RESET_REG_WDOG_CTRL); boot_status = (ctrl & WDOG_CTRL_LAST_RESET) ? WDIOF_CARDRESET : 0; err = misc_register(&ath79_wdt_miscdev); if (err) { dev_err(&pdev->dev, "unable to register misc device, err=%d\n", err); goto err_clk_disable; } return 0; err_clk_disable: clk_disable(wdt_clk); err_clk_put: clk_put(wdt_clk); return err; } static int __devexit ath79_wdt_remove(struct platform_device *pdev) { misc_deregister(&ath79_wdt_miscdev); clk_disable(wdt_clk); clk_put(wdt_clk); return 0; } static void ath97_wdt_shutdown(struct platform_device *pdev) { ath79_wdt_disable(); } static struct platform_driver ath79_wdt_driver = { .remove = __devexit_p(ath79_wdt_remove), .shutdown = ath97_wdt_shutdown, .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, }, }; static int __init ath79_wdt_init(void) { return platform_driver_probe(&ath79_wdt_driver, ath79_wdt_probe); } module_init(ath79_wdt_init); static void __exit ath79_wdt_exit(void) { platform_driver_unregister(&ath79_wdt_driver); } module_exit(ath79_wdt_exit); MODULE_DESCRIPTION("Atheros AR71XX/AR724X/AR913X hardware watchdog driver"); MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org"); MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" DRIVER_NAME); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
gpl-2.0
faux123/htc_m8
sound/mips/au1x00.c
5235
19210
/* * BRIEF MODULE DESCRIPTION * Driver for AMD Au1000 MIPS Processor, AC'97 Sound Port * * Copyright 2004 Cooper Street Innovations Inc. * Author: Charles Eidsness <charles@cooper-street.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. * * History: * * 2004-09-09 Charles Eidsness -- Original verion -- based on * sa11xx-uda1341.c ALSA driver and the * au1000.c OSS driver. * 2004-09-09 Matt Porter -- Added support for ALSA 1.0.6 * */ #include <linux/ioport.h> #include <linux/interrupt.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/module.h> #include <sound/core.h> #include <sound/initval.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/ac97_codec.h> #include <asm/mach-au1x00/au1000.h> #include <asm/mach-au1x00/au1000_dma.h> MODULE_AUTHOR("Charles Eidsness <charles@cooper-street.com>"); MODULE_DESCRIPTION("Au1000 AC'97 ALSA Driver"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{AMD,Au1000 AC'97}}"); #define PLAYBACK 0 #define CAPTURE 1 #define AC97_SLOT_3 0x01 #define AC97_SLOT_4 0x02 #define AC97_SLOT_6 0x08 #define AC97_CMD_IRQ 31 #define READ 0 #define WRITE 1 #define READ_WAIT 2 #define RW_DONE 3 struct au1000_period { u32 start; u32 relative_end; /*realtive to start of buffer*/ struct au1000_period * next; }; /*Au1000 AC97 Port Control Reisters*/ struct au1000_ac97_reg { u32 volatile config; u32 volatile status; u32 volatile data; u32 volatile cmd; u32 volatile cntrl; }; struct audio_stream { struct snd_pcm_substream *substream; int dma; spinlock_t dma_lock; struct au1000_period * buffer; unsigned int period_size; unsigned int periods; }; struct snd_au1000 { struct snd_card *card; struct au1000_ac97_reg volatile *ac97_ioport; struct resource *ac97_res_port; spinlock_t ac97_lock; struct snd_ac97 *ac97; struct snd_pcm *pcm; struct audio_stream *stream[2]; /* playback & capture */ }; /*--------------------------- Local Functions --------------------------------*/ static void au1000_set_ac97_xmit_slots(struct snd_au1000 *au1000, long xmit_slots) { u32 volatile ac97_config; spin_lock(&au1000->ac97_lock); ac97_config = au1000->ac97_ioport->config; ac97_config = ac97_config & ~AC97C_XMIT_SLOTS_MASK; ac97_config |= (xmit_slots << AC97C_XMIT_SLOTS_BIT); au1000->ac97_ioport->config = ac97_config; spin_unlock(&au1000->ac97_lock); } static void au1000_set_ac97_recv_slots(struct snd_au1000 *au1000, long recv_slots) { u32 volatile ac97_config; spin_lock(&au1000->ac97_lock); ac97_config = au1000->ac97_ioport->config; ac97_config = ac97_config & ~AC97C_RECV_SLOTS_MASK; ac97_config |= (recv_slots << AC97C_RECV_SLOTS_BIT); au1000->ac97_ioport->config = ac97_config; spin_unlock(&au1000->ac97_lock); } static void au1000_release_dma_link(struct audio_stream *stream) { struct au1000_period * pointer; struct au1000_period * pointer_next; stream->period_size = 0; stream->periods = 0; pointer = stream->buffer; if (! pointer) return; do { pointer_next = pointer->next; kfree(pointer); pointer = pointer_next; } while (pointer != stream->buffer); stream->buffer = NULL; } static int au1000_setup_dma_link(struct audio_stream *stream, unsigned int period_bytes, unsigned int periods) { struct snd_pcm_substream *substream = stream->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct au1000_period *pointer; unsigned long dma_start; int i; dma_start = virt_to_phys(runtime->dma_area); if (stream->period_size == period_bytes && stream->periods == periods) return 0; /* not changed */ au1000_release_dma_link(stream); stream->period_size = period_bytes; stream->periods = periods; stream->buffer = kmalloc(sizeof(struct au1000_period), GFP_KERNEL); if (! stream->buffer) return -ENOMEM; pointer = stream->buffer; for (i = 0; i < periods; i++) { pointer->start = (u32)(dma_start + (i * period_bytes)); pointer->relative_end = (u32) (((i+1) * period_bytes) - 0x1); if (i < periods - 1) { pointer->next = kmalloc(sizeof(struct au1000_period), GFP_KERNEL); if (! pointer->next) { au1000_release_dma_link(stream); return -ENOMEM; } pointer = pointer->next; } } pointer->next = stream->buffer; return 0; } static void au1000_dma_stop(struct audio_stream *stream) { if (snd_BUG_ON(!stream->buffer)) return; disable_dma(stream->dma); } static void au1000_dma_start(struct audio_stream *stream) { if (snd_BUG_ON(!stream->buffer)) return; init_dma(stream->dma); if (get_dma_active_buffer(stream->dma) == 0) { clear_dma_done0(stream->dma); set_dma_addr0(stream->dma, stream->buffer->start); set_dma_count0(stream->dma, stream->period_size >> 1); set_dma_addr1(stream->dma, stream->buffer->next->start); set_dma_count1(stream->dma, stream->period_size >> 1); } else { clear_dma_done1(stream->dma); set_dma_addr1(stream->dma, stream->buffer->start); set_dma_count1(stream->dma, stream->period_size >> 1); set_dma_addr0(stream->dma, stream->buffer->next->start); set_dma_count0(stream->dma, stream->period_size >> 1); } enable_dma_buffers(stream->dma); start_dma(stream->dma); } static irqreturn_t au1000_dma_interrupt(int irq, void *dev_id) { struct audio_stream *stream = (struct audio_stream *) dev_id; struct snd_pcm_substream *substream = stream->substream; spin_lock(&stream->dma_lock); switch (get_dma_buffer_done(stream->dma)) { case DMA_D0: stream->buffer = stream->buffer->next; clear_dma_done0(stream->dma); set_dma_addr0(stream->dma, stream->buffer->next->start); set_dma_count0(stream->dma, stream->period_size >> 1); enable_dma_buffer0(stream->dma); break; case DMA_D1: stream->buffer = stream->buffer->next; clear_dma_done1(stream->dma); set_dma_addr1(stream->dma, stream->buffer->next->start); set_dma_count1(stream->dma, stream->period_size >> 1); enable_dma_buffer1(stream->dma); break; case (DMA_D0 | DMA_D1): printk(KERN_ERR "DMA %d missed interrupt.\n",stream->dma); au1000_dma_stop(stream); au1000_dma_start(stream); break; case (~DMA_D0 & ~DMA_D1): printk(KERN_ERR "DMA %d empty irq.\n",stream->dma); } spin_unlock(&stream->dma_lock); snd_pcm_period_elapsed(substream); return IRQ_HANDLED; } /*-------------------------- PCM Audio Streams -------------------------------*/ static unsigned int rates[] = {8000, 11025, 16000, 22050}; static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, }; static struct snd_pcm_hardware snd_au1000_hw = { .info = (SNDRV_PCM_INFO_INTERLEAVED | \ SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050), .rate_min = 8000, .rate_max = 22050, .channels_min = 1, .channels_max = 2, .buffer_bytes_max = 128*1024, .period_bytes_min = 32, .period_bytes_max = 16*1024, .periods_min = 8, .periods_max = 255, .fifo_size = 16, }; static int snd_au1000_playback_open(struct snd_pcm_substream *substream) { struct snd_au1000 *au1000 = substream->pcm->private_data; au1000->stream[PLAYBACK]->substream = substream; au1000->stream[PLAYBACK]->buffer = NULL; substream->private_data = au1000->stream[PLAYBACK]; substream->runtime->hw = snd_au1000_hw; return (snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates) < 0); } static int snd_au1000_capture_open(struct snd_pcm_substream *substream) { struct snd_au1000 *au1000 = substream->pcm->private_data; au1000->stream[CAPTURE]->substream = substream; au1000->stream[CAPTURE]->buffer = NULL; substream->private_data = au1000->stream[CAPTURE]; substream->runtime->hw = snd_au1000_hw; return (snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates) < 0); } static int snd_au1000_playback_close(struct snd_pcm_substream *substream) { struct snd_au1000 *au1000 = substream->pcm->private_data; au1000->stream[PLAYBACK]->substream = NULL; return 0; } static int snd_au1000_capture_close(struct snd_pcm_substream *substream) { struct snd_au1000 *au1000 = substream->pcm->private_data; au1000->stream[CAPTURE]->substream = NULL; return 0; } static int snd_au1000_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct audio_stream *stream = substream->private_data; int err; err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); if (err < 0) return err; return au1000_setup_dma_link(stream, params_period_bytes(hw_params), params_periods(hw_params)); } static int snd_au1000_hw_free(struct snd_pcm_substream *substream) { struct audio_stream *stream = substream->private_data; au1000_release_dma_link(stream); return snd_pcm_lib_free_pages(substream); } static int snd_au1000_playback_prepare(struct snd_pcm_substream *substream) { struct snd_au1000 *au1000 = substream->pcm->private_data; struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->channels == 1) au1000_set_ac97_xmit_slots(au1000, AC97_SLOT_4); else au1000_set_ac97_xmit_slots(au1000, AC97_SLOT_3 | AC97_SLOT_4); snd_ac97_set_rate(au1000->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate); return 0; } static int snd_au1000_capture_prepare(struct snd_pcm_substream *substream) { struct snd_au1000 *au1000 = substream->pcm->private_data; struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->channels == 1) au1000_set_ac97_recv_slots(au1000, AC97_SLOT_4); else au1000_set_ac97_recv_slots(au1000, AC97_SLOT_3 | AC97_SLOT_4); snd_ac97_set_rate(au1000->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); return 0; } static int snd_au1000_trigger(struct snd_pcm_substream *substream, int cmd) { struct audio_stream *stream = substream->private_data; int err = 0; spin_lock(&stream->dma_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: au1000_dma_start(stream); break; case SNDRV_PCM_TRIGGER_STOP: au1000_dma_stop(stream); break; default: err = -EINVAL; break; } spin_unlock(&stream->dma_lock); return err; } static snd_pcm_uframes_t snd_au1000_pointer(struct snd_pcm_substream *substream) { struct audio_stream *stream = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; long location; spin_lock(&stream->dma_lock); location = get_dma_residue(stream->dma); spin_unlock(&stream->dma_lock); location = stream->buffer->relative_end - location; if (location == -1) location = 0; return bytes_to_frames(runtime,location); } static struct snd_pcm_ops snd_card_au1000_playback_ops = { .open = snd_au1000_playback_open, .close = snd_au1000_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_au1000_hw_params, .hw_free = snd_au1000_hw_free, .prepare = snd_au1000_playback_prepare, .trigger = snd_au1000_trigger, .pointer = snd_au1000_pointer, }; static struct snd_pcm_ops snd_card_au1000_capture_ops = { .open = snd_au1000_capture_open, .close = snd_au1000_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_au1000_hw_params, .hw_free = snd_au1000_hw_free, .prepare = snd_au1000_capture_prepare, .trigger = snd_au1000_trigger, .pointer = snd_au1000_pointer, }; static int __devinit snd_au1000_pcm_new(struct snd_au1000 *au1000) { struct snd_pcm *pcm; int err; unsigned long flags; if ((err = snd_pcm_new(au1000->card, "AU1000 AC97 PCM", 0, 1, 1, &pcm)) < 0) return err; snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data(GFP_KERNEL), 128*1024, 128*1024); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_au1000_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_au1000_capture_ops); pcm->private_data = au1000; pcm->info_flags = 0; strcpy(pcm->name, "Au1000 AC97 PCM"); spin_lock_init(&au1000->stream[PLAYBACK]->dma_lock); spin_lock_init(&au1000->stream[CAPTURE]->dma_lock); flags = claim_dma_lock(); if ((au1000->stream[PLAYBACK]->dma = request_au1000_dma(DMA_ID_AC97C_TX, "AC97 TX", au1000_dma_interrupt, 0, au1000->stream[PLAYBACK])) < 0) { release_dma_lock(flags); return -EBUSY; } if ((au1000->stream[CAPTURE]->dma = request_au1000_dma(DMA_ID_AC97C_RX, "AC97 RX", au1000_dma_interrupt, 0, au1000->stream[CAPTURE])) < 0){ release_dma_lock(flags); return -EBUSY; } /* enable DMA coherency in read/write DMA channels */ set_dma_mode(au1000->stream[PLAYBACK]->dma, get_dma_mode(au1000->stream[PLAYBACK]->dma) & ~DMA_NC); set_dma_mode(au1000->stream[CAPTURE]->dma, get_dma_mode(au1000->stream[CAPTURE]->dma) & ~DMA_NC); release_dma_lock(flags); au1000->pcm = pcm; return 0; } /*-------------------------- AC97 CODEC Control ------------------------------*/ static unsigned short snd_au1000_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { struct snd_au1000 *au1000 = ac97->private_data; u32 volatile cmd; u16 volatile data; int i; spin_lock(&au1000->ac97_lock); /* would rather use the interrupt than this polling but it works and I can't get the interrupt driven case to work efficiently */ for (i = 0; i < 0x5000; i++) if (!(au1000->ac97_ioport->status & AC97C_CP)) break; if (i == 0x5000) printk(KERN_ERR "au1000 AC97: AC97 command read timeout\n"); cmd = (u32) reg & AC97C_INDEX_MASK; cmd |= AC97C_READ; au1000->ac97_ioport->cmd = cmd; /* now wait for the data */ for (i = 0; i < 0x5000; i++) if (!(au1000->ac97_ioport->status & AC97C_CP)) break; if (i == 0x5000) { printk(KERN_ERR "au1000 AC97: AC97 command read timeout\n"); spin_unlock(&au1000->ac97_lock); return 0; } data = au1000->ac97_ioport->cmd & 0xffff; spin_unlock(&au1000->ac97_lock); return data; } static void snd_au1000_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { struct snd_au1000 *au1000 = ac97->private_data; u32 cmd; int i; spin_lock(&au1000->ac97_lock); /* would rather use the interrupt than this polling but it works and I can't get the interrupt driven case to work efficiently */ for (i = 0; i < 0x5000; i++) if (!(au1000->ac97_ioport->status & AC97C_CP)) break; if (i == 0x5000) printk(KERN_ERR "au1000 AC97: AC97 command write timeout\n"); cmd = (u32) reg & AC97C_INDEX_MASK; cmd &= ~AC97C_READ; cmd |= ((u32) val << AC97C_WD_BIT); au1000->ac97_ioport->cmd = cmd; spin_unlock(&au1000->ac97_lock); } static int __devinit snd_au1000_ac97_new(struct snd_au1000 *au1000) { int err; struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; static struct snd_ac97_bus_ops ops = { .write = snd_au1000_ac97_write, .read = snd_au1000_ac97_read, }; if ((au1000->ac97_res_port = request_mem_region(CPHYSADDR(AC97C_CONFIG), 0x100000, "Au1x00 AC97")) == NULL) { snd_printk(KERN_ERR "ALSA AC97: can't grap AC97 port\n"); return -EBUSY; } au1000->ac97_ioport = (struct au1000_ac97_reg *) KSEG1ADDR(au1000->ac97_res_port->start); spin_lock_init(&au1000->ac97_lock); /* configure pins for AC'97 TODO: move to board_setup.c */ au_writel(au_readl(SYS_PINFUNC) & ~0x02, SYS_PINFUNC); /* Initialise Au1000's AC'97 Control Block */ au1000->ac97_ioport->cntrl = AC97C_RS | AC97C_CE; udelay(10); au1000->ac97_ioport->cntrl = AC97C_CE; udelay(10); /* Initialise External CODEC -- cold reset */ au1000->ac97_ioport->config = AC97C_RESET; udelay(10); au1000->ac97_ioport->config = 0x0; mdelay(5); /* Initialise AC97 middle-layer */ if ((err = snd_ac97_bus(au1000->card, 0, &ops, au1000, &pbus)) < 0) return err; memset(&ac97, 0, sizeof(ac97)); ac97.private_data = au1000; if ((err = snd_ac97_mixer(pbus, &ac97, &au1000->ac97)) < 0) return err; return 0; } /*------------------------------ Setup / Destroy ----------------------------*/ void snd_au1000_free(struct snd_card *card) { struct snd_au1000 *au1000 = card->private_data; if (au1000->ac97_res_port) { /* put internal AC97 block into reset */ au1000->ac97_ioport->cntrl = AC97C_RS; au1000->ac97_ioport = NULL; release_and_free_resource(au1000->ac97_res_port); } if (au1000->stream[PLAYBACK]) { if (au1000->stream[PLAYBACK]->dma >= 0) free_au1000_dma(au1000->stream[PLAYBACK]->dma); kfree(au1000->stream[PLAYBACK]); } if (au1000->stream[CAPTURE]) { if (au1000->stream[CAPTURE]->dma >= 0) free_au1000_dma(au1000->stream[CAPTURE]->dma); kfree(au1000->stream[CAPTURE]); } } static struct snd_card *au1000_card; static int __init au1000_init(void) { int err; struct snd_card *card; struct snd_au1000 *au1000; err = snd_card_create(-1, "AC97", THIS_MODULE, sizeof(struct snd_au1000), &card); if (err < 0) return err; card->private_free = snd_au1000_free; au1000 = card->private_data; au1000->card = card; au1000->stream[PLAYBACK] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL); au1000->stream[CAPTURE ] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL); /* so that snd_au1000_free will work as intended */ au1000->ac97_res_port = NULL; if (au1000->stream[PLAYBACK]) au1000->stream[PLAYBACK]->dma = -1; if (au1000->stream[CAPTURE ]) au1000->stream[CAPTURE ]->dma = -1; if (au1000->stream[PLAYBACK] == NULL || au1000->stream[CAPTURE ] == NULL) { snd_card_free(card); return -ENOMEM; } if ((err = snd_au1000_ac97_new(au1000)) < 0 ) { snd_card_free(card); return err; } if ((err = snd_au1000_pcm_new(au1000)) < 0) { snd_card_free(card); return err; } strcpy(card->driver, "Au1000-AC97"); strcpy(card->shortname, "AMD Au1000-AC97"); sprintf(card->longname, "AMD Au1000--AC97 ALSA Driver"); if ((err = snd_card_register(card)) < 0) { snd_card_free(card); return err; } printk(KERN_INFO "ALSA AC97: Driver Initialized\n"); au1000_card = card; return 0; } static void __exit au1000_exit(void) { snd_card_free(au1000_card); } module_init(au1000_init); module_exit(au1000_exit);
gpl-2.0
mrg666/android_kernel_icon
drivers/mfd/tps6105x.c
7795
5698
/* * Core driver for TPS61050/61052 boost converters, used for while LED * driving, audio power amplification, white LED flash, and generic * boost conversion. Additionally it provides a 1-bit GPIO pin (out or in) * and a flash synchronization pin to synchronize flash events when used as * flashgun. * * Copyright (C) 2011 ST-Ericsson SA * Written on behalf of Linaro for ST-Ericsson * * Author: Linus Walleij <linus.walleij@linaro.org> * * License terms: GNU General Public License (GPL) version 2 */ #include <linux/module.h> #include <linux/init.h> #include <linux/i2c.h> #include <linux/mutex.h> #include <linux/gpio.h> #include <linux/spinlock.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/regulator/driver.h> #include <linux/mfd/core.h> #include <linux/mfd/tps6105x.h> int tps6105x_set(struct tps6105x *tps6105x, u8 reg, u8 value) { int ret; ret = mutex_lock_interruptible(&tps6105x->lock); if (ret) return ret; ret = i2c_smbus_write_byte_data(tps6105x->client, reg, value); mutex_unlock(&tps6105x->lock); if (ret < 0) return ret; return 0; } EXPORT_SYMBOL(tps6105x_set); int tps6105x_get(struct tps6105x *tps6105x, u8 reg, u8 *buf) { int ret; ret = mutex_lock_interruptible(&tps6105x->lock); if (ret) return ret; ret = i2c_smbus_read_byte_data(tps6105x->client, reg); mutex_unlock(&tps6105x->lock); if (ret < 0) return ret; *buf = ret; return 0; } EXPORT_SYMBOL(tps6105x_get); /* * Masks off the bits in the mask and sets the bits in the bitvalues * parameter in one atomic operation */ int tps6105x_mask_and_set(struct tps6105x *tps6105x, u8 reg, u8 bitmask, u8 bitvalues) { int ret; u8 regval; ret = mutex_lock_interruptible(&tps6105x->lock); if (ret) return ret; ret = i2c_smbus_read_byte_data(tps6105x->client, reg); if (ret < 0) goto fail; regval = ret; regval = (~bitmask & regval) | (bitmask & bitvalues); ret = i2c_smbus_write_byte_data(tps6105x->client, reg, regval); fail: mutex_unlock(&tps6105x->lock); if (ret < 0) return ret; return 0; } EXPORT_SYMBOL(tps6105x_mask_and_set); static int __devinit tps6105x_startup(struct tps6105x *tps6105x) { int ret; u8 regval; ret = tps6105x_get(tps6105x, TPS6105X_REG_0, &regval); if (ret) return ret; switch (regval >> TPS6105X_REG0_MODE_SHIFT) { case TPS6105X_REG0_MODE_SHUTDOWN: dev_info(&tps6105x->client->dev, "TPS6105x found in SHUTDOWN mode\n"); break; case TPS6105X_REG0_MODE_TORCH: dev_info(&tps6105x->client->dev, "TPS6105x found in TORCH mode\n"); break; case TPS6105X_REG0_MODE_TORCH_FLASH: dev_info(&tps6105x->client->dev, "TPS6105x found in FLASH mode\n"); break; case TPS6105X_REG0_MODE_VOLTAGE: dev_info(&tps6105x->client->dev, "TPS6105x found in VOLTAGE mode\n"); break; default: break; } return ret; } /* * MFD cells - we have one cell which is selected operation * mode, and we always have a GPIO cell. */ static struct mfd_cell tps6105x_cells[] = { { /* name will be runtime assigned */ .id = -1, }, { .name = "tps6105x-gpio", .id = -1, }, }; static int __devinit tps6105x_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct tps6105x *tps6105x; struct tps6105x_platform_data *pdata; int ret; int i; tps6105x = kmalloc(sizeof(*tps6105x), GFP_KERNEL); if (!tps6105x) return -ENOMEM; i2c_set_clientdata(client, tps6105x); tps6105x->client = client; pdata = client->dev.platform_data; tps6105x->pdata = pdata; mutex_init(&tps6105x->lock); ret = tps6105x_startup(tps6105x); if (ret) { dev_err(&client->dev, "chip initialization failed\n"); goto fail; } /* Remove warning texts when you implement new cell drivers */ switch (pdata->mode) { case TPS6105X_MODE_SHUTDOWN: dev_info(&client->dev, "present, not used for anything, only GPIO\n"); break; case TPS6105X_MODE_TORCH: tps6105x_cells[0].name = "tps6105x-leds"; dev_warn(&client->dev, "torch mode is unsupported\n"); break; case TPS6105X_MODE_TORCH_FLASH: tps6105x_cells[0].name = "tps6105x-flash"; dev_warn(&client->dev, "flash mode is unsupported\n"); break; case TPS6105X_MODE_VOLTAGE: tps6105x_cells[0].name ="tps6105x-regulator"; break; default: break; } /* Set up and register the platform devices. */ for (i = 0; i < ARRAY_SIZE(tps6105x_cells); i++) { /* One state holder for all drivers, this is simple */ tps6105x_cells[i].platform_data = tps6105x; tps6105x_cells[i].pdata_size = sizeof(*tps6105x); } ret = mfd_add_devices(&client->dev, 0, tps6105x_cells, ARRAY_SIZE(tps6105x_cells), NULL, 0); if (ret) goto fail; return 0; fail: kfree(tps6105x); return ret; } static int __devexit tps6105x_remove(struct i2c_client *client) { struct tps6105x *tps6105x = i2c_get_clientdata(client); mfd_remove_devices(&client->dev); /* Put chip in shutdown mode */ tps6105x_mask_and_set(tps6105x, TPS6105X_REG_0, TPS6105X_REG0_MODE_MASK, TPS6105X_MODE_SHUTDOWN << TPS6105X_REG0_MODE_SHIFT); kfree(tps6105x); return 0; } static const struct i2c_device_id tps6105x_id[] = { { "tps61050", 0 }, { "tps61052", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, tps6105x_id); static struct i2c_driver tps6105x_driver = { .driver = { .name = "tps6105x", }, .probe = tps6105x_probe, .remove = __devexit_p(tps6105x_remove), .id_table = tps6105x_id, }; static int __init tps6105x_init(void) { return i2c_add_driver(&tps6105x_driver); } subsys_initcall(tps6105x_init); static void __exit tps6105x_exit(void) { i2c_del_driver(&tps6105x_driver); } module_exit(tps6105x_exit); MODULE_AUTHOR("Linus Walleij"); MODULE_DESCRIPTION("TPS6105x White LED Boost Converter Driver"); MODULE_LICENSE("GPL v2");
gpl-2.0
leadpoizon/android_kernel_moto_shamu
sound/synth/emux/emux.c
8563
4329
/* * Copyright (C) 2000 Takashi Iwai <tiwai@suse.de> * * Routines for control of EMU WaveTable chip * * 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/wait.h> #include <linux/slab.h> #include <linux/string.h> #include <sound/core.h> #include <sound/emux_synth.h> #include <linux/init.h> #include <linux/module.h> #include "emux_voice.h" MODULE_AUTHOR("Takashi Iwai"); MODULE_DESCRIPTION("Routines for control of EMU WaveTable chip"); MODULE_LICENSE("GPL"); /* * create a new hardware dependent device for Emu8000/Emu10k1 */ int snd_emux_new(struct snd_emux **remu) { struct snd_emux *emu; *remu = NULL; emu = kzalloc(sizeof(*emu), GFP_KERNEL); if (emu == NULL) return -ENOMEM; spin_lock_init(&emu->voice_lock); mutex_init(&emu->register_mutex); emu->client = -1; #ifdef CONFIG_SND_SEQUENCER_OSS emu->oss_synth = NULL; #endif emu->max_voices = 0; emu->use_time = 0; init_timer(&emu->tlist); emu->tlist.function = snd_emux_timer_callback; emu->tlist.data = (unsigned long)emu; emu->timer_active = 0; *remu = emu; return 0; } EXPORT_SYMBOL(snd_emux_new); /* */ static int sf_sample_new(void *private_data, struct snd_sf_sample *sp, struct snd_util_memhdr *hdr, const void __user *buf, long count) { struct snd_emux *emu = private_data; return emu->ops.sample_new(emu, sp, hdr, buf, count); } static int sf_sample_free(void *private_data, struct snd_sf_sample *sp, struct snd_util_memhdr *hdr) { struct snd_emux *emu = private_data; return emu->ops.sample_free(emu, sp, hdr); } static void sf_sample_reset(void *private_data) { struct snd_emux *emu = private_data; emu->ops.sample_reset(emu); } int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, char *name) { int err; struct snd_sf_callback sf_cb; if (snd_BUG_ON(!emu->hw || emu->max_voices <= 0)) return -EINVAL; if (snd_BUG_ON(!card || !name)) return -EINVAL; emu->card = card; emu->name = kstrdup(name, GFP_KERNEL); emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice), GFP_KERNEL); if (emu->voices == NULL) return -ENOMEM; /* create soundfont list */ memset(&sf_cb, 0, sizeof(sf_cb)); sf_cb.private_data = emu; if (emu->ops.sample_new) sf_cb.sample_new = sf_sample_new; if (emu->ops.sample_free) sf_cb.sample_free = sf_sample_free; if (emu->ops.sample_reset) sf_cb.sample_reset = sf_sample_reset; emu->sflist = snd_sf_new(&sf_cb, emu->memhdr); if (emu->sflist == NULL) return -ENOMEM; if ((err = snd_emux_init_hwdep(emu)) < 0) return err; snd_emux_init_voices(emu); snd_emux_init_seq(emu, card, index); #ifdef CONFIG_SND_SEQUENCER_OSS snd_emux_init_seq_oss(emu); #endif snd_emux_init_virmidi(emu, card); #ifdef CONFIG_PROC_FS snd_emux_proc_init(emu, card, index); #endif return 0; } EXPORT_SYMBOL(snd_emux_register); /* */ int snd_emux_free(struct snd_emux *emu) { unsigned long flags; if (! emu) return -EINVAL; spin_lock_irqsave(&emu->voice_lock, flags); if (emu->timer_active) del_timer(&emu->tlist); spin_unlock_irqrestore(&emu->voice_lock, flags); #ifdef CONFIG_PROC_FS snd_emux_proc_free(emu); #endif snd_emux_delete_virmidi(emu); #ifdef CONFIG_SND_SEQUENCER_OSS snd_emux_detach_seq_oss(emu); #endif snd_emux_detach_seq(emu); snd_emux_delete_hwdep(emu); if (emu->sflist) snd_sf_free(emu->sflist); kfree(emu->voices); kfree(emu->name); kfree(emu); return 0; } EXPORT_SYMBOL(snd_emux_free); /* * INIT part */ static int __init alsa_emux_init(void) { return 0; } static void __exit alsa_emux_exit(void) { } module_init(alsa_emux_init) module_exit(alsa_emux_exit)
gpl-2.0
BPI-SINOVOIP/BPI-Mainline-kernel
linux-4.19/drivers/usb/gadget/function/f_sourcesink.c
116
31703
// SPDX-License-Identifier: GPL-2.0+ /* * f_sourcesink.c - USB peripheral source/sink configuration driver * * Copyright (C) 2003-2008 David Brownell * Copyright (C) 2008 by Nokia Corporation */ /* #define VERBOSE_DEBUG */ #include <linux/slab.h> #include <linux/kernel.h> #include <linux/device.h> #include <linux/module.h> #include <linux/usb/composite.h> #include <linux/err.h> #include "g_zero.h" #include "u_f.h" /* * SOURCE/SINK FUNCTION ... a primary testing vehicle for USB peripheral * controller drivers. * * This just sinks bulk packets OUT to the peripheral and sources them IN * to the host, optionally with specific data patterns for integrity tests. * As such it supports basic functionality and load tests. * * In terms of control messaging, this supports all the standard requests * plus two that support control-OUT tests. If the optional "autoresume" * mode is enabled, it provides good functional coverage for the "USBCV" * test harness from USB-IF. */ struct f_sourcesink { struct usb_function function; struct usb_ep *in_ep; struct usb_ep *out_ep; struct usb_ep *iso_in_ep; struct usb_ep *iso_out_ep; int cur_alt; unsigned pattern; unsigned isoc_interval; unsigned isoc_maxpacket; unsigned isoc_mult; unsigned isoc_maxburst; unsigned buflen; unsigned bulk_qlen; unsigned iso_qlen; }; static inline struct f_sourcesink *func_to_ss(struct usb_function *f) { return container_of(f, struct f_sourcesink, function); } /*-------------------------------------------------------------------------*/ static struct usb_interface_descriptor source_sink_intf_alt0 = { .bLength = USB_DT_INTERFACE_SIZE, .bDescriptorType = USB_DT_INTERFACE, .bAlternateSetting = 0, .bNumEndpoints = 2, .bInterfaceClass = USB_CLASS_VENDOR_SPEC, /* .iInterface = DYNAMIC */ }; static struct usb_interface_descriptor source_sink_intf_alt1 = { .bLength = USB_DT_INTERFACE_SIZE, .bDescriptorType = USB_DT_INTERFACE, .bAlternateSetting = 1, .bNumEndpoints = 4, .bInterfaceClass = USB_CLASS_VENDOR_SPEC, /* .iInterface = DYNAMIC */ }; /* full speed support: */ static struct usb_endpoint_descriptor fs_source_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, }; static struct usb_endpoint_descriptor fs_sink_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_OUT, .bmAttributes = USB_ENDPOINT_XFER_BULK, }; static struct usb_endpoint_descriptor fs_iso_source_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_ISOC, .wMaxPacketSize = cpu_to_le16(1023), .bInterval = 4, }; static struct usb_endpoint_descriptor fs_iso_sink_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_OUT, .bmAttributes = USB_ENDPOINT_XFER_ISOC, .wMaxPacketSize = cpu_to_le16(1023), .bInterval = 4, }; static struct usb_descriptor_header *fs_source_sink_descs[] = { (struct usb_descriptor_header *) &source_sink_intf_alt0, (struct usb_descriptor_header *) &fs_sink_desc, (struct usb_descriptor_header *) &fs_source_desc, (struct usb_descriptor_header *) &source_sink_intf_alt1, #define FS_ALT_IFC_1_OFFSET 3 (struct usb_descriptor_header *) &fs_sink_desc, (struct usb_descriptor_header *) &fs_source_desc, (struct usb_descriptor_header *) &fs_iso_sink_desc, (struct usb_descriptor_header *) &fs_iso_source_desc, NULL, }; /* high speed support: */ static struct usb_endpoint_descriptor hs_source_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor hs_sink_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, .wMaxPacketSize = cpu_to_le16(512), }; static struct usb_endpoint_descriptor hs_iso_source_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_ISOC, .wMaxPacketSize = cpu_to_le16(1024), .bInterval = 4, }; static struct usb_endpoint_descriptor hs_iso_sink_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_ISOC, .wMaxPacketSize = cpu_to_le16(1024), .bInterval = 4, }; static struct usb_descriptor_header *hs_source_sink_descs[] = { (struct usb_descriptor_header *) &source_sink_intf_alt0, (struct usb_descriptor_header *) &hs_source_desc, (struct usb_descriptor_header *) &hs_sink_desc, (struct usb_descriptor_header *) &source_sink_intf_alt1, #define HS_ALT_IFC_1_OFFSET 3 (struct usb_descriptor_header *) &hs_source_desc, (struct usb_descriptor_header *) &hs_sink_desc, (struct usb_descriptor_header *) &hs_iso_source_desc, (struct usb_descriptor_header *) &hs_iso_sink_desc, NULL, }; /* super speed support: */ static struct usb_endpoint_descriptor ss_source_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, .wMaxPacketSize = cpu_to_le16(1024), }; static struct usb_ss_ep_comp_descriptor ss_source_comp_desc = { .bLength = USB_DT_SS_EP_COMP_SIZE, .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, .bMaxBurst = 0, .bmAttributes = 0, .wBytesPerInterval = 0, }; static struct usb_endpoint_descriptor ss_sink_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_BULK, .wMaxPacketSize = cpu_to_le16(1024), }; static struct usb_ss_ep_comp_descriptor ss_sink_comp_desc = { .bLength = USB_DT_SS_EP_COMP_SIZE, .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, .bMaxBurst = 0, .bmAttributes = 0, .wBytesPerInterval = 0, }; static struct usb_endpoint_descriptor ss_iso_source_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_ISOC, .wMaxPacketSize = cpu_to_le16(1024), .bInterval = 4, }; static struct usb_ss_ep_comp_descriptor ss_iso_source_comp_desc = { .bLength = USB_DT_SS_EP_COMP_SIZE, .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, .bMaxBurst = 0, .bmAttributes = 0, .wBytesPerInterval = cpu_to_le16(1024), }; static struct usb_endpoint_descriptor ss_iso_sink_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bmAttributes = USB_ENDPOINT_XFER_ISOC, .wMaxPacketSize = cpu_to_le16(1024), .bInterval = 4, }; static struct usb_ss_ep_comp_descriptor ss_iso_sink_comp_desc = { .bLength = USB_DT_SS_EP_COMP_SIZE, .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, .bMaxBurst = 0, .bmAttributes = 0, .wBytesPerInterval = cpu_to_le16(1024), }; static struct usb_descriptor_header *ss_source_sink_descs[] = { (struct usb_descriptor_header *) &source_sink_intf_alt0, (struct usb_descriptor_header *) &ss_source_desc, (struct usb_descriptor_header *) &ss_source_comp_desc, (struct usb_descriptor_header *) &ss_sink_desc, (struct usb_descriptor_header *) &ss_sink_comp_desc, (struct usb_descriptor_header *) &source_sink_intf_alt1, #define SS_ALT_IFC_1_OFFSET 5 (struct usb_descriptor_header *) &ss_source_desc, (struct usb_descriptor_header *) &ss_source_comp_desc, (struct usb_descriptor_header *) &ss_sink_desc, (struct usb_descriptor_header *) &ss_sink_comp_desc, (struct usb_descriptor_header *) &ss_iso_source_desc, (struct usb_descriptor_header *) &ss_iso_source_comp_desc, (struct usb_descriptor_header *) &ss_iso_sink_desc, (struct usb_descriptor_header *) &ss_iso_sink_comp_desc, NULL, }; /* function-specific strings: */ static struct usb_string strings_sourcesink[] = { [0].s = "source and sink data", { } /* end of list */ }; static struct usb_gadget_strings stringtab_sourcesink = { .language = 0x0409, /* en-us */ .strings = strings_sourcesink, }; static struct usb_gadget_strings *sourcesink_strings[] = { &stringtab_sourcesink, NULL, }; /*-------------------------------------------------------------------------*/ static inline struct usb_request *ss_alloc_ep_req(struct usb_ep *ep, int len) { return alloc_ep_req(ep, len); } static void disable_ep(struct usb_composite_dev *cdev, struct usb_ep *ep) { int value; value = usb_ep_disable(ep); if (value < 0) DBG(cdev, "disable %s --> %d\n", ep->name, value); } void disable_endpoints(struct usb_composite_dev *cdev, struct usb_ep *in, struct usb_ep *out, struct usb_ep *iso_in, struct usb_ep *iso_out) { disable_ep(cdev, in); disable_ep(cdev, out); if (iso_in) disable_ep(cdev, iso_in); if (iso_out) disable_ep(cdev, iso_out); } static int sourcesink_bind(struct usb_configuration *c, struct usb_function *f) { struct usb_composite_dev *cdev = c->cdev; struct f_sourcesink *ss = func_to_ss(f); int id; int ret; /* allocate interface ID(s) */ id = usb_interface_id(c, f); if (id < 0) return id; source_sink_intf_alt0.bInterfaceNumber = id; source_sink_intf_alt1.bInterfaceNumber = id; /* allocate bulk endpoints */ ss->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc); if (!ss->in_ep) { autoconf_fail: ERROR(cdev, "%s: can't autoconfigure on %s\n", f->name, cdev->gadget->name); return -ENODEV; } ss->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_sink_desc); if (!ss->out_ep) goto autoconf_fail; /* sanity check the isoc module parameters */ if (ss->isoc_interval < 1) ss->isoc_interval = 1; if (ss->isoc_interval > 16) ss->isoc_interval = 16; if (ss->isoc_mult > 2) ss->isoc_mult = 2; if (ss->isoc_maxburst > 15) ss->isoc_maxburst = 15; /* fill in the FS isoc descriptors from the module parameters */ fs_iso_source_desc.wMaxPacketSize = ss->isoc_maxpacket > 1023 ? 1023 : ss->isoc_maxpacket; fs_iso_source_desc.bInterval = ss->isoc_interval; fs_iso_sink_desc.wMaxPacketSize = ss->isoc_maxpacket > 1023 ? 1023 : ss->isoc_maxpacket; fs_iso_sink_desc.bInterval = ss->isoc_interval; /* allocate iso endpoints */ ss->iso_in_ep = usb_ep_autoconfig(cdev->gadget, &fs_iso_source_desc); if (!ss->iso_in_ep) goto no_iso; ss->iso_out_ep = usb_ep_autoconfig(cdev->gadget, &fs_iso_sink_desc); if (!ss->iso_out_ep) { usb_ep_autoconfig_release(ss->iso_in_ep); ss->iso_in_ep = NULL; no_iso: /* * We still want to work even if the UDC doesn't have isoc * endpoints, so null out the alt interface that contains * them and continue. */ fs_source_sink_descs[FS_ALT_IFC_1_OFFSET] = NULL; hs_source_sink_descs[HS_ALT_IFC_1_OFFSET] = NULL; ss_source_sink_descs[SS_ALT_IFC_1_OFFSET] = NULL; } if (ss->isoc_maxpacket > 1024) ss->isoc_maxpacket = 1024; /* support high speed hardware */ hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; /* * Fill in the HS isoc descriptors from the module parameters. * We assume that the user knows what they are doing and won't * give parameters that their UDC doesn't support. */ hs_iso_source_desc.wMaxPacketSize = ss->isoc_maxpacket; hs_iso_source_desc.wMaxPacketSize |= ss->isoc_mult << 11; hs_iso_source_desc.bInterval = ss->isoc_interval; hs_iso_source_desc.bEndpointAddress = fs_iso_source_desc.bEndpointAddress; hs_iso_sink_desc.wMaxPacketSize = ss->isoc_maxpacket; hs_iso_sink_desc.wMaxPacketSize |= ss->isoc_mult << 11; hs_iso_sink_desc.bInterval = ss->isoc_interval; hs_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; /* support super speed hardware */ ss_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; ss_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; /* * Fill in the SS isoc descriptors from the module parameters. * We assume that the user knows what they are doing and won't * give parameters that their UDC doesn't support. */ ss_iso_source_desc.wMaxPacketSize = ss->isoc_maxpacket; ss_iso_source_desc.bInterval = ss->isoc_interval; ss_iso_source_comp_desc.bmAttributes = ss->isoc_mult; ss_iso_source_comp_desc.bMaxBurst = ss->isoc_maxburst; ss_iso_source_comp_desc.wBytesPerInterval = ss->isoc_maxpacket * (ss->isoc_mult + 1) * (ss->isoc_maxburst + 1); ss_iso_source_desc.bEndpointAddress = fs_iso_source_desc.bEndpointAddress; ss_iso_sink_desc.wMaxPacketSize = ss->isoc_maxpacket; ss_iso_sink_desc.bInterval = ss->isoc_interval; ss_iso_sink_comp_desc.bmAttributes = ss->isoc_mult; ss_iso_sink_comp_desc.bMaxBurst = ss->isoc_maxburst; ss_iso_sink_comp_desc.wBytesPerInterval = ss->isoc_maxpacket * (ss->isoc_mult + 1) * (ss->isoc_maxburst + 1); ss_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; ret = usb_assign_descriptors(f, fs_source_sink_descs, hs_source_sink_descs, ss_source_sink_descs, NULL); if (ret) return ret; DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n", (gadget_is_superspeed(c->cdev->gadget) ? "super" : (gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full")), f->name, ss->in_ep->name, ss->out_ep->name, ss->iso_in_ep ? ss->iso_in_ep->name : "<none>", ss->iso_out_ep ? ss->iso_out_ep->name : "<none>"); return 0; } static void sourcesink_free_func(struct usb_function *f) { struct f_ss_opts *opts; opts = container_of(f->fi, struct f_ss_opts, func_inst); mutex_lock(&opts->lock); opts->refcnt--; mutex_unlock(&opts->lock); usb_free_all_descriptors(f); kfree(func_to_ss(f)); } /* optionally require specific source/sink data patterns */ static int check_read_data(struct f_sourcesink *ss, struct usb_request *req) { unsigned i; u8 *buf = req->buf; struct usb_composite_dev *cdev = ss->function.config->cdev; int max_packet_size = le16_to_cpu(ss->out_ep->desc->wMaxPacketSize); if (ss->pattern == 2) return 0; for (i = 0; i < req->actual; i++, buf++) { switch (ss->pattern) { /* all-zeroes has no synchronization issues */ case 0: if (*buf == 0) continue; break; /* "mod63" stays in sync with short-terminated transfers, * OR otherwise when host and gadget agree on how large * each usb transfer request should be. Resync is done * with set_interface or set_config. (We *WANT* it to * get quickly out of sync if controllers or their drivers * stutter for any reason, including buffer duplication...) */ case 1: if (*buf == (u8)((i % max_packet_size) % 63)) continue; break; } ERROR(cdev, "bad OUT byte, buf[%d] = %d\n", i, *buf); usb_ep_set_halt(ss->out_ep); return -EINVAL; } return 0; } static void reinit_write_data(struct usb_ep *ep, struct usb_request *req) { unsigned i; u8 *buf = req->buf; int max_packet_size = le16_to_cpu(ep->desc->wMaxPacketSize); struct f_sourcesink *ss = ep->driver_data; switch (ss->pattern) { case 0: memset(req->buf, 0, req->length); break; case 1: for (i = 0; i < req->length; i++) *buf++ = (u8) ((i % max_packet_size) % 63); break; case 2: break; } } static void source_sink_complete(struct usb_ep *ep, struct usb_request *req) { struct usb_composite_dev *cdev; struct f_sourcesink *ss = ep->driver_data; int status = req->status; /* driver_data will be null if ep has been disabled */ if (!ss) return; cdev = ss->function.config->cdev; switch (status) { case 0: /* normal completion? */ if (ep == ss->out_ep) { check_read_data(ss, req); if (ss->pattern != 2) memset(req->buf, 0x55, req->length); } break; /* this endpoint is normally active while we're configured */ case -ECONNABORTED: /* hardware forced ep reset */ case -ECONNRESET: /* request dequeued */ case -ESHUTDOWN: /* disconnect from host */ VDBG(cdev, "%s gone (%d), %d/%d\n", ep->name, status, req->actual, req->length); if (ep == ss->out_ep) check_read_data(ss, req); free_ep_req(ep, req); return; case -EOVERFLOW: /* buffer overrun on read means that * we didn't provide a big enough * buffer. */ default: #if 1 DBG(cdev, "%s complete --> %d, %d/%d\n", ep->name, status, req->actual, req->length); #endif case -EREMOTEIO: /* short read */ break; } status = usb_ep_queue(ep, req, GFP_ATOMIC); if (status) { ERROR(cdev, "kill %s: resubmit %d bytes --> %d\n", ep->name, req->length, status); usb_ep_set_halt(ep); /* FIXME recover later ... somehow */ } } static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in, bool is_iso, int speed) { struct usb_ep *ep; struct usb_request *req; int i, size, qlen, status = 0; if (is_iso) { switch (speed) { case USB_SPEED_SUPER: size = ss->isoc_maxpacket * (ss->isoc_mult + 1) * (ss->isoc_maxburst + 1); break; case USB_SPEED_HIGH: size = ss->isoc_maxpacket * (ss->isoc_mult + 1); break; default: size = ss->isoc_maxpacket > 1023 ? 1023 : ss->isoc_maxpacket; break; } ep = is_in ? ss->iso_in_ep : ss->iso_out_ep; qlen = ss->iso_qlen; } else { ep = is_in ? ss->in_ep : ss->out_ep; qlen = ss->bulk_qlen; size = ss->buflen; } for (i = 0; i < qlen; i++) { req = ss_alloc_ep_req(ep, size); if (!req) return -ENOMEM; req->complete = source_sink_complete; if (is_in) reinit_write_data(ep, req); else if (ss->pattern != 2) memset(req->buf, 0x55, req->length); status = usb_ep_queue(ep, req, GFP_ATOMIC); if (status) { struct usb_composite_dev *cdev; cdev = ss->function.config->cdev; ERROR(cdev, "start %s%s %s --> %d\n", is_iso ? "ISO-" : "", is_in ? "IN" : "OUT", ep->name, status); free_ep_req(ep, req); return status; } } return status; } static void disable_source_sink(struct f_sourcesink *ss) { struct usb_composite_dev *cdev; cdev = ss->function.config->cdev; disable_endpoints(cdev, ss->in_ep, ss->out_ep, ss->iso_in_ep, ss->iso_out_ep); VDBG(cdev, "%s disabled\n", ss->function.name); } static int enable_source_sink(struct usb_composite_dev *cdev, struct f_sourcesink *ss, int alt) { int result = 0; int speed = cdev->gadget->speed; struct usb_ep *ep; /* one bulk endpoint writes (sources) zeroes IN (to the host) */ ep = ss->in_ep; result = config_ep_by_speed(cdev->gadget, &(ss->function), ep); if (result) return result; result = usb_ep_enable(ep); if (result < 0) return result; ep->driver_data = ss; result = source_sink_start_ep(ss, true, false, speed); if (result < 0) { fail: ep = ss->in_ep; usb_ep_disable(ep); return result; } /* one bulk endpoint reads (sinks) anything OUT (from the host) */ ep = ss->out_ep; result = config_ep_by_speed(cdev->gadget, &(ss->function), ep); if (result) goto fail; result = usb_ep_enable(ep); if (result < 0) goto fail; ep->driver_data = ss; result = source_sink_start_ep(ss, false, false, speed); if (result < 0) { fail2: ep = ss->out_ep; usb_ep_disable(ep); goto fail; } if (alt == 0) goto out; /* one iso endpoint writes (sources) zeroes IN (to the host) */ ep = ss->iso_in_ep; if (ep) { result = config_ep_by_speed(cdev->gadget, &(ss->function), ep); if (result) goto fail2; result = usb_ep_enable(ep); if (result < 0) goto fail2; ep->driver_data = ss; result = source_sink_start_ep(ss, true, true, speed); if (result < 0) { fail3: ep = ss->iso_in_ep; if (ep) usb_ep_disable(ep); goto fail2; } } /* one iso endpoint reads (sinks) anything OUT (from the host) */ ep = ss->iso_out_ep; if (ep) { result = config_ep_by_speed(cdev->gadget, &(ss->function), ep); if (result) goto fail3; result = usb_ep_enable(ep); if (result < 0) goto fail3; ep->driver_data = ss; result = source_sink_start_ep(ss, false, true, speed); if (result < 0) { usb_ep_disable(ep); goto fail3; } } out: ss->cur_alt = alt; DBG(cdev, "%s enabled, alt intf %d\n", ss->function.name, alt); return result; } static int sourcesink_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct f_sourcesink *ss = func_to_ss(f); struct usb_composite_dev *cdev = f->config->cdev; disable_source_sink(ss); return enable_source_sink(cdev, ss, alt); } static int sourcesink_get_alt(struct usb_function *f, unsigned intf) { struct f_sourcesink *ss = func_to_ss(f); return ss->cur_alt; } static void sourcesink_disable(struct usb_function *f) { struct f_sourcesink *ss = func_to_ss(f); disable_source_sink(ss); } /*-------------------------------------------------------------------------*/ static int sourcesink_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) { struct usb_configuration *c = f->config; struct usb_request *req = c->cdev->req; int value = -EOPNOTSUPP; u16 w_index = le16_to_cpu(ctrl->wIndex); u16 w_value = le16_to_cpu(ctrl->wValue); u16 w_length = le16_to_cpu(ctrl->wLength); req->length = USB_COMP_EP0_BUFSIZ; /* composite driver infrastructure handles everything except * the two control test requests. */ switch (ctrl->bRequest) { /* * These are the same vendor-specific requests supported by * Intel's USB 2.0 compliance test devices. We exceed that * device spec by allowing multiple-packet requests. * * NOTE: the Control-OUT data stays in req->buf ... better * would be copying it into a scratch buffer, so that other * requests may safely intervene. */ case 0x5b: /* control WRITE test -- fill the buffer */ if (ctrl->bRequestType != (USB_DIR_OUT|USB_TYPE_VENDOR)) goto unknown; if (w_value || w_index) break; /* just read that many bytes into the buffer */ if (w_length > req->length) break; value = w_length; break; case 0x5c: /* control READ test -- return the buffer */ if (ctrl->bRequestType != (USB_DIR_IN|USB_TYPE_VENDOR)) goto unknown; if (w_value || w_index) break; /* expect those bytes are still in the buffer; send back */ if (w_length > req->length) break; value = w_length; break; default: unknown: VDBG(c->cdev, "unknown control req%02x.%02x v%04x i%04x l%d\n", ctrl->bRequestType, ctrl->bRequest, w_value, w_index, w_length); } /* respond with data transfer or status phase? */ if (value >= 0) { VDBG(c->cdev, "source/sink req%02x.%02x v%04x i%04x l%d\n", ctrl->bRequestType, ctrl->bRequest, w_value, w_index, w_length); req->zero = 0; req->length = value; value = usb_ep_queue(c->cdev->gadget->ep0, req, GFP_ATOMIC); if (value < 0) ERROR(c->cdev, "source/sink response, err %d\n", value); } /* device either stalls (value < 0) or reports success */ return value; } static struct usb_function *source_sink_alloc_func( struct usb_function_instance *fi) { struct f_sourcesink *ss; struct f_ss_opts *ss_opts; ss = kzalloc(sizeof(*ss), GFP_KERNEL); if (!ss) return NULL; ss_opts = container_of(fi, struct f_ss_opts, func_inst); mutex_lock(&ss_opts->lock); ss_opts->refcnt++; mutex_unlock(&ss_opts->lock); ss->pattern = ss_opts->pattern; ss->isoc_interval = ss_opts->isoc_interval; ss->isoc_maxpacket = ss_opts->isoc_maxpacket; ss->isoc_mult = ss_opts->isoc_mult; ss->isoc_maxburst = ss_opts->isoc_maxburst; ss->buflen = ss_opts->bulk_buflen; ss->bulk_qlen = ss_opts->bulk_qlen; ss->iso_qlen = ss_opts->iso_qlen; ss->function.name = "source/sink"; ss->function.bind = sourcesink_bind; ss->function.set_alt = sourcesink_set_alt; ss->function.get_alt = sourcesink_get_alt; ss->function.disable = sourcesink_disable; ss->function.setup = sourcesink_setup; ss->function.strings = sourcesink_strings; ss->function.free_func = sourcesink_free_func; return &ss->function; } static inline struct f_ss_opts *to_f_ss_opts(struct config_item *item) { return container_of(to_config_group(item), struct f_ss_opts, func_inst.group); } static void ss_attr_release(struct config_item *item) { struct f_ss_opts *ss_opts = to_f_ss_opts(item); usb_put_function_instance(&ss_opts->func_inst); } static struct configfs_item_operations ss_item_ops = { .release = ss_attr_release, }; static ssize_t f_ss_opts_pattern_show(struct config_item *item, char *page) { struct f_ss_opts *opts = to_f_ss_opts(item); int result; mutex_lock(&opts->lock); result = sprintf(page, "%u\n", opts->pattern); mutex_unlock(&opts->lock); return result; } static ssize_t f_ss_opts_pattern_store(struct config_item *item, const char *page, size_t len) { struct f_ss_opts *opts = to_f_ss_opts(item); int ret; u8 num; mutex_lock(&opts->lock); if (opts->refcnt) { ret = -EBUSY; goto end; } ret = kstrtou8(page, 0, &num); if (ret) goto end; if (num != 0 && num != 1 && num != 2) { ret = -EINVAL; goto end; } opts->pattern = num; ret = len; end: mutex_unlock(&opts->lock); return ret; } CONFIGFS_ATTR(f_ss_opts_, pattern); static ssize_t f_ss_opts_isoc_interval_show(struct config_item *item, char *page) { struct f_ss_opts *opts = to_f_ss_opts(item); int result; mutex_lock(&opts->lock); result = sprintf(page, "%u\n", opts->isoc_interval); mutex_unlock(&opts->lock); return result; } static ssize_t f_ss_opts_isoc_interval_store(struct config_item *item, const char *page, size_t len) { struct f_ss_opts *opts = to_f_ss_opts(item); int ret; u8 num; mutex_lock(&opts->lock); if (opts->refcnt) { ret = -EBUSY; goto end; } ret = kstrtou8(page, 0, &num); if (ret) goto end; if (num > 16) { ret = -EINVAL; goto end; } opts->isoc_interval = num; ret = len; end: mutex_unlock(&opts->lock); return ret; } CONFIGFS_ATTR(f_ss_opts_, isoc_interval); static ssize_t f_ss_opts_isoc_maxpacket_show(struct config_item *item, char *page) { struct f_ss_opts *opts = to_f_ss_opts(item); int result; mutex_lock(&opts->lock); result = sprintf(page, "%u\n", opts->isoc_maxpacket); mutex_unlock(&opts->lock); return result; } static ssize_t f_ss_opts_isoc_maxpacket_store(struct config_item *item, const char *page, size_t len) { struct f_ss_opts *opts = to_f_ss_opts(item); int ret; u16 num; mutex_lock(&opts->lock); if (opts->refcnt) { ret = -EBUSY; goto end; } ret = kstrtou16(page, 0, &num); if (ret) goto end; if (num > 1024) { ret = -EINVAL; goto end; } opts->isoc_maxpacket = num; ret = len; end: mutex_unlock(&opts->lock); return ret; } CONFIGFS_ATTR(f_ss_opts_, isoc_maxpacket); static ssize_t f_ss_opts_isoc_mult_show(struct config_item *item, char *page) { struct f_ss_opts *opts = to_f_ss_opts(item); int result; mutex_lock(&opts->lock); result = sprintf(page, "%u\n", opts->isoc_mult); mutex_unlock(&opts->lock); return result; } static ssize_t f_ss_opts_isoc_mult_store(struct config_item *item, const char *page, size_t len) { struct f_ss_opts *opts = to_f_ss_opts(item); int ret; u8 num; mutex_lock(&opts->lock); if (opts->refcnt) { ret = -EBUSY; goto end; } ret = kstrtou8(page, 0, &num); if (ret) goto end; if (num > 2) { ret = -EINVAL; goto end; } opts->isoc_mult = num; ret = len; end: mutex_unlock(&opts->lock); return ret; } CONFIGFS_ATTR(f_ss_opts_, isoc_mult); static ssize_t f_ss_opts_isoc_maxburst_show(struct config_item *item, char *page) { struct f_ss_opts *opts = to_f_ss_opts(item); int result; mutex_lock(&opts->lock); result = sprintf(page, "%u\n", opts->isoc_maxburst); mutex_unlock(&opts->lock); return result; } static ssize_t f_ss_opts_isoc_maxburst_store(struct config_item *item, const char *page, size_t len) { struct f_ss_opts *opts = to_f_ss_opts(item); int ret; u8 num; mutex_lock(&opts->lock); if (opts->refcnt) { ret = -EBUSY; goto end; } ret = kstrtou8(page, 0, &num); if (ret) goto end; if (num > 15) { ret = -EINVAL; goto end; } opts->isoc_maxburst = num; ret = len; end: mutex_unlock(&opts->lock); return ret; } CONFIGFS_ATTR(f_ss_opts_, isoc_maxburst); static ssize_t f_ss_opts_bulk_buflen_show(struct config_item *item, char *page) { struct f_ss_opts *opts = to_f_ss_opts(item); int result; mutex_lock(&opts->lock); result = sprintf(page, "%u\n", opts->bulk_buflen); mutex_unlock(&opts->lock); return result; } static ssize_t f_ss_opts_bulk_buflen_store(struct config_item *item, const char *page, size_t len) { struct f_ss_opts *opts = to_f_ss_opts(item); int ret; u32 num; mutex_lock(&opts->lock); if (opts->refcnt) { ret = -EBUSY; goto end; } ret = kstrtou32(page, 0, &num); if (ret) goto end; opts->bulk_buflen = num; ret = len; end: mutex_unlock(&opts->lock); return ret; } CONFIGFS_ATTR(f_ss_opts_, bulk_buflen); static ssize_t f_ss_opts_bulk_qlen_show(struct config_item *item, char *page) { struct f_ss_opts *opts = to_f_ss_opts(item); int result; mutex_lock(&opts->lock); result = sprintf(page, "%u\n", opts->bulk_qlen); mutex_unlock(&opts->lock); return result; } static ssize_t f_ss_opts_bulk_qlen_store(struct config_item *item, const char *page, size_t len) { struct f_ss_opts *opts = to_f_ss_opts(item); int ret; u32 num; mutex_lock(&opts->lock); if (opts->refcnt) { ret = -EBUSY; goto end; } ret = kstrtou32(page, 0, &num); if (ret) goto end; opts->bulk_qlen = num; ret = len; end: mutex_unlock(&opts->lock); return ret; } CONFIGFS_ATTR(f_ss_opts_, bulk_qlen); static ssize_t f_ss_opts_iso_qlen_show(struct config_item *item, char *page) { struct f_ss_opts *opts = to_f_ss_opts(item); int result; mutex_lock(&opts->lock); result = sprintf(page, "%u\n", opts->iso_qlen); mutex_unlock(&opts->lock); return result; } static ssize_t f_ss_opts_iso_qlen_store(struct config_item *item, const char *page, size_t len) { struct f_ss_opts *opts = to_f_ss_opts(item); int ret; u32 num; mutex_lock(&opts->lock); if (opts->refcnt) { ret = -EBUSY; goto end; } ret = kstrtou32(page, 0, &num); if (ret) goto end; opts->iso_qlen = num; ret = len; end: mutex_unlock(&opts->lock); return ret; } CONFIGFS_ATTR(f_ss_opts_, iso_qlen); static struct configfs_attribute *ss_attrs[] = { &f_ss_opts_attr_pattern, &f_ss_opts_attr_isoc_interval, &f_ss_opts_attr_isoc_maxpacket, &f_ss_opts_attr_isoc_mult, &f_ss_opts_attr_isoc_maxburst, &f_ss_opts_attr_bulk_buflen, &f_ss_opts_attr_bulk_qlen, &f_ss_opts_attr_iso_qlen, NULL, }; static const struct config_item_type ss_func_type = { .ct_item_ops = &ss_item_ops, .ct_attrs = ss_attrs, .ct_owner = THIS_MODULE, }; static void source_sink_free_instance(struct usb_function_instance *fi) { struct f_ss_opts *ss_opts; ss_opts = container_of(fi, struct f_ss_opts, func_inst); kfree(ss_opts); } static struct usb_function_instance *source_sink_alloc_inst(void) { struct f_ss_opts *ss_opts; ss_opts = kzalloc(sizeof(*ss_opts), GFP_KERNEL); if (!ss_opts) return ERR_PTR(-ENOMEM); mutex_init(&ss_opts->lock); ss_opts->func_inst.free_func_inst = source_sink_free_instance; ss_opts->isoc_interval = GZERO_ISOC_INTERVAL; ss_opts->isoc_maxpacket = GZERO_ISOC_MAXPACKET; ss_opts->bulk_buflen = GZERO_BULK_BUFLEN; ss_opts->bulk_qlen = GZERO_SS_BULK_QLEN; ss_opts->iso_qlen = GZERO_SS_ISO_QLEN; config_group_init_type_name(&ss_opts->func_inst.group, "", &ss_func_type); return &ss_opts->func_inst; } DECLARE_USB_FUNCTION(SourceSink, source_sink_alloc_inst, source_sink_alloc_func); static int __init sslb_modinit(void) { int ret; ret = usb_function_register(&SourceSinkusb_func); if (ret) return ret; ret = lb_modinit(); if (ret) usb_function_unregister(&SourceSinkusb_func); return ret; } static void __exit sslb_modexit(void) { usb_function_unregister(&SourceSinkusb_func); lb_modexit(); } module_init(sslb_modinit); module_exit(sslb_modexit); MODULE_LICENSE("GPL");
gpl-2.0
Amperific/kernel_tuna_4.3
security/smc/tf_comm_mshield.c
116
26029
/** * Copyright (c) 2010 Trusted Logic S.A. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <asm/div64.h> #include <asm/system.h> #include <asm/cputype.h> #include <linux/uaccess.h> #include <linux/io.h> #include <linux/interrupt.h> #include <linux/page-flags.h> #include <linux/pagemap.h> #include <linux/vmalloc.h> #include <linux/version.h> #include <linux/jiffies.h> #include <linux/dma-mapping.h> #include <linux/cpu.h> #include <asm/cacheflush.h> #include "tf_defs.h" #include "tf_comm.h" #include "tf_util.h" #include "tf_conn.h" #include "tf_zebra.h" #include "tf_crypto.h" /*-------------------------------------------------------------------------- * Internal constants *-------------------------------------------------------------------------- */ /* RPC commands */ #define RPC_CMD_YIELD 0x00 #define RPC_CMD_INIT 0x01 #define RPC_CMD_TRACE 0x02 /* RPC return values to secure world */ #define RPC_SUCCESS 0x00000000 #define RPC_ERROR_BAD_PARAMETERS 0xFFFF0006 #define RPC_ERROR_CONNECTION_PROTOCOL 0xFFFF3020 /* * RPC call status * * 0: the secure world yielded due to an interrupt * 1: the secure world yielded on an RPC (no public world thread is handling it) * 2: the secure world yielded on an RPC and the response to that RPC is now in * place */ #define RPC_ADVANCEMENT_NONE 0 #define RPC_ADVANCEMENT_PENDING 1 #define RPC_ADVANCEMENT_FINISHED 2 u32 g_RPC_advancement; u32 g_RPC_parameters[4] = {0, 0, 0, 0}; u32 g_secure_task_id; u32 g_service_end; /* * Secure ROMCode HAL API Identifiers */ #define API_HAL_SDP_RUNTIMEINIT_INDEX 0x04 #define API_HAL_LM_PALOAD_INDEX 0x05 #define API_HAL_LM_PAUNLOADALL_INDEX 0x07 #define API_HAL_TASK_MGR_RPCINIT_INDEX 0x08 #define API_HAL_KM_GETSECUREROMCODECRC_INDEX 0x0B #define API_HAL_SEC_L3_RAM_RESIZE_INDEX 0x17 #define API_HAL_RET_VALUE_OK 0x0 /* SE entry flags */ #define FLAG_START_HAL_CRITICAL 0x4 #define FLAG_IRQFIQ_MASK 0x3 #define FLAG_IRQ_ENABLE 0x2 #define FLAG_FIQ_ENABLE 0x1 #define SMICODEPUB_IRQ_END 0xFE #define SMICODEPUB_FIQ_END 0xFD #define SMICODEPUB_RPC_END 0xFC #define SEC_RAM_SIZE_40KB 0x0000A000 #define SEC_RAM_SIZE_48KB 0x0000C000 #define SEC_RAM_SIZE_52KB 0x0000D000 #define SEC_RAM_SIZE_60KB 0x0000F000 #define SEC_RAM_SIZE_64KB 0x00010000 struct tf_ns_pa_info { void *certificate; void *parameters; void *results; }; /* * AFY: I would like to remove the L0 buffer altogether: * - you can use the L1 shared buffer to pass the RPC parameters and results: * I think these easily fit in 256 bytes and you can use the area at * offset 0x2C0-0x3BF in the L1 shared buffer */ struct tf_init_buffer { u32 init_status; u32 protocol_version; u32 l1_shared_buffer_descr; u32 backing_store_addr; u32 backext_storage_addr; u32 workspace_addr; u32 workspace_size; u32 properties_length; u8 properties_buffer[1]; }; #ifdef CONFIG_HAS_WAKELOCK static struct wake_lock g_tf_wake_lock; static u32 tf_wake_lock_count = 0; #endif static struct clockdomain *smc_l4_sec_clkdm; static u32 smc_l4_sec_clkdm_use_count = 0; static int __init tf_early_init(void) { g_secure_task_id = 0; dprintk(KERN_INFO "SMC early init\n"); smc_l4_sec_clkdm = clkdm_lookup("l4_secure_clkdm"); if (smc_l4_sec_clkdm == NULL) return -EFAULT; #ifdef CONFIG_HAS_WAKELOCK wake_lock_init(&g_tf_wake_lock, WAKE_LOCK_SUSPEND, TF_DEVICE_BASE_NAME); #endif return 0; } early_initcall(tf_early_init); /* * Function responsible for formatting parameters to pass from NS world to * S world */ u32 omap4_secure_dispatcher(u32 app_id, u32 flags, u32 nargs, u32 arg1, u32 arg2, u32 arg3, u32 arg4) { u32 ret; unsigned long iflags; u32 pub2sec_args[5] = {0, 0, 0, 0, 0}; /*dprintk(KERN_INFO "omap4_secure_dispatcher: " "app_id=0x%08x, flags=0x%08x, nargs=%u\n", app_id, flags, nargs);*/ /*if (nargs != 0) dprintk(KERN_INFO "omap4_secure_dispatcher: args=%08x, %08x, %08x, %08x\n", arg1, arg2, arg3, arg4);*/ pub2sec_args[0] = nargs; pub2sec_args[1] = arg1; pub2sec_args[2] = arg2; pub2sec_args[3] = arg3; pub2sec_args[4] = arg4; /* Make sure parameters are visible to the secure world */ dmac_flush_range((void *)pub2sec_args, (void *)(((u32)(pub2sec_args)) + 5*sizeof(u32))); outer_clean_range(__pa(pub2sec_args), __pa(pub2sec_args) + 5*sizeof(u32)); wmb(); /* * Put L4 Secure clock domain to SW_WKUP so that modules are accessible */ tf_l4sec_clkdm_wakeup(false); local_irq_save(iflags); #ifdef DEBUG BUG_ON((read_mpidr() & 0x00000003) != 0); #endif /* proc_id is always 0 */ ret = schedule_secure_world(app_id, 0, flags, __pa(pub2sec_args)); local_irq_restore(iflags); /* Restore the HW_SUP on L4 Sec clock domain so hardware can idle */ tf_l4sec_clkdm_allow_idle(false); /*dprintk(KERN_INFO "omap4_secure_dispatcher()\n");*/ return ret; } /* Yields the Secure World */ int tf_schedule_secure_world(struct tf_comm *comm, bool prepare_exit) { int status = 0; int ret; unsigned long iflags; u32 appli_id; tf_set_current_time(comm); local_irq_save(iflags); switch (g_RPC_advancement) { case RPC_ADVANCEMENT_NONE: /* Return from IRQ */ appli_id = SMICODEPUB_IRQ_END; if (prepare_exit) status = STATUS_PENDING; break; case RPC_ADVANCEMENT_PENDING: /* nothing to do in this case */ goto exit; default: case RPC_ADVANCEMENT_FINISHED: if (prepare_exit) goto exit; appli_id = SMICODEPUB_RPC_END; g_RPC_advancement = RPC_ADVANCEMENT_NONE; break; } g_service_end = 1; /* yield to the Secure World */ ret = omap4_secure_dispatcher(appli_id, /* app_id */ 0, 0, /* flags, nargs */ 0, 0, 0, 0); /* arg1, arg2, arg3, arg4 */ if (g_service_end != 0) { dprintk(KERN_ERR "Service End ret=%X\n", ret); if (ret == 0) { dmac_flush_range((void *)comm->init_shared_buffer, (void *)(((u32)(comm->init_shared_buffer)) + PAGE_SIZE)); outer_inv_range(__pa(comm->init_shared_buffer), __pa(comm->init_shared_buffer) + PAGE_SIZE); ret = ((struct tf_init_buffer *) (comm->init_shared_buffer))->init_status; dprintk(KERN_ERR "SMC PA failure ret=%X\n", ret); if (ret == 0) ret = -EFAULT; } clear_bit(TF_COMM_FLAG_PA_AVAILABLE, &comm->flags); omap4_secure_dispatcher(API_HAL_LM_PAUNLOADALL_INDEX, FLAG_START_HAL_CRITICAL, 0, 0, 0, 0, 0); status = ret; } exit: local_irq_restore(iflags); return status; } /* Initializes the SE (SDP, SRAM resize, RPC handler) */ static int tf_se_init(struct tf_comm *comm, u32 sdp_backing_store_addr, u32 sdp_bkext_store_addr) { int error; unsigned int crc; if (comm->se_initialized) { dprintk(KERN_INFO "tf_se_init: SE already initialized... " "nothing to do\n"); return 0; } /* Secure CRC read */ dprintk(KERN_INFO "tf_se_init: Secure CRC Read...\n"); crc = omap4_secure_dispatcher(API_HAL_KM_GETSECUREROMCODECRC_INDEX, 0, 0, 0, 0, 0, 0); printk(KERN_INFO "SMC: SecureCRC=0x%08X\n", crc); /* * Flush caches before resize, just to be sure there is no * pending public data writes back to SRAM that could trigger a * security violation once their address space is marked as * secure. */ #define OMAP4_SRAM_PA 0x40300000 #define OMAP4_SRAM_SIZE 0xe000 flush_cache_all(); outer_flush_range(OMAP4_SRAM_PA, OMAP4_SRAM_PA + OMAP4_SRAM_SIZE); wmb(); /* SRAM resize */ dprintk(KERN_INFO "tf_se_init: SRAM resize (52KB)...\n"); error = omap4_secure_dispatcher(API_HAL_SEC_L3_RAM_RESIZE_INDEX, FLAG_FIQ_ENABLE | FLAG_START_HAL_CRITICAL, 1, SEC_RAM_SIZE_52KB, 0, 0, 0); if (error == API_HAL_RET_VALUE_OK) { dprintk(KERN_INFO "tf_se_init: SRAM resize OK\n"); } else { dprintk(KERN_ERR "tf_se_init: " "SRAM resize failed [0x%x]\n", error); goto error; } /* SDP init */ dprintk(KERN_INFO "tf_se_init: SDP runtime init..." "(sdp_backing_store_addr=%x, sdp_bkext_store_addr=%x)\n", sdp_backing_store_addr, sdp_bkext_store_addr); error = omap4_secure_dispatcher(API_HAL_SDP_RUNTIMEINIT_INDEX, FLAG_FIQ_ENABLE | FLAG_START_HAL_CRITICAL, 2, sdp_backing_store_addr, sdp_bkext_store_addr, 0, 0); if (error == API_HAL_RET_VALUE_OK) { dprintk(KERN_INFO "tf_se_init: SDP runtime init OK\n"); } else { dprintk(KERN_ERR "tf_se_init: " "SDP runtime init failed [0x%x]\n", error); goto error; } /* RPC init */ dprintk(KERN_INFO "tf_se_init: RPC init...\n"); error = omap4_secure_dispatcher(API_HAL_TASK_MGR_RPCINIT_INDEX, FLAG_START_HAL_CRITICAL, 1, (u32) (u32(*const) (u32, u32, u32, u32)) &rpc_handler, 0, 0, 0); if (error == API_HAL_RET_VALUE_OK) { dprintk(KERN_INFO "tf_se_init: RPC init OK\n"); } else { dprintk(KERN_ERR "tf_se_init: " "RPC init failed [0x%x]\n", error); goto error; } comm->se_initialized = true; return 0; error: return -EFAULT; } /* Check protocol version returned by the PA */ static u32 tf_rpc_init(struct tf_comm *comm) { u32 protocol_version; u32 rpc_error = RPC_SUCCESS; dprintk(KERN_INFO "tf_rpc_init(%p)\n", comm); spin_lock(&(comm->lock)); dmac_flush_range((void *)comm->init_shared_buffer, (void *)(((u32)(comm->init_shared_buffer)) + PAGE_SIZE)); outer_inv_range(__pa(comm->init_shared_buffer), __pa(comm->init_shared_buffer) + PAGE_SIZE); protocol_version = ((struct tf_init_buffer *) (comm->init_shared_buffer))->protocol_version; if ((GET_PROTOCOL_MAJOR_VERSION(protocol_version)) != TF_S_PROTOCOL_MAJOR_VERSION) { dprintk(KERN_ERR "SMC: Unsupported SMC Protocol PA Major " "Version (0x%02x, expected 0x%02x)!\n", GET_PROTOCOL_MAJOR_VERSION(protocol_version), TF_S_PROTOCOL_MAJOR_VERSION); rpc_error = RPC_ERROR_CONNECTION_PROTOCOL; } else { rpc_error = RPC_SUCCESS; } spin_unlock(&(comm->lock)); register_smc_public_crypto_digest(); register_smc_public_crypto_aes(); return rpc_error; } static u32 tf_rpc_trace(struct tf_comm *comm) { dprintk(KERN_INFO "tf_rpc_trace(%p)\n", comm); #ifdef CONFIG_SECURE_TRACE spin_lock(&(comm->lock)); printk(KERN_INFO "SMC PA: %s", comm->pBuffer->rpc_trace_buffer); spin_unlock(&(comm->lock)); #endif return RPC_SUCCESS; } /* * Handles RPC calls * * Returns: * - RPC_NO if there was no RPC to execute * - RPC_YIELD if there was a Yield RPC * - RPC_NON_YIELD if there was a non-Yield RPC */ int tf_rpc_execute(struct tf_comm *comm) { u32 rpc_command; u32 rpc_error = RPC_NO; #ifdef DEBUG BUG_ON((read_mpidr() & 0x00000003) != 0); #endif /* Lock the RPC */ mutex_lock(&(comm->rpc_mutex)); rpc_command = g_RPC_parameters[1]; if (g_RPC_advancement == RPC_ADVANCEMENT_PENDING) { dprintk(KERN_INFO "tf_rpc_execute: " "Executing CMD=0x%x\n", g_RPC_parameters[1]); switch (rpc_command) { case RPC_CMD_YIELD: dprintk(KERN_INFO "tf_rpc_execute: " "RPC_CMD_YIELD\n"); rpc_error = RPC_YIELD; g_RPC_parameters[0] = RPC_SUCCESS; break; case RPC_CMD_TRACE: rpc_error = RPC_NON_YIELD; g_RPC_parameters[0] = tf_rpc_trace(comm); break; default: if (tf_crypto_execute_rpc(rpc_command, comm->pBuffer->rpc_cus_buffer) != 0) g_RPC_parameters[0] = RPC_ERROR_BAD_PARAMETERS; else g_RPC_parameters[0] = RPC_SUCCESS; rpc_error = RPC_NON_YIELD; break; } g_RPC_advancement = RPC_ADVANCEMENT_FINISHED; } mutex_unlock(&(comm->rpc_mutex)); dprintk(KERN_INFO "tf_rpc_execute: Return 0x%x\n", rpc_error); return rpc_error; } /*-------------------------------------------------------------------------- * L4 SEC Clock domain handling *-------------------------------------------------------------------------- */ static DEFINE_SPINLOCK(clk_lock); void tf_l4sec_clkdm_wakeup(bool wakelock) { unsigned long flags; spin_lock_irqsave(&clk_lock, flags); #ifdef CONFIG_HAS_WAKELOCK if (wakelock) { tf_wake_lock_count++; wake_lock(&g_tf_wake_lock); } #endif smc_l4_sec_clkdm_use_count++; clkdm_wakeup(smc_l4_sec_clkdm); spin_unlock_irqrestore(&clk_lock, flags); } void tf_l4sec_clkdm_allow_idle(bool wakeunlock) { unsigned long flags; spin_lock_irqsave(&clk_lock, flags); smc_l4_sec_clkdm_use_count--; if (smc_l4_sec_clkdm_use_count == 0) clkdm_allow_idle(smc_l4_sec_clkdm); #ifdef CONFIG_HAS_WAKELOCK if (wakeunlock){ tf_wake_lock_count--; if (tf_wake_lock_count == 0) wake_unlock(&g_tf_wake_lock); } #endif spin_unlock_irqrestore(&clk_lock, flags); } /*-------------------------------------------------------------------------- * Power management *-------------------------------------------------------------------------- */ /* * Perform a Secure World shutdown operation. * The routine does not return if the operation succeeds. * the routine returns an appropriate error code if * the operation fails. */ int tf_pm_shutdown(struct tf_comm *comm) { int error; union tf_command command; union tf_answer answer; dprintk(KERN_INFO "tf_pm_shutdown()\n"); memset(&command, 0, sizeof(command)); command.header.message_type = TF_MESSAGE_TYPE_MANAGEMENT; command.header.message_size = (sizeof(struct tf_command_management) - sizeof(struct tf_command_header))/sizeof(u32); command.management.command = TF_MANAGEMENT_SHUTDOWN; error = tf_send_receive( comm, &command, &answer, NULL, false); if (error != 0) { dprintk(KERN_ERR "tf_pm_shutdown(): " "tf_send_receive failed (error %d)!\n", error); return error; } #ifdef CONFIG_TF_DRIVER_DEBUG_SUPPORT if (answer.header.error_code != 0) dprintk(KERN_ERR "tf_driver: shutdown failed.\n"); else dprintk(KERN_INFO "tf_driver: shutdown succeeded.\n"); #endif return answer.header.error_code; } int tf_pm_hibernate(struct tf_comm *comm) { struct tf_device *dev = tf_get_device(); dprintk(KERN_INFO "tf_pm_hibernate()\n"); /* * As we enter in CORE OFF, the keys are going to be cleared. * Reset the global key context. * When the system leaves CORE OFF, this will force the driver to go * through the secure world which will reconfigure the accelerators. */ dev->aes1_key_context = 0; dev->des_key_context = 0; #ifndef CONFIG_SMC_KERNEL_CRYPTO dev->sham1_is_public = false; #endif return 0; } #ifdef CONFIG_SMC_KERNEL_CRYPTO #define DELAYED_RESUME_NONE 0 #define DELAYED_RESUME_PENDING 1 #define DELAYED_RESUME_ONGOING 2 static DEFINE_SPINLOCK(tf_delayed_resume_lock); static int tf_need_delayed_resume = DELAYED_RESUME_NONE; int tf_delayed_secure_resume(void) { int ret; union tf_command message; union tf_answer answer; struct tf_device *dev = tf_get_device(); spin_lock(&tf_delayed_resume_lock); if (likely(tf_need_delayed_resume == DELAYED_RESUME_NONE)) { spin_unlock(&tf_delayed_resume_lock); return 0; } if (unlikely(tf_need_delayed_resume == DELAYED_RESUME_ONGOING)) { spin_unlock(&tf_delayed_resume_lock); /* * Wait for the other caller to actually finish the delayed * resume operation */ while (tf_need_delayed_resume != DELAYED_RESUME_NONE) cpu_relax(); return 0; } tf_need_delayed_resume = DELAYED_RESUME_ONGOING; spin_unlock(&tf_delayed_resume_lock); /* * When the system leaves CORE OFF, HWA are configured as secure. We * need them as public for the Linux Crypto API. */ memset(&message, 0, sizeof(message)); message.header.message_type = TF_MESSAGE_TYPE_MANAGEMENT; message.header.message_size = (sizeof(struct tf_command_management) - sizeof(struct tf_command_header))/sizeof(u32); message.management.command = TF_MANAGEMENT_RESUME_FROM_CORE_OFF; ret = tf_send_receive(&dev->sm, &message, &answer, NULL, false); if (ret) { printk(KERN_ERR "tf_pm_resume(%p): " "tf_send_receive failed (error %d)!\n", &dev->sm, ret); unregister_smc_public_crypto_digest(); unregister_smc_public_crypto_aes(); return ret; } if (answer.header.error_code) { unregister_smc_public_crypto_digest(); unregister_smc_public_crypto_aes(); } spin_lock(&tf_delayed_resume_lock); tf_need_delayed_resume = DELAYED_RESUME_NONE; spin_unlock(&tf_delayed_resume_lock); return answer.header.error_code; } #endif int tf_pm_resume(struct tf_comm *comm) { dprintk(KERN_INFO "tf_pm_resume()\n"); #if 0 { void *workspace_va; struct tf_device *dev = tf_get_device(); workspace_va = ioremap(dev->workspace_addr, dev->workspace_size); printk(KERN_INFO "Read first word of workspace [0x%x]\n", *(uint32_t *)workspace_va); } #endif #ifdef CONFIG_SMC_KERNEL_CRYPTO spin_lock(&tf_delayed_resume_lock); tf_need_delayed_resume = DELAYED_RESUME_PENDING; spin_unlock(&tf_delayed_resume_lock); #endif return 0; } /*-------------------------------------------------------------------------- * Initialization *-------------------------------------------------------------------------- */ int tf_init(struct tf_comm *comm) { spin_lock_init(&(comm->lock)); comm->flags = 0; comm->pBuffer = NULL; comm->init_shared_buffer = NULL; comm->se_initialized = false; init_waitqueue_head(&(comm->wait_queue)); mutex_init(&(comm->rpc_mutex)); if (tf_crypto_init() != PUBLIC_CRYPTO_OPERATION_SUCCESS) return -EFAULT; if (omap_type() == OMAP2_DEVICE_TYPE_GP) { register_smc_public_crypto_digest(); register_smc_public_crypto_aes(); } return 0; } /* Start the SMC PA */ int tf_start(struct tf_comm *comm, u32 workspace_addr, u32 workspace_size, u8 *pa_buffer, u32 pa_size, u8 *properties_buffer, u32 properties_length) { struct tf_init_buffer *init_shared_buffer = NULL; struct tf_l1_shared_buffer *l1_shared_buffer = NULL; u32 l1_shared_buffer_descr; struct tf_ns_pa_info pa_info; int ret; u32 descr; u32 sdp_backing_store_addr; u32 sdp_bkext_store_addr; #ifdef CONFIG_SMP long ret_affinity; cpumask_t saved_cpu_mask; cpumask_t local_cpu_mask = CPU_MASK_NONE; /* OMAP4 Secure ROM Code can only be called from CPU0. */ cpu_set(0, local_cpu_mask); sched_getaffinity(0, &saved_cpu_mask); ret_affinity = sched_setaffinity(0, &local_cpu_mask); if (ret_affinity != 0) dprintk(KERN_ERR "sched_setaffinity #1 -> 0x%lX", ret_affinity); #endif tf_l4sec_clkdm_wakeup(true); workspace_size -= SZ_1M; sdp_backing_store_addr = workspace_addr + workspace_size; workspace_size -= 0x20000; sdp_bkext_store_addr = workspace_addr + workspace_size; /* * Implementation notes: * * 1/ The PA buffer (pa_buffer)is now owned by this function. * In case of error, it is responsible for releasing the buffer. * * 2/ The PA Info and PA Buffer will be freed through a RPC call * at the beginning of the PA entry in the SE. */ if (test_bit(TF_COMM_FLAG_PA_AVAILABLE, &comm->flags)) { dprintk(KERN_ERR "tf_start(%p): " "The SMC PA is already started\n", comm); ret = -EFAULT; goto error1; } if (sizeof(struct tf_l1_shared_buffer) != PAGE_SIZE) { dprintk(KERN_ERR "tf_start(%p): " "The L1 structure size is incorrect!\n", comm); ret = -EFAULT; goto error1; } ret = tf_se_init(comm, sdp_backing_store_addr, sdp_bkext_store_addr); if (ret != 0) { dprintk(KERN_ERR "tf_start(%p): " "SE initialization failed\n", comm); goto error1; } init_shared_buffer = (struct tf_init_buffer *) internal_get_zeroed_page(GFP_KERNEL); if (init_shared_buffer == NULL) { dprintk(KERN_ERR "tf_start(%p): " "Ouf of memory!\n", comm); ret = -ENOMEM; goto error1; } /* Ensure the page is mapped */ __set_page_locked(virt_to_page(init_shared_buffer)); l1_shared_buffer = (struct tf_l1_shared_buffer *) internal_get_zeroed_page(GFP_KERNEL); if (l1_shared_buffer == NULL) { dprintk(KERN_ERR "tf_start(%p): " "Ouf of memory!\n", comm); ret = -ENOMEM; goto error1; } /* Ensure the page is mapped */ __set_page_locked(virt_to_page(l1_shared_buffer)); dprintk(KERN_INFO "tf_start(%p): " "L0SharedBuffer={0x%08x, 0x%08x}\n", comm, (u32) init_shared_buffer, (u32) __pa(init_shared_buffer)); dprintk(KERN_INFO "tf_start(%p): " "L1SharedBuffer={0x%08x, 0x%08x}\n", comm, (u32) l1_shared_buffer, (u32) __pa(l1_shared_buffer)); descr = tf_get_l2_descriptor_common((u32) l1_shared_buffer, current->mm); l1_shared_buffer_descr = ( ((u32) __pa(l1_shared_buffer) & 0xFFFFF000) | (descr & 0xFFF)); pa_info.certificate = (void *) __pa(pa_buffer); pa_info.parameters = (void *) __pa(init_shared_buffer); pa_info.results = (void *) __pa(init_shared_buffer); init_shared_buffer->l1_shared_buffer_descr = l1_shared_buffer_descr; init_shared_buffer->backing_store_addr = sdp_backing_store_addr; init_shared_buffer->backext_storage_addr = sdp_bkext_store_addr; init_shared_buffer->workspace_addr = workspace_addr; init_shared_buffer->workspace_size = workspace_size; init_shared_buffer->properties_length = properties_length; if (properties_length == 0) { init_shared_buffer->properties_buffer[0] = 0; } else { /* Test for overflow */ if ((init_shared_buffer->properties_buffer + properties_length > init_shared_buffer->properties_buffer) && (properties_length <= init_shared_buffer->properties_length)) { memcpy(init_shared_buffer->properties_buffer, properties_buffer, properties_length); } else { dprintk(KERN_INFO "tf_start(%p): " "Configuration buffer size from userland is " "incorrect(%d, %d)\n", comm, (u32) properties_length, init_shared_buffer->properties_length); ret = -EFAULT; goto error1; } } dprintk(KERN_INFO "tf_start(%p): " "System Configuration (%d bytes)\n", comm, init_shared_buffer->properties_length); dprintk(KERN_INFO "tf_start(%p): " "Starting PA (%d bytes)...\n", comm, pa_size); /* * Make sure all data is visible to the secure world */ dmac_flush_range((void *)init_shared_buffer, (void *)(((u32)init_shared_buffer) + PAGE_SIZE)); outer_clean_range(__pa(init_shared_buffer), __pa(init_shared_buffer) + PAGE_SIZE); dmac_flush_range((void *)pa_buffer, (void *)(pa_buffer + pa_size)); outer_clean_range(__pa(pa_buffer), __pa(pa_buffer) + pa_size); dmac_flush_range((void *)&pa_info, (void *)(((u32)&pa_info) + sizeof(struct tf_ns_pa_info))); outer_clean_range(__pa(&pa_info), __pa(&pa_info) + sizeof(struct tf_ns_pa_info)); wmb(); spin_lock(&(comm->lock)); comm->init_shared_buffer = init_shared_buffer; comm->pBuffer = l1_shared_buffer; spin_unlock(&(comm->lock)); init_shared_buffer = NULL; l1_shared_buffer = NULL; /* * Set the OS current time in the L1 shared buffer first. The secure * world uses it as itw boot reference time. */ tf_set_current_time(comm); /* Workaround for issue #6081 */ if ((omap_rev() && 0xFFF000FF) == OMAP443X_CLASS) disable_nonboot_cpus(); /* * Start the SMC PA */ ret = omap4_secure_dispatcher(API_HAL_LM_PALOAD_INDEX, FLAG_IRQ_ENABLE | FLAG_FIQ_ENABLE | FLAG_START_HAL_CRITICAL, 1, __pa(&pa_info), 0, 0, 0); if (ret != API_HAL_RET_VALUE_OK) { printk(KERN_ERR "SMC: Error while loading the PA [0x%x]\n", ret); goto error2; } /* Loop until the first S Yield RPC is received */ loop: mutex_lock(&(comm->rpc_mutex)); if (g_RPC_advancement == RPC_ADVANCEMENT_PENDING) { dprintk(KERN_INFO "tf_rpc_execute: " "Executing CMD=0x%x\n", g_RPC_parameters[1]); switch (g_RPC_parameters[1]) { case RPC_CMD_YIELD: dprintk(KERN_INFO "tf_rpc_execute: " "RPC_CMD_YIELD\n"); set_bit(TF_COMM_FLAG_L1_SHARED_ALLOCATED, &(comm->flags)); g_RPC_parameters[0] = RPC_SUCCESS; break; case RPC_CMD_INIT: dprintk(KERN_INFO "tf_rpc_execute: " "RPC_CMD_INIT\n"); g_RPC_parameters[0] = tf_rpc_init(comm); break; case RPC_CMD_TRACE: g_RPC_parameters[0] = tf_rpc_trace(comm); break; default: g_RPC_parameters[0] = RPC_ERROR_BAD_PARAMETERS; break; } g_RPC_advancement = RPC_ADVANCEMENT_FINISHED; } mutex_unlock(&(comm->rpc_mutex)); ret = tf_schedule_secure_world(comm, false); if (ret != 0) { printk(KERN_ERR "SMC: Error while loading the PA [0x%x]\n", ret); goto error2; } if (!test_bit(TF_COMM_FLAG_L1_SHARED_ALLOCATED, &(comm->flags))) goto loop; set_bit(TF_COMM_FLAG_PA_AVAILABLE, &comm->flags); wake_up(&(comm->wait_queue)); ret = 0; #if 0 { void *workspace_va; workspace_va = ioremap(workspace_addr, workspace_size); printk(KERN_INFO "Read first word of workspace [0x%x]\n", *(uint32_t *)workspace_va); } #endif /* Workaround for issue #6081 */ if ((omap_rev() && 0xFFF000FF) == OMAP443X_CLASS) enable_nonboot_cpus(); goto exit; error2: /* Workaround for issue #6081 */ if ((omap_rev() && 0xFFF000FF) == OMAP443X_CLASS) enable_nonboot_cpus(); spin_lock(&(comm->lock)); l1_shared_buffer = comm->pBuffer; init_shared_buffer = comm->init_shared_buffer; comm->pBuffer = NULL; comm->init_shared_buffer = NULL; spin_unlock(&(comm->lock)); error1: if (init_shared_buffer != NULL) { __clear_page_locked(virt_to_page(init_shared_buffer)); internal_free_page((unsigned long) init_shared_buffer); } if (l1_shared_buffer != NULL) { __clear_page_locked(virt_to_page(l1_shared_buffer)); internal_free_page((unsigned long) l1_shared_buffer); } exit: #ifdef CONFIG_SMP ret_affinity = sched_setaffinity(0, &saved_cpu_mask); if (ret_affinity != 0) dprintk(KERN_ERR "sched_setaffinity #2 -> 0x%lX", ret_affinity); #endif tf_l4sec_clkdm_allow_idle(true); if (ret > 0) ret = -EFAULT; return ret; } void tf_terminate(struct tf_comm *comm) { dprintk(KERN_INFO "tf_terminate(%p)\n", comm); spin_lock(&(comm->lock)); tf_crypto_terminate(); spin_unlock(&(comm->lock)); }
gpl-2.0
tgnice/kvm
sound/soc/pxa/ttc-dkb.c
372
5118
/* * linux/sound/soc/pxa/ttc_dkb.c * * Copyright (C) 2012 Marvell International Ltd. * * 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/module.h> #include <linux/moduleparam.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/soc.h> #include <sound/jack.h> #include <asm/mach-types.h> #include <sound/pcm_params.h> #include "../codecs/88pm860x-codec.h" static struct snd_soc_jack hs_jack, mic_jack; static struct snd_soc_jack_pin hs_jack_pins[] = { { .pin = "Headset Stereophone", .mask = SND_JACK_HEADPHONE, }, }; static struct snd_soc_jack_pin mic_jack_pins[] = { { .pin = "Headset Mic 2", .mask = SND_JACK_MICROPHONE, }, }; /* ttc machine dapm widgets */ static const struct snd_soc_dapm_widget ttc_dapm_widgets[] = { SND_SOC_DAPM_HP("Headset Stereophone", NULL), SND_SOC_DAPM_LINE("Lineout Out 1", NULL), SND_SOC_DAPM_LINE("Lineout Out 2", NULL), SND_SOC_DAPM_SPK("Ext Speaker", NULL), SND_SOC_DAPM_MIC("Ext Mic 1", NULL), SND_SOC_DAPM_MIC("Headset Mic 2", NULL), SND_SOC_DAPM_MIC("Ext Mic 3", NULL), }; /* ttc machine audio map */ static const struct snd_soc_dapm_route ttc_audio_map[] = { {"Headset Stereophone", NULL, "HS1"}, {"Headset Stereophone", NULL, "HS2"}, {"Ext Speaker", NULL, "LSP"}, {"Ext Speaker", NULL, "LSN"}, {"Lineout Out 1", NULL, "LINEOUT1"}, {"Lineout Out 2", NULL, "LINEOUT2"}, {"MIC1P", NULL, "Mic1 Bias"}, {"MIC1N", NULL, "Mic1 Bias"}, {"Mic1 Bias", NULL, "Ext Mic 1"}, {"MIC2P", NULL, "Mic1 Bias"}, {"MIC2N", NULL, "Mic1 Bias"}, {"Mic1 Bias", NULL, "Headset Mic 2"}, {"MIC3P", NULL, "Mic3 Bias"}, {"MIC3N", NULL, "Mic3 Bias"}, {"Mic3 Bias", NULL, "Ext Mic 3"}, }; static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; /* connected pins */ snd_soc_dapm_enable_pin(dapm, "Ext Speaker"); snd_soc_dapm_enable_pin(dapm, "Ext Mic 1"); snd_soc_dapm_enable_pin(dapm, "Ext Mic 3"); snd_soc_dapm_disable_pin(dapm, "Headset Mic 2"); snd_soc_dapm_disable_pin(dapm, "Headset Stereophone"); /* Headset jack detection */ snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2, &hs_jack); snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), hs_jack_pins); snd_soc_jack_new(codec, "Microphone Jack", SND_JACK_MICROPHONE, &mic_jack); snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins), mic_jack_pins); /* headphone, microphone detection & headset short detection */ pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE, SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2); pm860x_mic_jack_detect(codec, &hs_jack, SND_JACK_MICROPHONE); return 0; } /* ttc/td-dkb digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link ttc_pm860x_hifi_dai[] = { { .name = "88pm860x i2s", .stream_name = "audio playback", .codec_name = "88pm860x-codec", .platform_name = "mmp-pcm-audio", .cpu_dai_name = "pxa-ssp-dai.1", .codec_dai_name = "88pm860x-i2s", .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM, .init = ttc_pm860x_init, }, }; /* ttc/td audio machine driver */ static struct snd_soc_card ttc_dkb_card = { .name = "ttc-dkb-hifi", .owner = THIS_MODULE, .dai_link = ttc_pm860x_hifi_dai, .num_links = ARRAY_SIZE(ttc_pm860x_hifi_dai), .dapm_widgets = ttc_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ttc_dapm_widgets), .dapm_routes = ttc_audio_map, .num_dapm_routes = ARRAY_SIZE(ttc_audio_map), }; static int ttc_dkb_probe(struct platform_device *pdev) { struct snd_soc_card *card = &ttc_dkb_card; int ret; card->dev = &pdev->dev; ret = snd_soc_register_card(card); if (ret) dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); return ret; } static int ttc_dkb_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); snd_soc_unregister_card(card); return 0; } static struct platform_driver ttc_dkb_driver = { .driver = { .name = "ttc-dkb-audio", .owner = THIS_MODULE, .pm = &snd_soc_pm_ops, }, .probe = ttc_dkb_probe, .remove = ttc_dkb_remove, }; module_platform_driver(ttc_dkb_driver); /* Module information */ MODULE_AUTHOR("Qiao Zhou, <zhouqiao@marvell.com>"); MODULE_DESCRIPTION("ALSA SoC TTC DKB"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:ttc-dkb-audio");
gpl-2.0
G620s-Development/android_kernel_huawei_g620s
drivers/staging/vt6656/80211mgr.c
2676
24223
/* * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * File: 80211mgr.c * * Purpose: Handles the 802.11 management support functions * * Author: Lyndon Chen * * Date: May 8, 2002 * * Functions: * vMgrEncodeBeacon - Encode the Beacon frame * vMgrDecodeBeacon - Decode the Beacon frame * vMgrEncodeDisassociation - Encode the Disassociation frame * vMgrDecodeDisassociation - Decode the Disassociation frame * vMgrEncodeAssocRequest - Encode the Association request frame * vMgrDecodeAssocRequest - Decode the Association request frame * vMgrEncodeAssocResponse - Encode the Association response frame * vMgrDecodeAssocResponse - Decode the Association response frame * vMgrEncodeReAssocRequest - Encode the ReAssociation request frame * vMgrDecodeReAssocRequest - Decode the ReAssociation request frame * vMgrEncodeProbeRequest - Encode the Probe request frame * vMgrDecodeProbeRequest - Decode the Probe request frame * vMgrEncodeProbeResponse - Encode the Probe response frame * vMgrDecodeProbeResponse - Decode the Probe response frame * vMgrEncodeAuthen - Encode the Authentication frame * vMgrDecodeAuthen - Decode the Authentication frame * vMgrEncodeDeauthen - Encode the DeAuthentication frame * vMgrDecodeDeauthen - Decode the DeAuthentication frame * vMgrEncodeReassocResponse - Encode the Reassociation response frame * * Revision History: * */ #include "device.h" #include "tmacro.h" #include "tether.h" #include "80211mgr.h" #include "80211hdr.h" #include "wpa.h" static int msglevel = MSG_LEVEL_INFO; /*static int msglevel =MSG_LEVEL_DEBUG;*/ /*+ * * Routine Description: * Encode Beacon frame body offset * * Return Value: * None. * -*/ void vMgrEncodeBeacon( PWLAN_FR_BEACON pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pqwTimestamp = (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_TS); pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_BCN_INT); pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_CAPINFO); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID; return; } /*+ * * Routine Description: * Decode Beacon frame body offset * * * Return Value: * None. * -*/ void vMgrDecodeBeacon( PWLAN_FR_BEACON pFrame ) { PWLAN_IE pItem; pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pqwTimestamp = (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_TS); pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_BCN_INT); pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_CAPINFO); /* Information elements */ pItem = (PWLAN_IE)((u8 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))) + WLAN_BEACON_OFF_SSID); while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) { switch (pItem->byElementID) { case WLAN_EID_SSID: if (pFrame->pSSID == NULL) pFrame->pSSID = (PWLAN_IE_SSID)pItem; break; case WLAN_EID_SUPP_RATES: if (pFrame->pSuppRates == NULL) pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; case WLAN_EID_FH_PARMS: /* pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; */ break; case WLAN_EID_DS_PARMS: if (pFrame->pDSParms == NULL) pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem; break; case WLAN_EID_CF_PARMS: if (pFrame->pCFParms == NULL) pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem; break; case WLAN_EID_IBSS_PARMS: if (pFrame->pIBSSParms == NULL) pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem; break; case WLAN_EID_TIM: if (pFrame->pTIM == NULL) pFrame->pTIM = (PWLAN_IE_TIM)pItem; break; case WLAN_EID_RSN: if (pFrame->pRSN == NULL) pFrame->pRSN = (PWLAN_IE_RSN)pItem; break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) { if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; } break; case WLAN_EID_ERP: if (pFrame->pERP == NULL) pFrame->pERP = (PWLAN_IE_ERP)pItem; break; case WLAN_EID_EXTSUPP_RATES: if (pFrame->pExtSuppRates == NULL) pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; case WLAN_EID_COUNTRY: /* 7 */ if (pFrame->pIE_Country == NULL) pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem; break; case WLAN_EID_PWR_CONSTRAINT: /* 32 */ if (pFrame->pIE_PowerConstraint == NULL) pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem; break; case WLAN_EID_CH_SWITCH: /* 37 */ if (pFrame->pIE_CHSW == NULL) pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem; break; case WLAN_EID_QUIET: /* 40 */ if (pFrame->pIE_Quiet == NULL) pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem; break; case WLAN_EID_IBSS_DFS: if (pFrame->pIE_IBSSDFS == NULL) pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem; break; default: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID); break; } pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len); } } /*+ * * Routine Description: * Encode Disassociation * * * Return Value: * None. * -*/ void vMgrEncodeDisassociation( PWLAN_FR_DISASSOC pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DISASSOC_OFF_REASON); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason)); } /*+ * * Routine Description: * Decode Disassociation * * * Return Value: * None. * -*/ void vMgrDecodeDisassociation( PWLAN_FR_DISASSOC pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DISASSOC_OFF_REASON); } /*+ * * Routine Description: * Encode Association Request * * * Return Value: * None. * -*/ void vMgrEncodeAssocRequest( PWLAN_FR_ASSOCREQ pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_CAP_INFO); pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_LISTEN_INT); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval)); } /*+ * * Routine Description: (AP) * Decode Association Request * * * Return Value: * None. * -*/ void vMgrDecodeAssocRequest( PWLAN_FR_ASSOCREQ pFrame ) { PWLAN_IE pItem; pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_CAP_INFO); pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_LISTEN_INT); /* Information elements */ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_SSID); while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) { switch (pItem->byElementID) { case WLAN_EID_SSID: if (pFrame->pSSID == NULL) pFrame->pSSID = (PWLAN_IE_SSID)pItem; break; case WLAN_EID_SUPP_RATES: if (pFrame->pSuppRates == NULL) pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; case WLAN_EID_RSN: if (pFrame->pRSN == NULL) pFrame->pRSN = (PWLAN_IE_RSN)pItem; break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) { if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; } break; case WLAN_EID_EXTSUPP_RATES: if (pFrame->pExtSuppRates == NULL) pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; default: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n", pItem->byElementID); break; } pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len); } } /*+ * * Routine Description: (AP) * Encode Association Response * * * Return Value: * None. * -*/ void vMgrEncodeAssocResponse( PWLAN_FR_ASSOCRESP pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_CAP_INFO); pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_STATUS); pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_AID); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid)); } /*+ * * Routine Description: * Decode Association Response * * * Return Value: * None. * -*/ void vMgrDecodeAssocResponse( PWLAN_FR_ASSOCRESP pFrame ) { PWLAN_IE pItem; pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_CAP_INFO); pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_STATUS); pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_AID); /* Information elements */ pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_SUPP_RATES); pItem = (PWLAN_IE)(pFrame->pSuppRates); pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len); if ((((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) { pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem); } else pFrame->pExtSuppRates = NULL; } /*+ * * Routine Description: * Encode Reassociation Request * * * Return Value: * None. * -*/ void vMgrEncodeReassocRequest( PWLAN_FR_REASSOCREQ pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CAP_INFO); pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_LISTEN_INT); pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CURR_AP); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP)); } /*+ * * Routine Description: (AP) * Decode Reassociation Request * * * Return Value: * None. * -*/ void vMgrDecodeReassocRequest( PWLAN_FR_REASSOCREQ pFrame ) { PWLAN_IE pItem; pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CAP_INFO); pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_LISTEN_INT); pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CURR_AP); /* Information elements */ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_SSID); while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) { switch (pItem->byElementID) { case WLAN_EID_SSID: if (pFrame->pSSID == NULL) pFrame->pSSID = (PWLAN_IE_SSID)pItem; break; case WLAN_EID_SUPP_RATES: if (pFrame->pSuppRates == NULL) pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; case WLAN_EID_RSN: if (pFrame->pRSN == NULL) pFrame->pRSN = (PWLAN_IE_RSN)pItem; break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; break; case WLAN_EID_EXTSUPP_RATES: if (pFrame->pExtSuppRates == NULL) pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; default: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n", pItem->byElementID); break; } pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len); } } /*+ * * Routine Description: * Encode Probe Request * * * Return Value: * None. * -*/ void vMgrEncodeProbeRequest( PWLAN_FR_PROBEREQ pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; pFrame->len = WLAN_HDR_ADDR3_LEN; } /*+ * * Routine Description: * Decode Probe Request * * * Return Value: * None. * -*/ void vMgrDecodeProbeRequest( PWLAN_FR_PROBEREQ pFrame ) { PWLAN_IE pItem; pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Information elements */ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))); while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) { switch (pItem->byElementID) { case WLAN_EID_SSID: if (pFrame->pSSID == NULL) pFrame->pSSID = (PWLAN_IE_SSID)pItem; break; case WLAN_EID_SUPP_RATES: if (pFrame->pSuppRates == NULL) pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; case WLAN_EID_EXTSUPP_RATES: if (pFrame->pExtSuppRates == NULL) pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; default: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID); break; } pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len); } } /*+ * * Routine Description: * Encode Probe Response * * * Return Value: * None. * -*/ void vMgrEncodeProbeResponse( PWLAN_FR_PROBERESP pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pqwTimestamp = (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_TS); pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_BCN_INT); pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_CAP_INFO); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO + sizeof(*(pFrame->pwCapInfo)); } /*+ * * Routine Description: * Decode Probe Response * * * Return Value: * None. * -*/ void vMgrDecodeProbeResponse( PWLAN_FR_PROBERESP pFrame ) { PWLAN_IE pItem; pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pqwTimestamp = (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_TS); pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_BCN_INT); pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_CAP_INFO); /* Information elements */ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_SSID); while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) { switch (pItem->byElementID) { case WLAN_EID_SSID: if (pFrame->pSSID == NULL) pFrame->pSSID = (PWLAN_IE_SSID)pItem; break; case WLAN_EID_SUPP_RATES: if (pFrame->pSuppRates == NULL) pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; case WLAN_EID_FH_PARMS: break; case WLAN_EID_DS_PARMS: if (pFrame->pDSParms == NULL) pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem; break; case WLAN_EID_CF_PARMS: if (pFrame->pCFParms == NULL) pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem; break; case WLAN_EID_IBSS_PARMS: if (pFrame->pIBSSParms == NULL) pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem; break; case WLAN_EID_RSN: if (pFrame->pRSN == NULL) pFrame->pRSN = (PWLAN_IE_RSN)pItem; break; case WLAN_EID_RSN_WPA: if (pFrame->pRSNWPA == NULL) { if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true) pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; } break; case WLAN_EID_ERP: if (pFrame->pERP == NULL) pFrame->pERP = (PWLAN_IE_ERP)pItem; break; case WLAN_EID_EXTSUPP_RATES: if (pFrame->pExtSuppRates == NULL) pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; case WLAN_EID_COUNTRY: /* 7 */ if (pFrame->pIE_Country == NULL) pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem; break; case WLAN_EID_PWR_CONSTRAINT: /* 32 */ if (pFrame->pIE_PowerConstraint == NULL) pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem; break; case WLAN_EID_CH_SWITCH: /* 37 */ if (pFrame->pIE_CHSW == NULL) pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem; break; case WLAN_EID_QUIET: /* 40 */ if (pFrame->pIE_Quiet == NULL) pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem; break; case WLAN_EID_IBSS_DFS: if (pFrame->pIE_IBSSDFS == NULL) pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem; break; default: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID); break; } pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len); } } /*+ * * Routine Description: * Encode Authentication frame * * * Return Value: * None. * -*/ void vMgrEncodeAuthen( PWLAN_FR_AUTHEN pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwAuthAlgorithm = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_AUTH_ALG); pFrame->pwAuthSequence = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_AUTH_SEQ); pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_STATUS); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus)); } /*+ * * Routine Description: * Decode Authentication * * * Return Value: * None. * -*/ void vMgrDecodeAuthen( PWLAN_FR_AUTHEN pFrame ) { PWLAN_IE pItem; pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwAuthAlgorithm = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_AUTH_ALG); pFrame->pwAuthSequence = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_AUTH_SEQ); pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_STATUS); /* Information elements */ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_CHALLENGE); if ((((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE)) pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem; } /*+ * * Routine Description: * Encode Authentication * * * Return Value: * None. * -*/ void vMgrEncodeDeauthen( PWLAN_FR_DEAUTHEN pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DEAUTHEN_OFF_REASON); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason)); } /*+ * * Routine Description: * Decode Deauthentication * * * Return Value: * None. * -*/ void vMgrDecodeDeauthen( PWLAN_FR_DEAUTHEN pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DEAUTHEN_OFF_REASON); } /*+ * * Routine Description: (AP) * Encode Reassociation Response * * * Return Value: * None. * -*/ void vMgrEncodeReassocResponse( PWLAN_FR_REASSOCRESP pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; /* Fixed Fields */ pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_CAP_INFO); pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_STATUS); pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_AID); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid)); }
gpl-2.0
thicklizard/jewel
arch/arm/mach-spear6xx/clock.c
2932
16791
/* * arch/arm/mach-spear6xx/clock.c * * SPEAr6xx machines clock framework source file * * Copyright (C) 2009 ST Microelectronics * Viresh Kumar<viresh.kumar@st.com> * * This file is licensed under the terms of the GNU General Public * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ #include <linux/init.h> #include <linux/kernel.h> #include <plat/clock.h> #include <mach/misc_regs.h> /* root clks */ /* 32 KHz oscillator clock */ static struct clk osc_32k_clk = { .flags = ALWAYS_ENABLED, .rate = 32000, }; /* 30 MHz oscillator clock */ static struct clk osc_30m_clk = { .flags = ALWAYS_ENABLED, .rate = 30000000, }; /* clock derived from 32 KHz osc clk */ /* rtc clock */ static struct clk rtc_clk = { .pclk = &osc_32k_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = RTC_CLK_ENB, .recalc = &follow_parent, }; /* clock derived from 30 MHz osc clk */ /* pll masks structure */ static struct pll_clk_masks pll1_masks = { .mode_mask = PLL_MODE_MASK, .mode_shift = PLL_MODE_SHIFT, .norm_fdbk_m_mask = PLL_NORM_FDBK_M_MASK, .norm_fdbk_m_shift = PLL_NORM_FDBK_M_SHIFT, .dith_fdbk_m_mask = PLL_DITH_FDBK_M_MASK, .dith_fdbk_m_shift = PLL_DITH_FDBK_M_SHIFT, .div_p_mask = PLL_DIV_P_MASK, .div_p_shift = PLL_DIV_P_SHIFT, .div_n_mask = PLL_DIV_N_MASK, .div_n_shift = PLL_DIV_N_SHIFT, }; /* pll1 configuration structure */ static struct pll_clk_config pll1_config = { .mode_reg = PLL1_CTR, .cfg_reg = PLL1_FRQ, .masks = &pll1_masks, }; /* pll rate configuration table, in ascending order of rates */ struct pll_rate_tbl pll_rtbl[] = { {.mode = 0, .m = 0x85, .n = 0x0C, .p = 0x1}, /* 266 MHz */ {.mode = 0, .m = 0xA6, .n = 0x0C, .p = 0x1}, /* 332 MHz */ }; /* PLL1 clock */ static struct clk pll1_clk = { .flags = ENABLED_ON_INIT, .pclk = &osc_30m_clk, .en_reg = PLL1_CTR, .en_reg_bit = PLL_ENABLE, .calc_rate = &pll_calc_rate, .recalc = &pll_clk_recalc, .set_rate = &pll_clk_set_rate, .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1}, .private_data = &pll1_config, }; /* PLL3 48 MHz clock */ static struct clk pll3_48m_clk = { .flags = ALWAYS_ENABLED, .pclk = &osc_30m_clk, .rate = 48000000, }; /* watch dog timer clock */ static struct clk wdt_clk = { .flags = ALWAYS_ENABLED, .pclk = &osc_30m_clk, .recalc = &follow_parent, }; /* clock derived from pll1 clk */ /* cpu clock */ static struct clk cpu_clk = { .flags = ALWAYS_ENABLED, .pclk = &pll1_clk, .recalc = &follow_parent, }; /* ahb masks structure */ static struct bus_clk_masks ahb_masks = { .mask = PLL_HCLK_RATIO_MASK, .shift = PLL_HCLK_RATIO_SHIFT, }; /* ahb configuration structure */ static struct bus_clk_config ahb_config = { .reg = CORE_CLK_CFG, .masks = &ahb_masks, }; /* ahb rate configuration table, in ascending order of rates */ struct bus_rate_tbl bus_rtbl[] = { {.div = 3}, /* == parent divided by 4 */ {.div = 2}, /* == parent divided by 3 */ {.div = 1}, /* == parent divided by 2 */ {.div = 0}, /* == parent divided by 1 */ }; /* ahb clock */ static struct clk ahb_clk = { .flags = ALWAYS_ENABLED, .pclk = &pll1_clk, .calc_rate = &bus_calc_rate, .recalc = &bus_clk_recalc, .set_rate = &bus_clk_set_rate, .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2}, .private_data = &ahb_config, }; /* auxiliary synthesizers masks */ static struct aux_clk_masks aux_masks = { .eq_sel_mask = AUX_EQ_SEL_MASK, .eq_sel_shift = AUX_EQ_SEL_SHIFT, .eq1_mask = AUX_EQ1_SEL, .eq2_mask = AUX_EQ2_SEL, .xscale_sel_mask = AUX_XSCALE_MASK, .xscale_sel_shift = AUX_XSCALE_SHIFT, .yscale_sel_mask = AUX_YSCALE_MASK, .yscale_sel_shift = AUX_YSCALE_SHIFT, }; /* uart configurations */ static struct aux_clk_config uart_synth_config = { .synth_reg = UART_CLK_SYNT, .masks = &aux_masks, }; /* aux rate configuration table, in ascending order of rates */ struct aux_rate_tbl aux_rtbl[] = { /* For PLL1 = 332 MHz */ {.xscale = 1, .yscale = 8, .eq = 1}, /* 41.5 MHz */ {.xscale = 1, .yscale = 4, .eq = 1}, /* 83 MHz */ {.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */ }; /* uart synth clock */ static struct clk uart_synth_clk = { .en_reg = UART_CLK_SYNT, .en_reg_bit = AUX_SYNT_ENB, .pclk = &pll1_clk, .calc_rate = &aux_calc_rate, .recalc = &aux_clk_recalc, .set_rate = &aux_clk_set_rate, .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, .private_data = &uart_synth_config, }; /* uart parents */ static struct pclk_info uart_pclk_info[] = { { .pclk = &uart_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* uart parent select structure */ static struct pclk_sel uart_pclk_sel = { .pclk_info = uart_pclk_info, .pclk_count = ARRAY_SIZE(uart_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = UART_CLK_MASK, }; /* uart0 clock */ static struct clk uart0_clk = { .en_reg = PERIP1_CLK_ENB, .en_reg_bit = UART0_CLK_ENB, .pclk_sel = &uart_pclk_sel, .pclk_sel_shift = UART_CLK_SHIFT, .recalc = &follow_parent, }; /* uart1 clock */ static struct clk uart1_clk = { .en_reg = PERIP1_CLK_ENB, .en_reg_bit = UART1_CLK_ENB, .pclk_sel = &uart_pclk_sel, .pclk_sel_shift = UART_CLK_SHIFT, .recalc = &follow_parent, }; /* firda configurations */ static struct aux_clk_config firda_synth_config = { .synth_reg = FIRDA_CLK_SYNT, .masks = &aux_masks, }; /* firda synth clock */ static struct clk firda_synth_clk = { .en_reg = FIRDA_CLK_SYNT, .en_reg_bit = AUX_SYNT_ENB, .pclk = &pll1_clk, .calc_rate = &aux_calc_rate, .recalc = &aux_clk_recalc, .set_rate = &aux_clk_set_rate, .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, .private_data = &firda_synth_config, }; /* firda parents */ static struct pclk_info firda_pclk_info[] = { { .pclk = &firda_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* firda parent select structure */ static struct pclk_sel firda_pclk_sel = { .pclk_info = firda_pclk_info, .pclk_count = ARRAY_SIZE(firda_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = FIRDA_CLK_MASK, }; /* firda clock */ static struct clk firda_clk = { .en_reg = PERIP1_CLK_ENB, .en_reg_bit = FIRDA_CLK_ENB, .pclk_sel = &firda_pclk_sel, .pclk_sel_shift = FIRDA_CLK_SHIFT, .recalc = &follow_parent, }; /* clcd configurations */ static struct aux_clk_config clcd_synth_config = { .synth_reg = CLCD_CLK_SYNT, .masks = &aux_masks, }; /* firda synth clock */ static struct clk clcd_synth_clk = { .en_reg = CLCD_CLK_SYNT, .en_reg_bit = AUX_SYNT_ENB, .pclk = &pll1_clk, .calc_rate = &aux_calc_rate, .recalc = &aux_clk_recalc, .set_rate = &aux_clk_set_rate, .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, .private_data = &clcd_synth_config, }; /* clcd parents */ static struct pclk_info clcd_pclk_info[] = { { .pclk = &clcd_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* clcd parent select structure */ static struct pclk_sel clcd_pclk_sel = { .pclk_info = clcd_pclk_info, .pclk_count = ARRAY_SIZE(clcd_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = CLCD_CLK_MASK, }; /* clcd clock */ static struct clk clcd_clk = { .en_reg = PERIP1_CLK_ENB, .en_reg_bit = CLCD_CLK_ENB, .pclk_sel = &clcd_pclk_sel, .pclk_sel_shift = CLCD_CLK_SHIFT, .recalc = &follow_parent, }; /* gpt synthesizer masks */ static struct gpt_clk_masks gpt_masks = { .mscale_sel_mask = GPT_MSCALE_MASK, .mscale_sel_shift = GPT_MSCALE_SHIFT, .nscale_sel_mask = GPT_NSCALE_MASK, .nscale_sel_shift = GPT_NSCALE_SHIFT, }; /* gpt rate configuration table, in ascending order of rates */ struct gpt_rate_tbl gpt_rtbl[] = { /* For pll1 = 332 MHz */ {.mscale = 4, .nscale = 0}, /* 41.5 MHz */ {.mscale = 2, .nscale = 0}, /* 55.3 MHz */ {.mscale = 1, .nscale = 0}, /* 83 MHz */ }; /* gpt0 synth clk config*/ static struct gpt_clk_config gpt0_synth_config = { .synth_reg = PRSC1_CLK_CFG, .masks = &gpt_masks, }; /* gpt synth clock */ static struct clk gpt0_synth_clk = { .flags = ALWAYS_ENABLED, .pclk = &pll1_clk, .calc_rate = &gpt_calc_rate, .recalc = &gpt_clk_recalc, .set_rate = &gpt_clk_set_rate, .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, .private_data = &gpt0_synth_config, }; /* gpt parents */ static struct pclk_info gpt0_pclk_info[] = { { .pclk = &gpt0_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* gpt parent select structure */ static struct pclk_sel gpt0_pclk_sel = { .pclk_info = gpt0_pclk_info, .pclk_count = ARRAY_SIZE(gpt0_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = GPT_CLK_MASK, }; /* gpt0 ARM1 subsystem timer clock */ static struct clk gpt0_clk = { .flags = ALWAYS_ENABLED, .pclk_sel = &gpt0_pclk_sel, .pclk_sel_shift = GPT0_CLK_SHIFT, .recalc = &follow_parent, }; /* Note: gpt0 and gpt1 share same parent clocks */ /* gpt parent select structure */ static struct pclk_sel gpt1_pclk_sel = { .pclk_info = gpt0_pclk_info, .pclk_count = ARRAY_SIZE(gpt0_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = GPT_CLK_MASK, }; /* gpt1 timer clock */ static struct clk gpt1_clk = { .flags = ALWAYS_ENABLED, .pclk_sel = &gpt1_pclk_sel, .pclk_sel_shift = GPT1_CLK_SHIFT, .recalc = &follow_parent, }; /* gpt2 synth clk config*/ static struct gpt_clk_config gpt2_synth_config = { .synth_reg = PRSC2_CLK_CFG, .masks = &gpt_masks, }; /* gpt synth clock */ static struct clk gpt2_synth_clk = { .flags = ALWAYS_ENABLED, .pclk = &pll1_clk, .calc_rate = &gpt_calc_rate, .recalc = &gpt_clk_recalc, .set_rate = &gpt_clk_set_rate, .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, .private_data = &gpt2_synth_config, }; /* gpt parents */ static struct pclk_info gpt2_pclk_info[] = { { .pclk = &gpt2_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* gpt parent select structure */ static struct pclk_sel gpt2_pclk_sel = { .pclk_info = gpt2_pclk_info, .pclk_count = ARRAY_SIZE(gpt2_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = GPT_CLK_MASK, }; /* gpt2 timer clock */ static struct clk gpt2_clk = { .flags = ALWAYS_ENABLED, .pclk_sel = &gpt2_pclk_sel, .pclk_sel_shift = GPT2_CLK_SHIFT, .recalc = &follow_parent, }; /* gpt3 synth clk config*/ static struct gpt_clk_config gpt3_synth_config = { .synth_reg = PRSC3_CLK_CFG, .masks = &gpt_masks, }; /* gpt synth clock */ static struct clk gpt3_synth_clk = { .flags = ALWAYS_ENABLED, .pclk = &pll1_clk, .calc_rate = &gpt_calc_rate, .recalc = &gpt_clk_recalc, .set_rate = &gpt_clk_set_rate, .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, .private_data = &gpt3_synth_config, }; /* gpt parents */ static struct pclk_info gpt3_pclk_info[] = { { .pclk = &gpt3_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* gpt parent select structure */ static struct pclk_sel gpt3_pclk_sel = { .pclk_info = gpt3_pclk_info, .pclk_count = ARRAY_SIZE(gpt3_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = GPT_CLK_MASK, }; /* gpt3 timer clock */ static struct clk gpt3_clk = { .flags = ALWAYS_ENABLED, .pclk_sel = &gpt3_pclk_sel, .pclk_sel_shift = GPT3_CLK_SHIFT, .recalc = &follow_parent, }; /* clock derived from pll3 clk */ /* usbh0 clock */ static struct clk usbh0_clk = { .pclk = &pll3_48m_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = USBH0_CLK_ENB, .recalc = &follow_parent, }; /* usbh1 clock */ static struct clk usbh1_clk = { .pclk = &pll3_48m_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = USBH1_CLK_ENB, .recalc = &follow_parent, }; /* usbd clock */ static struct clk usbd_clk = { .pclk = &pll3_48m_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = USBD_CLK_ENB, .recalc = &follow_parent, }; /* clock derived from ahb clk */ /* apb masks structure */ static struct bus_clk_masks apb_masks = { .mask = HCLK_PCLK_RATIO_MASK, .shift = HCLK_PCLK_RATIO_SHIFT, }; /* apb configuration structure */ static struct bus_clk_config apb_config = { .reg = CORE_CLK_CFG, .masks = &apb_masks, }; /* apb clock */ static struct clk apb_clk = { .flags = ALWAYS_ENABLED, .pclk = &ahb_clk, .calc_rate = &bus_calc_rate, .recalc = &bus_clk_recalc, .set_rate = &bus_clk_set_rate, .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2}, .private_data = &apb_config, }; /* i2c clock */ static struct clk i2c_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = I2C_CLK_ENB, .recalc = &follow_parent, }; /* dma clock */ static struct clk dma_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = DMA_CLK_ENB, .recalc = &follow_parent, }; /* jpeg clock */ static struct clk jpeg_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = JPEG_CLK_ENB, .recalc = &follow_parent, }; /* gmac clock */ static struct clk gmac_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = GMAC_CLK_ENB, .recalc = &follow_parent, }; /* smi clock */ static struct clk smi_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = SMI_CLK_ENB, .recalc = &follow_parent, }; /* fsmc clock */ static struct clk fsmc_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = FSMC_CLK_ENB, .recalc = &follow_parent, }; /* clock derived from apb clk */ /* adc clock */ static struct clk adc_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = ADC_CLK_ENB, .recalc = &follow_parent, }; /* ssp0 clock */ static struct clk ssp0_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = SSP0_CLK_ENB, .recalc = &follow_parent, }; /* ssp1 clock */ static struct clk ssp1_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = SSP1_CLK_ENB, .recalc = &follow_parent, }; /* ssp2 clock */ static struct clk ssp2_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = SSP2_CLK_ENB, .recalc = &follow_parent, }; /* gpio0 ARM subsystem clock */ static struct clk gpio0_clk = { .flags = ALWAYS_ENABLED, .pclk = &apb_clk, .recalc = &follow_parent, }; /* gpio1 clock */ static struct clk gpio1_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = GPIO1_CLK_ENB, .recalc = &follow_parent, }; /* gpio2 clock */ static struct clk gpio2_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = GPIO2_CLK_ENB, .recalc = &follow_parent, }; static struct clk dummy_apb_pclk; /* array of all spear 6xx clock lookups */ static struct clk_lookup spear_clk_lookups[] = { { .con_id = "apb_pclk", .clk = &dummy_apb_pclk}, /* root clks */ { .con_id = "osc_32k_clk", .clk = &osc_32k_clk}, { .con_id = "osc_30m_clk", .clk = &osc_30m_clk}, /* clock derived from 32 KHz os clk */ { .dev_id = "rtc-spear", .clk = &rtc_clk}, /* clock derived from 30 MHz os clk */ { .con_id = "pll1_clk", .clk = &pll1_clk}, { .con_id = "pll3_48m_clk", .clk = &pll3_48m_clk}, { .dev_id = "wdt", .clk = &wdt_clk}, /* clock derived from pll1 clk */ { .con_id = "cpu_clk", .clk = &cpu_clk}, { .con_id = "ahb_clk", .clk = &ahb_clk}, { .con_id = "uart_synth_clk", .clk = &uart_synth_clk}, { .con_id = "firda_synth_clk", .clk = &firda_synth_clk}, { .con_id = "clcd_synth_clk", .clk = &clcd_synth_clk}, { .con_id = "gpt0_synth_clk", .clk = &gpt0_synth_clk}, { .con_id = "gpt2_synth_clk", .clk = &gpt2_synth_clk}, { .con_id = "gpt3_synth_clk", .clk = &gpt3_synth_clk}, { .dev_id = "uart0", .clk = &uart0_clk}, { .dev_id = "uart1", .clk = &uart1_clk}, { .dev_id = "firda", .clk = &firda_clk}, { .dev_id = "clcd", .clk = &clcd_clk}, { .dev_id = "gpt0", .clk = &gpt0_clk}, { .dev_id = "gpt1", .clk = &gpt1_clk}, { .dev_id = "gpt2", .clk = &gpt2_clk}, { .dev_id = "gpt3", .clk = &gpt3_clk}, /* clock derived from pll3 clk */ { .dev_id = "designware_udc", .clk = &usbd_clk}, { .con_id = "usbh.0_clk", .clk = &usbh0_clk}, { .con_id = "usbh.1_clk", .clk = &usbh1_clk}, /* clock derived from ahb clk */ { .con_id = "apb_clk", .clk = &apb_clk}, { .dev_id = "i2c_designware.0", .clk = &i2c_clk}, { .dev_id = "dma", .clk = &dma_clk}, { .dev_id = "jpeg", .clk = &jpeg_clk}, { .dev_id = "gmac", .clk = &gmac_clk}, { .dev_id = "smi", .clk = &smi_clk}, { .con_id = "fsmc", .clk = &fsmc_clk}, /* clock derived from apb clk */ { .dev_id = "adc", .clk = &adc_clk}, { .dev_id = "ssp-pl022.0", .clk = &ssp0_clk}, { .dev_id = "ssp-pl022.1", .clk = &ssp1_clk}, { .dev_id = "ssp-pl022.2", .clk = &ssp2_clk}, { .dev_id = "gpio0", .clk = &gpio0_clk}, { .dev_id = "gpio1", .clk = &gpio1_clk}, { .dev_id = "gpio2", .clk = &gpio2_clk}, }; void __init spear6xx_clk_init(void) { int i; for (i = 0; i < ARRAY_SIZE(spear_clk_lookups); i++) clk_register(&spear_clk_lookups[i]); clk_init(); }
gpl-2.0
ivkos/kernel_i9500
fs/ecryptfs/kthread.c
3444
5745
/** * eCryptfs: Linux filesystem encryption layer * * Copyright (C) 2008 International Business Machines Corp. * Author(s): Michael A. Halcrow <mahalcro@us.ibm.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/kthread.h> #include <linux/freezer.h> #include <linux/slab.h> #include <linux/wait.h> #include <linux/mount.h> #include "ecryptfs_kernel.h" struct kmem_cache *ecryptfs_open_req_cache; static struct ecryptfs_kthread_ctl { #define ECRYPTFS_KTHREAD_ZOMBIE 0x00000001 u32 flags; struct mutex mux; struct list_head req_list; wait_queue_head_t wait; } ecryptfs_kthread_ctl; static struct task_struct *ecryptfs_kthread; /** * ecryptfs_threadfn * @ignored: ignored * * The eCryptfs kernel thread that has the responsibility of getting * the lower file with RW permissions. * * Returns zero on success; non-zero otherwise */ static int ecryptfs_threadfn(void *ignored) { set_freezable(); while (1) { struct ecryptfs_open_req *req; wait_event_freezable( ecryptfs_kthread_ctl.wait, (!list_empty(&ecryptfs_kthread_ctl.req_list) || kthread_should_stop())); mutex_lock(&ecryptfs_kthread_ctl.mux); if (ecryptfs_kthread_ctl.flags & ECRYPTFS_KTHREAD_ZOMBIE) { mutex_unlock(&ecryptfs_kthread_ctl.mux); goto out; } while (!list_empty(&ecryptfs_kthread_ctl.req_list)) { req = list_first_entry(&ecryptfs_kthread_ctl.req_list, struct ecryptfs_open_req, kthread_ctl_list); mutex_lock(&req->mux); list_del(&req->kthread_ctl_list); if (!(req->flags & ECRYPTFS_REQ_ZOMBIE)) { dget(req->lower_dentry); mntget(req->lower_mnt); (*req->lower_file) = dentry_open( req->lower_dentry, req->lower_mnt, (O_RDWR | O_LARGEFILE), current_cred()); req->flags |= ECRYPTFS_REQ_PROCESSED; } wake_up(&req->wait); mutex_unlock(&req->mux); } mutex_unlock(&ecryptfs_kthread_ctl.mux); } out: return 0; } int __init ecryptfs_init_kthread(void) { int rc = 0; mutex_init(&ecryptfs_kthread_ctl.mux); init_waitqueue_head(&ecryptfs_kthread_ctl.wait); INIT_LIST_HEAD(&ecryptfs_kthread_ctl.req_list); ecryptfs_kthread = kthread_run(&ecryptfs_threadfn, NULL, "ecryptfs-kthread"); if (IS_ERR(ecryptfs_kthread)) { rc = PTR_ERR(ecryptfs_kthread); printk(KERN_ERR "%s: Failed to create kernel thread; rc = [%d]" "\n", __func__, rc); } return rc; } void ecryptfs_destroy_kthread(void) { struct ecryptfs_open_req *req; mutex_lock(&ecryptfs_kthread_ctl.mux); ecryptfs_kthread_ctl.flags |= ECRYPTFS_KTHREAD_ZOMBIE; list_for_each_entry(req, &ecryptfs_kthread_ctl.req_list, kthread_ctl_list) { mutex_lock(&req->mux); req->flags |= ECRYPTFS_REQ_ZOMBIE; wake_up(&req->wait); mutex_unlock(&req->mux); } mutex_unlock(&ecryptfs_kthread_ctl.mux); kthread_stop(ecryptfs_kthread); wake_up(&ecryptfs_kthread_ctl.wait); } /** * ecryptfs_privileged_open * @lower_file: Result of dentry_open by root on lower dentry * @lower_dentry: Lower dentry for file to open * @lower_mnt: Lower vfsmount for file to open * * This function gets a r/w file opened againt the lower dentry. * * Returns zero on success; non-zero otherwise */ int ecryptfs_privileged_open(struct file **lower_file, struct dentry *lower_dentry, struct vfsmount *lower_mnt, const struct cred *cred) { struct ecryptfs_open_req *req; int flags = O_LARGEFILE; int rc = 0; /* Corresponding dput() and mntput() are done when the * lower file is fput() when all eCryptfs files for the inode are * released. */ dget(lower_dentry); mntget(lower_mnt); flags |= IS_RDONLY(lower_dentry->d_inode) ? O_RDONLY : O_RDWR; (*lower_file) = dentry_open(lower_dentry, lower_mnt, flags, cred); if (!IS_ERR(*lower_file)) goto out; if ((flags & O_ACCMODE) == O_RDONLY) { rc = PTR_ERR((*lower_file)); goto out; } req = kmem_cache_alloc(ecryptfs_open_req_cache, GFP_KERNEL); if (!req) { rc = -ENOMEM; goto out; } mutex_init(&req->mux); req->lower_file = lower_file; req->lower_dentry = lower_dentry; req->lower_mnt = lower_mnt; init_waitqueue_head(&req->wait); req->flags = 0; mutex_lock(&ecryptfs_kthread_ctl.mux); if (ecryptfs_kthread_ctl.flags & ECRYPTFS_KTHREAD_ZOMBIE) { rc = -EIO; mutex_unlock(&ecryptfs_kthread_ctl.mux); printk(KERN_ERR "%s: We are in the middle of shutting down; " "aborting privileged request to open lower file\n", __func__); goto out_free; } list_add_tail(&req->kthread_ctl_list, &ecryptfs_kthread_ctl.req_list); mutex_unlock(&ecryptfs_kthread_ctl.mux); wake_up(&ecryptfs_kthread_ctl.wait); wait_event(req->wait, (req->flags != 0)); mutex_lock(&req->mux); BUG_ON(req->flags == 0); if (req->flags & ECRYPTFS_REQ_DROPPED || req->flags & ECRYPTFS_REQ_ZOMBIE) { rc = -EIO; printk(KERN_WARNING "%s: Privileged open request dropped\n", __func__); goto out_unlock; } if (IS_ERR(*req->lower_file)) rc = PTR_ERR(*req->lower_file); out_unlock: mutex_unlock(&req->mux); out_free: kmem_cache_free(ecryptfs_open_req_cache, req); out: return rc; }
gpl-2.0
cwxda/android_kernel_xiaomi_armani_caf
arch/mips/bcm63xx/setup.c
4468
3283
/* * 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. * * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> */ #include <linux/init.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/bootmem.h> #include <linux/ioport.h> #include <linux/pm.h> #include <asm/bootinfo.h> #include <asm/time.h> #include <asm/reboot.h> #include <asm/cacheflush.h> #include <bcm63xx_board.h> #include <bcm63xx_cpu.h> #include <bcm63xx_regs.h> #include <bcm63xx_io.h> void bcm63xx_machine_halt(void) { printk(KERN_INFO "System halted\n"); while (1) ; } static void bcm6348_a1_reboot(void) { u32 reg; /* soft reset all blocks */ printk(KERN_INFO "soft-resetting all blocks ...\n"); reg = bcm_perf_readl(PERF_SOFTRESET_REG); reg &= ~SOFTRESET_6348_ALL; bcm_perf_writel(reg, PERF_SOFTRESET_REG); mdelay(10); reg = bcm_perf_readl(PERF_SOFTRESET_REG); reg |= SOFTRESET_6348_ALL; bcm_perf_writel(reg, PERF_SOFTRESET_REG); mdelay(10); /* Jump to the power on address. */ printk(KERN_INFO "jumping to reset vector.\n"); /* set high vectors (base at 0xbfc00000 */ set_c0_status(ST0_BEV | ST0_ERL); /* run uncached in kseg0 */ change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED); __flush_cache_all(); /* remove all wired TLB entries */ write_c0_wired(0); __asm__ __volatile__( "jr\t%0" : : "r" (0xbfc00000)); while (1) ; } void bcm63xx_machine_reboot(void) { u32 reg, perf_regs[2] = { 0, 0 }; unsigned int i; /* mask and clear all external irq */ switch (bcm63xx_get_cpu_id()) { case BCM6338_CPU_ID: perf_regs[0] = PERF_EXTIRQ_CFG_REG_6338; break; case BCM6348_CPU_ID: perf_regs[0] = PERF_EXTIRQ_CFG_REG_6348; break; case BCM6358_CPU_ID: perf_regs[0] = PERF_EXTIRQ_CFG_REG_6358; break; } for (i = 0; i < 2; i++) { reg = bcm_perf_readl(perf_regs[i]); if (BCMCPU_IS_6348()) { reg &= ~EXTIRQ_CFG_MASK_ALL_6348; reg |= EXTIRQ_CFG_CLEAR_ALL_6348; } else { reg &= ~EXTIRQ_CFG_MASK_ALL; reg |= EXTIRQ_CFG_CLEAR_ALL; } bcm_perf_writel(reg, perf_regs[i]); } if (BCMCPU_IS_6348() && (bcm63xx_get_cpu_rev() == 0xa1)) bcm6348_a1_reboot(); printk(KERN_INFO "triggering watchdog soft-reset...\n"); reg = bcm_perf_readl(PERF_SYS_PLL_CTL_REG); reg |= SYS_PLL_SOFT_RESET; bcm_perf_writel(reg, PERF_SYS_PLL_CTL_REG); while (1) ; } static void __bcm63xx_machine_reboot(char *p) { bcm63xx_machine_reboot(); } /* * return system type in /proc/cpuinfo */ const char *get_system_type(void) { static char buf[128]; snprintf(buf, sizeof(buf), "bcm63xx/%s (0x%04x/0x%04X)", board_get_name(), bcm63xx_get_cpu_id(), bcm63xx_get_cpu_rev()); return buf; } void __init plat_time_init(void) { mips_hpt_frequency = bcm63xx_get_cpu_freq() / 2; } void __init plat_mem_setup(void) { add_memory_region(0, bcm63xx_get_memory_size(), BOOT_MEM_RAM); _machine_halt = bcm63xx_machine_halt; _machine_restart = __bcm63xx_machine_reboot; pm_power_off = bcm63xx_machine_halt; set_io_port_base(0); ioport_resource.start = 0; ioport_resource.end = ~0; board_setup(); } int __init bcm63xx_register_devices(void) { return board_register_devices(); } device_initcall(bcm63xx_register_devices);
gpl-2.0
SlimRoms/kernel_sony_apq8064
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
4468
5327
/* * Copyright 2009-2010 Freescale Semiconductor, Inc. * * QorIQ (P1/P2) L2 controller init for Cache-SRAM instantiation * * Author: Vivek Mahajan <vivek.mahajan@freescale.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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/of_platform.h> #include <asm/io.h> #include "fsl_85xx_cache_ctlr.h" static char *sram_size; static char *sram_offset; struct mpc85xx_l2ctlr __iomem *l2ctlr; static long get_cache_sram_size(void) { unsigned long val; if (!sram_size || (strict_strtoul(sram_size, 0, &val) < 0)) return -EINVAL; return val; } static long get_cache_sram_offset(void) { unsigned long val; if (!sram_offset || (strict_strtoul(sram_offset, 0, &val) < 0)) return -EINVAL; return val; } static int __init get_size_from_cmdline(char *str) { if (!str) return 0; sram_size = str; return 1; } static int __init get_offset_from_cmdline(char *str) { if (!str) return 0; sram_offset = str; return 1; } __setup("cache-sram-size=", get_size_from_cmdline); __setup("cache-sram-offset=", get_offset_from_cmdline); static int __devinit mpc85xx_l2ctlr_of_probe(struct platform_device *dev) { long rval; unsigned int rem; unsigned char ways; const unsigned int *prop; unsigned int l2cache_size; struct sram_parameters sram_params; if (!dev->dev.of_node) { dev_err(&dev->dev, "Device's OF-node is NULL\n"); return -EINVAL; } prop = of_get_property(dev->dev.of_node, "cache-size", NULL); if (!prop) { dev_err(&dev->dev, "Missing L2 cache-size\n"); return -EINVAL; } l2cache_size = *prop; sram_params.sram_size = get_cache_sram_size(); if ((int)sram_params.sram_size <= 0) { dev_err(&dev->dev, "Entire L2 as cache, Aborting Cache-SRAM stuff\n"); return -EINVAL; } sram_params.sram_offset = get_cache_sram_offset(); if ((int64_t)sram_params.sram_offset <= 0) { dev_err(&dev->dev, "Entire L2 as cache, provide a valid sram offset\n"); return -EINVAL; } rem = l2cache_size % sram_params.sram_size; ways = LOCK_WAYS_FULL * sram_params.sram_size / l2cache_size; if (rem || (ways & (ways - 1))) { dev_err(&dev->dev, "Illegal cache-sram-size in command line\n"); return -EINVAL; } l2ctlr = of_iomap(dev->dev.of_node, 0); if (!l2ctlr) { dev_err(&dev->dev, "Can't map L2 controller\n"); return -EINVAL; } /* * Write bits[0-17] to srbar0 */ out_be32(&l2ctlr->srbar0, sram_params.sram_offset & L2SRAM_BAR_MSK_LO18); /* * Write bits[18-21] to srbare0 */ #ifdef CONFIG_PHYS_64BIT out_be32(&l2ctlr->srbarea0, (sram_params.sram_offset >> 32) & L2SRAM_BARE_MSK_HI4); #endif clrsetbits_be32(&l2ctlr->ctl, L2CR_L2E, L2CR_L2FI); switch (ways) { case LOCK_WAYS_EIGHTH: setbits32(&l2ctlr->ctl, L2CR_L2E | L2CR_L2FI | L2CR_SRAM_EIGHTH); break; case LOCK_WAYS_TWO_EIGHTH: setbits32(&l2ctlr->ctl, L2CR_L2E | L2CR_L2FI | L2CR_SRAM_QUART); break; case LOCK_WAYS_HALF: setbits32(&l2ctlr->ctl, L2CR_L2E | L2CR_L2FI | L2CR_SRAM_HALF); break; case LOCK_WAYS_FULL: default: setbits32(&l2ctlr->ctl, L2CR_L2E | L2CR_L2FI | L2CR_SRAM_FULL); break; } eieio(); rval = instantiate_cache_sram(dev, sram_params); if (rval < 0) { dev_err(&dev->dev, "Can't instantiate Cache-SRAM\n"); iounmap(l2ctlr); return -EINVAL; } return 0; } static int __devexit mpc85xx_l2ctlr_of_remove(struct platform_device *dev) { BUG_ON(!l2ctlr); iounmap(l2ctlr); remove_cache_sram(dev); dev_info(&dev->dev, "MPC85xx L2 controller unloaded\n"); return 0; } static struct of_device_id mpc85xx_l2ctlr_of_match[] = { { .compatible = "fsl,p2020-l2-cache-controller", }, { .compatible = "fsl,p2010-l2-cache-controller", }, { .compatible = "fsl,p1020-l2-cache-controller", }, { .compatible = "fsl,p1011-l2-cache-controller", }, { .compatible = "fsl,p1013-l2-cache-controller", }, { .compatible = "fsl,p1022-l2-cache-controller", }, { .compatible = "fsl,mpc8548-l2-cache-controller", }, {}, }; static struct platform_driver mpc85xx_l2ctlr_of_platform_driver = { .driver = { .name = "fsl-l2ctlr", .owner = THIS_MODULE, .of_match_table = mpc85xx_l2ctlr_of_match, }, .probe = mpc85xx_l2ctlr_of_probe, .remove = __devexit_p(mpc85xx_l2ctlr_of_remove), }; static __init int mpc85xx_l2ctlr_of_init(void) { return platform_driver_register(&mpc85xx_l2ctlr_of_platform_driver); } static void __exit mpc85xx_l2ctlr_of_exit(void) { platform_driver_unregister(&mpc85xx_l2ctlr_of_platform_driver); } subsys_initcall(mpc85xx_l2ctlr_of_init); module_exit(mpc85xx_l2ctlr_of_exit); MODULE_DESCRIPTION("Freescale MPC85xx L2 controller init"); MODULE_LICENSE("GPL v2");
gpl-2.0
mrjaydee82/SinLessKernel-4.4.4
arch/arm/mach-msm/board-mahimahi-flashlight.c
4980
6403
/* * arch/arm/mach-msm/flashlight.c - flashlight driver * * Copyright (C) 2009 zion huang <zion_huang@htc.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; version 2 of the License. */ #define DEBUG #include <linux/delay.h> #include <linux/earlysuspend.h> #include <linux/platform_device.h> #include <linux/leds.h> #include <linux/wakelock.h> #include <linux/hrtimer.h> #include <mach/msm_iomap.h> #include <asm/gpio.h> #include <asm/io.h> #include "board-mahimahi-flashlight.h" struct flashlight_struct { struct led_classdev fl_lcdev; struct early_suspend early_suspend_flashlight; spinlock_t spin_lock; struct hrtimer timer; int brightness; int gpio_torch; int gpio_flash; int flash_duration_ms; }; static struct flashlight_struct the_fl; static inline void toggle(void) { gpio_direction_output(the_fl.gpio_torch, 0); udelay(2); gpio_direction_output(the_fl.gpio_torch, 1); udelay(2); } static void flashlight_hw_command(uint8_t addr, uint8_t data) { int i; for (i = 0; i < addr + 17; i++) toggle(); udelay(500); for (i = 0; i < data; i++) toggle(); udelay(500); } static enum hrtimer_restart flashlight_timeout(struct hrtimer *timer) { unsigned long flags; pr_debug("%s\n", __func__); spin_lock_irqsave(&the_fl.spin_lock, flags); gpio_direction_output(the_fl.gpio_flash, 0); the_fl.brightness = LED_OFF; spin_unlock_irqrestore(&the_fl.spin_lock, flags); return HRTIMER_NORESTART; } int flashlight_control(int mode) { int ret = 0; unsigned long flags; pr_debug("%s: mode %d -> %d\n", __func__, the_fl.brightness, mode); spin_lock_irqsave(&the_fl.spin_lock, flags); the_fl.brightness = mode; switch (mode) { case FLASHLIGHT_TORCH: pr_info("%s: half\n", __func__); /* If we are transitioning from flash to torch, make sure to * cancel the flash timeout timer, otherwise when it expires, * the torch will go off as well. */ hrtimer_cancel(&the_fl.timer); flashlight_hw_command(2, 4); break; case FLASHLIGHT_FLASH: pr_info("%s: full\n", __func__); hrtimer_cancel(&the_fl.timer); gpio_direction_output(the_fl.gpio_flash, 0); udelay(40); gpio_direction_output(the_fl.gpio_flash, 1); hrtimer_start(&the_fl.timer, ktime_set(the_fl.flash_duration_ms / 1000, (the_fl.flash_duration_ms % 1000) * NSEC_PER_MSEC), HRTIMER_MODE_REL); /* Flash overrides torch mode, and after the flash period, the * flash LED will turn off. */ mode = LED_OFF; break; case FLASHLIGHT_OFF: pr_info("%s: off\n", __func__); gpio_direction_output(the_fl.gpio_flash, 0); gpio_direction_output(the_fl.gpio_torch, 0); break; default: pr_err("%s: unknown flash_light flags: %d\n", __func__, mode); ret = -EINVAL; goto done; } done: spin_unlock_irqrestore(&the_fl.spin_lock, flags); return ret; } EXPORT_SYMBOL(flashlight_control); static void fl_lcdev_brightness_set(struct led_classdev *led_cdev, enum led_brightness brightness) { int level; switch (brightness) { case LED_HALF: level = FLASHLIGHT_TORCH; break; case LED_FULL: level = FLASHLIGHT_FLASH; break; case LED_OFF: default: level = FLASHLIGHT_OFF; }; flashlight_control(level); } static void flashlight_early_suspend(struct early_suspend *handler) { flashlight_control(FLASHLIGHT_OFF); } static int flashlight_setup_gpio(struct flashlight_platform_data *fl_pdata) { int ret; pr_debug("%s\n", __func__); if (fl_pdata->gpio_init) { ret = fl_pdata->gpio_init(); if (ret < 0) { pr_err("%s: gpio init failed: %d\n", __func__, ret); return ret; } } if (fl_pdata->torch) { ret = gpio_request(fl_pdata->torch, "flashlight_torch"); if (ret < 0) { pr_err("%s: gpio_request failed\n", __func__); return ret; } } if (fl_pdata->flash) { ret = gpio_request(fl_pdata->flash, "flashlight_flash"); if (ret < 0) { pr_err("%s: gpio_request failed\n", __func__); gpio_free(fl_pdata->torch); return ret; } } the_fl.gpio_torch = fl_pdata->torch; the_fl.gpio_flash = fl_pdata->flash; the_fl.flash_duration_ms = fl_pdata->flash_duration_ms; return 0; } static int flashlight_probe(struct platform_device *pdev) { struct flashlight_platform_data *fl_pdata = pdev->dev.platform_data; int err = 0; pr_debug("%s\n", __func__); err = flashlight_setup_gpio(fl_pdata); if (err < 0) { pr_err("%s: setup GPIO failed\n", __func__); goto fail_free_mem; } spin_lock_init(&the_fl.spin_lock); the_fl.fl_lcdev.name = pdev->name; the_fl.fl_lcdev.brightness_set = fl_lcdev_brightness_set; the_fl.fl_lcdev.brightness = LED_OFF; err = led_classdev_register(&pdev->dev, &the_fl.fl_lcdev); if (err < 0) { pr_err("failed on led_classdev_register\n"); goto fail_free_gpio; } hrtimer_init(&the_fl.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); the_fl.timer.function = flashlight_timeout; #ifdef CONFIG_HAS_EARLYSUSPEND the_fl.early_suspend_flashlight.suspend = flashlight_early_suspend; the_fl.early_suspend_flashlight.resume = NULL; register_early_suspend(&the_fl.early_suspend_flashlight); #endif return 0; fail_free_gpio: if (fl_pdata->torch) gpio_free(fl_pdata->torch); if (fl_pdata->flash) gpio_free(fl_pdata->flash); fail_free_mem: return err; } static int flashlight_remove(struct platform_device *pdev) { struct flashlight_platform_data *fl_pdata = pdev->dev.platform_data; pr_debug("%s\n", __func__); hrtimer_cancel(&the_fl.timer); unregister_early_suspend(&the_fl.early_suspend_flashlight); flashlight_control(FLASHLIGHT_OFF); led_classdev_unregister(&the_fl.fl_lcdev); if (fl_pdata->torch) gpio_free(fl_pdata->torch); if (fl_pdata->flash) gpio_free(fl_pdata->flash); return 0; } static struct platform_driver flashlight_driver = { .probe = flashlight_probe, .remove = flashlight_remove, .driver = { .name = FLASHLIGHT_NAME, .owner = THIS_MODULE, }, }; static int __init flashlight_init(void) { pr_debug("%s\n", __func__); return platform_driver_register(&flashlight_driver); } static void __exit flashlight_exit(void) { pr_debug("%s\n", __func__); platform_driver_unregister(&flashlight_driver); } module_init(flashlight_init); module_exit(flashlight_exit); MODULE_AUTHOR("Zion Huang <zion_huang@htc.com>"); MODULE_DESCRIPTION("flash light driver"); MODULE_LICENSE("GPL");
gpl-2.0
TeamRegular/android_kernel_samsung_exynos5420
drivers/watchdog/jz4740_wdt.c
4980
6247
/* * Copyright (C) 2010, Paul Cercueil <paul@crapouillou.net> * JZ4740 Watchdog driver * * 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. * * 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/module.h> #include <linux/moduleparam.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/miscdevice.h> #include <linux/watchdog.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/io.h> #include <linux/device.h> #include <linux/clk.h> #include <linux/slab.h> #include <linux/err.h> #include <asm/mach-jz4740/timer.h> #define JZ_REG_WDT_TIMER_DATA 0x0 #define JZ_REG_WDT_COUNTER_ENABLE 0x4 #define JZ_REG_WDT_TIMER_COUNTER 0x8 #define JZ_REG_WDT_TIMER_CONTROL 0xC #define JZ_WDT_CLOCK_PCLK 0x1 #define JZ_WDT_CLOCK_RTC 0x2 #define JZ_WDT_CLOCK_EXT 0x4 #define JZ_WDT_CLOCK_DIV_SHIFT 3 #define JZ_WDT_CLOCK_DIV_1 (0 << JZ_WDT_CLOCK_DIV_SHIFT) #define JZ_WDT_CLOCK_DIV_4 (1 << JZ_WDT_CLOCK_DIV_SHIFT) #define JZ_WDT_CLOCK_DIV_16 (2 << JZ_WDT_CLOCK_DIV_SHIFT) #define JZ_WDT_CLOCK_DIV_64 (3 << JZ_WDT_CLOCK_DIV_SHIFT) #define JZ_WDT_CLOCK_DIV_256 (4 << JZ_WDT_CLOCK_DIV_SHIFT) #define JZ_WDT_CLOCK_DIV_1024 (5 << JZ_WDT_CLOCK_DIV_SHIFT) #define DEFAULT_HEARTBEAT 5 #define MAX_HEARTBEAT 2048 static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); static unsigned int heartbeat = DEFAULT_HEARTBEAT; module_param(heartbeat, uint, 0); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat period in seconds from 1 to " __MODULE_STRING(MAX_HEARTBEAT) ", default " __MODULE_STRING(DEFAULT_HEARTBEAT)); struct jz4740_wdt_drvdata { struct watchdog_device wdt; void __iomem *base; struct clk *rtc_clk; }; static int jz4740_wdt_ping(struct watchdog_device *wdt_dev) { struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev); writew(0x0, drvdata->base + JZ_REG_WDT_TIMER_COUNTER); return 0; } static int jz4740_wdt_set_timeout(struct watchdog_device *wdt_dev, unsigned int new_timeout) { struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev); unsigned int rtc_clk_rate; unsigned int timeout_value; unsigned short clock_div = JZ_WDT_CLOCK_DIV_1; rtc_clk_rate = clk_get_rate(drvdata->rtc_clk); timeout_value = rtc_clk_rate * new_timeout; while (timeout_value > 0xffff) { if (clock_div == JZ_WDT_CLOCK_DIV_1024) { /* Requested timeout too high; * use highest possible value. */ timeout_value = 0xffff; break; } timeout_value >>= 2; clock_div += (1 << JZ_WDT_CLOCK_DIV_SHIFT); } writeb(0x0, drvdata->base + JZ_REG_WDT_COUNTER_ENABLE); writew(clock_div, drvdata->base + JZ_REG_WDT_TIMER_CONTROL); writew((u16)timeout_value, drvdata->base + JZ_REG_WDT_TIMER_DATA); writew(0x0, drvdata->base + JZ_REG_WDT_TIMER_COUNTER); writew(clock_div | JZ_WDT_CLOCK_RTC, drvdata->base + JZ_REG_WDT_TIMER_CONTROL); writeb(0x1, drvdata->base + JZ_REG_WDT_COUNTER_ENABLE); wdt_dev->timeout = new_timeout; return 0; } static int jz4740_wdt_start(struct watchdog_device *wdt_dev) { jz4740_timer_enable_watchdog(); jz4740_wdt_set_timeout(wdt_dev, wdt_dev->timeout); return 0; } static int jz4740_wdt_stop(struct watchdog_device *wdt_dev) { struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev); jz4740_timer_disable_watchdog(); writeb(0x0, drvdata->base + JZ_REG_WDT_COUNTER_ENABLE); return 0; } static const struct watchdog_info jz4740_wdt_info = { .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, .identity = "jz4740 Watchdog", }; static const struct watchdog_ops jz4740_wdt_ops = { .owner = THIS_MODULE, .start = jz4740_wdt_start, .stop = jz4740_wdt_stop, .ping = jz4740_wdt_ping, .set_timeout = jz4740_wdt_set_timeout, }; static int __devinit jz4740_wdt_probe(struct platform_device *pdev) { struct jz4740_wdt_drvdata *drvdata; struct watchdog_device *jz4740_wdt; struct resource *res; int ret; drvdata = devm_kzalloc(&pdev->dev, sizeof(struct jz4740_wdt_drvdata), GFP_KERNEL); if (!drvdata) { dev_err(&pdev->dev, "Unable to alloacate watchdog device\n"); return -ENOMEM; } if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) heartbeat = DEFAULT_HEARTBEAT; jz4740_wdt = &drvdata->wdt; jz4740_wdt->info = &jz4740_wdt_info; jz4740_wdt->ops = &jz4740_wdt_ops; jz4740_wdt->timeout = heartbeat; jz4740_wdt->min_timeout = 1; jz4740_wdt->max_timeout = MAX_HEARTBEAT; watchdog_set_nowayout(jz4740_wdt, nowayout); watchdog_set_drvdata(jz4740_wdt, drvdata); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); drvdata->base = devm_request_and_ioremap(&pdev->dev, res); if (drvdata->base == NULL) { ret = -EBUSY; goto err_out; } drvdata->rtc_clk = clk_get(NULL, "rtc"); if (IS_ERR(drvdata->rtc_clk)) { dev_err(&pdev->dev, "cannot find RTC clock\n"); ret = PTR_ERR(drvdata->rtc_clk); goto err_out; } ret = watchdog_register_device(&drvdata->wdt); if (ret < 0) goto err_disable_clk; platform_set_drvdata(pdev, drvdata); return 0; err_disable_clk: clk_put(drvdata->rtc_clk); err_out: return ret; } static int __devexit jz4740_wdt_remove(struct platform_device *pdev) { struct jz4740_wdt_drvdata *drvdata = platform_get_drvdata(pdev); jz4740_wdt_stop(&drvdata->wdt); watchdog_unregister_device(&drvdata->wdt); clk_put(drvdata->rtc_clk); return 0; } static struct platform_driver jz4740_wdt_driver = { .probe = jz4740_wdt_probe, .remove = __devexit_p(jz4740_wdt_remove), .driver = { .name = "jz4740-wdt", .owner = THIS_MODULE, }, }; module_platform_driver(jz4740_wdt_driver); MODULE_AUTHOR("Paul Cercueil <paul@crapouillou.net>"); MODULE_DESCRIPTION("jz4740 Watchdog Driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); MODULE_ALIAS("platform:jz4740-wdt");
gpl-2.0
AndreiLux/Perseus-UNIVERSAL5410
drivers/ssb/driver_extif.c
5748
3826
/* * Sonics Silicon Backplane * Broadcom EXTIF core driver * * Copyright 2005, Broadcom Corporation * Copyright 2006, 2007, Michael Buesch <m@bues.ch> * Copyright 2006, 2007, Felix Fietkau <nbd@openwrt.org> * Copyright 2007, Aurelien Jarno <aurelien@aurel32.net> * * Licensed under the GNU/GPL. See COPYING for details. */ #include <linux/serial.h> #include <linux/serial_core.h> #include <linux/serial_reg.h> #include "ssb_private.h" static inline u32 extif_read32(struct ssb_extif *extif, u16 offset) { return ssb_read32(extif->dev, offset); } static inline void extif_write32(struct ssb_extif *extif, u16 offset, u32 value) { ssb_write32(extif->dev, offset, value); } static inline u32 extif_write32_masked(struct ssb_extif *extif, u16 offset, u32 mask, u32 value) { value &= mask; value |= extif_read32(extif, offset) & ~mask; extif_write32(extif, offset, value); return value; } #ifdef CONFIG_SSB_SERIAL static bool serial_exists(u8 *regs) { u8 save_mcr, msr = 0; if (regs) { save_mcr = regs[UART_MCR]; regs[UART_MCR] = (UART_MCR_LOOP | UART_MCR_OUT2 | UART_MCR_RTS); msr = regs[UART_MSR] & (UART_MSR_DCD | UART_MSR_RI | UART_MSR_CTS | UART_MSR_DSR); regs[UART_MCR] = save_mcr; } return (msr == (UART_MSR_DCD | UART_MSR_CTS)); } int ssb_extif_serial_init(struct ssb_extif *extif, struct ssb_serial_port *ports) { u32 i, nr_ports = 0; /* Disable GPIO interrupt initially */ extif_write32(extif, SSB_EXTIF_GPIO_INTPOL, 0); extif_write32(extif, SSB_EXTIF_GPIO_INTMASK, 0); for (i = 0; i < 2; i++) { void __iomem *uart_regs; uart_regs = ioremap_nocache(SSB_EUART, 16); if (uart_regs) { uart_regs += (i * 8); if (serial_exists(uart_regs) && ports) { extif_write32(extif, SSB_EXTIF_GPIO_INTMASK, 2); nr_ports++; ports[i].regs = uart_regs; ports[i].irq = 2; ports[i].baud_base = 13500000; ports[i].reg_shift = 0; } iounmap(uart_regs); } } return nr_ports; } #endif /* CONFIG_SSB_SERIAL */ void ssb_extif_timing_init(struct ssb_extif *extif, unsigned long ns) { u32 tmp; /* Initialize extif so we can get to the LEDs and external UART */ extif_write32(extif, SSB_EXTIF_PROG_CFG, SSB_EXTCFG_EN); /* Set timing for the flash */ tmp = DIV_ROUND_UP(10, ns) << SSB_PROG_WCNT_3_SHIFT; tmp |= DIV_ROUND_UP(40, ns) << SSB_PROG_WCNT_1_SHIFT; tmp |= DIV_ROUND_UP(120, ns); extif_write32(extif, SSB_EXTIF_PROG_WAITCNT, tmp); /* Set programmable interface timing for external uart */ tmp = DIV_ROUND_UP(10, ns) << SSB_PROG_WCNT_3_SHIFT; tmp |= DIV_ROUND_UP(20, ns) << SSB_PROG_WCNT_2_SHIFT; tmp |= DIV_ROUND_UP(100, ns) << SSB_PROG_WCNT_1_SHIFT; tmp |= DIV_ROUND_UP(120, ns); extif_write32(extif, SSB_EXTIF_PROG_WAITCNT, tmp); } void ssb_extif_get_clockcontrol(struct ssb_extif *extif, u32 *pll_type, u32 *n, u32 *m) { *pll_type = SSB_PLLTYPE_1; *n = extif_read32(extif, SSB_EXTIF_CLOCK_N); *m = extif_read32(extif, SSB_EXTIF_CLOCK_SB); } void ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks) { extif_write32(extif, SSB_EXTIF_WATCHDOG, ticks); } u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask) { return extif_read32(extif, SSB_EXTIF_GPIO_IN) & mask; } u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value) { return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUT(0), mask, value); } u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value) { return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUTEN(0), mask, value); } u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask, u32 value) { return extif_write32_masked(extif, SSB_EXTIF_GPIO_INTPOL, mask, value); } u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask, u32 value) { return extif_write32_masked(extif, SSB_EXTIF_GPIO_INTMASK, mask, value); }
gpl-2.0
gelotus/hammerhead-nirvana
arch/openrisc/kernel/time.c
8308
4659
/* * OpenRISC time.c * * Linux architectural port borrowing liberally from similar works of * others. All original copyrights apply as per the original source * declaration. * * Modifications for the OpenRISC architecture: * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> * * 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. */ #include <linux/kernel.h> #include <linux/time.h> #include <linux/timex.h> #include <linux/interrupt.h> #include <linux/ftrace.h> #include <linux/clocksource.h> #include <linux/clockchips.h> #include <linux/irq.h> #include <linux/io.h> #include <asm/cpuinfo.h> static int openrisc_timer_set_next_event(unsigned long delta, struct clock_event_device *dev) { u32 c; /* Read 32-bit counter value, add delta, mask off the low 28 bits. * We're guaranteed delta won't be bigger than 28 bits because the * generic timekeeping code ensures that for us. */ c = mfspr(SPR_TTCR); c += delta; c &= SPR_TTMR_TP; /* Set counter and enable interrupt. * Keep timer in continuous mode always. */ mtspr(SPR_TTMR, SPR_TTMR_CR | SPR_TTMR_IE | c); return 0; } static void openrisc_timer_set_mode(enum clock_event_mode mode, struct clock_event_device *evt) { switch (mode) { case CLOCK_EVT_MODE_PERIODIC: pr_debug(KERN_INFO "%s: periodic\n", __func__); BUG(); break; case CLOCK_EVT_MODE_ONESHOT: pr_debug(KERN_INFO "%s: oneshot\n", __func__); break; case CLOCK_EVT_MODE_UNUSED: pr_debug(KERN_INFO "%s: unused\n", __func__); break; case CLOCK_EVT_MODE_SHUTDOWN: pr_debug(KERN_INFO "%s: shutdown\n", __func__); break; case CLOCK_EVT_MODE_RESUME: pr_debug(KERN_INFO "%s: resume\n", __func__); break; } } /* This is the clock event device based on the OR1K tick timer. * As the timer is being used as a continuous clock-source (required for HR * timers) we cannot enable the PERIODIC feature. The tick timer can run using * one-shot events, so no problem. */ static struct clock_event_device clockevent_openrisc_timer = { .name = "openrisc_timer_clockevent", .features = CLOCK_EVT_FEAT_ONESHOT, .rating = 300, .set_next_event = openrisc_timer_set_next_event, .set_mode = openrisc_timer_set_mode, }; static inline void timer_ack(void) { /* Clear the IP bit and disable further interrupts */ /* This can be done very simply... we just need to keep the timer running, so just maintain the CR bits while clearing the rest of the register */ mtspr(SPR_TTMR, SPR_TTMR_CR); } /* * The timer interrupt is mostly handled in generic code nowadays... this * function just acknowledges the interrupt and fires the event handler that * has been set on the clockevent device by the generic time management code. * * This function needs to be called by the timer exception handler and that's * all the exception handler needs to do. */ irqreturn_t __irq_entry timer_interrupt(struct pt_regs *regs) { struct pt_regs *old_regs = set_irq_regs(regs); struct clock_event_device *evt = &clockevent_openrisc_timer; timer_ack(); /* * update_process_times() expects us to have called irq_enter(). */ irq_enter(); evt->event_handler(evt); irq_exit(); set_irq_regs(old_regs); return IRQ_HANDLED; } static __init void openrisc_clockevent_init(void) { clockevent_openrisc_timer.cpumask = cpumask_of(0); /* We only have 28 bits */ clockevents_config_and_register(&clockevent_openrisc_timer, cpuinfo.clock_frequency, 100, 0x0fffffff); } /** * Clocksource: Based on OpenRISC timer/counter * * This sets up the OpenRISC Tick Timer as a clock source. The tick timer * is 32 bits wide and runs at the CPU clock frequency. */ static cycle_t openrisc_timer_read(struct clocksource *cs) { return (cycle_t) mfspr(SPR_TTCR); } static struct clocksource openrisc_timer = { .name = "openrisc_timer", .rating = 200, .read = openrisc_timer_read, .mask = CLOCKSOURCE_MASK(32), .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; static int __init openrisc_timer_init(void) { if (clocksource_register_hz(&openrisc_timer, cpuinfo.clock_frequency)) panic("failed to register clocksource"); /* Enable the incrementer: 'continuous' mode with interrupt disabled */ mtspr(SPR_TTMR, SPR_TTMR_CR); return 0; } void __init time_init(void) { u32 upr; upr = mfspr(SPR_UPR); if (!(upr & SPR_UPR_TTP)) panic("Linux not supported on devices without tick timer"); openrisc_timer_init(); openrisc_clockevent_init(); }
gpl-2.0
robertdolca/linux
arch/m32r/platforms/usrv/io.c
13940
5665
/* * linux/arch/m32r/platforms/usrv/io.c * * Typical I/O routines for uServer board. * * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata, * Hitoshi Yamamoto, Takeo Takahashi * * 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. * */ #include <asm/m32r.h> #include <asm/page.h> #include <asm/io.h> #include <linux/types.h> #include "../../../../drivers/pcmcia/m32r_cfc.h" extern void pcc_ioread_byte(int, unsigned long, void *, size_t, size_t, int); extern void pcc_ioread_word(int, unsigned long, void *, size_t, size_t, int); extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int); extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); #define CFC_IOSTART CFC_IOPORT_BASE #define CFC_IOEND (CFC_IOSTART + (M32R_PCC_MAPSIZE * M32R_MAX_PCC) - 1) #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) #define UART0_REGSTART 0x04c20000 #define UART1_REGSTART 0x04c20100 #define UART_IOMAP_SIZE 8 #define UART0_IOSTART 0x3f8 #define UART0_IOEND (UART0_IOSTART + UART_IOMAP_SIZE - 1) #define UART1_IOSTART 0x2f8 #define UART1_IOEND (UART1_IOSTART + UART_IOMAP_SIZE - 1) #endif /* CONFIG_SERIAL_8250 || CONFIG_SERIAL_8250_MODULE */ #define PORT2ADDR(port) _port2addr(port) static inline void *_port2addr(unsigned long port) { #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) if (port >= UART0_IOSTART && port <= UART0_IOEND) port = ((port - UART0_IOSTART) << 1) + UART0_REGSTART; else if (port >= UART1_IOSTART && port <= UART1_IOEND) port = ((port - UART1_IOSTART) << 1) + UART1_REGSTART; #endif /* CONFIG_SERIAL_8250 || CONFIG_SERIAL_8250_MODULE */ return (void *)(port | (NONCACHE_OFFSET)); } static inline void delay(void) { __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory"); } unsigned char _inb(unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) { unsigned char b; pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0); return b; } else return *(volatile unsigned char *)PORT2ADDR(port); } unsigned short _inw(unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) { unsigned short w; pcc_ioread_word(0, port, &w, sizeof(w), 1, 0); return w; } else return *(volatile unsigned short *)PORT2ADDR(port); } unsigned long _inl(unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) { unsigned long l; pcc_ioread_word(0, port, &l, sizeof(l), 1, 0); return l; } else return *(volatile unsigned long *)PORT2ADDR(port); } unsigned char _inb_p(unsigned long port) { unsigned char v = _inb(port); delay(); return v; } unsigned short _inw_p(unsigned long port) { unsigned short v = _inw(port); delay(); return v; } unsigned long _inl_p(unsigned long port) { unsigned long v = _inl(port); delay(); return v; } void _outb(unsigned char b, unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0); else *(volatile unsigned char *)PORT2ADDR(port) = b; } void _outw(unsigned short w, unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0); else *(volatile unsigned short *)PORT2ADDR(port) = w; } void _outl(unsigned long l, unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_iowrite_word(0, port, &l, sizeof(l), 1, 0); else *(volatile unsigned long *)PORT2ADDR(port) = l; } void _outb_p(unsigned char b, unsigned long port) { _outb(b, port); delay(); } void _outw_p(unsigned short w, unsigned long port) { _outw(w, port); delay(); } void _outl_p(unsigned long l, unsigned long port) { _outl(l, port); delay(); } void _insb(unsigned int port, void * addr, unsigned long count) { if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_ioread_byte(0, port, addr, sizeof(unsigned char), count, 1); else { unsigned char *buf = addr; unsigned char *portp = PORT2ADDR(port); while (count--) *buf++ = *(volatile unsigned char *)portp; } } void _insw(unsigned int port, void * addr, unsigned long count) { unsigned short *buf = addr; unsigned short *portp; if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_ioread_word(0, port, addr, sizeof(unsigned short), count, 1); else { portp = PORT2ADDR(port); while (count--) *buf++ = *(volatile unsigned short *)portp; } } void _insl(unsigned int port, void * addr, unsigned long count) { unsigned long *buf = addr; unsigned long *portp; portp = PORT2ADDR(port); while (count--) *buf++ = *(volatile unsigned long *)portp; } void _outsb(unsigned int port, const void * addr, unsigned long count) { const unsigned char *buf = addr; unsigned char *portp; if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char), count, 1); else { portp = PORT2ADDR(port); while (count--) *(volatile unsigned char *)portp = *buf++; } } void _outsw(unsigned int port, const void * addr, unsigned long count) { const unsigned short *buf = addr; unsigned short *portp; if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_iowrite_word(0, port, (void *)addr, sizeof(unsigned short), count, 1); else { portp = PORT2ADDR(port); while (count--) *(volatile unsigned short *)portp = *buf++; } } void _outsl(unsigned int port, const void * addr, unsigned long count) { const unsigned long *buf = addr; unsigned char *portp; portp = PORT2ADDR(port); while (count--) *(volatile unsigned long *)portp = *buf++; }
gpl-2.0
nikez/android_kernel_htc_msm8660
arch/m32r/platforms/usrv/io.c
13940
5665
/* * linux/arch/m32r/platforms/usrv/io.c * * Typical I/O routines for uServer board. * * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata, * Hitoshi Yamamoto, Takeo Takahashi * * 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. * */ #include <asm/m32r.h> #include <asm/page.h> #include <asm/io.h> #include <linux/types.h> #include "../../../../drivers/pcmcia/m32r_cfc.h" extern void pcc_ioread_byte(int, unsigned long, void *, size_t, size_t, int); extern void pcc_ioread_word(int, unsigned long, void *, size_t, size_t, int); extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int); extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); #define CFC_IOSTART CFC_IOPORT_BASE #define CFC_IOEND (CFC_IOSTART + (M32R_PCC_MAPSIZE * M32R_MAX_PCC) - 1) #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) #define UART0_REGSTART 0x04c20000 #define UART1_REGSTART 0x04c20100 #define UART_IOMAP_SIZE 8 #define UART0_IOSTART 0x3f8 #define UART0_IOEND (UART0_IOSTART + UART_IOMAP_SIZE - 1) #define UART1_IOSTART 0x2f8 #define UART1_IOEND (UART1_IOSTART + UART_IOMAP_SIZE - 1) #endif /* CONFIG_SERIAL_8250 || CONFIG_SERIAL_8250_MODULE */ #define PORT2ADDR(port) _port2addr(port) static inline void *_port2addr(unsigned long port) { #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) if (port >= UART0_IOSTART && port <= UART0_IOEND) port = ((port - UART0_IOSTART) << 1) + UART0_REGSTART; else if (port >= UART1_IOSTART && port <= UART1_IOEND) port = ((port - UART1_IOSTART) << 1) + UART1_REGSTART; #endif /* CONFIG_SERIAL_8250 || CONFIG_SERIAL_8250_MODULE */ return (void *)(port | (NONCACHE_OFFSET)); } static inline void delay(void) { __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory"); } unsigned char _inb(unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) { unsigned char b; pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0); return b; } else return *(volatile unsigned char *)PORT2ADDR(port); } unsigned short _inw(unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) { unsigned short w; pcc_ioread_word(0, port, &w, sizeof(w), 1, 0); return w; } else return *(volatile unsigned short *)PORT2ADDR(port); } unsigned long _inl(unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) { unsigned long l; pcc_ioread_word(0, port, &l, sizeof(l), 1, 0); return l; } else return *(volatile unsigned long *)PORT2ADDR(port); } unsigned char _inb_p(unsigned long port) { unsigned char v = _inb(port); delay(); return v; } unsigned short _inw_p(unsigned long port) { unsigned short v = _inw(port); delay(); return v; } unsigned long _inl_p(unsigned long port) { unsigned long v = _inl(port); delay(); return v; } void _outb(unsigned char b, unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0); else *(volatile unsigned char *)PORT2ADDR(port) = b; } void _outw(unsigned short w, unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0); else *(volatile unsigned short *)PORT2ADDR(port) = w; } void _outl(unsigned long l, unsigned long port) { if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_iowrite_word(0, port, &l, sizeof(l), 1, 0); else *(volatile unsigned long *)PORT2ADDR(port) = l; } void _outb_p(unsigned char b, unsigned long port) { _outb(b, port); delay(); } void _outw_p(unsigned short w, unsigned long port) { _outw(w, port); delay(); } void _outl_p(unsigned long l, unsigned long port) { _outl(l, port); delay(); } void _insb(unsigned int port, void * addr, unsigned long count) { if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_ioread_byte(0, port, addr, sizeof(unsigned char), count, 1); else { unsigned char *buf = addr; unsigned char *portp = PORT2ADDR(port); while (count--) *buf++ = *(volatile unsigned char *)portp; } } void _insw(unsigned int port, void * addr, unsigned long count) { unsigned short *buf = addr; unsigned short *portp; if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_ioread_word(0, port, addr, sizeof(unsigned short), count, 1); else { portp = PORT2ADDR(port); while (count--) *buf++ = *(volatile unsigned short *)portp; } } void _insl(unsigned int port, void * addr, unsigned long count) { unsigned long *buf = addr; unsigned long *portp; portp = PORT2ADDR(port); while (count--) *buf++ = *(volatile unsigned long *)portp; } void _outsb(unsigned int port, const void * addr, unsigned long count) { const unsigned char *buf = addr; unsigned char *portp; if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char), count, 1); else { portp = PORT2ADDR(port); while (count--) *(volatile unsigned char *)portp = *buf++; } } void _outsw(unsigned int port, const void * addr, unsigned long count) { const unsigned short *buf = addr; unsigned short *portp; if (port >= CFC_IOSTART && port <= CFC_IOEND) pcc_iowrite_word(0, port, (void *)addr, sizeof(unsigned short), count, 1); else { portp = PORT2ADDR(port); while (count--) *(volatile unsigned short *)portp = *buf++; } } void _outsl(unsigned int port, const void * addr, unsigned long count) { const unsigned long *buf = addr; unsigned char *portp; portp = PORT2ADDR(port); while (count--) *(volatile unsigned long *)portp = *buf++; }
gpl-2.0
wkhtmltopdf/qtwebkit
Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.cpp
117
7179
/* * Copyright (C) 2013 Igalia S.L. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "config.h" #include "WebKitInjectedBundleClient.h" #include "WebImage.h" #include "WebKitURIRequestPrivate.h" #include "WebKitURIResponsePrivate.h" #include "WebKitWebContextPrivate.h" #include "WebKitWebResourcePrivate.h" #include "WebKitWebViewPrivate.h" #include <wtf/gobject/GOwnPtr.h> using namespace WebKit; using namespace WebCore; static void didReceiveWebViewMessageFromInjectedBundle(WebKitWebView* webView, const char* messageName, ImmutableDictionary& message) { if (g_str_equal(messageName, "DidInitiateLoadForResource")) { WebFrameProxy* frame = static_cast<WebFrameProxy*>(message.get(String::fromUTF8("Frame"))); WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); WebURLRequest* webRequest = static_cast<WebURLRequest*>(message.get(String::fromUTF8("Request"))); GRefPtr<WebKitURIRequest> request = adoptGRef(webkitURIRequestCreateForResourceRequest(webRequest->resourceRequest())); webkitWebViewResourceLoadStarted(webView, frame, resourceIdentifier->value(), request.get()); } else if (g_str_equal(messageName, "DidSendRequestForResource")) { WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); GRefPtr<WebKitWebResource> resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier->value()); if (!resource) return; WebURLRequest* webRequest = static_cast<WebURLRequest*>(message.get(String::fromUTF8("Request"))); GRefPtr<WebKitURIRequest> request = adoptGRef(webkitURIRequestCreateForResourceRequest(webRequest->resourceRequest())); WebURLResponse* webRedirectResponse = static_cast<WebURLResponse*>(message.get(String::fromUTF8("RedirectResponse"))); GRefPtr<WebKitURIResponse> redirectResponse = webRedirectResponse ? adoptGRef(webkitURIResponseCreateForResourceResponse(webRedirectResponse->resourceResponse())) : 0; webkitWebResourceSentRequest(resource.get(), request.get(), redirectResponse.get()); } else if (g_str_equal(messageName, "DidReceiveResponseForResource")) { WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); GRefPtr<WebKitWebResource> resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier->value()); if (!resource) return; WebURLResponse* webResponse = static_cast<WebURLResponse*>(message.get(String::fromUTF8("Response"))); GRefPtr<WebKitURIResponse> response = adoptGRef(webkitURIResponseCreateForResourceResponse(webResponse->resourceResponse())); webkitWebResourceSetResponse(resource.get(), response.get()); } else if (g_str_equal(messageName, "DidReceiveContentLengthForResource")) { WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); GRefPtr<WebKitWebResource> resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier->value()); if (!resource) return; WebUInt64* contentLength = static_cast<WebUInt64*>(message.get(String::fromUTF8("ContentLength"))); webkitWebResourceNotifyProgress(resource.get(), contentLength->value()); } else if (g_str_equal(messageName, "DidFinishLoadForResource")) { WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); GRefPtr<WebKitWebResource> resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier->value()); if (!resource) return; webkitWebResourceFinished(resource.get()); webkitWebViewRemoveLoadingWebResource(webView, resourceIdentifier->value()); } else if (g_str_equal(messageName, "DidFailLoadForResource")) { WebUInt64* resourceIdentifier = static_cast<WebUInt64*>(message.get(String::fromUTF8("Identifier"))); GRefPtr<WebKitWebResource> resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier->value()); if (!resource) return; WebError* webError = static_cast<WebError*>(message.get(String::fromUTF8("Error"))); const ResourceError& platformError = webError->platformError(); GOwnPtr<GError> resourceError(g_error_new_literal(g_quark_from_string(platformError.domain().utf8().data()), platformError.errorCode(), platformError.localizedDescription().utf8().data())); webkitWebResourceFailed(resource.get(), resourceError.get()); webkitWebViewRemoveLoadingWebResource(webView, resourceIdentifier->value()); } else if (g_str_equal(messageName, "DidGetSnapshot")) { WebUInt64* callbackID = static_cast<WebUInt64*>(message.get("CallbackID")); WebImage* image = static_cast<WebImage*>(message.get("Snapshot")); webKitWebViewDidReceiveSnapshot(webView, callbackID->value(), image); } else ASSERT_NOT_REACHED(); } static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo) { ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); ImmutableDictionary& message = *toImpl(static_cast<WKDictionaryRef>(messageBody)); CString messageNameCString = toImpl(messageName)->string().utf8(); const char* messageNameUTF8 = messageNameCString.data(); if (g_str_has_prefix(messageNameUTF8, "WebPage.")) { WebPageProxy* page = static_cast<WebPageProxy*>(message.get(String::fromUTF8("Page"))); WebKitWebView* webView = webkitWebContextGetWebViewForPage(WEBKIT_WEB_CONTEXT(clientInfo), page); if (!webView) return; didReceiveWebViewMessageFromInjectedBundle(webView, messageNameUTF8 + strlen("WebPage."), message); } else ASSERT_NOT_REACHED(); } void attachInjectedBundleClientToContext(WebKitWebContext* webContext) { WKContextInjectedBundleClient wkInjectedBundleClient = { kWKContextInjectedBundleClientCurrentVersion, webContext, // clientInfo didReceiveMessageFromInjectedBundle, 0, // didReceiveSynchronousMessageFromInjectedBundle 0 // getInjectedBundleInitializationUserData }; WKContextSetInjectedBundleClient(toAPI(webkitWebContextGetContext(webContext)), &wkInjectedBundleClient); }
gpl-2.0
schqiushui/kernel_lollipop_sense_a52
drivers/media/platform/msm/camera_v2/sensor/mt9m114.c
117
44394
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only 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. * */ #include "msm_sensor.h" #include "msm_cci.h" #include "msm_camera_io_util.h" #define MT9M114_SENSOR_NAME "mt9m114" #define PLATFORM_DRIVER_NAME "msm_camera_mt9m114" #define mt9m114_obj mt9m114_##obj #undef CDBG #define CDBG(fmt, args...) pr_debug(fmt, ##args) /* Sysctl registers */ #define MT9M114_COMMAND_REGISTER 0x0080 #define MT9M114_COMMAND_REGISTER_APPLY_PATCH (1 << 0) #define MT9M114_COMMAND_REGISTER_SET_STATE (1 << 1) #define MT9M114_COMMAND_REGISTER_REFRESH (1 << 2) #define MT9M114_COMMAND_REGISTER_WAIT_FOR_EVENT (1 << 3) #define MT9M114_COMMAND_REGISTER_OK (1 << 15) DEFINE_MSM_MUTEX(mt9m114_mut); static struct msm_sensor_ctrl_t mt9m114_s_ctrl; static struct msm_sensor_power_setting mt9m114_power_setting[] = { { .seq_type = SENSOR_VREG, .seq_val = CAM_VIO, .config_val = 0, .delay = 0, }, { .seq_type = SENSOR_VREG, .seq_val = CAM_VDIG, .config_val = 0, .delay = 0, }, { .seq_type = SENSOR_VREG, .seq_val = CAM_VANA, .config_val = 0, .delay = 0, }, { .seq_type = SENSOR_GPIO, .seq_val = SENSOR_GPIO_RESET, .config_val = GPIO_OUT_LOW, .delay = 1, }, { .seq_type = SENSOR_GPIO, .seq_val = SENSOR_GPIO_RESET, .config_val = GPIO_OUT_HIGH, .delay = 30, }, { .seq_type = SENSOR_CLK, .seq_val = SENSOR_CAM_MCLK, .config_val = 0, .delay = 100, }, { .seq_type = SENSOR_I2C_MUX, .seq_val = 0, .config_val = 0, .delay = 0, }, }; static struct msm_camera_i2c_reg_conf mt9m114_720p_settings[] = { {0xdc00, 0x50, MSM_CAMERA_I2C_BYTE_DATA, MSM_CAMERA_I2C_CMD_WRITE}, {MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_SET_STATE, MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL}, {MT9M114_COMMAND_REGISTER, (MT9M114_COMMAND_REGISTER_OK | MT9M114_COMMAND_REGISTER_SET_STATE), MSM_CAMERA_I2C_WORD_DATA, MSM_CAMERA_I2C_CMD_WRITE}, {MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_SET_STATE, MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL}, {0xDC01, 0x52, MSM_CAMERA_I2C_BYTE_DATA, MSM_CAMERA_I2C_CMD_POLL}, {0x098E, 0, MSM_CAMERA_I2C_BYTE_DATA}, {0xC800, 0x007C,},/*y_addr_start = 124*/ {0xC802, 0x0004,},/*x_addr_start = 4*/ {0xC804, 0x0353,},/*y_addr_end = 851*/ {0xC806, 0x050B,},/*x_addr_end = 1291*/ {0xC808, 0x02DC,},/*pixclk = 48000000*/ {0xC80A, 0x6C00,},/*pixclk = 48000000*/ {0xC80C, 0x0001,},/*row_speed = 1*/ {0xC80E, 0x00DB,},/*fine_integ_time_min = 219*/ {0xC810, 0x05BD,},/*fine_integ_time_max = 1469*/ {0xC812, 0x03E8,},/*frame_length_lines = 1000*/ {0xC814, 0x0640,},/*line_length_pck = 1600*/ {0xC816, 0x0060,},/*fine_correction = 96*/ {0xC818, 0x02D3,},/*cpipe_last_row = 723*/ {0xC826, 0x0020,},/*reg_0_data = 32*/ {0xC834, 0x0000,},/*sensor_control_read_mode = 0*/ {0xC854, 0x0000,},/*crop_window_xoffset = 0*/ {0xC856, 0x0000,},/*crop_window_yoffset = 0*/ {0xC858, 0x0500,},/*crop_window_width = 1280*/ {0xC85A, 0x02D0,},/*crop_window_height = 720*/ {0xC85C, 0x03, MSM_CAMERA_I2C_BYTE_DATA}, /*crop_cropmode = 3*/ {0xC868, 0x0500,},/*output_width = 1280*/ {0xC86A, 0x02D0,},/*output_height = 720*/ {0xC878, 0x00, MSM_CAMERA_I2C_BYTE_DATA}, /*aet_aemode = 0*/ {0xC88C, 0x1E00,},/*aet_max_frame_rate = 7680*/ {0xC88E, 0x1E00,},/*aet_min_frame_rate = 7680*/ {0xC914, 0x0000,},/*stat_awb_window_xstart = 0*/ {0xC916, 0x0000,},/*stat_awb_window_ystart = 0*/ {0xC918, 0x04FF,},/*stat_awb_window_xend = 1279*/ {0xC91A, 0x02CF,},/*stat_awb_window_yend = 719*/ {0xC91C, 0x0000,},/*stat_ae_window_xstart = 0*/ {0xC91E, 0x0000,},/*stat_ae_window_ystart = 0*/ {0xC920, 0x00FF,},/*stat_ae_window_xend = 255*/ {0xC922, 0x008F,},/*stat_ae_window_yend = 143*/ }; static struct msm_camera_i2c_reg_conf mt9m114_recommend_settings[] = { {0x301A, 0x0200, MSM_CAMERA_I2C_SET_WORD_MASK}, {0x098E, 0, MSM_CAMERA_I2C_BYTE_DATA}, /*cam_sysctl_pll_enable = 1*/ {0xC97E, 0x01, MSM_CAMERA_I2C_BYTE_DATA}, /*cam_sysctl_pll_divider_m_n = 288*/ {0xC980, 0x0120,}, /*cam_sysctl_pll_divider_p = 1792*/ {0xC982, 0x0700,}, /*output_control = 32769*/ {0xC984, 0x8001,}, /*mipi_timing_t_hs_zero = 3840*/ {0xC988, 0x0F00,}, /*mipi_timing_t_hs_exit_hs_trail = 2823*/ {0xC98A, 0x0B07,}, /*mipi_timing_t_clk_post_clk_pre = 3329*/ {0xC98C, 0x0D01,}, /*mipi_timing_t_clk_trail_clk_zero = 1821*/ {0xC98E, 0x071D,}, /*mipi_timing_t_lpx = 6*/ {0xC990, 0x0006,}, /*mipi_timing_init_timing = 2572*/ {0xC992, 0x0A0C,}, {0xC800, 0x007C,},/*y_addr_start = 124*/ {0xC802, 0x0004,},/*x_addr_start = 4*/ {0xC804, 0x0353,},/*y_addr_end = 851*/ {0xC806, 0x050B,},/*x_addr_end = 1291*/ {0xC808, 0x02DC,},/*pixclk = 48000000*/ {0xC80A, 0x6C00,},/*pixclk = 48000000*/ {0xC80C, 0x0001,},/*row_speed = 1*/ {0xC80E, 0x00DB,},/*fine_integ_time_min = 219*/ {0xC810, 0x05BD,},/*fine_integ_time_max = 1469*/ {0xC812, 0x03E8,},/*frame_length_lines = 1000*/ {0xC814, 0x0640,},/*line_length_pck = 1600*/ {0xC816, 0x0060,},/*fine_correction = 96*/ {0xC818, 0x02D3,},/*cpipe_last_row = 723*/ {0xC826, 0x0020,},/*reg_0_data = 32*/ {0xC834, 0x0000,},/*sensor_control_read_mode = 0*/ {0xC854, 0x0000,},/*crop_window_xoffset = 0*/ {0xC856, 0x0000,},/*crop_window_yoffset = 0*/ {0xC858, 0x0500,},/*crop_window_width = 1280*/ {0xC85A, 0x02D0,},/*crop_window_height = 720*/ {0xC85C, 0x03, MSM_CAMERA_I2C_BYTE_DATA}, /*crop_cropmode = 3*/ {0xC868, 0x0500,},/*output_width = 1280*/ {0xC86A, 0x02D0,},/*output_height = 720*/ {0xC878, 0x00, MSM_CAMERA_I2C_BYTE_DATA}, /*aet_aemode = 0*/ {0xC88C, 0x1E00,},/*aet_max_frame_rate = 7680*/ {0xC88E, 0x1E00,},/*aet_min_frame_rate = 7680*/ {0xC914, 0x0000,},/*stat_awb_window_xstart = 0*/ {0xC916, 0x0000,},/*stat_awb_window_ystart = 0*/ {0xC918, 0x04FF,},/*stat_awb_window_xend = 1279*/ {0xC91A, 0x02CF,},/*stat_awb_window_yend = 719*/ {0xC91C, 0x0000,},/*stat_ae_window_xstart = 0*/ {0xC91E, 0x0000,},/*stat_ae_window_ystart = 0*/ {0xC920, 0x00FF,},/*stat_ae_window_xend = 255*/ {0xC922, 0x008F,},/*stat_ae_window_yend = 143*/ /*Sensor optimization*/ {0x316A, 0x8270,}, {0x316C, 0x8270,}, {0x3ED0, 0x2305,}, {0x3ED2, 0x77CF,}, {0x316E, 0x8202,}, {0x3180, 0x87FF,}, {0x30D4, 0x6080,}, {0xA802, 0x0008,},/*AE_TRACK_MODE*/ {0x3E14, 0xFF39,}, {0x0982, 0x0001,},/*ACCESS_CTL_STAT*/ {0x098A, 0x5000,},/*PHYSICAL_ADDRESS_ACCESS*/ {0xD000, 0x70CF,}, {0xD002, 0xFFFF,}, {0xD004, 0xC5D4,}, {0xD006, 0x903A,}, {0xD008, 0x2144,}, {0xD00A, 0x0C00,}, {0xD00C, 0x2186,}, {0xD00E, 0x0FF3,}, {0xD010, 0xB844,}, {0xD012, 0xB948,}, {0xD014, 0xE082,}, {0xD016, 0x20CC,}, {0xD018, 0x80E2,}, {0xD01A, 0x21CC,}, {0xD01C, 0x80A2,}, {0xD01E, 0x21CC,}, {0xD020, 0x80E2,}, {0xD022, 0xF404,}, {0xD024, 0xD801,}, {0xD026, 0xF003,}, {0xD028, 0xD800,}, {0xD02A, 0x7EE0,}, {0xD02C, 0xC0F1,}, {0xD02E, 0x08BA,}, {0xD030, 0x0600,}, {0xD032, 0xC1A1,}, {0xD034, 0x76CF,}, {0xD036, 0xFFFF,}, {0xD038, 0xC130,}, {0xD03A, 0x6E04,}, {0xD03C, 0xC040,}, {0xD03E, 0x71CF,}, {0xD040, 0xFFFF,}, {0xD042, 0xC790,}, {0xD044, 0x8103,}, {0xD046, 0x77CF,}, {0xD048, 0xFFFF,}, {0xD04A, 0xC7C0,}, {0xD04C, 0xE001,}, {0xD04E, 0xA103,}, {0xD050, 0xD800,}, {0xD052, 0x0C6A,}, {0xD054, 0x04E0,}, {0xD056, 0xB89E,}, {0xD058, 0x7508,}, {0xD05A, 0x8E1C,}, {0xD05C, 0x0809,}, {0xD05E, 0x0191,}, {0xD060, 0xD801,}, {0xD062, 0xAE1D,}, {0xD064, 0xE580,}, {0xD066, 0x20CA,}, {0xD068, 0x0022,}, {0xD06A, 0x20CF,}, {0xD06C, 0x0522,}, {0xD06E, 0x0C5C,}, {0xD070, 0x04E2,}, {0xD072, 0x21CA,}, {0xD074, 0x0062,}, {0xD076, 0xE580,}, {0xD078, 0xD901,}, {0xD07A, 0x79C0,}, {0xD07C, 0xD800,}, {0xD07E, 0x0BE6,}, {0xD080, 0x04E0,}, {0xD082, 0xB89E,}, {0xD084, 0x70CF,}, {0xD086, 0xFFFF,}, {0xD088, 0xC8D4,}, {0xD08A, 0x9002,}, {0xD08C, 0x0857,}, {0xD08E, 0x025E,}, {0xD090, 0xFFDC,}, {0xD092, 0xE080,}, {0xD094, 0x25CC,}, {0xD096, 0x9022,}, {0xD098, 0xF225,}, {0xD09A, 0x1700,}, {0xD09C, 0x108A,}, {0xD09E, 0x73CF,}, {0xD0A0, 0xFF00,}, {0xD0A2, 0x3174,}, {0xD0A4, 0x9307,}, {0xD0A6, 0x2A04,}, {0xD0A8, 0x103E,}, {0xD0AA, 0x9328,}, {0xD0AC, 0x2942,}, {0xD0AE, 0x7140,}, {0xD0B0, 0x2A04,}, {0xD0B2, 0x107E,}, {0xD0B4, 0x9349,}, {0xD0B6, 0x2942,}, {0xD0B8, 0x7141,}, {0xD0BA, 0x2A04,}, {0xD0BC, 0x10BE,}, {0xD0BE, 0x934A,}, {0xD0C0, 0x2942,}, {0xD0C2, 0x714B,}, {0xD0C4, 0x2A04,}, {0xD0C6, 0x10BE,}, {0xD0C8, 0x130C,}, {0xD0CA, 0x010A,}, {0xD0CC, 0x2942,}, {0xD0CE, 0x7142,}, {0xD0D0, 0x2250,}, {0xD0D2, 0x13CA,}, {0xD0D4, 0x1B0C,}, {0xD0D6, 0x0284,}, {0xD0D8, 0xB307,}, {0xD0DA, 0xB328,}, {0xD0DC, 0x1B12,}, {0xD0DE, 0x02C4,}, {0xD0E0, 0xB34A,}, {0xD0E2, 0xED88,}, {0xD0E4, 0x71CF,}, {0xD0E6, 0xFF00,}, {0xD0E8, 0x3174,}, {0xD0EA, 0x9106,}, {0xD0EC, 0xB88F,}, {0xD0EE, 0xB106,}, {0xD0F0, 0x210A,}, {0xD0F2, 0x8340,}, {0xD0F4, 0xC000,}, {0xD0F6, 0x21CA,}, {0xD0F8, 0x0062,}, {0xD0FA, 0x20F0,}, {0xD0FC, 0x0040,}, {0xD0FE, 0x0B02,}, {0xD100, 0x0320,}, {0xD102, 0xD901,}, {0xD104, 0x07F1,}, {0xD106, 0x05E0,}, {0xD108, 0xC0A1,}, {0xD10A, 0x78E0,}, {0xD10C, 0xC0F1,}, {0xD10E, 0x71CF,}, {0xD110, 0xFFFF,}, {0xD112, 0xC7C0,}, {0xD114, 0xD840,}, {0xD116, 0xA900,}, {0xD118, 0x71CF,}, {0xD11A, 0xFFFF,}, {0xD11C, 0xD02C,}, {0xD11E, 0xD81E,}, {0xD120, 0x0A5A,}, {0xD122, 0x04E0,}, {0xD124, 0xDA00,}, {0xD126, 0xD800,}, {0xD128, 0xC0D1,}, {0xD12A, 0x7EE0,}, {0x098E, 0x0000,}, {0x0982, 0x0001,}, {0x098A, 0x5C10,}, {0xDC10, 0xC0F1,}, {0xDC12, 0x0CDA,}, {0xDC14, 0x0580,}, {0xDC16, 0x76CF,}, {0xDC18, 0xFF00,}, {0xDC1A, 0x2184,}, {0xDC1C, 0x9624,}, {0xDC1E, 0x218C,}, {0xDC20, 0x8FC3,}, {0xDC22, 0x75CF,}, {0xDC24, 0xFFFF,}, {0xDC26, 0xE058,}, {0xDC28, 0xF686,}, {0xDC2A, 0x1550,}, {0xDC2C, 0x1080,}, {0xDC2E, 0xE001,}, {0xDC30, 0x1D50,}, {0xDC32, 0x1002,}, {0xDC34, 0x1552,}, {0xDC36, 0x1100,}, {0xDC38, 0x6038,}, {0xDC3A, 0x1D52,}, {0xDC3C, 0x1004,}, {0xDC3E, 0x1540,}, {0xDC40, 0x1080,}, {0xDC42, 0x081B,}, {0xDC44, 0x00D1,}, {0xDC46, 0x8512,}, {0xDC48, 0x1000,}, {0xDC4A, 0x00C0,}, {0xDC4C, 0x7822,}, {0xDC4E, 0x2089,}, {0xDC50, 0x0FC1,}, {0xDC52, 0x2008,}, {0xDC54, 0x0F81,}, {0xDC56, 0xFFFF,}, {0xDC58, 0xFF80,}, {0xDC5A, 0x8512,}, {0xDC5C, 0x1801,}, {0xDC5E, 0x0052,}, {0xDC60, 0xA512,}, {0xDC62, 0x1544,}, {0xDC64, 0x1080,}, {0xDC66, 0xB861,}, {0xDC68, 0x262F,}, {0xDC6A, 0xF007,}, {0xDC6C, 0x1D44,}, {0xDC6E, 0x1002,}, {0xDC70, 0x20CA,}, {0xDC72, 0x0021,}, {0xDC74, 0x20CF,}, {0xDC76, 0x04E1,}, {0xDC78, 0x0850,}, {0xDC7A, 0x04A1,}, {0xDC7C, 0x21CA,}, {0xDC7E, 0x0021,}, {0xDC80, 0x1542,}, {0xDC82, 0x1140,}, {0xDC84, 0x8D2C,}, {0xDC86, 0x6038,}, {0xDC88, 0x1D42,}, {0xDC8A, 0x1004,}, {0xDC8C, 0x1542,}, {0xDC8E, 0x1140,}, {0xDC90, 0xB601,}, {0xDC92, 0x046D,}, {0xDC94, 0x0580,}, {0xDC96, 0x78E0,}, {0xDC98, 0xD800,}, {0xDC9A, 0xB893,}, {0xDC9C, 0x002D,}, {0xDC9E, 0x04A0,}, {0xDCA0, 0xD900,}, {0xDCA2, 0x78E0,}, {0xDCA4, 0x72CF,}, {0xDCA6, 0xFFFF,}, {0xDCA8, 0xE058,}, {0xDCAA, 0x2240,}, {0xDCAC, 0x0340,}, {0xDCAE, 0xA212,}, {0xDCB0, 0x208A,}, {0xDCB2, 0x0FFF,}, {0xDCB4, 0x1A42,}, {0xDCB6, 0x0004,}, {0xDCB8, 0xD830,}, {0xDCBA, 0x1A44,}, {0xDCBC, 0x0002,}, {0xDCBE, 0xD800,}, {0xDCC0, 0x1A50,}, {0xDCC2, 0x0002,}, {0xDCC4, 0x1A52,}, {0xDCC6, 0x0004,}, {0xDCC8, 0x1242,}, {0xDCCA, 0x0140,}, {0xDCCC, 0x8A2C,}, {0xDCCE, 0x6038,}, {0xDCD0, 0x1A42,}, {0xDCD2, 0x0004,}, {0xDCD4, 0x1242,}, {0xDCD6, 0x0141,}, {0xDCD8, 0x70CF,}, {0xDCDA, 0xFF00,}, {0xDCDC, 0x2184,}, {0xDCDE, 0xB021,}, {0xDCE0, 0xD800,}, {0xDCE2, 0xB893,}, {0xDCE4, 0x07E5,}, {0xDCE6, 0x0460,}, {0xDCE8, 0xD901,}, {0xDCEA, 0x78E0,}, {0xDCEC, 0xC0F1,}, {0xDCEE, 0x0BFA,}, {0xDCF0, 0x05A0,}, {0xDCF2, 0x216F,}, {0xDCF4, 0x0043,}, {0xDCF6, 0xC1A4,}, {0xDCF8, 0x220A,}, {0xDCFA, 0x1F80,}, {0xDCFC, 0xFFFF,}, {0xDCFE, 0xE058,}, {0xDD00, 0x2240,}, {0xDD02, 0x134F,}, {0xDD04, 0x1A48,}, {0xDD06, 0x13C0,}, {0xDD08, 0x1248,}, {0xDD0A, 0x1002,}, {0xDD0C, 0x70CF,}, {0xDD0E, 0x7FFF,}, {0xDD10, 0xFFFF,}, {0xDD12, 0xE230,}, {0xDD14, 0xC240,}, {0xDD16, 0xDA00,}, {0xDD18, 0xF00C,}, {0xDD1A, 0x1248,}, {0xDD1C, 0x1003,}, {0xDD1E, 0x1301,}, {0xDD20, 0x04CB,}, {0xDD22, 0x7261,}, {0xDD24, 0x2108,}, {0xDD26, 0x0081,}, {0xDD28, 0x2009,}, {0xDD2A, 0x0080,}, {0xDD2C, 0x1A48,}, {0xDD2E, 0x10C0,}, {0xDD30, 0x1248,}, {0xDD32, 0x100B,}, {0xDD34, 0xC300,}, {0xDD36, 0x0BE7,}, {0xDD38, 0x90C4,}, {0xDD3A, 0x2102,}, {0xDD3C, 0x0003,}, {0xDD3E, 0x238C,}, {0xDD40, 0x8FC3,}, {0xDD42, 0xF6C7,}, {0xDD44, 0xDAFF,}, {0xDD46, 0x1A05,}, {0xDD48, 0x1082,}, {0xDD4A, 0xC241,}, {0xDD4C, 0xF005,}, {0xDD4E, 0x7A6F,}, {0xDD50, 0xC241,}, {0xDD52, 0x1A05,}, {0xDD54, 0x10C2,}, {0xDD56, 0x2000,}, {0xDD58, 0x8040,}, {0xDD5A, 0xDA00,}, {0xDD5C, 0x20C0,}, {0xDD5E, 0x0064,}, {0xDD60, 0x781C,}, {0xDD62, 0xC042,}, {0xDD64, 0x1C0E,}, {0xDD66, 0x3082,}, {0xDD68, 0x1A48,}, {0xDD6A, 0x13C0,}, {0xDD6C, 0x7548,}, {0xDD6E, 0x7348,}, {0xDD70, 0x7148,}, {0xDD72, 0x7648,}, {0xDD74, 0xF002,}, {0xDD76, 0x7608,}, {0xDD78, 0x1248,}, {0xDD7A, 0x1000,}, {0xDD7C, 0x1400,}, {0xDD7E, 0x300B,}, {0xDD80, 0x084D,}, {0xDD82, 0x02C5,}, {0xDD84, 0x1248,}, {0xDD86, 0x1000,}, {0xDD88, 0xE101,}, {0xDD8A, 0x1001,}, {0xDD8C, 0x04CB,}, {0xDD8E, 0x1A48,}, {0xDD90, 0x1000,}, {0xDD92, 0x7361,}, {0xDD94, 0x1408,}, {0xDD96, 0x300B,}, {0xDD98, 0x2302,}, {0xDD9A, 0x02C0,}, {0xDD9C, 0x780D,}, {0xDD9E, 0x2607,}, {0xDDA0, 0x903E,}, {0xDDA2, 0x07D6,}, {0xDDA4, 0xFFE3,}, {0xDDA6, 0x792F,}, {0xDDA8, 0x09CF,}, {0xDDAA, 0x8152,}, {0xDDAC, 0x1248,}, {0xDDAE, 0x100E,}, {0xDDB0, 0x2400,}, {0xDDB2, 0x334B,}, {0xDDB4, 0xE501,}, {0xDDB6, 0x7EE2,}, {0xDDB8, 0x0DBF,}, {0xDDBA, 0x90F2,}, {0xDDBC, 0x1B0C,}, {0xDDBE, 0x1382,}, {0xDDC0, 0xC123,}, {0xDDC2, 0x140E,}, {0xDDC4, 0x3080,}, {0xDDC6, 0x7822,}, {0xDDC8, 0x1A07,}, {0xDDCA, 0x1002,}, {0xDDCC, 0x124C,}, {0xDDCE, 0x1000,}, {0xDDD0, 0x120B,}, {0xDDD2, 0x1081,}, {0xDDD4, 0x1207,}, {0xDDD6, 0x1083,}, {0xDDD8, 0x2142,}, {0xDDDA, 0x004B,}, {0xDDDC, 0x781B,}, {0xDDDE, 0x0B21,}, {0xDDE0, 0x02E2,}, {0xDDE2, 0x1A4C,}, {0xDDE4, 0x1000,}, {0xDDE6, 0xE101,}, {0xDDE8, 0x0915,}, {0xDDEA, 0x00C2,}, {0xDDEC, 0xC101,}, {0xDDEE, 0x1204,}, {0xDDF0, 0x1083,}, {0xDDF2, 0x090D,}, {0xDDF4, 0x00C2,}, {0xDDF6, 0xE001,}, {0xDDF8, 0x1A4C,}, {0xDDFA, 0x1000,}, {0xDDFC, 0x1A06,}, {0xDDFE, 0x1002,}, {0xDE00, 0x234A,}, {0xDE02, 0x1000,}, {0xDE04, 0x7169,}, {0xDE06, 0xF008,}, {0xDE08, 0x2053,}, {0xDE0A, 0x0003,}, {0xDE0C, 0x6179,}, {0xDE0E, 0x781C,}, {0xDE10, 0x2340,}, {0xDE12, 0x104B,}, {0xDE14, 0x1203,}, {0xDE16, 0x1083,}, {0xDE18, 0x0BF1,}, {0xDE1A, 0x90C2,}, {0xDE1C, 0x1202,}, {0xDE1E, 0x1080,}, {0xDE20, 0x091D,}, {0xDE22, 0x0004,}, {0xDE24, 0x70CF,}, {0xDE26, 0xFFFF,}, {0xDE28, 0xC644,}, {0xDE2A, 0x881B,}, {0xDE2C, 0xE0B2,}, {0xDE2E, 0xD83C,}, {0xDE30, 0x20CA,}, {0xDE32, 0x0CA2,}, {0xDE34, 0x1A01,}, {0xDE36, 0x1002,}, {0xDE38, 0x1A4C,}, {0xDE3A, 0x1080,}, {0xDE3C, 0x02B9,}, {0xDE3E, 0x05A0,}, {0xDE40, 0xC0A4,}, {0xDE42, 0x78E0,}, {0xDE44, 0xC0F1,}, {0xDE46, 0xFF95,}, {0xDE48, 0xD800,}, {0xDE4A, 0x71CF,}, {0xDE4C, 0xFF00,}, {0xDE4E, 0x1FE0,}, {0xDE50, 0x19D0,}, {0xDE52, 0x001C,}, {0xDE54, 0x19D1,}, {0xDE56, 0x001C,}, {0xDE58, 0x70CF,}, {0xDE5A, 0xFFFF,}, {0xDE5C, 0xE058,}, {0xDE5E, 0x901F,}, {0xDE60, 0xB861,}, {0xDE62, 0x19D2,}, {0xDE64, 0x001C,}, {0xDE66, 0xC0D1,}, {0xDE68, 0x7EE0,}, {0xDE6A, 0x78E0,}, {0xDE6C, 0xC0F1,}, {0xDE6E, 0x0A7A,}, {0xDE70, 0x0580,}, {0xDE72, 0x70CF,}, {0xDE74, 0xFFFF,}, {0xDE76, 0xC5D4,}, {0xDE78, 0x9041,}, {0xDE7A, 0x9023,}, {0xDE7C, 0x75CF,}, {0xDE7E, 0xFFFF,}, {0xDE80, 0xE058,}, {0xDE82, 0x7942,}, {0xDE84, 0xB967,}, {0xDE86, 0x7F30,}, {0xDE88, 0xB53F,}, {0xDE8A, 0x71CF,}, {0xDE8C, 0xFFFF,}, {0xDE8E, 0xC84C,}, {0xDE90, 0x91D3,}, {0xDE92, 0x108B,}, {0xDE94, 0x0081,}, {0xDE96, 0x2615,}, {0xDE98, 0x1380,}, {0xDE9A, 0x090F,}, {0xDE9C, 0x0C91,}, {0xDE9E, 0x0A8E,}, {0xDEA0, 0x05A0,}, {0xDEA2, 0xD906,}, {0xDEA4, 0x7E10,}, {0xDEA6, 0x2615,}, {0xDEA8, 0x1380,}, {0xDEAA, 0x0A82,}, {0xDEAC, 0x05A0,}, {0xDEAE, 0xD960,}, {0xDEB0, 0x790F,}, {0xDEB2, 0x090D,}, {0xDEB4, 0x0133,}, {0xDEB6, 0xAD0C,}, {0xDEB8, 0xD904,}, {0xDEBA, 0xAD2C,}, {0xDEBC, 0x79EC,}, {0xDEBE, 0x2941,}, {0xDEC0, 0x7402,}, {0xDEC2, 0x71CF,}, {0xDEC4, 0xFF00,}, {0xDEC6, 0x2184,}, {0xDEC8, 0xB142,}, {0xDECA, 0x1906,}, {0xDECC, 0x0E44,}, {0xDECE, 0xFFDE,}, {0xDED0, 0x70C9,}, {0xDED2, 0x0A5A,}, {0xDED4, 0x05A0,}, {0xDED6, 0x8D2C,}, {0xDED8, 0xAD0B,}, {0xDEDA, 0xD800,}, {0xDEDC, 0xAD01,}, {0xDEDE, 0x0219,}, {0xDEE0, 0x05A0,}, {0xDEE2, 0xA513,}, {0xDEE4, 0xC0F1,}, {0xDEE6, 0x71CF,}, {0xDEE8, 0xFFFF,}, {0xDEEA, 0xC644,}, {0xDEEC, 0xA91B,}, {0xDEEE, 0xD902,}, {0xDEF0, 0x70CF,}, {0xDEF2, 0xFFFF,}, {0xDEF4, 0xC84C,}, {0xDEF6, 0x093E,}, {0xDEF8, 0x03A0,}, {0xDEFA, 0xA826,}, {0xDEFC, 0xFFDC,}, {0xDEFE, 0xF1B5,}, {0xDF00, 0xC0F1,}, {0xDF02, 0x09EA,}, {0xDF04, 0x0580,}, {0xDF06, 0x75CF,}, {0xDF08, 0xFFFF,}, {0xDF0A, 0xE058,}, {0xDF0C, 0x1540,}, {0xDF0E, 0x1080,}, {0xDF10, 0x08A7,}, {0xDF12, 0x0010,}, {0xDF14, 0x8D00,}, {0xDF16, 0x0813,}, {0xDF18, 0x009E,}, {0xDF1A, 0x1540,}, {0xDF1C, 0x1081,}, {0xDF1E, 0xE181,}, {0xDF20, 0x20CA,}, {0xDF22, 0x00A1,}, {0xDF24, 0xF24B,}, {0xDF26, 0x1540,}, {0xDF28, 0x1081,}, {0xDF2A, 0x090F,}, {0xDF2C, 0x0050,}, {0xDF2E, 0x1540,}, {0xDF30, 0x1081,}, {0xDF32, 0x0927,}, {0xDF34, 0x0091,}, {0xDF36, 0x1550,}, {0xDF38, 0x1081,}, {0xDF3A, 0xDE00,}, {0xDF3C, 0xAD2A,}, {0xDF3E, 0x1D50,}, {0xDF40, 0x1382,}, {0xDF42, 0x1552,}, {0xDF44, 0x1101,}, {0xDF46, 0x1D52,}, {0xDF48, 0x1384,}, {0xDF4A, 0xB524,}, {0xDF4C, 0x082D,}, {0xDF4E, 0x015F,}, {0xDF50, 0xFF55,}, {0xDF52, 0xD803,}, {0xDF54, 0xF033,}, {0xDF56, 0x1540,}, {0xDF58, 0x1081,}, {0xDF5A, 0x0967,}, {0xDF5C, 0x00D1,}, {0xDF5E, 0x1550,}, {0xDF60, 0x1081,}, {0xDF62, 0xDE00,}, {0xDF64, 0xAD2A,}, {0xDF66, 0x1D50,}, {0xDF68, 0x1382,}, {0xDF6A, 0x1552,}, {0xDF6C, 0x1101,}, {0xDF6E, 0x1D52,}, {0xDF70, 0x1384,}, {0xDF72, 0xB524,}, {0xDF74, 0x0811,}, {0xDF76, 0x019E,}, {0xDF78, 0xB8A0,}, {0xDF7A, 0xAD00,}, {0xDF7C, 0xFF47,}, {0xDF7E, 0x1D40,}, {0xDF80, 0x1382,}, {0xDF82, 0xF01F,}, {0xDF84, 0xFF5A,}, {0xDF86, 0x8D01,}, {0xDF88, 0x8D40,}, {0xDF8A, 0xE812,}, {0xDF8C, 0x71CF,}, {0xDF8E, 0xFFFF,}, {0xDF90, 0xC644,}, {0xDF92, 0x893B,}, {0xDF94, 0x7030,}, {0xDF96, 0x22D1,}, {0xDF98, 0x8062,}, {0xDF9A, 0xF20A,}, {0xDF9C, 0x0A0F,}, {0xDF9E, 0x009E,}, {0xDFA0, 0x71CF,}, {0xDFA2, 0xFFFF,}, {0xDFA4, 0xC84C,}, {0xDFA6, 0x893B,}, {0xDFA8, 0xE902,}, {0xDFAA, 0xFFCF,}, {0xDFAC, 0x8D00,}, {0xDFAE, 0xB8E7,}, {0xDFB0, 0x26CA,}, {0xDFB2, 0x1022,}, {0xDFB4, 0xF5E2,}, {0xDFB6, 0xFF3C,}, {0xDFB8, 0xD801,}, {0xDFBA, 0x1D40,}, {0xDFBC, 0x1002,}, {0xDFBE, 0x0141,}, {0xDFC0, 0x0580,}, {0xDFC2, 0x78E0,}, {0xDFC4, 0xC0F1,}, {0xDFC6, 0xC5E1,}, {0xDFC8, 0xFF34,}, {0xDFCA, 0xDD00,}, {0xDFCC, 0x70CF,}, {0xDFCE, 0xFFFF,}, {0xDFD0, 0xE090,}, {0xDFD2, 0xA8A8,}, {0xDFD4, 0xD800,}, {0xDFD6, 0xB893,}, {0xDFD8, 0x0C8A,}, {0xDFDA, 0x0460,}, {0xDFDC, 0xD901,}, {0xDFDE, 0x71CF,}, {0xDFE0, 0xFFFF,}, {0xDFE2, 0xDC10,}, {0xDFE4, 0xD813,}, {0xDFE6, 0x0B96,}, {0xDFE8, 0x0460,}, {0xDFEA, 0x72A9,}, {0xDFEC, 0x0119,}, {0xDFEE, 0x0580,}, {0xDFF0, 0xC0F1,}, {0xDFF2, 0x71CF,}, {0xDFF4, 0x0000,}, {0xDFF6, 0x5BAE,}, {0xDFF8, 0x7940,}, {0xDFFA, 0xFF9D,}, {0xDFFC, 0xF135,}, {0xDFFE, 0x78E0,}, {0xE000, 0xC0F1,}, {0xE002, 0x70CF,}, {0xE004, 0x0000,}, {0xE006, 0x5CBA,}, {0xE008, 0x7840,}, {0xE00A, 0x70CF,}, {0xE00C, 0xFFFF,}, {0xE00E, 0xE058,}, {0xE010, 0x8800,}, {0xE012, 0x0815,}, {0xE014, 0x001E,}, {0xE016, 0x70CF,}, {0xE018, 0xFFFF,}, {0xE01A, 0xC84C,}, {0xE01C, 0x881A,}, {0xE01E, 0xE080,}, {0xE020, 0x0EE0,}, {0xE022, 0xFFC1,}, {0xE024, 0xF121,}, {0xE026, 0x78E0,}, {0xE028, 0xC0F1,}, {0xE02A, 0xD900,}, {0xE02C, 0xF009,}, {0xE02E, 0x70CF,}, {0xE030, 0xFFFF,}, {0xE032, 0xE0AC,}, {0xE034, 0x7835,}, {0xE036, 0x8041,}, {0xE038, 0x8000,}, {0xE03A, 0xE102,}, {0xE03C, 0xA040,}, {0xE03E, 0x09F3,}, {0xE040, 0x8114,}, {0xE042, 0x71CF,}, {0xE044, 0xFFFF,}, {0xE046, 0xE058,}, {0xE048, 0x70CF,}, {0xE04A, 0xFFFF,}, {0xE04C, 0xC594,}, {0xE04E, 0xB030,}, {0xE050, 0xFFDD,}, {0xE052, 0xD800,}, {0xE054, 0xF109,}, {0xE056, 0x0000,}, {0xE058, 0x0300,}, {0xE05A, 0x0204,}, {0xE05C, 0x0700,}, {0xE05E, 0x0000,}, {0xE060, 0x0000,}, {0xE062, 0x0000,}, {0xE064, 0x0000,}, {0xE066, 0x0000,}, {0xE068, 0x0000,}, {0xE06A, 0x0000,}, {0xE06C, 0x0000,}, {0xE06E, 0x0000,}, {0xE070, 0x0000,}, {0xE072, 0x0000,}, {0xE074, 0x0000,}, {0xE076, 0x0000,}, {0xE078, 0x0000,}, {0xE07A, 0x0000,}, {0xE07C, 0x0000,}, {0xE07E, 0x0000,}, {0xE080, 0x0000,}, {0xE082, 0x0000,}, {0xE084, 0x0000,}, {0xE086, 0x0000,}, {0xE088, 0x0000,}, {0xE08A, 0x0000,}, {0xE08C, 0x0000,}, {0xE08E, 0x0000,}, {0xE090, 0x0000,}, {0xE092, 0x0000,}, {0xE094, 0x0000,}, {0xE096, 0x0000,}, {0xE098, 0x0000,}, {0xE09A, 0x0000,}, {0xE09C, 0x0000,}, {0xE09E, 0x0000,}, {0xE0A0, 0x0000,}, {0xE0A2, 0x0000,}, {0xE0A4, 0x0000,}, {0xE0A6, 0x0000,}, {0xE0A8, 0x0000,}, {0xE0AA, 0x0000,}, {0xE0AC, 0xFFFF,}, {0xE0AE, 0xCB68,}, {0xE0B0, 0xFFFF,}, {0xE0B2, 0xDFF0,}, {0xE0B4, 0xFFFF,}, {0xE0B6, 0xCB6C,}, {0xE0B8, 0xFFFF,}, {0xE0BA, 0xE000,}, {0x098E, 0x0000,}, /*MIPI setting for SOC1040*/ {0x3C5A, 0x0009,}, {0x3C44, 0x0080,},/*MIPI_CUSTOM_SHORT_PKT*/ /*[Tuning_settings]*/ /*[CCM]*/ {0xC892, 0x0267,},/*CAM_AWB_CCM_L_0*/ {0xC894, 0xFF1A,},/*CAM_AWB_CCM_L_1*/ {0xC896, 0xFFB3,},/*CAM_AWB_CCM_L_2*/ {0xC898, 0xFF80,},/*CAM_AWB_CCM_L_3*/ {0xC89A, 0x0166,},/*CAM_AWB_CCM_L_4*/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80, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_K_B_L*/ {0xC90F, 0x88, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_K_R_R*/ {0xC910, 0x80, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_K_G_R*/ {0xC911, 0x80, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_K_B_R*/ /*[Step7-CPIPE_Preference]*/ {0xC926, 0x0020,},/*CAM_LL_START_BRIGHTNESS*/ {0xC928, 0x009A,},/*CAM_LL_STOP_BRIGHTNESS*/ {0xC946, 0x0070,},/*CAM_LL_START_GAIN_METRIC*/ {0xC948, 0x00F3,},/*CAM_LL_STOP_GAIN_METRIC*/ {0xC952, 0x0020,},/*CAM_LL_START_TARGET_LUMA_BM*/ {0xC954, 0x009A,},/*CAM_LL_STOP_TARGET_LUMA_BM*/ {0xC92A, 0x80, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_SATURATION*/ {0xC92B, 0x4B, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_END_SATURATION*/ {0xC92C, 0x00, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_DESATURATION*/ {0xC92D, 0xFF, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_END_DESATURATION*/ {0xC92E, 0x3C, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_DEMOSAIC*/ {0xC92F, 0x02, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_AP_GAIN*/ {0xC930, 0x06, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_AP_THRESH*/ {0xC931, 0x64, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_DEMOSAIC*/ {0xC932, 0x01, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_AP_GAIN*/ {0xC933, 0x0C, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_AP_THRESH*/ {0xC934, 0x3C, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_NR_RED*/ {0xC935, 0x3C, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_NR_GREEN*/ {0xC936, 0x3C, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_NR_BLUE*/ {0xC937, 0x0F, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_NR_THRESH*/ {0xC938, 0x64, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_NR_RED*/ {0xC939, 0x64, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_NR_GREEN*/ {0xC93A, 0x64, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_NR_BLUE*/ {0xC93B, 0x32, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_NR_THRESH*/ {0xC93C, 0x0020,},/*CAM_LL_START_CONTRAST_BM*/ {0xC93E, 0x009A,},/*CAM_LL_STOP_CONTRAST_BM*/ {0xC940, 0x00DC,},/*CAM_LL_GAMMA*/ /*CAM_LL_START_CONTRAST_GRADIENT*/ {0xC942, 0x38, MSM_CAMERA_I2C_BYTE_DATA}, /*CAM_LL_STOP_CONTRAST_GRADIENT*/ {0xC943, 0x30, MSM_CAMERA_I2C_BYTE_DATA}, {0xC944, 0x50, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_CONTRAST_LUMA*/ {0xC945, 0x19, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_CONTRAST_LUMA*/ {0xC94A, 0x0230,},/*CAM_LL_START_FADE_TO_BLACK_LUMA*/ {0xC94C, 0x0010,},/*CAM_LL_STOP_FADE_TO_BLACK_LUMA*/ {0xC94E, 0x01CD,},/*CAM_LL_CLUSTER_DC_TH_BM*/ {0xC950, 0x05, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_CLUSTER_DC_GATE*/ {0xC951, 0x40, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_SUMMING_SENSITIVITY*/ /*CAM_AET_TARGET_AVERAGE_LUMA_DARK*/ {0xC87B, 0x1B, MSM_CAMERA_I2C_BYTE_DATA}, {0xC878, 0x0E, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AET_AEMODE*/ {0xC890, 0x0080,},/*CAM_AET_TARGET_GAIN*/ {0xC886, 0x0100,},/*CAM_AET_AE_MAX_VIRT_AGAIN*/ {0xC87C, 0x005A,},/*CAM_AET_BLACK_CLIPPING_TARGET*/ {0xB42A, 0x05, MSM_CAMERA_I2C_BYTE_DATA},/*CCM_DELTA_GAIN*/ /*AE_TRACK_AE_TRACKING_DAMPENING*/ {0xA80A, 0x20, MSM_CAMERA_I2C_BYTE_DATA}, {0x3C44, 0x0080,}, {0x3C40, 0x0004, MSM_CAMERA_I2C_UNSET_WORD_MASK}, {0xA802, 0x08, MSM_CAMERA_I2C_SET_BYTE_MASK}, {0xC908, 0x01, MSM_CAMERA_I2C_BYTE_DATA}, {0xC879, 0x01, MSM_CAMERA_I2C_BYTE_DATA}, {0xC909, 0x01, MSM_CAMERA_I2C_UNSET_BYTE_MASK}, {0xA80A, 0x18, MSM_CAMERA_I2C_BYTE_DATA}, {0xA80B, 0x18, MSM_CAMERA_I2C_BYTE_DATA}, {0xAC16, 0x18, MSM_CAMERA_I2C_BYTE_DATA}, {0xC878, 0x08, MSM_CAMERA_I2C_SET_BYTE_MASK}, {0xBC02, 0x08, MSM_CAMERA_I2C_UNSET_BYTE_MASK}, }; static struct v4l2_subdev_info mt9m114_subdev_info[] = { { .code = V4L2_MBUS_FMT_YUYV8_2X8, .colorspace = V4L2_COLORSPACE_JPEG, .fmt = 1, .order = 0, }, }; static struct msm_camera_i2c_reg_conf mt9m114_config_change_settings[] = { {0xdc00, 0x28, MSM_CAMERA_I2C_BYTE_DATA, MSM_CAMERA_I2C_CMD_WRITE}, {MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_SET_STATE, MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL}, {MT9M114_COMMAND_REGISTER, (MT9M114_COMMAND_REGISTER_OK | MT9M114_COMMAND_REGISTER_SET_STATE), MSM_CAMERA_I2C_WORD_DATA, MSM_CAMERA_I2C_CMD_WRITE}, {MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_SET_STATE, MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL}, {0xDC01, 0x31, MSM_CAMERA_I2C_BYTE_DATA}, }; static const struct i2c_device_id mt9m114_i2c_id[] = { {MT9M114_SENSOR_NAME, (kernel_ulong_t)&mt9m114_s_ctrl}, { } }; static int32_t msm_mt9m114_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { return msm_sensor_i2c_probe(client, id, &mt9m114_s_ctrl); } static struct i2c_driver mt9m114_i2c_driver = { .id_table = mt9m114_i2c_id, .probe = msm_mt9m114_i2c_probe, .driver = { .name = MT9M114_SENSOR_NAME, }, }; static struct msm_camera_i2c_client mt9m114_sensor_i2c_client = { .addr_type = MSM_CAMERA_I2C_WORD_ADDR, }; static const struct of_device_id mt9m114_dt_match[] = { {.compatible = "qcom,mt9m114", .data = &mt9m114_s_ctrl}, {} }; MODULE_DEVICE_TABLE(of, mt9m114_dt_match); static struct platform_driver mt9m114_platform_driver = { .driver = { .name = "qcom,mt9m114", .owner = THIS_MODULE, .of_match_table = mt9m114_dt_match, }, }; static int32_t mt9m114_platform_probe(struct platform_device *pdev) { int32_t rc; const struct of_device_id *match; match = of_match_device(mt9m114_dt_match, &pdev->dev); if (match) rc = msm_sensor_platform_probe(pdev, match->data); else { pr_err("%s:%d match is null\n", __func__, __LINE__); rc = -EINVAL; } return rc; } static int __init mt9m114_init_module(void) { int32_t rc; pr_info("%s:%d\n", __func__, __LINE__); rc = platform_driver_probe(&mt9m114_platform_driver, mt9m114_platform_probe); if (!rc) return rc; pr_err("%s:%d rc %d\n", __func__, __LINE__, rc); return i2c_add_driver(&mt9m114_i2c_driver); } static void __exit mt9m114_exit_module(void) { pr_info("%s:%d\n", __func__, __LINE__); if (mt9m114_s_ctrl.pdev) { msm_sensor_free_sensor_data(&mt9m114_s_ctrl); platform_driver_unregister(&mt9m114_platform_driver); } else i2c_del_driver(&mt9m114_i2c_driver); return; } int32_t mt9m114_sensor_config(struct msm_sensor_ctrl_t *s_ctrl, void __user *argp) { struct sensorb_cfg_data *cdata = (struct sensorb_cfg_data *)argp; int32_t rc = 0; int32_t i = 0; mutex_lock(s_ctrl->msm_sensor_mutex); CDBG("%s:%d %s cfgtype = %d\n", __func__, __LINE__, s_ctrl->sensordata->sensor_name, cdata->cfgtype); switch (cdata->cfgtype) { case CFG_GET_SENSOR_INFO: memcpy(cdata->cfg.sensor_info.sensor_name, s_ctrl->sensordata->sensor_name, sizeof(cdata->cfg.sensor_info.sensor_name)); cdata->cfg.sensor_info.session_id = s_ctrl->sensordata->sensor_info->session_id; for (i = 0; i < SUB_MODULE_MAX; i++) { cdata->cfg.sensor_info.subdev_id[i] = s_ctrl->sensordata->sensor_info->subdev_id[i]; cdata->cfg.sensor_info.subdev_intf[i] = s_ctrl->sensordata->sensor_info->subdev_intf[i]; } cdata->cfg.sensor_info.is_mount_angle_valid = s_ctrl->sensordata->sensor_info->is_mount_angle_valid; cdata->cfg.sensor_info.sensor_mount_angle = s_ctrl->sensordata->sensor_info->sensor_mount_angle; CDBG("%s:%d sensor name %s\n", __func__, __LINE__, cdata->cfg.sensor_info.sensor_name); CDBG("%s:%d session id %d\n", __func__, __LINE__, cdata->cfg.sensor_info.session_id); for (i = 0; i < SUB_MODULE_MAX; i++) CDBG("%s:%d subdev_id[%d] %d\n", __func__, __LINE__, i, cdata->cfg.sensor_info.subdev_id[i]); CDBG("%s:%d mount angle valid %d value %d\n", __func__, __LINE__, cdata->cfg.sensor_info.is_mount_angle_valid, cdata->cfg.sensor_info.sensor_mount_angle); break; case CFG_SET_INIT_SETTING: /* 1. Write Recommend settings */ /* 2. Write change settings */ rc = s_ctrl->sensor_i2c_client->i2c_func_tbl-> i2c_write_conf_tbl( s_ctrl->sensor_i2c_client, mt9m114_recommend_settings, ARRAY_SIZE(mt9m114_recommend_settings), MSM_CAMERA_I2C_WORD_DATA); rc = s_ctrl->sensor_i2c_client->i2c_func_tbl-> i2c_write_conf_tbl( s_ctrl->sensor_i2c_client, mt9m114_config_change_settings, ARRAY_SIZE(mt9m114_config_change_settings), MSM_CAMERA_I2C_WORD_DATA); break; case CFG_SET_RESOLUTION: rc = s_ctrl->sensor_i2c_client->i2c_func_tbl-> i2c_write_conf_tbl( s_ctrl->sensor_i2c_client, mt9m114_720p_settings, ARRAY_SIZE(mt9m114_720p_settings), MSM_CAMERA_I2C_WORD_DATA); break; case CFG_SET_STOP_STREAM: break; case CFG_SET_START_STREAM: rc = s_ctrl->sensor_i2c_client->i2c_func_tbl-> i2c_write_conf_tbl( s_ctrl->sensor_i2c_client, mt9m114_config_change_settings, ARRAY_SIZE(mt9m114_config_change_settings), MSM_CAMERA_I2C_WORD_DATA); break; case CFG_GET_SENSOR_INIT_PARAMS: cdata->cfg.sensor_init_params.modes_supported = s_ctrl->sensordata->sensor_info->modes_supported; cdata->cfg.sensor_init_params.position = s_ctrl->sensordata->sensor_info->position; cdata->cfg.sensor_init_params.sensor_mount_angle = s_ctrl->sensordata->sensor_info->sensor_mount_angle; CDBG("%s:%d init params mode %d pos %d mount %d\n", __func__, __LINE__, cdata->cfg.sensor_init_params.modes_supported, cdata->cfg.sensor_init_params.position, cdata->cfg.sensor_init_params.sensor_mount_angle); break; case CFG_WRITE_I2C_ARRAY: { struct msm_camera_i2c_reg_setting conf_array; struct msm_camera_i2c_reg_array *reg_setting = NULL; if (copy_from_user(&conf_array, (void *)cdata->cfg.setting, sizeof(struct msm_camera_i2c_reg_setting))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } reg_setting = kzalloc(conf_array.size * (sizeof(struct msm_camera_i2c_reg_array)), GFP_KERNEL); if (!reg_setting) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -ENOMEM; break; } if (copy_from_user(reg_setting, (void *)conf_array.reg_setting, conf_array.size * sizeof(struct msm_camera_i2c_reg_array))) { pr_err("%s:%d failed\n", __func__, __LINE__); kfree(reg_setting); rc = -EFAULT; break; } conf_array.reg_setting = reg_setting; rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write_table( s_ctrl->sensor_i2c_client, &conf_array); kfree(reg_setting); break; } case CFG_POWER_UP: if (s_ctrl->func_tbl->sensor_power_up) rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl); else rc = -EFAULT; break; case CFG_POWER_DOWN: if (s_ctrl->func_tbl->sensor_power_down) rc = s_ctrl->func_tbl->sensor_power_down(s_ctrl); else rc = -EFAULT; break; case CFG_SET_STOP_STREAM_SETTING: { struct msm_camera_i2c_reg_setting *stop_setting = &s_ctrl->stop_setting; struct msm_camera_i2c_reg_array *reg_setting = NULL; if (copy_from_user(stop_setting, (void *)cdata->cfg.setting, sizeof(struct msm_camera_i2c_reg_setting))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } reg_setting = stop_setting->reg_setting; stop_setting->reg_setting = kzalloc(stop_setting->size * (sizeof(struct msm_camera_i2c_reg_array)), GFP_KERNEL); if (!stop_setting->reg_setting) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -ENOMEM; break; } if (copy_from_user(stop_setting->reg_setting, (void *)reg_setting, stop_setting->size * sizeof(struct msm_camera_i2c_reg_array))) { pr_err("%s:%d failed\n", __func__, __LINE__); kfree(stop_setting->reg_setting); stop_setting->reg_setting = NULL; stop_setting->size = 0; rc = -EFAULT; break; } break; } case CFG_SET_SATURATION: { int32_t sat_lev; if (copy_from_user(&sat_lev, (void *)cdata->cfg.setting, sizeof(int32_t))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } pr_debug("%s: Saturation Value is %d", __func__, sat_lev); break; } case CFG_SET_CONTRAST: { int32_t con_lev; if (copy_from_user(&con_lev, (void *)cdata->cfg.setting, sizeof(int32_t))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } pr_debug("%s: Contrast Value is %d", __func__, con_lev); break; } case CFG_SET_SHARPNESS: { int32_t shp_lev; if (copy_from_user(&shp_lev, (void *)cdata->cfg.setting, sizeof(int32_t))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } pr_debug("%s: Sharpness Value is %d", __func__, shp_lev); break; } case CFG_SET_AUTOFOCUS: { /* TO-DO: set the Auto Focus */ pr_debug("%s: Setting Auto Focus", __func__); break; } case CFG_CANCEL_AUTOFOCUS: { /* TO-DO: Cancel the Auto Focus */ pr_debug("%s: Cancelling Auto Focus", __func__); break; } case CFG_SET_WHITE_BALANCE: break; case CFG_SET_EXPOSURE_COMPENSATION: break; case CFG_SET_EFFECT: break; case CFG_SET_ANTIBANDING: break; case CFG_SET_BESTSHOT_MODE: break; case CFG_SET_ISO: break; default: rc = -EFAULT; break; } mutex_unlock(s_ctrl->msm_sensor_mutex); return rc; } #ifdef CONFIG_COMPAT int32_t mt9m114_sensor_config32(struct msm_sensor_ctrl_t *s_ctrl, void __user *argp) { struct sensorb_cfg_data32 *cdata = (struct sensorb_cfg_data32 *)argp; int32_t rc = 0; int32_t i = 0; mutex_lock(s_ctrl->msm_sensor_mutex); CDBG("%s:%d %s cfgtype = %d\n", __func__, __LINE__, s_ctrl->sensordata->sensor_name, cdata->cfgtype); switch (cdata->cfgtype) { case CFG_GET_SENSOR_INFO: memcpy(cdata->cfg.sensor_info.sensor_name, s_ctrl->sensordata->sensor_name, sizeof(cdata->cfg.sensor_info.sensor_name)); cdata->cfg.sensor_info.session_id = s_ctrl->sensordata->sensor_info->session_id; for (i = 0; i < SUB_MODULE_MAX; i++) { cdata->cfg.sensor_info.subdev_id[i] = s_ctrl->sensordata->sensor_info->subdev_id[i]; cdata->cfg.sensor_info.subdev_intf[i] = s_ctrl->sensordata->sensor_info->subdev_intf[i]; } cdata->cfg.sensor_info.is_mount_angle_valid = s_ctrl->sensordata->sensor_info->is_mount_angle_valid; cdata->cfg.sensor_info.sensor_mount_angle = s_ctrl->sensordata->sensor_info->sensor_mount_angle; CDBG("%s:%d sensor name %s\n", __func__, __LINE__, cdata->cfg.sensor_info.sensor_name); CDBG("%s:%d session id %d\n", __func__, __LINE__, cdata->cfg.sensor_info.session_id); for (i = 0; i < SUB_MODULE_MAX; i++) CDBG("%s:%d subdev_id[%d] %d\n", __func__, __LINE__, i, cdata->cfg.sensor_info.subdev_id[i]); CDBG("%s:%d mount angle valid %d value %d\n", __func__, __LINE__, cdata->cfg.sensor_info.is_mount_angle_valid, cdata->cfg.sensor_info.sensor_mount_angle); break; case CFG_SET_INIT_SETTING: /* 1. Write Recommend settings */ /* 2. Write change settings */ rc = s_ctrl->sensor_i2c_client->i2c_func_tbl-> i2c_write_conf_tbl( s_ctrl->sensor_i2c_client, mt9m114_recommend_settings, ARRAY_SIZE(mt9m114_recommend_settings), MSM_CAMERA_I2C_WORD_DATA); rc = s_ctrl->sensor_i2c_client->i2c_func_tbl-> i2c_write_conf_tbl( s_ctrl->sensor_i2c_client, mt9m114_config_change_settings, ARRAY_SIZE(mt9m114_config_change_settings), MSM_CAMERA_I2C_WORD_DATA); break; case CFG_SET_RESOLUTION: rc = s_ctrl->sensor_i2c_client->i2c_func_tbl-> i2c_write_conf_tbl( s_ctrl->sensor_i2c_client, mt9m114_720p_settings, ARRAY_SIZE(mt9m114_720p_settings), MSM_CAMERA_I2C_WORD_DATA); break; case CFG_SET_STOP_STREAM: break; case CFG_SET_START_STREAM: rc = s_ctrl->sensor_i2c_client->i2c_func_tbl-> i2c_write_conf_tbl( s_ctrl->sensor_i2c_client, mt9m114_config_change_settings, ARRAY_SIZE(mt9m114_config_change_settings), MSM_CAMERA_I2C_WORD_DATA); break; case CFG_GET_SENSOR_INIT_PARAMS: cdata->cfg.sensor_init_params.modes_supported = s_ctrl->sensordata->sensor_info->modes_supported; cdata->cfg.sensor_init_params.position = s_ctrl->sensordata->sensor_info->position; cdata->cfg.sensor_init_params.sensor_mount_angle = s_ctrl->sensordata->sensor_info->sensor_mount_angle; CDBG("%s:%d init params mode %d pos %d mount %d\n", __func__, __LINE__, cdata->cfg.sensor_init_params.modes_supported, cdata->cfg.sensor_init_params.position, cdata->cfg.sensor_init_params.sensor_mount_angle); break; case CFG_WRITE_I2C_ARRAY: { struct msm_camera_i2c_reg_setting32 conf_array32; struct msm_camera_i2c_reg_setting conf_array; struct msm_camera_i2c_reg_array *reg_setting = NULL; if (copy_from_user(&conf_array32, (void *)compat_ptr(cdata->cfg.setting), sizeof(struct msm_camera_i2c_reg_setting32))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } conf_array.addr_type = conf_array32.addr_type; conf_array.data_type = conf_array32.data_type; conf_array.delay = conf_array32.delay; conf_array.size = conf_array32.size; conf_array.reg_setting = compat_ptr(conf_array32.reg_setting); reg_setting = kzalloc(conf_array.size * (sizeof(struct msm_camera_i2c_reg_array)), GFP_KERNEL); if (!reg_setting) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -ENOMEM; break; } if (copy_from_user(reg_setting, (void *)conf_array.reg_setting, conf_array.size * sizeof(struct msm_camera_i2c_reg_array))) { pr_err("%s:%d failed\n", __func__, __LINE__); kfree(reg_setting); rc = -EFAULT; break; } conf_array.reg_setting = reg_setting; rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write_table( s_ctrl->sensor_i2c_client, &conf_array); kfree(reg_setting); break; } case CFG_POWER_UP: if (s_ctrl->func_tbl->sensor_power_up) rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl); else rc = -EFAULT; break; case CFG_POWER_DOWN: if (s_ctrl->func_tbl->sensor_power_down) rc = s_ctrl->func_tbl->sensor_power_down(s_ctrl); else rc = -EFAULT; break; case CFG_SET_SATURATION: { int32_t sat_lev; if (copy_from_user(&sat_lev, (void *)compat_ptr(cdata->cfg.setting), sizeof(int32_t))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } pr_debug("%s: Saturation Value is %d", __func__, sat_lev); break; } case CFG_SET_CONTRAST: { int32_t con_lev; if (copy_from_user(&con_lev, (void *)compat_ptr(cdata->cfg.setting), sizeof(int32_t))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } pr_debug("%s: Contrast Value is %d", __func__, con_lev); break; } case CFG_SET_SHARPNESS: { int32_t shp_lev; if (copy_from_user(&shp_lev, (void *)compat_ptr(cdata->cfg.setting), sizeof(int32_t))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } pr_debug("%s: Sharpness Value is %d", __func__, shp_lev); break; } case CFG_SET_AUTOFOCUS: { /* TO-DO: set the Auto Focus */ pr_debug("%s: Setting Auto Focus", __func__); break; } case CFG_CANCEL_AUTOFOCUS: { /* TO-DO: Cancel the Auto Focus */ pr_debug("%s: Cancelling Auto Focus", __func__); break; } case CFG_SET_WHITE_BALANCE: break; case CFG_SET_EXPOSURE_COMPENSATION: break; case CFG_SET_EFFECT: break; case CFG_SET_ANTIBANDING: break; case CFG_SET_BESTSHOT_MODE: break; case CFG_SET_ISO: break; default: pr_err("Invalid cfgtype func %s line %d cfgtype = %d\n", __func__, __LINE__, (int32_t)cdata->cfgtype); rc = -EFAULT; break; } mutex_unlock(s_ctrl->msm_sensor_mutex); return rc; } #endif static struct msm_sensor_fn_t mt9m114_sensor_func_tbl = { .sensor_config = mt9m114_sensor_config, #ifdef CONFIG_COMPAT .sensor_config32 = mt9m114_sensor_config32, #endif .sensor_power_up = msm_sensor_power_up, .sensor_power_down = msm_sensor_power_down, .sensor_match_id = msm_sensor_match_id, }; static struct msm_sensor_ctrl_t mt9m114_s_ctrl = { .sensor_i2c_client = &mt9m114_sensor_i2c_client, .power_setting_array.power_setting = mt9m114_power_setting, .power_setting_array.size = ARRAY_SIZE(mt9m114_power_setting), .msm_sensor_mutex = &mt9m114_mut, .sensor_v4l2_subdev_info = mt9m114_subdev_info, .sensor_v4l2_subdev_info_size = ARRAY_SIZE(mt9m114_subdev_info), .func_tbl = &mt9m114_sensor_func_tbl, }; module_init(mt9m114_init_module); module_exit(mt9m114_exit_module); MODULE_DESCRIPTION("Aptina 1.26MP YUV sensor driver"); MODULE_LICENSE("GPL v2");
gpl-2.0
genesi/linux-testing
net/bluetooth/l2cap_sock.c
117
23417
/* BlueZ - Bluetooth protocol stack for Linux Copyright (C) 2000-2001 Qualcomm Incorporated Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> Copyright (C) 2010 Google Inc. Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.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; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS SOFTWARE IS DISCLAIMED. */ /* Bluetooth L2CAP sockets. */ #include <linux/security.h> #include <linux/export.h> #include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> #include <net/bluetooth/l2cap.h> #include <net/bluetooth/smp.h> static const struct proto_ops l2cap_sock_ops; static void l2cap_sock_init(struct sock *sk, struct sock *parent); static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio); static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct sockaddr_l2 la; int len, err = 0; BT_DBG("sk %p", sk); if (!addr || addr->sa_family != AF_BLUETOOTH) return -EINVAL; memset(&la, 0, sizeof(la)); len = min_t(unsigned int, sizeof(la), alen); memcpy(&la, addr, len); if (la.l2_cid && la.l2_psm) return -EINVAL; lock_sock(sk); if (sk->sk_state != BT_OPEN) { err = -EBADFD; goto done; } if (la.l2_psm) { __u16 psm = __le16_to_cpu(la.l2_psm); /* PSM must be odd and lsb of upper byte must be 0 */ if ((psm & 0x0101) != 0x0001) { err = -EINVAL; goto done; } /* Restrict usage of well-known PSMs */ if (psm < 0x1001 && !capable(CAP_NET_BIND_SERVICE)) { err = -EACCES; goto done; } } if (la.l2_cid) err = l2cap_add_scid(chan, la.l2_cid); else err = l2cap_add_psm(chan, &la.l2_bdaddr, la.l2_psm); if (err < 0) goto done; if (__le16_to_cpu(la.l2_psm) == 0x0001 || __le16_to_cpu(la.l2_psm) == 0x0003) chan->sec_level = BT_SECURITY_SDP; bacpy(&bt_sk(sk)->src, &la.l2_bdaddr); chan->state = BT_BOUND; sk->sk_state = BT_BOUND; done: release_sock(sk); return err; } static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int flags) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct sockaddr_l2 la; int len, err = 0; BT_DBG("sk %p", sk); if (!addr || alen < sizeof(addr->sa_family) || addr->sa_family != AF_BLUETOOTH) return -EINVAL; memset(&la, 0, sizeof(la)); len = min_t(unsigned int, sizeof(la), alen); memcpy(&la, addr, len); if (la.l2_cid && la.l2_psm) return -EINVAL; lock_sock(sk); if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && !(la.l2_psm || la.l2_cid)) { err = -EINVAL; goto done; } switch (chan->mode) { case L2CAP_MODE_BASIC: break; case L2CAP_MODE_ERTM: case L2CAP_MODE_STREAMING: if (!disable_ertm) break; /* fall through */ default: err = -ENOTSUPP; goto done; } switch (sk->sk_state) { case BT_CONNECT: case BT_CONNECT2: case BT_CONFIG: /* Already connecting */ goto wait; case BT_CONNECTED: /* Already connected */ err = -EISCONN; goto done; case BT_OPEN: case BT_BOUND: /* Can connect */ break; default: err = -EBADFD; goto done; } /* PSM must be odd and lsb of upper byte must be 0 */ if ((__le16_to_cpu(la.l2_psm) & 0x0101) != 0x0001 && !la.l2_cid && chan->chan_type != L2CAP_CHAN_RAW) { err = -EINVAL; goto done; } /* Set destination address and psm */ bacpy(&bt_sk(sk)->dst, &la.l2_bdaddr); chan->psm = la.l2_psm; chan->dcid = la.l2_cid; err = l2cap_chan_connect(l2cap_pi(sk)->chan); if (err) goto done; wait: err = bt_sock_wait_state(sk, BT_CONNECTED, sock_sndtimeo(sk, flags & O_NONBLOCK)); done: release_sock(sk); return err; } static int l2cap_sock_listen(struct socket *sock, int backlog) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; int err = 0; BT_DBG("sk %p backlog %d", sk, backlog); lock_sock(sk); if ((sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM) || sk->sk_state != BT_BOUND) { err = -EBADFD; goto done; } switch (chan->mode) { case L2CAP_MODE_BASIC: break; case L2CAP_MODE_ERTM: case L2CAP_MODE_STREAMING: if (!disable_ertm) break; /* fall through */ default: err = -ENOTSUPP; goto done; } sk->sk_max_ack_backlog = backlog; sk->sk_ack_backlog = 0; chan->state = BT_LISTEN; sk->sk_state = BT_LISTEN; done: release_sock(sk); return err; } static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int flags) { DECLARE_WAITQUEUE(wait, current); struct sock *sk = sock->sk, *nsk; long timeo; int err = 0; lock_sock_nested(sk, SINGLE_DEPTH_NESTING); timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); BT_DBG("sk %p timeo %ld", sk, timeo); /* Wait for an incoming connection. (wake-one). */ add_wait_queue_exclusive(sk_sleep(sk), &wait); while (1) { set_current_state(TASK_INTERRUPTIBLE); if (sk->sk_state != BT_LISTEN) { err = -EBADFD; break; } nsk = bt_accept_dequeue(sk, newsock); if (nsk) break; if (!timeo) { err = -EAGAIN; break; } if (signal_pending(current)) { err = sock_intr_errno(timeo); break; } release_sock(sk); timeo = schedule_timeout(timeo); lock_sock_nested(sk, SINGLE_DEPTH_NESTING); } __set_current_state(TASK_RUNNING); remove_wait_queue(sk_sleep(sk), &wait); if (err) goto done; newsock->state = SS_CONNECTED; BT_DBG("new socket %p", nsk); done: release_sock(sk); return err; } static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer) { struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr; struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; BT_DBG("sock %p, sk %p", sock, sk); addr->sa_family = AF_BLUETOOTH; *len = sizeof(struct sockaddr_l2); if (peer) { la->l2_psm = chan->psm; bacpy(&la->l2_bdaddr, &bt_sk(sk)->dst); la->l2_cid = cpu_to_le16(chan->dcid); } else { la->l2_psm = chan->sport; bacpy(&la->l2_bdaddr, &bt_sk(sk)->src); la->l2_cid = cpu_to_le16(chan->scid); } return 0; } static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __user *optval, int __user *optlen) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct l2cap_options opts; struct l2cap_conninfo cinfo; int len, err = 0; u32 opt; BT_DBG("sk %p", sk); if (get_user(len, optlen)) return -EFAULT; lock_sock(sk); switch (optname) { case L2CAP_OPTIONS: memset(&opts, 0, sizeof(opts)); opts.imtu = chan->imtu; opts.omtu = chan->omtu; opts.flush_to = chan->flush_to; opts.mode = chan->mode; opts.fcs = chan->fcs; opts.max_tx = chan->max_tx; opts.txwin_size = (__u16)chan->tx_win; len = min_t(unsigned int, len, sizeof(opts)); if (copy_to_user(optval, (char *) &opts, len)) err = -EFAULT; break; case L2CAP_LM: switch (chan->sec_level) { case BT_SECURITY_LOW: opt = L2CAP_LM_AUTH; break; case BT_SECURITY_MEDIUM: opt = L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT; break; case BT_SECURITY_HIGH: opt = L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT | L2CAP_LM_SECURE; break; default: opt = 0; break; } if (chan->role_switch) opt |= L2CAP_LM_MASTER; if (chan->force_reliable) opt |= L2CAP_LM_RELIABLE; if (put_user(opt, (u32 __user *) optval)) err = -EFAULT; break; case L2CAP_CONNINFO: if (sk->sk_state != BT_CONNECTED && !(sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup)) { err = -ENOTCONN; break; } memset(&cinfo, 0, sizeof(cinfo)); cinfo.hci_handle = chan->conn->hcon->handle; memcpy(cinfo.dev_class, chan->conn->hcon->dev_class, 3); len = min_t(unsigned int, len, sizeof(cinfo)); if (copy_to_user(optval, (char *) &cinfo, len)) err = -EFAULT; break; default: err = -ENOPROTOOPT; break; } release_sock(sk); return err; } static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct bt_security sec; struct bt_power pwr; int len, err = 0; BT_DBG("sk %p", sk); if (level == SOL_L2CAP) return l2cap_sock_getsockopt_old(sock, optname, optval, optlen); if (level != SOL_BLUETOOTH) return -ENOPROTOOPT; if (get_user(len, optlen)) return -EFAULT; lock_sock(sk); switch (optname) { case BT_SECURITY: if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && chan->chan_type != L2CAP_CHAN_RAW) { err = -EINVAL; break; } memset(&sec, 0, sizeof(sec)); sec.level = chan->sec_level; if (sk->sk_state == BT_CONNECTED) sec.key_size = chan->conn->hcon->enc_key_size; len = min_t(unsigned int, len, sizeof(sec)); if (copy_to_user(optval, (char *) &sec, len)) err = -EFAULT; break; case BT_DEFER_SETUP: if (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) { err = -EINVAL; break; } if (put_user(bt_sk(sk)->defer_setup, (u32 __user *) optval)) err = -EFAULT; break; case BT_FLUSHABLE: if (put_user(chan->flushable, (u32 __user *) optval)) err = -EFAULT; break; case BT_POWER: if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM && sk->sk_type != SOCK_RAW) { err = -EINVAL; break; } pwr.force_active = chan->force_active; len = min_t(unsigned int, len, sizeof(pwr)); if (copy_to_user(optval, (char *) &pwr, len)) err = -EFAULT; break; default: err = -ENOPROTOOPT; break; } release_sock(sk); return err; } static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct l2cap_options opts; int len, err = 0; u32 opt; BT_DBG("sk %p", sk); lock_sock(sk); switch (optname) { case L2CAP_OPTIONS: if (sk->sk_state == BT_CONNECTED) { err = -EINVAL; break; } opts.imtu = chan->imtu; opts.omtu = chan->omtu; opts.flush_to = chan->flush_to; opts.mode = chan->mode; opts.fcs = chan->fcs; opts.max_tx = chan->max_tx; opts.txwin_size = (__u16)chan->tx_win; len = min_t(unsigned int, sizeof(opts), optlen); if (copy_from_user((char *) &opts, optval, len)) { err = -EFAULT; break; } if (opts.txwin_size > L2CAP_DEFAULT_TX_WINDOW) { err = -EINVAL; break; } chan->mode = opts.mode; switch (chan->mode) { case L2CAP_MODE_BASIC: clear_bit(CONF_STATE2_DEVICE, &chan->conf_state); break; case L2CAP_MODE_ERTM: case L2CAP_MODE_STREAMING: if (!disable_ertm) break; /* fall through */ default: err = -EINVAL; break; } chan->imtu = opts.imtu; chan->omtu = opts.omtu; chan->fcs = opts.fcs; chan->max_tx = opts.max_tx; chan->tx_win = (__u8)opts.txwin_size; break; case L2CAP_LM: if (get_user(opt, (u32 __user *) optval)) { err = -EFAULT; break; } if (opt & L2CAP_LM_AUTH) chan->sec_level = BT_SECURITY_LOW; if (opt & L2CAP_LM_ENCRYPT) chan->sec_level = BT_SECURITY_MEDIUM; if (opt & L2CAP_LM_SECURE) chan->sec_level = BT_SECURITY_HIGH; chan->role_switch = (opt & L2CAP_LM_MASTER); chan->force_reliable = (opt & L2CAP_LM_RELIABLE); break; default: err = -ENOPROTOOPT; break; } release_sock(sk); return err; } static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct bt_security sec; struct bt_power pwr; struct l2cap_conn *conn; int len, err = 0; u32 opt; BT_DBG("sk %p", sk); if (level == SOL_L2CAP) return l2cap_sock_setsockopt_old(sock, optname, optval, optlen); if (level != SOL_BLUETOOTH) return -ENOPROTOOPT; lock_sock(sk); switch (optname) { case BT_SECURITY: if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && chan->chan_type != L2CAP_CHAN_RAW) { err = -EINVAL; break; } sec.level = BT_SECURITY_LOW; len = min_t(unsigned int, sizeof(sec), optlen); if (copy_from_user((char *) &sec, optval, len)) { err = -EFAULT; break; } if (sec.level < BT_SECURITY_LOW || sec.level > BT_SECURITY_HIGH) { err = -EINVAL; break; } chan->sec_level = sec.level; conn = chan->conn; if (conn && chan->scid == L2CAP_CID_LE_DATA) { if (!conn->hcon->out) { err = -EINVAL; break; } if (smp_conn_security(conn, sec.level)) break; err = 0; sk->sk_state = BT_CONFIG; } break; case BT_DEFER_SETUP: if (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) { err = -EINVAL; break; } if (get_user(opt, (u32 __user *) optval)) { err = -EFAULT; break; } bt_sk(sk)->defer_setup = opt; break; case BT_FLUSHABLE: if (get_user(opt, (u32 __user *) optval)) { err = -EFAULT; break; } if (opt > BT_FLUSHABLE_ON) { err = -EINVAL; break; } if (opt == BT_FLUSHABLE_OFF) { struct l2cap_conn *conn = chan->conn; /* proceed further only when we have l2cap_conn and No Flush support in the LM */ if (!conn || !lmp_no_flush_capable(conn->hcon->hdev)) { err = -EINVAL; break; } } chan->flushable = opt; break; case BT_POWER: if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && chan->chan_type != L2CAP_CHAN_RAW) { err = -EINVAL; break; } pwr.force_active = BT_POWER_FORCE_ACTIVE_ON; len = min_t(unsigned int, sizeof(pwr), optlen); if (copy_from_user((char *) &pwr, optval, len)) { err = -EFAULT; break; } chan->force_active = pwr.force_active; break; default: err = -ENOPROTOOPT; break; } release_sock(sk); return err; } static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; int err; BT_DBG("sock %p, sk %p", sock, sk); err = sock_error(sk); if (err) return err; if (msg->msg_flags & MSG_OOB) return -EOPNOTSUPP; lock_sock(sk); if (sk->sk_state != BT_CONNECTED) { release_sock(sk); return -ENOTCONN; } err = l2cap_chan_send(chan, msg, len); release_sock(sk); return err; } static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags) { struct sock *sk = sock->sk; struct l2cap_pinfo *pi = l2cap_pi(sk); int err; lock_sock(sk); if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) { sk->sk_state = BT_CONFIG; __l2cap_connect_rsp_defer(pi->chan); release_sock(sk); return 0; } release_sock(sk); if (sock->type == SOCK_STREAM) err = bt_sock_stream_recvmsg(iocb, sock, msg, len, flags); else err = bt_sock_recvmsg(iocb, sock, msg, len, flags); if (pi->chan->mode != L2CAP_MODE_ERTM) return err; /* Attempt to put pending rx data in the socket buffer */ lock_sock(sk); if (!test_bit(CONN_LOCAL_BUSY, &pi->chan->conn_state)) goto done; if (pi->rx_busy_skb) { if (!sock_queue_rcv_skb(sk, pi->rx_busy_skb)) pi->rx_busy_skb = NULL; else goto done; } /* Restore data flow when half of the receive buffer is * available. This avoids resending large numbers of * frames. */ if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf >> 1) l2cap_chan_busy(pi->chan, 0); done: release_sock(sk); return err; } /* Kill socket (only if zapped and orphan) * Must be called on unlocked socket. */ static void l2cap_sock_kill(struct sock *sk) { if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket) return; BT_DBG("sk %p state %d", sk, sk->sk_state); /* Kill poor orphan */ l2cap_chan_destroy(l2cap_pi(sk)->chan); sock_set_flag(sk, SOCK_DEAD); sock_put(sk); } static int l2cap_sock_shutdown(struct socket *sock, int how) { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; int err = 0; BT_DBG("sock %p, sk %p", sock, sk); if (!sk) return 0; lock_sock(sk); if (!sk->sk_shutdown) { if (chan->mode == L2CAP_MODE_ERTM) err = __l2cap_wait_ack(sk); sk->sk_shutdown = SHUTDOWN_MASK; l2cap_chan_close(chan, 0); if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) err = bt_sock_wait_state(sk, BT_CLOSED, sk->sk_lingertime); } if (!err && sk->sk_err) err = -sk->sk_err; release_sock(sk); return err; } static int l2cap_sock_release(struct socket *sock) { struct sock *sk = sock->sk; int err; BT_DBG("sock %p, sk %p", sock, sk); if (!sk) return 0; err = l2cap_sock_shutdown(sock, 2); sock_orphan(sk); l2cap_sock_kill(sk); return err; } static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data) { struct sock *sk, *parent = data; sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, GFP_ATOMIC); if (!sk) return NULL; l2cap_sock_init(sk, parent); return l2cap_pi(sk)->chan; } static int l2cap_sock_recv_cb(void *data, struct sk_buff *skb) { int err; struct sock *sk = data; struct l2cap_pinfo *pi = l2cap_pi(sk); if (pi->rx_busy_skb) return -ENOMEM; err = sock_queue_rcv_skb(sk, skb); /* For ERTM, handle one skb that doesn't fit into the recv * buffer. This is important to do because the data frames * have already been acked, so the skb cannot be discarded. * * Notify the l2cap core that the buffer is full, so the * LOCAL_BUSY state is entered and no more frames are * acked and reassembled until there is buffer space * available. */ if (err < 0 && pi->chan->mode == L2CAP_MODE_ERTM) { pi->rx_busy_skb = skb; l2cap_chan_busy(pi->chan, 1); err = 0; } return err; } static void l2cap_sock_close_cb(void *data) { struct sock *sk = data; l2cap_sock_kill(sk); } static void l2cap_sock_state_change_cb(void *data, int state) { struct sock *sk = data; sk->sk_state = state; } static struct l2cap_ops l2cap_chan_ops = { .name = "L2CAP Socket Interface", .new_connection = l2cap_sock_new_connection_cb, .recv = l2cap_sock_recv_cb, .close = l2cap_sock_close_cb, .state_change = l2cap_sock_state_change_cb, }; static void l2cap_sock_destruct(struct sock *sk) { BT_DBG("sk %p", sk); if (l2cap_pi(sk)->rx_busy_skb) { kfree_skb(l2cap_pi(sk)->rx_busy_skb); l2cap_pi(sk)->rx_busy_skb = NULL; } skb_queue_purge(&sk->sk_receive_queue); skb_queue_purge(&sk->sk_write_queue); } static void l2cap_sock_init(struct sock *sk, struct sock *parent) { struct l2cap_pinfo *pi = l2cap_pi(sk); struct l2cap_chan *chan = pi->chan; BT_DBG("sk %p", sk); if (parent) { struct l2cap_chan *pchan = l2cap_pi(parent)->chan; sk->sk_type = parent->sk_type; bt_sk(sk)->defer_setup = bt_sk(parent)->defer_setup; chan->chan_type = pchan->chan_type; chan->imtu = pchan->imtu; chan->omtu = pchan->omtu; chan->conf_state = pchan->conf_state; chan->mode = pchan->mode; chan->fcs = pchan->fcs; chan->max_tx = pchan->max_tx; chan->tx_win = pchan->tx_win; chan->sec_level = pchan->sec_level; chan->role_switch = pchan->role_switch; chan->force_reliable = pchan->force_reliable; chan->flushable = pchan->flushable; chan->force_active = pchan->force_active; security_sk_clone(parent, sk); } else { switch (sk->sk_type) { case SOCK_RAW: chan->chan_type = L2CAP_CHAN_RAW; break; case SOCK_DGRAM: chan->chan_type = L2CAP_CHAN_CONN_LESS; break; case SOCK_SEQPACKET: case SOCK_STREAM: chan->chan_type = L2CAP_CHAN_CONN_ORIENTED; break; } chan->imtu = L2CAP_DEFAULT_MTU; chan->omtu = 0; if (!disable_ertm && sk->sk_type == SOCK_STREAM) { chan->mode = L2CAP_MODE_ERTM; set_bit(CONF_STATE2_DEVICE, &chan->conf_state); } else { chan->mode = L2CAP_MODE_BASIC; } chan->max_tx = L2CAP_DEFAULT_MAX_TX; chan->fcs = L2CAP_FCS_CRC16; chan->tx_win = L2CAP_DEFAULT_TX_WINDOW; chan->sec_level = BT_SECURITY_LOW; chan->role_switch = 0; chan->force_reliable = 0; chan->flushable = BT_FLUSHABLE_OFF; chan->force_active = BT_POWER_FORCE_ACTIVE_ON; } /* Default config options */ chan->flush_to = L2CAP_DEFAULT_FLUSH_TO; chan->data = sk; chan->ops = &l2cap_chan_ops; } static struct proto l2cap_proto = { .name = "L2CAP", .owner = THIS_MODULE, .obj_size = sizeof(struct l2cap_pinfo) }; static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio) { struct sock *sk; struct l2cap_chan *chan; sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto); if (!sk) return NULL; sock_init_data(sock, sk); INIT_LIST_HEAD(&bt_sk(sk)->accept_q); sk->sk_destruct = l2cap_sock_destruct; sk->sk_sndtimeo = L2CAP_CONN_TIMEOUT; sock_reset_flag(sk, SOCK_ZAPPED); sk->sk_protocol = proto; sk->sk_state = BT_OPEN; chan = l2cap_chan_create(sk); if (!chan) { l2cap_sock_kill(sk); return NULL; } l2cap_pi(sk)->chan = chan; return sk; } static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, int kern) { struct sock *sk; BT_DBG("sock %p", sock); sock->state = SS_UNCONNECTED; if (sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM && sock->type != SOCK_DGRAM && sock->type != SOCK_RAW) return -ESOCKTNOSUPPORT; if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) return -EPERM; sock->ops = &l2cap_sock_ops; sk = l2cap_sock_alloc(net, sock, protocol, GFP_ATOMIC); if (!sk) return -ENOMEM; l2cap_sock_init(sk, NULL); return 0; } static const struct proto_ops l2cap_sock_ops = { .family = PF_BLUETOOTH, .owner = THIS_MODULE, .release = l2cap_sock_release, .bind = l2cap_sock_bind, .connect = l2cap_sock_connect, .listen = l2cap_sock_listen, .accept = l2cap_sock_accept, .getname = l2cap_sock_getname, .sendmsg = l2cap_sock_sendmsg, .recvmsg = l2cap_sock_recvmsg, .poll = bt_sock_poll, .ioctl = bt_sock_ioctl, .mmap = sock_no_mmap, .socketpair = sock_no_socketpair, .shutdown = l2cap_sock_shutdown, .setsockopt = l2cap_sock_setsockopt, .getsockopt = l2cap_sock_getsockopt }; static const struct net_proto_family l2cap_sock_family_ops = { .family = PF_BLUETOOTH, .owner = THIS_MODULE, .create = l2cap_sock_create, }; int __init l2cap_init_sockets(void) { int err; err = proto_register(&l2cap_proto, 0); if (err < 0) return err; err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops); if (err < 0) goto error; BT_INFO("L2CAP socket layer initialized"); return 0; error: BT_ERR("L2CAP socket registration failed"); proto_unregister(&l2cap_proto); return err; } void l2cap_cleanup_sockets(void) { if (bt_sock_unregister(BTPROTO_L2CAP) < 0) BT_ERR("L2CAP socket unregistration failed"); proto_unregister(&l2cap_proto); }
gpl-2.0
liuzhengcn/hc-adm-2.6.36
drivers/net/sb1250-mac.c
117
66776
/* * Copyright (C) 2001,2002,2003,2004 Broadcom Corporation * Copyright (c) 2006, 2007 Maciej W. Rozycki * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * * This driver is designed for the Broadcom SiByte SOC built-in * Ethernet controllers. Written by Mitch Lichtenberg at Broadcom Corp. * * Updated to the driver model and the PHY abstraction layer * by Maciej W. Rozycki. */ #include <linux/bug.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/timer.h> #include <linux/errno.h> #include <linux/ioport.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> #include <linux/init.h> #include <linux/bitops.h> #include <linux/err.h> #include <linux/ethtool.h> #include <linux/mii.h> #include <linux/phy.h> #include <linux/platform_device.h> #include <asm/cache.h> #include <asm/io.h> #include <asm/processor.h> /* Processor type for cache alignment. */ /* Operational parameters that usually are not changed. */ #define CONFIG_SBMAC_COALESCE /* Time in jiffies before concluding the transmitter is hung. */ #define TX_TIMEOUT (2*HZ) MODULE_AUTHOR("Mitch Lichtenberg (Broadcom Corp.)"); MODULE_DESCRIPTION("Broadcom SiByte SOC GB Ethernet driver"); /* A few user-configurable values which may be modified when a driver module is loaded. */ /* 1 normal messages, 0 quiet .. 7 verbose. */ static int debug = 1; module_param(debug, int, S_IRUGO); MODULE_PARM_DESC(debug, "Debug messages"); #ifdef CONFIG_SBMAC_COALESCE static int int_pktcnt_tx = 255; module_param(int_pktcnt_tx, int, S_IRUGO); MODULE_PARM_DESC(int_pktcnt_tx, "TX packet count"); static int int_timeout_tx = 255; module_param(int_timeout_tx, int, S_IRUGO); MODULE_PARM_DESC(int_timeout_tx, "TX timeout value"); static int int_pktcnt_rx = 64; module_param(int_pktcnt_rx, int, S_IRUGO); MODULE_PARM_DESC(int_pktcnt_rx, "RX packet count"); static int int_timeout_rx = 64; module_param(int_timeout_rx, int, S_IRUGO); MODULE_PARM_DESC(int_timeout_rx, "RX timeout value"); #endif #include <asm/sibyte/board.h> #include <asm/sibyte/sb1250.h> #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) #include <asm/sibyte/bcm1480_regs.h> #include <asm/sibyte/bcm1480_int.h> #define R_MAC_DMA_OODPKTLOST_RX R_MAC_DMA_OODPKTLOST #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) #include <asm/sibyte/sb1250_regs.h> #include <asm/sibyte/sb1250_int.h> #else #error invalid SiByte MAC configuation #endif #include <asm/sibyte/sb1250_scd.h> #include <asm/sibyte/sb1250_mac.h> #include <asm/sibyte/sb1250_dma.h> #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) #define UNIT_INT(n) (K_BCM1480_INT_MAC_0 + ((n) * 2)) #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) #define UNIT_INT(n) (K_INT_MAC_0 + (n)) #else #error invalid SiByte MAC configuation #endif #ifdef K_INT_PHY #define SBMAC_PHY_INT K_INT_PHY #else #define SBMAC_PHY_INT PHY_POLL #endif /********************************************************************** * Simple types ********************************************************************* */ enum sbmac_speed { sbmac_speed_none = 0, sbmac_speed_10 = SPEED_10, sbmac_speed_100 = SPEED_100, sbmac_speed_1000 = SPEED_1000, }; enum sbmac_duplex { sbmac_duplex_none = -1, sbmac_duplex_half = DUPLEX_HALF, sbmac_duplex_full = DUPLEX_FULL, }; enum sbmac_fc { sbmac_fc_none, sbmac_fc_disabled, sbmac_fc_frame, sbmac_fc_collision, sbmac_fc_carrier, }; enum sbmac_state { sbmac_state_uninit, sbmac_state_off, sbmac_state_on, sbmac_state_broken, }; /********************************************************************** * Macros ********************************************************************* */ #define SBDMA_NEXTBUF(d,f) ((((d)->f+1) == (d)->sbdma_dscrtable_end) ? \ (d)->sbdma_dscrtable : (d)->f+1) #define NUMCACHEBLKS(x) (((x)+SMP_CACHE_BYTES-1)/SMP_CACHE_BYTES) #define SBMAC_MAX_TXDESCR 256 #define SBMAC_MAX_RXDESCR 256 #define ETHER_ADDR_LEN 6 #define ENET_PACKET_SIZE 1518 /*#define ENET_PACKET_SIZE 9216 */ /********************************************************************** * DMA Descriptor structure ********************************************************************* */ struct sbdmadscr { uint64_t dscr_a; uint64_t dscr_b; }; /********************************************************************** * DMA Controller structure ********************************************************************* */ struct sbmacdma { /* * This stuff is used to identify the channel and the registers * associated with it. */ struct sbmac_softc *sbdma_eth; /* back pointer to associated MAC */ int sbdma_channel; /* channel number */ int sbdma_txdir; /* direction (1=transmit) */ int sbdma_maxdescr; /* total # of descriptors in ring */ #ifdef CONFIG_SBMAC_COALESCE int sbdma_int_pktcnt; /* # descriptors rx/tx before interrupt */ int sbdma_int_timeout; /* # usec rx/tx interrupt */ #endif void __iomem *sbdma_config0; /* DMA config register 0 */ void __iomem *sbdma_config1; /* DMA config register 1 */ void __iomem *sbdma_dscrbase; /* descriptor base address */ void __iomem *sbdma_dscrcnt; /* descriptor count register */ void __iomem *sbdma_curdscr; /* current descriptor address */ void __iomem *sbdma_oodpktlost; /* pkt drop (rx only) */ /* * This stuff is for maintenance of the ring */ void *sbdma_dscrtable_unaligned; struct sbdmadscr *sbdma_dscrtable; /* base of descriptor table */ struct sbdmadscr *sbdma_dscrtable_end; /* end of descriptor table */ struct sk_buff **sbdma_ctxtable; /* context table, one per descr */ dma_addr_t sbdma_dscrtable_phys; /* and also the phys addr */ struct sbdmadscr *sbdma_addptr; /* next dscr for sw to add */ struct sbdmadscr *sbdma_remptr; /* next dscr for sw to remove */ }; /********************************************************************** * Ethernet softc structure ********************************************************************* */ struct sbmac_softc { /* * Linux-specific things */ struct net_device *sbm_dev; /* pointer to linux device */ struct napi_struct napi; struct phy_device *phy_dev; /* the associated PHY device */ struct mii_bus *mii_bus; /* the MII bus */ int phy_irq[PHY_MAX_ADDR]; spinlock_t sbm_lock; /* spin lock */ int sbm_devflags; /* current device flags */ /* * Controller-specific things */ void __iomem *sbm_base; /* MAC's base address */ enum sbmac_state sbm_state; /* current state */ void __iomem *sbm_macenable; /* MAC Enable Register */ void __iomem *sbm_maccfg; /* MAC Config Register */ void __iomem *sbm_fifocfg; /* FIFO Config Register */ void __iomem *sbm_framecfg; /* Frame Config Register */ void __iomem *sbm_rxfilter; /* Receive Filter Register */ void __iomem *sbm_isr; /* Interrupt Status Register */ void __iomem *sbm_imr; /* Interrupt Mask Register */ void __iomem *sbm_mdio; /* MDIO Register */ enum sbmac_speed sbm_speed; /* current speed */ enum sbmac_duplex sbm_duplex; /* current duplex */ enum sbmac_fc sbm_fc; /* cur. flow control setting */ int sbm_pause; /* current pause setting */ int sbm_link; /* current link state */ unsigned char sbm_hwaddr[ETHER_ADDR_LEN]; struct sbmacdma sbm_txdma; /* only channel 0 for now */ struct sbmacdma sbm_rxdma; int rx_hw_checksum; int sbe_idx; }; /********************************************************************** * Externs ********************************************************************* */ /********************************************************************** * Prototypes ********************************************************************* */ static void sbdma_initctx(struct sbmacdma *d, struct sbmac_softc *s, int chan, int txrx, int maxdescr); static void sbdma_channel_start(struct sbmacdma *d, int rxtx); static int sbdma_add_rcvbuffer(struct sbmac_softc *sc, struct sbmacdma *d, struct sk_buff *m); static int sbdma_add_txbuffer(struct sbmacdma *d, struct sk_buff *m); static void sbdma_emptyring(struct sbmacdma *d); static void sbdma_fillring(struct sbmac_softc *sc, struct sbmacdma *d); static int sbdma_rx_process(struct sbmac_softc *sc, struct sbmacdma *d, int work_to_do, int poll); static void sbdma_tx_process(struct sbmac_softc *sc, struct sbmacdma *d, int poll); static int sbmac_initctx(struct sbmac_softc *s); static void sbmac_channel_start(struct sbmac_softc *s); static void sbmac_channel_stop(struct sbmac_softc *s); static enum sbmac_state sbmac_set_channel_state(struct sbmac_softc *, enum sbmac_state); static void sbmac_promiscuous_mode(struct sbmac_softc *sc, int onoff); static uint64_t sbmac_addr2reg(unsigned char *ptr); static irqreturn_t sbmac_intr(int irq, void *dev_instance); static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev); static void sbmac_setmulti(struct sbmac_softc *sc); static int sbmac_init(struct platform_device *pldev, long long base); static int sbmac_set_speed(struct sbmac_softc *s, enum sbmac_speed speed); static int sbmac_set_duplex(struct sbmac_softc *s, enum sbmac_duplex duplex, enum sbmac_fc fc); static int sbmac_open(struct net_device *dev); static void sbmac_tx_timeout (struct net_device *dev); static void sbmac_set_rx_mode(struct net_device *dev); static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static int sbmac_close(struct net_device *dev); static int sbmac_poll(struct napi_struct *napi, int budget); static void sbmac_mii_poll(struct net_device *dev); static int sbmac_mii_probe(struct net_device *dev); static void sbmac_mii_sync(void __iomem *sbm_mdio); static void sbmac_mii_senddata(void __iomem *sbm_mdio, unsigned int data, int bitcnt); static int sbmac_mii_read(struct mii_bus *bus, int phyaddr, int regidx); static int sbmac_mii_write(struct mii_bus *bus, int phyaddr, int regidx, u16 val); /********************************************************************** * Globals ********************************************************************* */ static char sbmac_string[] = "sb1250-mac"; static char sbmac_mdio_string[] = "sb1250-mac-mdio"; /********************************************************************** * MDIO constants ********************************************************************* */ #define MII_COMMAND_START 0x01 #define MII_COMMAND_READ 0x02 #define MII_COMMAND_WRITE 0x01 #define MII_COMMAND_ACK 0x02 #define M_MAC_MDIO_DIR_OUTPUT 0 /* for clarity */ #define ENABLE 1 #define DISABLE 0 /********************************************************************** * SBMAC_MII_SYNC(sbm_mdio) * * Synchronize with the MII - send a pattern of bits to the MII * that will guarantee that it is ready to accept a command. * * Input parameters: * sbm_mdio - address of the MAC's MDIO register * * Return value: * nothing ********************************************************************* */ static void sbmac_mii_sync(void __iomem *sbm_mdio) { int cnt; uint64_t bits; int mac_mdio_genc; mac_mdio_genc = __raw_readq(sbm_mdio) & M_MAC_GENC; bits = M_MAC_MDIO_DIR_OUTPUT | M_MAC_MDIO_OUT; __raw_writeq(bits | mac_mdio_genc, sbm_mdio); for (cnt = 0; cnt < 32; cnt++) { __raw_writeq(bits | M_MAC_MDC | mac_mdio_genc, sbm_mdio); __raw_writeq(bits | mac_mdio_genc, sbm_mdio); } } /********************************************************************** * SBMAC_MII_SENDDATA(sbm_mdio, data, bitcnt) * * Send some bits to the MII. The bits to be sent are right- * justified in the 'data' parameter. * * Input parameters: * sbm_mdio - address of the MAC's MDIO register * data - data to send * bitcnt - number of bits to send ********************************************************************* */ static void sbmac_mii_senddata(void __iomem *sbm_mdio, unsigned int data, int bitcnt) { int i; uint64_t bits; unsigned int curmask; int mac_mdio_genc; mac_mdio_genc = __raw_readq(sbm_mdio) & M_MAC_GENC; bits = M_MAC_MDIO_DIR_OUTPUT; __raw_writeq(bits | mac_mdio_genc, sbm_mdio); curmask = 1 << (bitcnt - 1); for (i = 0; i < bitcnt; i++) { if (data & curmask) bits |= M_MAC_MDIO_OUT; else bits &= ~M_MAC_MDIO_OUT; __raw_writeq(bits | mac_mdio_genc, sbm_mdio); __raw_writeq(bits | M_MAC_MDC | mac_mdio_genc, sbm_mdio); __raw_writeq(bits | mac_mdio_genc, sbm_mdio); curmask >>= 1; } } /********************************************************************** * SBMAC_MII_READ(bus, phyaddr, regidx) * Read a PHY register. * * Input parameters: * bus - MDIO bus handle * phyaddr - PHY's address * regnum - index of register to read * * Return value: * value read, or 0xffff if an error occurred. ********************************************************************* */ static int sbmac_mii_read(struct mii_bus *bus, int phyaddr, int regidx) { struct sbmac_softc *sc = (struct sbmac_softc *)bus->priv; void __iomem *sbm_mdio = sc->sbm_mdio; int idx; int error; int regval; int mac_mdio_genc; /* * Synchronize ourselves so that the PHY knows the next * thing coming down is a command */ sbmac_mii_sync(sbm_mdio); /* * Send the data to the PHY. The sequence is * a "start" command (2 bits) * a "read" command (2 bits) * the PHY addr (5 bits) * the register index (5 bits) */ sbmac_mii_senddata(sbm_mdio, MII_COMMAND_START, 2); sbmac_mii_senddata(sbm_mdio, MII_COMMAND_READ, 2); sbmac_mii_senddata(sbm_mdio, phyaddr, 5); sbmac_mii_senddata(sbm_mdio, regidx, 5); mac_mdio_genc = __raw_readq(sbm_mdio) & M_MAC_GENC; /* * Switch the port around without a clock transition. */ __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, sbm_mdio); /* * Send out a clock pulse to signal we want the status */ __raw_writeq(M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc, sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, sbm_mdio); /* * If an error occurred, the PHY will signal '1' back */ error = __raw_readq(sbm_mdio) & M_MAC_MDIO_IN; /* * Issue an 'idle' clock pulse, but keep the direction * the same. */ __raw_writeq(M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc, sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, sbm_mdio); regval = 0; for (idx = 0; idx < 16; idx++) { regval <<= 1; if (error == 0) { if (__raw_readq(sbm_mdio) & M_MAC_MDIO_IN) regval |= 1; } __raw_writeq(M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc, sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, sbm_mdio); } /* Switch back to output */ __raw_writeq(M_MAC_MDIO_DIR_OUTPUT | mac_mdio_genc, sbm_mdio); if (error == 0) return regval; return 0xffff; } /********************************************************************** * SBMAC_MII_WRITE(bus, phyaddr, regidx, regval) * * Write a value to a PHY register. * * Input parameters: * bus - MDIO bus handle * phyaddr - PHY to use * regidx - register within the PHY * regval - data to write to register * * Return value: * 0 for success ********************************************************************* */ static int sbmac_mii_write(struct mii_bus *bus, int phyaddr, int regidx, u16 regval) { struct sbmac_softc *sc = (struct sbmac_softc *)bus->priv; void __iomem *sbm_mdio = sc->sbm_mdio; int mac_mdio_genc; sbmac_mii_sync(sbm_mdio); sbmac_mii_senddata(sbm_mdio, MII_COMMAND_START, 2); sbmac_mii_senddata(sbm_mdio, MII_COMMAND_WRITE, 2); sbmac_mii_senddata(sbm_mdio, phyaddr, 5); sbmac_mii_senddata(sbm_mdio, regidx, 5); sbmac_mii_senddata(sbm_mdio, MII_COMMAND_ACK, 2); sbmac_mii_senddata(sbm_mdio, regval, 16); mac_mdio_genc = __raw_readq(sbm_mdio) & M_MAC_GENC; __raw_writeq(M_MAC_MDIO_DIR_OUTPUT | mac_mdio_genc, sbm_mdio); return 0; } /********************************************************************** * SBDMA_INITCTX(d,s,chan,txrx,maxdescr) * * Initialize a DMA channel context. Since there are potentially * eight DMA channels per MAC, it's nice to do this in a standard * way. * * Input parameters: * d - struct sbmacdma (DMA channel context) * s - struct sbmac_softc (pointer to a MAC) * chan - channel number (0..1 right now) * txrx - Identifies DMA_TX or DMA_RX for channel direction * maxdescr - number of descriptors * * Return value: * nothing ********************************************************************* */ static void sbdma_initctx(struct sbmacdma *d, struct sbmac_softc *s, int chan, int txrx, int maxdescr) { #ifdef CONFIG_SBMAC_COALESCE int int_pktcnt, int_timeout; #endif /* * Save away interesting stuff in the structure */ d->sbdma_eth = s; d->sbdma_channel = chan; d->sbdma_txdir = txrx; #if 0 /* RMON clearing */ s->sbe_idx =(s->sbm_base - A_MAC_BASE_0)/MAC_SPACING; #endif __raw_writeq(0, s->sbm_base + R_MAC_RMON_TX_BYTES); __raw_writeq(0, s->sbm_base + R_MAC_RMON_COLLISIONS); __raw_writeq(0, s->sbm_base + R_MAC_RMON_LATE_COL); __raw_writeq(0, s->sbm_base + R_MAC_RMON_EX_COL); __raw_writeq(0, s->sbm_base + R_MAC_RMON_FCS_ERROR); __raw_writeq(0, s->sbm_base + R_MAC_RMON_TX_ABORT); __raw_writeq(0, s->sbm_base + R_MAC_RMON_TX_BAD); __raw_writeq(0, s->sbm_base + R_MAC_RMON_TX_GOOD); __raw_writeq(0, s->sbm_base + R_MAC_RMON_TX_RUNT); __raw_writeq(0, s->sbm_base + R_MAC_RMON_TX_OVERSIZE); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_BYTES); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_MCAST); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_BCAST); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_BAD); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_GOOD); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_RUNT); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_OVERSIZE); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_FCS_ERROR); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_LENGTH_ERROR); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_CODE_ERROR); __raw_writeq(0, s->sbm_base + R_MAC_RMON_RX_ALIGN_ERROR); /* * initialize register pointers */ d->sbdma_config0 = s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CONFIG0); d->sbdma_config1 = s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CONFIG1); d->sbdma_dscrbase = s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_DSCR_BASE); d->sbdma_dscrcnt = s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_DSCR_CNT); d->sbdma_curdscr = s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CUR_DSCRADDR); if (d->sbdma_txdir) d->sbdma_oodpktlost = NULL; else d->sbdma_oodpktlost = s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_OODPKTLOST_RX); /* * Allocate memory for the ring */ d->sbdma_maxdescr = maxdescr; d->sbdma_dscrtable_unaligned = kcalloc(d->sbdma_maxdescr + 1, sizeof(*d->sbdma_dscrtable), GFP_KERNEL); /* * The descriptor table must be aligned to at least 16 bytes or the * MAC will corrupt it. */ d->sbdma_dscrtable = (struct sbdmadscr *) ALIGN((unsigned long)d->sbdma_dscrtable_unaligned, sizeof(*d->sbdma_dscrtable)); d->sbdma_dscrtable_end = d->sbdma_dscrtable + d->sbdma_maxdescr; d->sbdma_dscrtable_phys = virt_to_phys(d->sbdma_dscrtable); /* * And context table */ d->sbdma_ctxtable = kcalloc(d->sbdma_maxdescr, sizeof(*d->sbdma_ctxtable), GFP_KERNEL); #ifdef CONFIG_SBMAC_COALESCE /* * Setup Rx/Tx DMA coalescing defaults */ int_pktcnt = (txrx == DMA_TX) ? int_pktcnt_tx : int_pktcnt_rx; if ( int_pktcnt ) { d->sbdma_int_pktcnt = int_pktcnt; } else { d->sbdma_int_pktcnt = 1; } int_timeout = (txrx == DMA_TX) ? int_timeout_tx : int_timeout_rx; if ( int_timeout ) { d->sbdma_int_timeout = int_timeout; } else { d->sbdma_int_timeout = 0; } #endif } /********************************************************************** * SBDMA_CHANNEL_START(d) * * Initialize the hardware registers for a DMA channel. * * Input parameters: * d - DMA channel to init (context must be previously init'd * rxtx - DMA_RX or DMA_TX depending on what type of channel * * Return value: * nothing ********************************************************************* */ static void sbdma_channel_start(struct sbmacdma *d, int rxtx) { /* * Turn on the DMA channel */ #ifdef CONFIG_SBMAC_COALESCE __raw_writeq(V_DMA_INT_TIMEOUT(d->sbdma_int_timeout) | 0, d->sbdma_config1); __raw_writeq(M_DMA_EOP_INT_EN | V_DMA_RINGSZ(d->sbdma_maxdescr) | V_DMA_INT_PKTCNT(d->sbdma_int_pktcnt) | 0, d->sbdma_config0); #else __raw_writeq(0, d->sbdma_config1); __raw_writeq(V_DMA_RINGSZ(d->sbdma_maxdescr) | 0, d->sbdma_config0); #endif __raw_writeq(d->sbdma_dscrtable_phys, d->sbdma_dscrbase); /* * Initialize ring pointers */ d->sbdma_addptr = d->sbdma_dscrtable; d->sbdma_remptr = d->sbdma_dscrtable; } /********************************************************************** * SBDMA_CHANNEL_STOP(d) * * Initialize the hardware registers for a DMA channel. * * Input parameters: * d - DMA channel to init (context must be previously init'd * * Return value: * nothing ********************************************************************* */ static void sbdma_channel_stop(struct sbmacdma *d) { /* * Turn off the DMA channel */ __raw_writeq(0, d->sbdma_config1); __raw_writeq(0, d->sbdma_dscrbase); __raw_writeq(0, d->sbdma_config0); /* * Zero ring pointers */ d->sbdma_addptr = NULL; d->sbdma_remptr = NULL; } static inline void sbdma_align_skb(struct sk_buff *skb, unsigned int power2, unsigned int offset) { unsigned char *addr = skb->data; unsigned char *newaddr = PTR_ALIGN(addr, power2); skb_reserve(skb, newaddr - addr + offset); } /********************************************************************** * SBDMA_ADD_RCVBUFFER(d,sb) * * Add a buffer to the specified DMA channel. For receive channels, * this queues a buffer for inbound packets. * * Input parameters: * sc - softc structure * d - DMA channel descriptor * sb - sk_buff to add, or NULL if we should allocate one * * Return value: * 0 if buffer could not be added (ring is full) * 1 if buffer added successfully ********************************************************************* */ static int sbdma_add_rcvbuffer(struct sbmac_softc *sc, struct sbmacdma *d, struct sk_buff *sb) { struct net_device *dev = sc->sbm_dev; struct sbdmadscr *dsc; struct sbdmadscr *nextdsc; struct sk_buff *sb_new = NULL; int pktsize = ENET_PACKET_SIZE; /* get pointer to our current place in the ring */ dsc = d->sbdma_addptr; nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr); /* * figure out if the ring is full - if the next descriptor * is the same as the one that we're going to remove from * the ring, the ring is full */ if (nextdsc == d->sbdma_remptr) { return -ENOSPC; } /* * Allocate a sk_buff if we don't already have one. * If we do have an sk_buff, reset it so that it's empty. * * Note: sk_buffs don't seem to be guaranteed to have any sort * of alignment when they are allocated. Therefore, allocate enough * extra space to make sure that: * * 1. the data does not start in the middle of a cache line. * 2. The data does not end in the middle of a cache line * 3. The buffer can be aligned such that the IP addresses are * naturally aligned. * * Remember, the SOCs MAC writes whole cache lines at a time, * without reading the old contents first. So, if the sk_buff's * data portion starts in the middle of a cache line, the SOC * DMA will trash the beginning (and ending) portions. */ if (sb == NULL) { sb_new = netdev_alloc_skb(dev, ENET_PACKET_SIZE + SMP_CACHE_BYTES * 2 + NET_IP_ALIGN); if (sb_new == NULL) { pr_info("%s: sk_buff allocation failed\n", d->sbdma_eth->sbm_dev->name); return -ENOBUFS; } sbdma_align_skb(sb_new, SMP_CACHE_BYTES, NET_IP_ALIGN); } else { sb_new = sb; /* * nothing special to reinit buffer, it's already aligned * and sb->data already points to a good place. */ } /* * fill in the descriptor */ #ifdef CONFIG_SBMAC_COALESCE /* * Do not interrupt per DMA transfer. */ dsc->dscr_a = virt_to_phys(sb_new->data) | V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize + NET_IP_ALIGN)) | 0; #else dsc->dscr_a = virt_to_phys(sb_new->data) | V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize + NET_IP_ALIGN)) | M_DMA_DSCRA_INTERRUPT; #endif /* receiving: no options */ dsc->dscr_b = 0; /* * fill in the context */ d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb_new; /* * point at next packet */ d->sbdma_addptr = nextdsc; /* * Give the buffer to the DMA engine. */ __raw_writeq(1, d->sbdma_dscrcnt); return 0; /* we did it */ } /********************************************************************** * SBDMA_ADD_TXBUFFER(d,sb) * * Add a transmit buffer to the specified DMA channel, causing a * transmit to start. * * Input parameters: * d - DMA channel descriptor * sb - sk_buff to add * * Return value: * 0 transmit queued successfully * otherwise error code ********************************************************************* */ static int sbdma_add_txbuffer(struct sbmacdma *d, struct sk_buff *sb) { struct sbdmadscr *dsc; struct sbdmadscr *nextdsc; uint64_t phys; uint64_t ncb; int length; /* get pointer to our current place in the ring */ dsc = d->sbdma_addptr; nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr); /* * figure out if the ring is full - if the next descriptor * is the same as the one that we're going to remove from * the ring, the ring is full */ if (nextdsc == d->sbdma_remptr) { return -ENOSPC; } /* * Under Linux, it's not necessary to copy/coalesce buffers * like it is on NetBSD. We think they're all contiguous, * but that may not be true for GBE. */ length = sb->len; /* * fill in the descriptor. Note that the number of cache * blocks in the descriptor is the number of blocks * *spanned*, so we need to add in the offset (if any) * while doing the calculation. */ phys = virt_to_phys(sb->data); ncb = NUMCACHEBLKS(length+(phys & (SMP_CACHE_BYTES - 1))); dsc->dscr_a = phys | V_DMA_DSCRA_A_SIZE(ncb) | #ifndef CONFIG_SBMAC_COALESCE M_DMA_DSCRA_INTERRUPT | #endif M_DMA_ETHTX_SOP; /* transmitting: set outbound options and length */ dsc->dscr_b = V_DMA_DSCRB_OPTIONS(K_DMA_ETHTX_APPENDCRC_APPENDPAD) | V_DMA_DSCRB_PKT_SIZE(length); /* * fill in the context */ d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb; /* * point at next packet */ d->sbdma_addptr = nextdsc; /* * Give the buffer to the DMA engine. */ __raw_writeq(1, d->sbdma_dscrcnt); return 0; /* we did it */ } /********************************************************************** * SBDMA_EMPTYRING(d) * * Free all allocated sk_buffs on the specified DMA channel; * * Input parameters: * d - DMA channel * * Return value: * nothing ********************************************************************* */ static void sbdma_emptyring(struct sbmacdma *d) { int idx; struct sk_buff *sb; for (idx = 0; idx < d->sbdma_maxdescr; idx++) { sb = d->sbdma_ctxtable[idx]; if (sb) { dev_kfree_skb(sb); d->sbdma_ctxtable[idx] = NULL; } } } /********************************************************************** * SBDMA_FILLRING(d) * * Fill the specified DMA channel (must be receive channel) * with sk_buffs * * Input parameters: * sc - softc structure * d - DMA channel * * Return value: * nothing ********************************************************************* */ static void sbdma_fillring(struct sbmac_softc *sc, struct sbmacdma *d) { int idx; for (idx = 0; idx < SBMAC_MAX_RXDESCR - 1; idx++) { if (sbdma_add_rcvbuffer(sc, d, NULL) != 0) break; } } #ifdef CONFIG_NET_POLL_CONTROLLER static void sbmac_netpoll(struct net_device *netdev) { struct sbmac_softc *sc = netdev_priv(netdev); int irq = sc->sbm_dev->irq; __raw_writeq(0, sc->sbm_imr); sbmac_intr(irq, netdev); #ifdef CONFIG_SBMAC_COALESCE __raw_writeq(((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_TX_CH0) | ((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_RX_CH0), sc->sbm_imr); #else __raw_writeq((M_MAC_INT_CHANNEL << S_MAC_TX_CH0) | (M_MAC_INT_CHANNEL << S_MAC_RX_CH0), sc->sbm_imr); #endif } #endif /********************************************************************** * SBDMA_RX_PROCESS(sc,d,work_to_do,poll) * * Process "completed" receive buffers on the specified DMA channel. * * Input parameters: * sc - softc structure * d - DMA channel context * work_to_do - no. of packets to process before enabling interrupt * again (for NAPI) * poll - 1: using polling (for NAPI) * * Return value: * nothing ********************************************************************* */ static int sbdma_rx_process(struct sbmac_softc *sc, struct sbmacdma *d, int work_to_do, int poll) { struct net_device *dev = sc->sbm_dev; int curidx; int hwidx; struct sbdmadscr *dsc; struct sk_buff *sb; int len; int work_done = 0; int dropped = 0; prefetch(d); again: /* Check if the HW dropped any frames */ dev->stats.rx_fifo_errors += __raw_readq(sc->sbm_rxdma.sbdma_oodpktlost) & 0xffff; __raw_writeq(0, sc->sbm_rxdma.sbdma_oodpktlost); while (work_to_do-- > 0) { /* * figure out where we are (as an index) and where * the hardware is (also as an index) * * This could be done faster if (for example) the * descriptor table was page-aligned and contiguous in * both virtual and physical memory -- you could then * just compare the low-order bits of the virtual address * (sbdma_remptr) and the physical address (sbdma_curdscr CSR) */ dsc = d->sbdma_remptr; curidx = dsc - d->sbdma_dscrtable; prefetch(dsc); prefetch(&d->sbdma_ctxtable[curidx]); hwidx = ((__raw_readq(d->sbdma_curdscr) & M_DMA_CURDSCR_ADDR) - d->sbdma_dscrtable_phys) / sizeof(*d->sbdma_dscrtable); /* * If they're the same, that means we've processed all * of the descriptors up to (but not including) the one that * the hardware is working on right now. */ if (curidx == hwidx) goto done; /* * Otherwise, get the packet's sk_buff ptr back */ sb = d->sbdma_ctxtable[curidx]; d->sbdma_ctxtable[curidx] = NULL; len = (int)G_DMA_DSCRB_PKT_SIZE(dsc->dscr_b) - 4; /* * Check packet status. If good, process it. * If not, silently drop it and put it back on the * receive ring. */ if (likely (!(dsc->dscr_a & M_DMA_ETHRX_BAD))) { /* * Add a new buffer to replace the old one. If we fail * to allocate a buffer, we're going to drop this * packet and put it right back on the receive ring. */ if (unlikely(sbdma_add_rcvbuffer(sc, d, NULL) == -ENOBUFS)) { dev->stats.rx_dropped++; /* Re-add old buffer */ sbdma_add_rcvbuffer(sc, d, sb); /* No point in continuing at the moment */ printk(KERN_ERR "dropped packet (1)\n"); d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr); goto done; } else { /* * Set length into the packet */ skb_put(sb,len); /* * Buffer has been replaced on the * receive ring. Pass the buffer to * the kernel */ sb->protocol = eth_type_trans(sb,d->sbdma_eth->sbm_dev); /* Check hw IPv4/TCP checksum if supported */ if (sc->rx_hw_checksum == ENABLE) { if (!((dsc->dscr_a) & M_DMA_ETHRX_BADIP4CS) && !((dsc->dscr_a) & M_DMA_ETHRX_BADTCPCS)) { sb->ip_summed = CHECKSUM_UNNECESSARY; /* don't need to set sb->csum */ } else { sb->ip_summed = CHECKSUM_NONE; } } prefetch(sb->data); prefetch((const void *)(((char *)sb->data)+32)); if (poll) dropped = netif_receive_skb(sb); else dropped = netif_rx(sb); if (dropped == NET_RX_DROP) { dev->stats.rx_dropped++; d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr); goto done; } else { dev->stats.rx_bytes += len; dev->stats.rx_packets++; } } } else { /* * Packet was mangled somehow. Just drop it and * put it back on the receive ring. */ dev->stats.rx_errors++; sbdma_add_rcvbuffer(sc, d, sb); } /* * .. and advance to the next buffer. */ d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr); work_done++; } if (!poll) { work_to_do = 32; goto again; /* collect fifo drop statistics again */ } done: return work_done; } /********************************************************************** * SBDMA_TX_PROCESS(sc,d) * * Process "completed" transmit buffers on the specified DMA channel. * This is normally called within the interrupt service routine. * Note that this isn't really ideal for priority channels, since * it processes all of the packets on a given channel before * returning. * * Input parameters: * sc - softc structure * d - DMA channel context * poll - 1: using polling (for NAPI) * * Return value: * nothing ********************************************************************* */ static void sbdma_tx_process(struct sbmac_softc *sc, struct sbmacdma *d, int poll) { struct net_device *dev = sc->sbm_dev; int curidx; int hwidx; struct sbdmadscr *dsc; struct sk_buff *sb; unsigned long flags; int packets_handled = 0; spin_lock_irqsave(&(sc->sbm_lock), flags); if (d->sbdma_remptr == d->sbdma_addptr) goto end_unlock; hwidx = ((__raw_readq(d->sbdma_curdscr) & M_DMA_CURDSCR_ADDR) - d->sbdma_dscrtable_phys) / sizeof(*d->sbdma_dscrtable); for (;;) { /* * figure out where we are (as an index) and where * the hardware is (also as an index) * * This could be done faster if (for example) the * descriptor table was page-aligned and contiguous in * both virtual and physical memory -- you could then * just compare the low-order bits of the virtual address * (sbdma_remptr) and the physical address (sbdma_curdscr CSR) */ curidx = d->sbdma_remptr - d->sbdma_dscrtable; /* * If they're the same, that means we've processed all * of the descriptors up to (but not including) the one that * the hardware is working on right now. */ if (curidx == hwidx) break; /* * Otherwise, get the packet's sk_buff ptr back */ dsc = &(d->sbdma_dscrtable[curidx]); sb = d->sbdma_ctxtable[curidx]; d->sbdma_ctxtable[curidx] = NULL; /* * Stats */ dev->stats.tx_bytes += sb->len; dev->stats.tx_packets++; /* * for transmits, we just free buffers. */ dev_kfree_skb_irq(sb); /* * .. and advance to the next buffer. */ d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr); packets_handled++; } /* * Decide if we should wake up the protocol or not. * Other drivers seem to do this when we reach a low * watermark on the transmit queue. */ if (packets_handled) netif_wake_queue(d->sbdma_eth->sbm_dev); end_unlock: spin_unlock_irqrestore(&(sc->sbm_lock), flags); } /********************************************************************** * SBMAC_INITCTX(s) * * Initialize an Ethernet context structure - this is called * once per MAC on the 1250. Memory is allocated here, so don't * call it again from inside the ioctl routines that bring the * interface up/down * * Input parameters: * s - sbmac context structure * * Return value: * 0 ********************************************************************* */ static int sbmac_initctx(struct sbmac_softc *s) { /* * figure out the addresses of some ports */ s->sbm_macenable = s->sbm_base + R_MAC_ENABLE; s->sbm_maccfg = s->sbm_base + R_MAC_CFG; s->sbm_fifocfg = s->sbm_base + R_MAC_THRSH_CFG; s->sbm_framecfg = s->sbm_base + R_MAC_FRAMECFG; s->sbm_rxfilter = s->sbm_base + R_MAC_ADFILTER_CFG; s->sbm_isr = s->sbm_base + R_MAC_STATUS; s->sbm_imr = s->sbm_base + R_MAC_INT_MASK; s->sbm_mdio = s->sbm_base + R_MAC_MDIO; /* * Initialize the DMA channels. Right now, only one per MAC is used * Note: Only do this _once_, as it allocates memory from the kernel! */ sbdma_initctx(&(s->sbm_txdma),s,0,DMA_TX,SBMAC_MAX_TXDESCR); sbdma_initctx(&(s->sbm_rxdma),s,0,DMA_RX,SBMAC_MAX_RXDESCR); /* * initial state is OFF */ s->sbm_state = sbmac_state_off; return 0; } static void sbdma_uninitctx(struct sbmacdma *d) { if (d->sbdma_dscrtable_unaligned) { kfree(d->sbdma_dscrtable_unaligned); d->sbdma_dscrtable_unaligned = d->sbdma_dscrtable = NULL; } if (d->sbdma_ctxtable) { kfree(d->sbdma_ctxtable); d->sbdma_ctxtable = NULL; } } static void sbmac_uninitctx(struct sbmac_softc *sc) { sbdma_uninitctx(&(sc->sbm_txdma)); sbdma_uninitctx(&(sc->sbm_rxdma)); } /********************************************************************** * SBMAC_CHANNEL_START(s) * * Start packet processing on this MAC. * * Input parameters: * s - sbmac structure * * Return value: * nothing ********************************************************************* */ static void sbmac_channel_start(struct sbmac_softc *s) { uint64_t reg; void __iomem *port; uint64_t cfg,fifo,framecfg; int idx, th_value; /* * Don't do this if running */ if (s->sbm_state == sbmac_state_on) return; /* * Bring the controller out of reset, but leave it off. */ __raw_writeq(0, s->sbm_macenable); /* * Ignore all received packets */ __raw_writeq(0, s->sbm_rxfilter); /* * Calculate values for various control registers. */ cfg = M_MAC_RETRY_EN | M_MAC_TX_HOLD_SOP_EN | V_MAC_TX_PAUSE_CNT_16K | M_MAC_AP_STAT_EN | M_MAC_FAST_SYNC | M_MAC_SS_EN | 0; /* * Be sure that RD_THRSH+WR_THRSH <= 32 for pass1 pars * and make sure that RD_THRSH + WR_THRSH <=128 for pass2 and above * Use a larger RD_THRSH for gigabit */ if (soc_type == K_SYS_SOC_TYPE_BCM1250 && periph_rev < 2) th_value = 28; else th_value = 64; fifo = V_MAC_TX_WR_THRSH(4) | /* Must be '4' or '8' */ ((s->sbm_speed == sbmac_speed_1000) ? V_MAC_TX_RD_THRSH(th_value) : V_MAC_TX_RD_THRSH(4)) | V_MAC_TX_RL_THRSH(4) | V_MAC_RX_PL_THRSH(4) | V_MAC_RX_RD_THRSH(4) | /* Must be '4' */ V_MAC_RX_RL_THRSH(8) | 0; framecfg = V_MAC_MIN_FRAMESZ_DEFAULT | V_MAC_MAX_FRAMESZ_DEFAULT | V_MAC_BACKOFF_SEL(1); /* * Clear out the hash address map */ port = s->sbm_base + R_MAC_HASH_BASE; for (idx = 0; idx < MAC_HASH_COUNT; idx++) { __raw_writeq(0, port); port += sizeof(uint64_t); } /* * Clear out the exact-match table */ port = s->sbm_base + R_MAC_ADDR_BASE; for (idx = 0; idx < MAC_ADDR_COUNT; idx++) { __raw_writeq(0, port); port += sizeof(uint64_t); } /* * Clear out the DMA Channel mapping table registers */ port = s->sbm_base + R_MAC_CHUP0_BASE; for (idx = 0; idx < MAC_CHMAP_COUNT; idx++) { __raw_writeq(0, port); port += sizeof(uint64_t); } port = s->sbm_base + R_MAC_CHLO0_BASE; for (idx = 0; idx < MAC_CHMAP_COUNT; idx++) { __raw_writeq(0, port); port += sizeof(uint64_t); } /* * Program the hardware address. It goes into the hardware-address * register as well as the first filter register. */ reg = sbmac_addr2reg(s->sbm_hwaddr); port = s->sbm_base + R_MAC_ADDR_BASE; __raw_writeq(reg, port); port = s->sbm_base + R_MAC_ETHERNET_ADDR; #ifdef CONFIG_SB1_PASS_1_WORKAROUNDS /* * Pass1 SOCs do not receive packets addressed to the * destination address in the R_MAC_ETHERNET_ADDR register. * Set the value to zero. */ __raw_writeq(0, port); #else __raw_writeq(reg, port); #endif /* * Set the receive filter for no packets, and write values * to the various config registers */ __raw_writeq(0, s->sbm_rxfilter); __raw_writeq(0, s->sbm_imr); __raw_writeq(framecfg, s->sbm_framecfg); __raw_writeq(fifo, s->sbm_fifocfg); __raw_writeq(cfg, s->sbm_maccfg); /* * Initialize DMA channels (rings should be ok now) */ sbdma_channel_start(&(s->sbm_rxdma), DMA_RX); sbdma_channel_start(&(s->sbm_txdma), DMA_TX); /* * Configure the speed, duplex, and flow control */ sbmac_set_speed(s,s->sbm_speed); sbmac_set_duplex(s,s->sbm_duplex,s->sbm_fc); /* * Fill the receive ring */ sbdma_fillring(s, &(s->sbm_rxdma)); /* * Turn on the rest of the bits in the enable register */ #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) __raw_writeq(M_MAC_RXDMA_EN0 | M_MAC_TXDMA_EN0, s->sbm_macenable); #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) __raw_writeq(M_MAC_RXDMA_EN0 | M_MAC_TXDMA_EN0 | M_MAC_RX_ENABLE | M_MAC_TX_ENABLE, s->sbm_macenable); #else #error invalid SiByte MAC configuation #endif #ifdef CONFIG_SBMAC_COALESCE __raw_writeq(((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_TX_CH0) | ((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_RX_CH0), s->sbm_imr); #else __raw_writeq((M_MAC_INT_CHANNEL << S_MAC_TX_CH0) | (M_MAC_INT_CHANNEL << S_MAC_RX_CH0), s->sbm_imr); #endif /* * Enable receiving unicasts and broadcasts */ __raw_writeq(M_MAC_UCAST_EN | M_MAC_BCAST_EN, s->sbm_rxfilter); /* * we're running now. */ s->sbm_state = sbmac_state_on; /* * Program multicast addresses */ sbmac_setmulti(s); /* * If channel was in promiscuous mode before, turn that on */ if (s->sbm_devflags & IFF_PROMISC) { sbmac_promiscuous_mode(s,1); } } /********************************************************************** * SBMAC_CHANNEL_STOP(s) * * Stop packet processing on this MAC. * * Input parameters: * s - sbmac structure * * Return value: * nothing ********************************************************************* */ static void sbmac_channel_stop(struct sbmac_softc *s) { /* don't do this if already stopped */ if (s->sbm_state == sbmac_state_off) return; /* don't accept any packets, disable all interrupts */ __raw_writeq(0, s->sbm_rxfilter); __raw_writeq(0, s->sbm_imr); /* Turn off ticker */ /* XXX */ /* turn off receiver and transmitter */ __raw_writeq(0, s->sbm_macenable); /* We're stopped now. */ s->sbm_state = sbmac_state_off; /* * Stop DMA channels (rings should be ok now) */ sbdma_channel_stop(&(s->sbm_rxdma)); sbdma_channel_stop(&(s->sbm_txdma)); /* Empty the receive and transmit rings */ sbdma_emptyring(&(s->sbm_rxdma)); sbdma_emptyring(&(s->sbm_txdma)); } /********************************************************************** * SBMAC_SET_CHANNEL_STATE(state) * * Set the channel's state ON or OFF * * Input parameters: * state - new state * * Return value: * old state ********************************************************************* */ static enum sbmac_state sbmac_set_channel_state(struct sbmac_softc *sc, enum sbmac_state state) { enum sbmac_state oldstate = sc->sbm_state; /* * If same as previous state, return */ if (state == oldstate) { return oldstate; } /* * If new state is ON, turn channel on */ if (state == sbmac_state_on) { sbmac_channel_start(sc); } else { sbmac_channel_stop(sc); } /* * Return previous state */ return oldstate; } /********************************************************************** * SBMAC_PROMISCUOUS_MODE(sc,onoff) * * Turn on or off promiscuous mode * * Input parameters: * sc - softc * onoff - 1 to turn on, 0 to turn off * * Return value: * nothing ********************************************************************* */ static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff) { uint64_t reg; if (sc->sbm_state != sbmac_state_on) return; if (onoff) { reg = __raw_readq(sc->sbm_rxfilter); reg |= M_MAC_ALLPKT_EN; __raw_writeq(reg, sc->sbm_rxfilter); } else { reg = __raw_readq(sc->sbm_rxfilter); reg &= ~M_MAC_ALLPKT_EN; __raw_writeq(reg, sc->sbm_rxfilter); } } /********************************************************************** * SBMAC_SETIPHDR_OFFSET(sc,onoff) * * Set the iphdr offset as 15 assuming ethernet encapsulation * * Input parameters: * sc - softc * * Return value: * nothing ********************************************************************* */ static void sbmac_set_iphdr_offset(struct sbmac_softc *sc) { uint64_t reg; /* Hard code the off set to 15 for now */ reg = __raw_readq(sc->sbm_rxfilter); reg &= ~M_MAC_IPHDR_OFFSET | V_MAC_IPHDR_OFFSET(15); __raw_writeq(reg, sc->sbm_rxfilter); /* BCM1250 pass1 didn't have hardware checksum. Everything later does. */ if (soc_type == K_SYS_SOC_TYPE_BCM1250 && periph_rev < 2) { sc->rx_hw_checksum = DISABLE; } else { sc->rx_hw_checksum = ENABLE; } } /********************************************************************** * SBMAC_ADDR2REG(ptr) * * Convert six bytes into the 64-bit register value that * we typically write into the SBMAC's address/mcast registers * * Input parameters: * ptr - pointer to 6 bytes * * Return value: * register value ********************************************************************* */ static uint64_t sbmac_addr2reg(unsigned char *ptr) { uint64_t reg = 0; ptr += 6; reg |= (uint64_t) *(--ptr); reg <<= 8; reg |= (uint64_t) *(--ptr); reg <<= 8; reg |= (uint64_t) *(--ptr); reg <<= 8; reg |= (uint64_t) *(--ptr); reg <<= 8; reg |= (uint64_t) *(--ptr); reg <<= 8; reg |= (uint64_t) *(--ptr); return reg; } /********************************************************************** * SBMAC_SET_SPEED(s,speed) * * Configure LAN speed for the specified MAC. * Warning: must be called when MAC is off! * * Input parameters: * s - sbmac structure * speed - speed to set MAC to (see enum sbmac_speed) * * Return value: * 1 if successful * 0 indicates invalid parameters ********************************************************************* */ static int sbmac_set_speed(struct sbmac_softc *s, enum sbmac_speed speed) { uint64_t cfg; uint64_t framecfg; /* * Save new current values */ s->sbm_speed = speed; if (s->sbm_state == sbmac_state_on) return 0; /* save for next restart */ /* * Read current register values */ cfg = __raw_readq(s->sbm_maccfg); framecfg = __raw_readq(s->sbm_framecfg); /* * Mask out the stuff we want to change */ cfg &= ~(M_MAC_BURST_EN | M_MAC_SPEED_SEL); framecfg &= ~(M_MAC_IFG_RX | M_MAC_IFG_TX | M_MAC_IFG_THRSH | M_MAC_SLOT_SIZE); /* * Now add in the new bits */ switch (speed) { case sbmac_speed_10: framecfg |= V_MAC_IFG_RX_10 | V_MAC_IFG_TX_10 | K_MAC_IFG_THRSH_10 | V_MAC_SLOT_SIZE_10; cfg |= V_MAC_SPEED_SEL_10MBPS; break; case sbmac_speed_100: framecfg |= V_MAC_IFG_RX_100 | V_MAC_IFG_TX_100 | V_MAC_IFG_THRSH_100 | V_MAC_SLOT_SIZE_100; cfg |= V_MAC_SPEED_SEL_100MBPS ; break; case sbmac_speed_1000: framecfg |= V_MAC_IFG_RX_1000 | V_MAC_IFG_TX_1000 | V_MAC_IFG_THRSH_1000 | V_MAC_SLOT_SIZE_1000; cfg |= V_MAC_SPEED_SEL_1000MBPS | M_MAC_BURST_EN; break; default: return 0; } /* * Send the bits back to the hardware */ __raw_writeq(framecfg, s->sbm_framecfg); __raw_writeq(cfg, s->sbm_maccfg); return 1; } /********************************************************************** * SBMAC_SET_DUPLEX(s,duplex,fc) * * Set Ethernet duplex and flow control options for this MAC * Warning: must be called when MAC is off! * * Input parameters: * s - sbmac structure * duplex - duplex setting (see enum sbmac_duplex) * fc - flow control setting (see enum sbmac_fc) * * Return value: * 1 if ok * 0 if an invalid parameter combination was specified ********************************************************************* */ static int sbmac_set_duplex(struct sbmac_softc *s, enum sbmac_duplex duplex, enum sbmac_fc fc) { uint64_t cfg; /* * Save new current values */ s->sbm_duplex = duplex; s->sbm_fc = fc; if (s->sbm_state == sbmac_state_on) return 0; /* save for next restart */ /* * Read current register values */ cfg = __raw_readq(s->sbm_maccfg); /* * Mask off the stuff we're about to change */ cfg &= ~(M_MAC_FC_SEL | M_MAC_FC_CMD | M_MAC_HDX_EN); switch (duplex) { case sbmac_duplex_half: switch (fc) { case sbmac_fc_disabled: cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_DISABLED; break; case sbmac_fc_collision: cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_ENABLED; break; case sbmac_fc_carrier: cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_ENAB_FALSECARR; break; case sbmac_fc_frame: /* not valid in half duplex */ default: /* invalid selection */ return 0; } break; case sbmac_duplex_full: switch (fc) { case sbmac_fc_disabled: cfg |= V_MAC_FC_CMD_DISABLED; break; case sbmac_fc_frame: cfg |= V_MAC_FC_CMD_ENABLED; break; case sbmac_fc_collision: /* not valid in full duplex */ case sbmac_fc_carrier: /* not valid in full duplex */ default: return 0; } break; default: return 0; } /* * Send the bits back to the hardware */ __raw_writeq(cfg, s->sbm_maccfg); return 1; } /********************************************************************** * SBMAC_INTR() * * Interrupt handler for MAC interrupts * * Input parameters: * MAC structure * * Return value: * nothing ********************************************************************* */ static irqreturn_t sbmac_intr(int irq,void *dev_instance) { struct net_device *dev = (struct net_device *) dev_instance; struct sbmac_softc *sc = netdev_priv(dev); uint64_t isr; int handled = 0; /* * Read the ISR (this clears the bits in the real * register, except for counter addr) */ isr = __raw_readq(sc->sbm_isr) & ~M_MAC_COUNTER_ADDR; if (isr == 0) return IRQ_RETVAL(0); handled = 1; /* * Transmits on channel 0 */ if (isr & (M_MAC_INT_CHANNEL << S_MAC_TX_CH0)) sbdma_tx_process(sc,&(sc->sbm_txdma), 0); if (isr & (M_MAC_INT_CHANNEL << S_MAC_RX_CH0)) { if (napi_schedule_prep(&sc->napi)) { __raw_writeq(0, sc->sbm_imr); __napi_schedule(&sc->napi); /* Depend on the exit from poll to reenable intr */ } else { /* may leave some packets behind */ sbdma_rx_process(sc,&(sc->sbm_rxdma), SBMAC_MAX_RXDESCR * 2, 0); } } return IRQ_RETVAL(handled); } /********************************************************************** * SBMAC_START_TX(skb,dev) * * Start output on the specified interface. Basically, we * queue as many buffers as we can until the ring fills up, or * we run off the end of the queue, whichever comes first. * * Input parameters: * * * Return value: * nothing ********************************************************************* */ static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev) { struct sbmac_softc *sc = netdev_priv(dev); unsigned long flags; /* lock eth irq */ spin_lock_irqsave(&sc->sbm_lock, flags); /* * Put the buffer on the transmit ring. If we * don't have room, stop the queue. */ if (sbdma_add_txbuffer(&(sc->sbm_txdma),skb)) { /* XXX save skb that we could not send */ netif_stop_queue(dev); spin_unlock_irqrestore(&sc->sbm_lock, flags); return NETDEV_TX_BUSY; } spin_unlock_irqrestore(&sc->sbm_lock, flags); return NETDEV_TX_OK; } /********************************************************************** * SBMAC_SETMULTI(sc) * * Reprogram the multicast table into the hardware, given * the list of multicasts associated with the interface * structure. * * Input parameters: * sc - softc * * Return value: * nothing ********************************************************************* */ static void sbmac_setmulti(struct sbmac_softc *sc) { uint64_t reg; void __iomem *port; int idx; struct netdev_hw_addr *ha; struct net_device *dev = sc->sbm_dev; /* * Clear out entire multicast table. We do this by nuking * the entire hash table and all the direct matches except * the first one, which is used for our station address */ for (idx = 1; idx < MAC_ADDR_COUNT; idx++) { port = sc->sbm_base + R_MAC_ADDR_BASE+(idx*sizeof(uint64_t)); __raw_writeq(0, port); } for (idx = 0; idx < MAC_HASH_COUNT; idx++) { port = sc->sbm_base + R_MAC_HASH_BASE+(idx*sizeof(uint64_t)); __raw_writeq(0, port); } /* * Clear the filter to say we don't want any multicasts. */ reg = __raw_readq(sc->sbm_rxfilter); reg &= ~(M_MAC_MCAST_INV | M_MAC_MCAST_EN); __raw_writeq(reg, sc->sbm_rxfilter); if (dev->flags & IFF_ALLMULTI) { /* * Enable ALL multicasts. Do this by inverting the * multicast enable bit. */ reg = __raw_readq(sc->sbm_rxfilter); reg |= (M_MAC_MCAST_INV | M_MAC_MCAST_EN); __raw_writeq(reg, sc->sbm_rxfilter); return; } /* * Progam new multicast entries. For now, only use the * perfect filter. In the future we'll need to use the * hash filter if the perfect filter overflows */ /* XXX only using perfect filter for now, need to use hash * XXX if the table overflows */ idx = 1; /* skip station address */ netdev_for_each_mc_addr(ha, dev) { if (idx == MAC_ADDR_COUNT) break; reg = sbmac_addr2reg(ha->addr); port = sc->sbm_base + R_MAC_ADDR_BASE+(idx * sizeof(uint64_t)); __raw_writeq(reg, port); idx++; } /* * Enable the "accept multicast bits" if we programmed at least one * multicast. */ if (idx > 1) { reg = __raw_readq(sc->sbm_rxfilter); reg |= M_MAC_MCAST_EN; __raw_writeq(reg, sc->sbm_rxfilter); } } static int sb1250_change_mtu(struct net_device *_dev, int new_mtu) { if (new_mtu > ENET_PACKET_SIZE) return -EINVAL; _dev->mtu = new_mtu; pr_info("changing the mtu to %d\n", new_mtu); return 0; } static const struct net_device_ops sbmac_netdev_ops = { .ndo_open = sbmac_open, .ndo_stop = sbmac_close, .ndo_start_xmit = sbmac_start_tx, .ndo_set_multicast_list = sbmac_set_rx_mode, .ndo_tx_timeout = sbmac_tx_timeout, .ndo_do_ioctl = sbmac_mii_ioctl, .ndo_change_mtu = sb1250_change_mtu, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = eth_mac_addr, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = sbmac_netpoll, #endif }; /********************************************************************** * SBMAC_INIT(dev) * * Attach routine - init hardware and hook ourselves into linux * * Input parameters: * dev - net_device structure * * Return value: * status ********************************************************************* */ static int sbmac_init(struct platform_device *pldev, long long base) { struct net_device *dev = dev_get_drvdata(&pldev->dev); int idx = pldev->id; struct sbmac_softc *sc = netdev_priv(dev); unsigned char *eaddr; uint64_t ea_reg; int i; int err; sc->sbm_dev = dev; sc->sbe_idx = idx; eaddr = sc->sbm_hwaddr; /* * Read the ethernet address. The firmware left this programmed * for us in the ethernet address register for each mac. */ ea_reg = __raw_readq(sc->sbm_base + R_MAC_ETHERNET_ADDR); __raw_writeq(0, sc->sbm_base + R_MAC_ETHERNET_ADDR); for (i = 0; i < 6; i++) { eaddr[i] = (uint8_t) (ea_reg & 0xFF); ea_reg >>= 8; } for (i = 0; i < 6; i++) { dev->dev_addr[i] = eaddr[i]; } /* * Initialize context (get pointers to registers and stuff), then * allocate the memory for the descriptor tables. */ sbmac_initctx(sc); /* * Set up Linux device callins */ spin_lock_init(&(sc->sbm_lock)); dev->netdev_ops = &sbmac_netdev_ops; dev->watchdog_timeo = TX_TIMEOUT; netif_napi_add(dev, &sc->napi, sbmac_poll, 16); dev->irq = UNIT_INT(idx); /* This is needed for PASS2 for Rx H/W checksum feature */ sbmac_set_iphdr_offset(sc); sc->mii_bus = mdiobus_alloc(); if (sc->mii_bus == NULL) { err = -ENOMEM; goto uninit_ctx; } sc->mii_bus->name = sbmac_mdio_string; snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx); sc->mii_bus->priv = sc; sc->mii_bus->read = sbmac_mii_read; sc->mii_bus->write = sbmac_mii_write; sc->mii_bus->irq = sc->phy_irq; for (i = 0; i < PHY_MAX_ADDR; ++i) sc->mii_bus->irq[i] = SBMAC_PHY_INT; sc->mii_bus->parent = &pldev->dev; /* * Probe PHY address */ err = mdiobus_register(sc->mii_bus); if (err) { printk(KERN_ERR "%s: unable to register MDIO bus\n", dev->name); goto free_mdio; } dev_set_drvdata(&pldev->dev, sc->mii_bus); err = register_netdev(dev); if (err) { printk(KERN_ERR "%s.%d: unable to register netdev\n", sbmac_string, idx); goto unreg_mdio; } pr_info("%s.%d: registered as %s\n", sbmac_string, idx, dev->name); if (sc->rx_hw_checksum == ENABLE) pr_info("%s: enabling TCP rcv checksum\n", dev->name); /* * Display Ethernet address (this is called during the config * process so we need to finish off the config message that * was being displayed) */ pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %pM\n", dev->name, base, eaddr); return 0; unreg_mdio: mdiobus_unregister(sc->mii_bus); dev_set_drvdata(&pldev->dev, NULL); free_mdio: mdiobus_free(sc->mii_bus); uninit_ctx: sbmac_uninitctx(sc); return err; } static int sbmac_open(struct net_device *dev) { struct sbmac_softc *sc = netdev_priv(dev); int err; if (debug > 1) pr_debug("%s: sbmac_open() irq %d.\n", dev->name, dev->irq); /* * map/route interrupt (clear status first, in case something * weird is pending; we haven't initialized the mac registers * yet) */ __raw_readq(sc->sbm_isr); err = request_irq(dev->irq, sbmac_intr, IRQF_SHARED, dev->name, dev); if (err) { printk(KERN_ERR "%s: unable to get IRQ %d\n", dev->name, dev->irq); goto out_err; } sc->sbm_speed = sbmac_speed_none; sc->sbm_duplex = sbmac_duplex_none; sc->sbm_fc = sbmac_fc_none; sc->sbm_pause = -1; sc->sbm_link = 0; /* * Attach to the PHY */ err = sbmac_mii_probe(dev); if (err) goto out_unregister; /* * Turn on the channel */ sbmac_set_channel_state(sc,sbmac_state_on); netif_start_queue(dev); sbmac_set_rx_mode(dev); phy_start(sc->phy_dev); napi_enable(&sc->napi); return 0; out_unregister: free_irq(dev->irq, dev); out_err: return err; } static int sbmac_mii_probe(struct net_device *dev) { struct sbmac_softc *sc = netdev_priv(dev); struct phy_device *phy_dev; int i; for (i = 0; i < PHY_MAX_ADDR; i++) { phy_dev = sc->mii_bus->phy_map[i]; if (phy_dev) break; } if (!phy_dev) { printk(KERN_ERR "%s: no PHY found\n", dev->name); return -ENXIO; } phy_dev = phy_connect(dev, dev_name(&phy_dev->dev), &sbmac_mii_poll, 0, PHY_INTERFACE_MODE_GMII); if (IS_ERR(phy_dev)) { printk(KERN_ERR "%s: could not attach to PHY\n", dev->name); return PTR_ERR(phy_dev); } /* Remove any features not supported by the controller */ phy_dev->supported &= SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg | SUPPORTED_MII | SUPPORTED_Pause | SUPPORTED_Asym_Pause; phy_dev->advertising = phy_dev->supported; pr_info("%s: attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", dev->name, phy_dev->drv->name, dev_name(&phy_dev->dev), phy_dev->irq); sc->phy_dev = phy_dev; return 0; } static void sbmac_mii_poll(struct net_device *dev) { struct sbmac_softc *sc = netdev_priv(dev); struct phy_device *phy_dev = sc->phy_dev; unsigned long flags; enum sbmac_fc fc; int link_chg, speed_chg, duplex_chg, pause_chg, fc_chg; link_chg = (sc->sbm_link != phy_dev->link); speed_chg = (sc->sbm_speed != phy_dev->speed); duplex_chg = (sc->sbm_duplex != phy_dev->duplex); pause_chg = (sc->sbm_pause != phy_dev->pause); if (!link_chg && !speed_chg && !duplex_chg && !pause_chg) return; /* Hmmm... */ if (!phy_dev->link) { if (link_chg) { sc->sbm_link = phy_dev->link; sc->sbm_speed = sbmac_speed_none; sc->sbm_duplex = sbmac_duplex_none; sc->sbm_fc = sbmac_fc_disabled; sc->sbm_pause = -1; pr_info("%s: link unavailable\n", dev->name); } return; } if (phy_dev->duplex == DUPLEX_FULL) { if (phy_dev->pause) fc = sbmac_fc_frame; else fc = sbmac_fc_disabled; } else fc = sbmac_fc_collision; fc_chg = (sc->sbm_fc != fc); pr_info("%s: link available: %dbase-%cD\n", dev->name, phy_dev->speed, phy_dev->duplex == DUPLEX_FULL ? 'F' : 'H'); spin_lock_irqsave(&sc->sbm_lock, flags); sc->sbm_speed = phy_dev->speed; sc->sbm_duplex = phy_dev->duplex; sc->sbm_fc = fc; sc->sbm_pause = phy_dev->pause; sc->sbm_link = phy_dev->link; if ((speed_chg || duplex_chg || fc_chg) && sc->sbm_state != sbmac_state_off) { /* * something changed, restart the channel */ if (debug > 1) pr_debug("%s: restarting channel " "because PHY state changed\n", dev->name); sbmac_channel_stop(sc); sbmac_channel_start(sc); } spin_unlock_irqrestore(&sc->sbm_lock, flags); } static void sbmac_tx_timeout (struct net_device *dev) { struct sbmac_softc *sc = netdev_priv(dev); unsigned long flags; spin_lock_irqsave(&sc->sbm_lock, flags); dev->trans_start = jiffies; /* prevent tx timeout */ dev->stats.tx_errors++; spin_unlock_irqrestore(&sc->sbm_lock, flags); printk (KERN_WARNING "%s: Transmit timed out\n",dev->name); } static void sbmac_set_rx_mode(struct net_device *dev) { unsigned long flags; struct sbmac_softc *sc = netdev_priv(dev); spin_lock_irqsave(&sc->sbm_lock, flags); if ((dev->flags ^ sc->sbm_devflags) & IFF_PROMISC) { /* * Promiscuous changed. */ if (dev->flags & IFF_PROMISC) { sbmac_promiscuous_mode(sc,1); } else { sbmac_promiscuous_mode(sc,0); } } spin_unlock_irqrestore(&sc->sbm_lock, flags); /* * Program the multicasts. Do this every time. */ sbmac_setmulti(sc); } static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct sbmac_softc *sc = netdev_priv(dev); if (!netif_running(dev) || !sc->phy_dev) return -EINVAL; return phy_mii_ioctl(sc->phy_dev, rq, cmd); } static int sbmac_close(struct net_device *dev) { struct sbmac_softc *sc = netdev_priv(dev); napi_disable(&sc->napi); phy_stop(sc->phy_dev); sbmac_set_channel_state(sc, sbmac_state_off); netif_stop_queue(dev); if (debug > 1) pr_debug("%s: Shutting down ethercard\n", dev->name); phy_disconnect(sc->phy_dev); sc->phy_dev = NULL; free_irq(dev->irq, dev); sbdma_emptyring(&(sc->sbm_txdma)); sbdma_emptyring(&(sc->sbm_rxdma)); return 0; } static int sbmac_poll(struct napi_struct *napi, int budget) { struct sbmac_softc *sc = container_of(napi, struct sbmac_softc, napi); int work_done; work_done = sbdma_rx_process(sc, &(sc->sbm_rxdma), budget, 1); sbdma_tx_process(sc, &(sc->sbm_txdma), 1); if (work_done < budget) { napi_complete(napi); #ifdef CONFIG_SBMAC_COALESCE __raw_writeq(((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_TX_CH0) | ((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_RX_CH0), sc->sbm_imr); #else __raw_writeq((M_MAC_INT_CHANNEL << S_MAC_TX_CH0) | (M_MAC_INT_CHANNEL << S_MAC_RX_CH0), sc->sbm_imr); #endif } return work_done; } static int __devinit sbmac_probe(struct platform_device *pldev) { struct net_device *dev; struct sbmac_softc *sc; void __iomem *sbm_base; struct resource *res; u64 sbmac_orig_hwaddr; int err; res = platform_get_resource(pldev, IORESOURCE_MEM, 0); BUG_ON(!res); sbm_base = ioremap_nocache(res->start, res->end - res->start + 1); if (!sbm_base) { printk(KERN_ERR "%s: unable to map device registers\n", dev_name(&pldev->dev)); err = -ENOMEM; goto out_out; } /* * The R_MAC_ETHERNET_ADDR register will be set to some nonzero * value for us by the firmware if we're going to use this MAC. * If we find a zero, skip this MAC. */ sbmac_orig_hwaddr = __raw_readq(sbm_base + R_MAC_ETHERNET_ADDR); pr_debug("%s: %sconfiguring MAC at 0x%08Lx\n", dev_name(&pldev->dev), sbmac_orig_hwaddr ? "" : "not ", (long long)res->start); if (sbmac_orig_hwaddr == 0) { err = 0; goto out_unmap; } /* * Okay, cool. Initialize this MAC. */ dev = alloc_etherdev(sizeof(struct sbmac_softc)); if (!dev) { printk(KERN_ERR "%s: unable to allocate etherdev\n", dev_name(&pldev->dev)); err = -ENOMEM; goto out_unmap; } dev_set_drvdata(&pldev->dev, dev); SET_NETDEV_DEV(dev, &pldev->dev); sc = netdev_priv(dev); sc->sbm_base = sbm_base; err = sbmac_init(pldev, res->start); if (err) goto out_kfree; return 0; out_kfree: free_netdev(dev); __raw_writeq(sbmac_orig_hwaddr, sbm_base + R_MAC_ETHERNET_ADDR); out_unmap: iounmap(sbm_base); out_out: return err; } static int __exit sbmac_remove(struct platform_device *pldev) { struct net_device *dev = dev_get_drvdata(&pldev->dev); struct sbmac_softc *sc = netdev_priv(dev); unregister_netdev(dev); sbmac_uninitctx(sc); mdiobus_unregister(sc->mii_bus); mdiobus_free(sc->mii_bus); iounmap(sc->sbm_base); free_netdev(dev); return 0; } static struct platform_driver sbmac_driver = { .probe = sbmac_probe, .remove = __exit_p(sbmac_remove), .driver = { .name = sbmac_string, .owner = THIS_MODULE, }, }; static int __init sbmac_init_module(void) { return platform_driver_register(&sbmac_driver); } static void __exit sbmac_cleanup_module(void) { platform_driver_unregister(&sbmac_driver); } module_init(sbmac_init_module); module_exit(sbmac_cleanup_module);
gpl-2.0
linux-shield/kernel
arch/powerpc/perf/hv-gpci.c
373
7046
/* * Hypervisor supplied "gpci" ("get performance counter info") performance * counter support * * Author: Cody P Schafer <cody@linux.vnet.ibm.com> * Copyright 2014 IBM Corporation. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #define pr_fmt(fmt) "hv-gpci: " fmt #include <linux/init.h> #include <linux/perf_event.h> #include <asm/firmware.h> #include <asm/hvcall.h> #include <asm/io.h> #include "hv-gpci.h" #include "hv-common.h" /* * Example usage: * perf stat -e 'hv_gpci/counter_info_version=3,offset=0,length=8, * secondary_index=0,starting_index=0xffffffff,request=0x10/' ... */ /* u32 */ EVENT_DEFINE_RANGE_FORMAT(request, config, 0, 31); /* u32 */ EVENT_DEFINE_RANGE_FORMAT(starting_index, config, 32, 63); /* u16 */ EVENT_DEFINE_RANGE_FORMAT(secondary_index, config1, 0, 15); /* u8 */ EVENT_DEFINE_RANGE_FORMAT(counter_info_version, config1, 16, 23); /* u8, bytes of data (1-8) */ EVENT_DEFINE_RANGE_FORMAT(length, config1, 24, 31); /* u32, byte offset */ EVENT_DEFINE_RANGE_FORMAT(offset, config1, 32, 63); static struct attribute *format_attrs[] = { &format_attr_request.attr, &format_attr_starting_index.attr, &format_attr_secondary_index.attr, &format_attr_counter_info_version.attr, &format_attr_offset.attr, &format_attr_length.attr, NULL, }; static struct attribute_group format_group = { .name = "format", .attrs = format_attrs, }; #define HV_CAPS_ATTR(_name, _format) \ static ssize_t _name##_show(struct device *dev, \ struct device_attribute *attr, \ char *page) \ { \ struct hv_perf_caps caps; \ unsigned long hret = hv_perf_caps_get(&caps); \ if (hret) \ return -EIO; \ \ return sprintf(page, _format, caps._name); \ } \ static struct device_attribute hv_caps_attr_##_name = __ATTR_RO(_name) static ssize_t kernel_version_show(struct device *dev, struct device_attribute *attr, char *page) { return sprintf(page, "0x%x\n", COUNTER_INFO_VERSION_CURRENT); } static DEVICE_ATTR_RO(kernel_version); HV_CAPS_ATTR(version, "0x%x\n"); HV_CAPS_ATTR(ga, "%d\n"); HV_CAPS_ATTR(expanded, "%d\n"); HV_CAPS_ATTR(lab, "%d\n"); HV_CAPS_ATTR(collect_privileged, "%d\n"); static struct attribute *interface_attrs[] = { &dev_attr_kernel_version.attr, &hv_caps_attr_version.attr, &hv_caps_attr_ga.attr, &hv_caps_attr_expanded.attr, &hv_caps_attr_lab.attr, &hv_caps_attr_collect_privileged.attr, NULL, }; static struct attribute_group interface_group = { .name = "interface", .attrs = interface_attrs, }; static const struct attribute_group *attr_groups[] = { &format_group, &interface_group, NULL, }; #define GPCI_MAX_DATA_BYTES \ (1024 - sizeof(struct hv_get_perf_counter_info_params)) static unsigned long single_gpci_request(u32 req, u32 starting_index, u16 secondary_index, u8 version_in, u32 offset, u8 length, u64 *value) { unsigned long ret; size_t i; u64 count; struct { struct hv_get_perf_counter_info_params params; uint8_t bytes[GPCI_MAX_DATA_BYTES]; } __packed __aligned(sizeof(uint64_t)) arg = { .params = { .counter_request = cpu_to_be32(req), .starting_index = cpu_to_be32(starting_index), .secondary_index = cpu_to_be16(secondary_index), .counter_info_version_in = version_in, } }; ret = plpar_hcall_norets(H_GET_PERF_COUNTER_INFO, virt_to_phys(&arg), sizeof(arg)); if (ret) { pr_devel("hcall failed: 0x%lx\n", ret); return ret; } /* * we verify offset and length are within the zeroed buffer at event * init. */ count = 0; for (i = offset; i < offset + length; i++) count |= arg.bytes[i] << (i - offset); *value = count; return ret; } static u64 h_gpci_get_value(struct perf_event *event) { u64 count; unsigned long ret = single_gpci_request(event_get_request(event), event_get_starting_index(event), event_get_secondary_index(event), event_get_counter_info_version(event), event_get_offset(event), event_get_length(event), &count); if (ret) return 0; return count; } static void h_gpci_event_update(struct perf_event *event) { s64 prev; u64 now = h_gpci_get_value(event); prev = local64_xchg(&event->hw.prev_count, now); local64_add(now - prev, &event->count); } static void h_gpci_event_start(struct perf_event *event, int flags) { local64_set(&event->hw.prev_count, h_gpci_get_value(event)); } static void h_gpci_event_stop(struct perf_event *event, int flags) { h_gpci_event_update(event); } static int h_gpci_event_add(struct perf_event *event, int flags) { if (flags & PERF_EF_START) h_gpci_event_start(event, flags); return 0; } static int h_gpci_event_init(struct perf_event *event) { u64 count; u8 length; /* Not our event */ if (event->attr.type != event->pmu->type) return -ENOENT; /* config2 is unused */ if (event->attr.config2) { pr_devel("config2 set when reserved\n"); return -EINVAL; } /* unsupported modes and filters */ if (event->attr.exclude_user || event->attr.exclude_kernel || event->attr.exclude_hv || event->attr.exclude_idle || event->attr.exclude_host || event->attr.exclude_guest) return -EINVAL; /* no branch sampling */ if (has_branch_stack(event)) return -EOPNOTSUPP; length = event_get_length(event); if (length < 1 || length > 8) { pr_devel("length invalid\n"); return -EINVAL; } /* last byte within the buffer? */ if ((event_get_offset(event) + length) > GPCI_MAX_DATA_BYTES) { pr_devel("request outside of buffer: %zu > %zu\n", (size_t)event_get_offset(event) + length, GPCI_MAX_DATA_BYTES); return -EINVAL; } /* check if the request works... */ if (single_gpci_request(event_get_request(event), event_get_starting_index(event), event_get_secondary_index(event), event_get_counter_info_version(event), event_get_offset(event), length, &count)) { pr_devel("gpci hcall failed\n"); return -EINVAL; } return 0; } static struct pmu h_gpci_pmu = { .task_ctx_nr = perf_invalid_context, .name = "hv_gpci", .attr_groups = attr_groups, .event_init = h_gpci_event_init, .add = h_gpci_event_add, .del = h_gpci_event_stop, .start = h_gpci_event_start, .stop = h_gpci_event_stop, .read = h_gpci_event_update, }; static int hv_gpci_init(void) { int r; unsigned long hret; struct hv_perf_caps caps; if (!firmware_has_feature(FW_FEATURE_LPAR)) { pr_debug("not a virtualized system, not enabling\n"); return -ENODEV; } hret = hv_perf_caps_get(&caps); if (hret) { pr_debug("could not obtain capabilities, not enabling, rc=%ld\n", hret); return -ENODEV; } /* sampling not supported */ h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; r = perf_pmu_register(&h_gpci_pmu, h_gpci_pmu.name, -1); if (r) return r; return 0; } device_initcall(hv_gpci_init);
gpl-2.0
messi2050/android_kernel_huawei_msm8610
drivers/video/msm/msm_fb.c
1397
109622
/* drivers/video/msm/msm_fb.c * * Core MSM framebuffer driver. * * Copyright (C) 2007 Google Incorporated * Copyright (c) 2008-2013, The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * 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. */ #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/mm.h> #include <linux/fb.h> #include <linux/msm_mdp.h> #include <linux/init.h> #include <linux/ioport.h> #include <linux/device.h> #include <linux/dma-mapping.h> #include <mach/board.h> #include <linux/uaccess.h> #include <mach/iommu_domains.h> #include <linux/workqueue.h> #include <linux/string.h> #include <linux/version.h> #include <linux/proc_fs.h> #include <linux/vmalloc.h> #include <linux/debugfs.h> #include <linux/console.h> #include <linux/leds.h> #include <linux/pm_runtime.h> #include <linux/sync.h> #include <linux/sw_sync.h> #include <linux/file.h> #define MSM_FB_C #include "msm_fb.h" #include "mddihosti.h" #include "tvenc.h" #include "mdp.h" #include "mdp4.h" #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER #define MSM_FB_NUM 3 #endif static unsigned char *fbram; static unsigned char *fbram_phys; static int fbram_size; static boolean bf_supported; /* Set backlight on resume after 50 ms after first * pan display on the panel. This is to avoid panel specific * transients during resume. */ unsigned long backlight_duration = (HZ/20); static struct platform_device *pdev_list[MSM_FB_MAX_DEV_LIST]; static int pdev_list_cnt; int vsync_mode = 1; #define MAX_BLIT_REQ 256 #define MAX_FBI_LIST 32 static struct fb_info *fbi_list[MAX_FBI_LIST]; static int fbi_list_index; static struct msm_fb_data_type *mfd_list[MAX_FBI_LIST]; static int mfd_list_index; static u32 msm_fb_pseudo_palette[16] = { 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; static struct ion_client *iclient; u32 msm_fb_debug_enabled; /* Setting msm_fb_msg_level to 8 prints out ALL messages */ u32 msm_fb_msg_level = 7; /* Setting mddi_msg_level to 8 prints out ALL messages */ u32 mddi_msg_level = 5; extern int32 mdp_block_power_cnt[MDP_MAX_BLOCK]; extern unsigned long mdp_timer_duration; static int msm_fb_register(struct msm_fb_data_type *mfd); static int msm_fb_open(struct fb_info *info, int user); static int msm_fb_release(struct fb_info *info, int user); static int msm_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info); static int msm_fb_stop_sw_refresher(struct msm_fb_data_type *mfd); int msm_fb_resume_sw_refresher(struct msm_fb_data_type *mfd); static int msm_fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info); static int msm_fb_set_par(struct fb_info *info); static int msm_fb_blank_sub(int blank_mode, struct fb_info *info, boolean op_enable); static int msm_fb_suspend_sub(struct msm_fb_data_type *mfd); static int msm_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg); static int msm_fb_mmap(struct fb_info *info, struct vm_area_struct * vma); static int mdp_bl_scale_config(struct msm_fb_data_type *mfd, struct mdp_bl_scale_data *data); static void msm_fb_scale_bl(__u32 *bl_lvl); static void msm_fb_commit_wq_handler(struct work_struct *work); static int msm_fb_pan_idle(struct msm_fb_data_type *mfd); #ifdef MSM_FB_ENABLE_DBGFS #define MSM_FB_MAX_DBGFS 1024 #define MAX_BACKLIGHT_BRIGHTNESS 255 /* 200 ms for time out */ #define WAIT_FENCE_TIMEOUT 200 int msm_fb_debugfs_file_index; struct dentry *msm_fb_debugfs_root; struct dentry *msm_fb_debugfs_file[MSM_FB_MAX_DBGFS]; static int bl_scale, bl_min_lvl; DEFINE_MUTEX(msm_fb_notify_update_sem); void msmfb_no_update_notify_timer_cb(unsigned long data) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)data; if (!mfd) pr_err("%s mfd NULL\n", __func__); complete(&mfd->msmfb_no_update_notify); } struct dentry *msm_fb_get_debugfs_root(void) { if (msm_fb_debugfs_root == NULL) msm_fb_debugfs_root = debugfs_create_dir("msm_fb", NULL); return msm_fb_debugfs_root; } void msm_fb_debugfs_file_create(struct dentry *root, const char *name, u32 *var) { if (msm_fb_debugfs_file_index >= MSM_FB_MAX_DBGFS) return; msm_fb_debugfs_file[msm_fb_debugfs_file_index++] = debugfs_create_u32(name, S_IRUGO | S_IWUSR, root, var); } #endif int msm_fb_cursor(struct fb_info *info, struct fb_cursor *cursor) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; if (!mfd->cursor_update) return -ENODEV; return mfd->cursor_update(info, cursor); } static int msm_fb_resource_initialized; #ifndef CONFIG_FB_BACKLIGHT static int lcd_backlight_registered; static void msm_fb_set_bl_brightness(struct led_classdev *led_cdev, enum led_brightness value) { struct msm_fb_data_type *mfd = dev_get_drvdata(led_cdev->dev->parent); int bl_lvl; if (value > MAX_BACKLIGHT_BRIGHTNESS) value = MAX_BACKLIGHT_BRIGHTNESS; /* This maps android backlight level 0 to 255 into driver backlight level 0 to bl_max with rounding */ bl_lvl = (2 * value * mfd->panel_info.bl_max + MAX_BACKLIGHT_BRIGHTNESS) /(2 * MAX_BACKLIGHT_BRIGHTNESS); if (!bl_lvl && value) bl_lvl = 1; down(&mfd->sem); msm_fb_set_backlight(mfd, bl_lvl); up(&mfd->sem); } static struct led_classdev backlight_led = { .name = "lcd-backlight", .brightness = MAX_BACKLIGHT_BRIGHTNESS, .brightness_set = msm_fb_set_bl_brightness, }; #endif static struct msm_fb_platform_data *msm_fb_pdata; unsigned char hdmi_prim_display; unsigned char hdmi_prim_resolution; int msm_fb_detect_client(const char *name) { int ret = 0; u32 len; #ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT u32 id; #endif if (!msm_fb_pdata) return -EPERM; len = strnlen(name, PANEL_NAME_MAX_LEN); if (strnlen(msm_fb_pdata->prim_panel_name, PANEL_NAME_MAX_LEN)) { pr_err("\n name = %s, prim_display = %s", name, msm_fb_pdata->prim_panel_name); if (!strncmp((char *)msm_fb_pdata->prim_panel_name, name, len)) { if (!strncmp((char *)msm_fb_pdata->prim_panel_name, "hdmi_msm", len)) hdmi_prim_display = 1; hdmi_prim_resolution = msm_fb_pdata->ext_resolution; return 0; } else { ret = -EPERM; } } if (strnlen(msm_fb_pdata->ext_panel_name, PANEL_NAME_MAX_LEN)) { pr_err("\n name = %s, ext_display = %s", name, msm_fb_pdata->ext_panel_name); if (!strncmp((char *)msm_fb_pdata->ext_panel_name, name, len)) return 0; else ret = -EPERM; } if (ret) return ret; ret = -EPERM; if (msm_fb_pdata && msm_fb_pdata->detect_client) { ret = msm_fb_pdata->detect_client(name); /* if it's non mddi panel, we need to pre-scan mddi client to see if we can disable mddi host */ #ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT if (!ret && msm_fb_pdata->mddi_prescan) id = mddi_get_client_id(); #endif } return ret; } static ssize_t msm_fb_msm_fb_type(struct device *dev, struct device_attribute *attr, char *buf) { ssize_t ret = 0; struct fb_info *fbi = dev_get_drvdata(dev); struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)fbi->par; struct msm_fb_panel_data *pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; switch (pdata->panel_info.type) { case NO_PANEL: ret = snprintf(buf, PAGE_SIZE, "no panel\n"); break; case MDDI_PANEL: ret = snprintf(buf, PAGE_SIZE, "mddi panel\n"); break; case EBI2_PANEL: ret = snprintf(buf, PAGE_SIZE, "ebi2 panel\n"); break; case LCDC_PANEL: ret = snprintf(buf, PAGE_SIZE, "lcdc panel\n"); break; case EXT_MDDI_PANEL: ret = snprintf(buf, PAGE_SIZE, "ext mddi panel\n"); break; case TV_PANEL: ret = snprintf(buf, PAGE_SIZE, "tv panel\n"); break; case HDMI_PANEL: ret = snprintf(buf, PAGE_SIZE, "hdmi panel\n"); break; case LVDS_PANEL: ret = snprintf(buf, PAGE_SIZE, "lvds panel\n"); break; case DTV_PANEL: ret = snprintf(buf, PAGE_SIZE, "dtv panel\n"); break; case MIPI_VIDEO_PANEL: ret = snprintf(buf, PAGE_SIZE, "mipi dsi video panel\n"); break; case MIPI_CMD_PANEL: ret = snprintf(buf, PAGE_SIZE, "mipi dsi cmd panel\n"); break; case WRITEBACK_PANEL: ret = snprintf(buf, PAGE_SIZE, "writeback panel\n"); break; default: ret = snprintf(buf, PAGE_SIZE, "unknown panel\n"); break; } return ret; } static DEVICE_ATTR(msm_fb_type, S_IRUGO, msm_fb_msm_fb_type, NULL); static struct attribute *msm_fb_attrs[] = { &dev_attr_msm_fb_type.attr, NULL, }; static struct attribute_group msm_fb_attr_group = { .attrs = msm_fb_attrs, }; static int msm_fb_create_sysfs(struct platform_device *pdev) { int rc; struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); rc = sysfs_create_group(&mfd->fbi->dev->kobj, &msm_fb_attr_group); if (rc) MSM_FB_ERR("%s: sysfs group creation failed, rc=%d\n", __func__, rc); return rc; } static void msm_fb_remove_sysfs(struct platform_device *pdev) { struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); sysfs_remove_group(&mfd->fbi->dev->kobj, &msm_fb_attr_group); } static void bl_workqueue_handler(struct work_struct *work); static int msm_fb_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; int rc; int err = 0; MSM_FB_DEBUG("msm_fb_probe\n"); if ((pdev->id == 0) && (pdev->num_resources > 0)) { msm_fb_pdata = pdev->dev.platform_data; fbram_size = pdev->resource[0].end - pdev->resource[0].start + 1; fbram_phys = (char *)pdev->resource[0].start; fbram = __va(fbram_phys); if (!fbram) { printk(KERN_ERR "fbram ioremap failed!\n"); return -ENOMEM; } MSM_FB_DEBUG("msm_fb_probe: phy_Addr = 0x%x virt = 0x%x\n", (int)fbram_phys, (int)fbram); iclient = msm_ion_client_create(-1, pdev->name); if (IS_ERR_OR_NULL(iclient)) { pr_err("msm_ion_client_create() return" " error, val %p\n", iclient); iclient = NULL; } msm_fb_resource_initialized = 1; return 0; } if (!msm_fb_resource_initialized) return -EPERM; mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); INIT_DELAYED_WORK(&mfd->backlight_worker, bl_workqueue_handler); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; vsync_cntrl.dev = mfd->fbi->dev; mfd->panel_info.frame_count = 0; mfd->bl_level = 0; bl_scale = 1024; bl_min_lvl = 255; #ifdef CONFIG_FB_MSM_OVERLAY mfd->overlay_play_enable = 1; #endif bf_supported = mdp4_overlay_borderfill_supported(); rc = msm_fb_register(mfd); if (rc) return rc; err = pm_runtime_set_active(mfd->fbi->dev); if (err < 0) printk(KERN_ERR "pm_runtime: fail to set active.\n"); pm_runtime_enable(mfd->fbi->dev); #ifdef CONFIG_FB_BACKLIGHT msm_fb_config_backlight(mfd); #else /* android supports only one lcd-backlight/lcd for now */ if (!lcd_backlight_registered) { if (led_classdev_register(&pdev->dev, &backlight_led)) printk(KERN_ERR "led_classdev_register failed\n"); else lcd_backlight_registered = 1; } #endif pdev_list[pdev_list_cnt++] = pdev; msm_fb_create_sysfs(pdev); if (mfd->timeline == NULL) { mfd->timeline = sw_sync_timeline_create("mdp-timeline"); if (mfd->timeline == NULL) { pr_err("%s: cannot create time line", __func__); return -ENOMEM; } else { mfd->timeline_value = 0; } } return 0; } static int msm_fb_remove(struct platform_device *pdev) { struct msm_fb_data_type *mfd; MSM_FB_DEBUG("msm_fb_remove\n"); mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); msm_fb_remove_sysfs(pdev); pm_runtime_disable(mfd->fbi->dev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (msm_fb_suspend_sub(mfd)) printk(KERN_ERR "msm_fb_remove: can't stop the device %d\n", mfd->index); if (mfd->channel_irq != 0) free_irq(mfd->channel_irq, (void *)mfd); if (mfd->vsync_width_boundary) vfree(mfd->vsync_width_boundary); if (mfd->vsync_resync_timer.function) del_timer(&mfd->vsync_resync_timer); if (mfd->refresh_timer.function) del_timer(&mfd->refresh_timer); if (mfd->dma_hrtimer.function) hrtimer_cancel(&mfd->dma_hrtimer); if (mfd->msmfb_no_update_notify_timer.function) del_timer(&mfd->msmfb_no_update_notify_timer); complete(&mfd->msmfb_no_update_notify); complete(&mfd->msmfb_update_notify); /* remove /dev/fb* */ unregister_framebuffer(mfd->fbi); #ifdef CONFIG_FB_BACKLIGHT /* remove /sys/class/backlight */ backlight_device_unregister(mfd->fbi->bl_dev); #else if (lcd_backlight_registered) { lcd_backlight_registered = 0; led_classdev_unregister(&backlight_led); } #endif #ifdef MSM_FB_ENABLE_DBGFS if (mfd->sub_dir) debugfs_remove(mfd->sub_dir); #endif return 0; } #if defined(CONFIG_PM) && !defined(CONFIG_HAS_EARLYSUSPEND) static int msm_fb_suspend(struct platform_device *pdev, pm_message_t state) { struct msm_fb_data_type *mfd; int ret = 0; MSM_FB_DEBUG("msm_fb_suspend\n"); mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); if ((!mfd) || (mfd->key != MFD_KEY)) return 0; console_lock(); fb_set_suspend(mfd->fbi, FBINFO_STATE_SUSPENDED); ret = msm_fb_suspend_sub(mfd); if (ret != 0) { printk(KERN_ERR "msm_fb: failed to suspend! %d\n", ret); fb_set_suspend(mfd->fbi, FBINFO_STATE_RUNNING); } else { pdev->dev.power.power_state = state; } console_unlock(); return ret; } #else #define msm_fb_suspend NULL #endif static int msm_fb_suspend_sub(struct msm_fb_data_type *mfd) { int ret = 0; if ((!mfd) || (mfd->key != MFD_KEY)) return 0; if (mfd->msmfb_no_update_notify_timer.function) del_timer(&mfd->msmfb_no_update_notify_timer); complete(&mfd->msmfb_no_update_notify); /* * suspend this channel */ mfd->suspend.sw_refreshing_enable = mfd->sw_refreshing_enable; mfd->suspend.op_enable = mfd->op_enable; mfd->suspend.panel_power_on = mfd->panel_power_on; mfd->suspend.op_suspend = true; if (mfd->op_enable) { ret = msm_fb_blank_sub(FB_BLANK_POWERDOWN, mfd->fbi, mfd->suspend.op_enable); if (ret) { MSM_FB_INFO ("msm_fb_suspend: can't turn off display!\n"); return ret; } mfd->op_enable = FALSE; } /* * try to power down */ mdp_pipe_ctrl(MDP_MASTER_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); /* * detach display channel irq if there's any * or wait until vsync-resync completes */ if ((mfd->dest == DISPLAY_LCD)) { if (mfd->panel_info.lcd.vsync_enable) { if (mfd->panel_info.lcd.hw_vsync_mode) { if (mfd->channel_irq != 0) disable_irq(mfd->channel_irq); } else { volatile boolean vh_pending; do { vh_pending = mfd->vsync_handler_pending; } while (vh_pending); } } } return 0; } #ifdef CONFIG_PM static int msm_fb_resume_sub(struct msm_fb_data_type *mfd) { int ret = 0; struct msm_fb_panel_data *pdata = NULL; if ((!mfd) || (mfd->key != MFD_KEY)) return 0; pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; /* attach display channel irq if there's any */ if (mfd->channel_irq != 0) enable_irq(mfd->channel_irq); /* resume state var recover */ mfd->sw_refreshing_enable = mfd->suspend.sw_refreshing_enable; mfd->op_enable = mfd->suspend.op_enable; if (mfd->suspend.panel_power_on) { ret = msm_fb_blank_sub(FB_BLANK_UNBLANK, mfd->fbi, mfd->op_enable); if (ret) MSM_FB_INFO("msm_fb_resume: can't turn on display!\n"); } mfd->suspend.op_suspend = false; return ret; } #endif #if defined(CONFIG_PM) && !defined(CONFIG_HAS_EARLYSUSPEND) static int msm_fb_resume(struct platform_device *pdev) { /* This resume function is called when interrupt is enabled. */ int ret = 0; struct msm_fb_data_type *mfd; MSM_FB_DEBUG("msm_fb_resume\n"); mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); if ((!mfd) || (mfd->key != MFD_KEY)) return 0; console_lock(); ret = msm_fb_resume_sub(mfd); pdev->dev.power.power_state = PMSG_ON; fb_set_suspend(mfd->fbi, FBINFO_STATE_RUNNING); console_unlock(); return ret; } #else #define msm_fb_resume NULL #endif static int msm_fb_runtime_suspend(struct device *dev) { dev_dbg(dev, "pm_runtime: suspending...\n"); return 0; } static int msm_fb_runtime_resume(struct device *dev) { dev_dbg(dev, "pm_runtime: resuming...\n"); return 0; } static int msm_fb_runtime_idle(struct device *dev) { dev_dbg(dev, "pm_runtime: idling...\n"); return 0; } #if (defined(CONFIG_SUSPEND) && defined(CONFIG_FB_MSM_HDMI_MSM_PANEL)) static int msm_fb_ext_suspend(struct device *dev) { struct msm_fb_data_type *mfd = dev_get_drvdata(dev); struct msm_fb_panel_data *pdata = NULL; int ret = 0; if ((!mfd) || (mfd->key != MFD_KEY)) return 0; pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; if (mfd->panel_info.type == HDMI_PANEL || mfd->panel_info.type == DTV_PANEL) { ret = msm_fb_suspend_sub(mfd); /* Turn off the HPD circuitry */ if (pdata->power_ctrl) { MSM_FB_INFO("%s: Turning off HPD circuitry\n", __func__); pdata->power_ctrl(FALSE); } } return ret; } static int msm_fb_ext_resume(struct device *dev) { struct msm_fb_data_type *mfd = dev_get_drvdata(dev); struct msm_fb_panel_data *pdata = NULL; int ret = 0; if ((!mfd) || (mfd->key != MFD_KEY)) return 0; pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; if (mfd->panel_info.type == HDMI_PANEL || mfd->panel_info.type == DTV_PANEL) { /* Turn on the HPD circuitry */ if (pdata->power_ctrl) { pdata->power_ctrl(TRUE); MSM_FB_INFO("%s: Turning on HPD circuitry\n", __func__); } ret = msm_fb_resume_sub(mfd); } return ret; } #endif static struct dev_pm_ops msm_fb_dev_pm_ops = { .runtime_suspend = msm_fb_runtime_suspend, .runtime_resume = msm_fb_runtime_resume, .runtime_idle = msm_fb_runtime_idle, #if (defined(CONFIG_SUSPEND) && defined(CONFIG_FB_MSM_HDMI_MSM_PANEL)) .suspend = msm_fb_ext_suspend, .resume = msm_fb_ext_resume, #endif }; static struct platform_driver msm_fb_driver = { .probe = msm_fb_probe, .remove = msm_fb_remove, #ifndef CONFIG_HAS_EARLYSUSPEND .suspend = msm_fb_suspend, .resume = msm_fb_resume, #endif .shutdown = NULL, .driver = { /* Driver name must match the device name added in platform.c. */ .name = "msm_fb", .pm = &msm_fb_dev_pm_ops, }, }; #ifdef CONFIG_HAS_EARLYSUSPEND static void msmfb_early_suspend(struct early_suspend *h) { struct msm_fb_data_type *mfd = container_of(h, struct msm_fb_data_type, early_suspend); msm_fb_suspend_sub(mfd); } static void msmfb_early_resume(struct early_suspend *h) { struct msm_fb_data_type *mfd = container_of(h, struct msm_fb_data_type, early_suspend); msm_fb_resume_sub(mfd); } #endif static int unset_bl_level, bl_updated; static int bl_level_old; static int mdp_bl_scale_config(struct msm_fb_data_type *mfd, struct mdp_bl_scale_data *data) { int ret = 0; int curr_bl; down(&mfd->sem); curr_bl = mfd->bl_level; bl_scale = data->scale; bl_min_lvl = data->min_lvl; pr_debug("%s: update scale = %d, min_lvl = %d\n", __func__, bl_scale, bl_min_lvl); /* update current backlight to use new scaling*/ msm_fb_set_backlight(mfd, curr_bl); up(&mfd->sem); return ret; } static void msm_fb_scale_bl(__u32 *bl_lvl) { __u32 temp = *bl_lvl; pr_debug("%s: input = %d, scale = %d", __func__, temp, bl_scale); if (temp >= bl_min_lvl) { /* bl_scale is the numerator of scaling fraction (x/1024)*/ temp = ((*bl_lvl) * bl_scale) / 1024; /*if less than minimum level, use min level*/ if (temp < bl_min_lvl) temp = bl_min_lvl; } pr_debug("%s: output = %d", __func__, temp); (*bl_lvl) = temp; } /*must call this function from within mfd->sem*/ void msm_fb_set_backlight(struct msm_fb_data_type *mfd, __u32 bkl_lvl) { struct msm_fb_panel_data *pdata; __u32 temp = bkl_lvl; if (!mfd->panel_power_on || !bl_updated) { unset_bl_level = bkl_lvl; return; } else { unset_bl_level = 0; } pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; if ((pdata) && (pdata->set_backlight)) { msm_fb_scale_bl(&temp); if (bl_level_old == temp) { return; } mfd->bl_level = temp; pdata->set_backlight(mfd); mfd->bl_level = bkl_lvl; bl_level_old = temp; } } static int msm_fb_blank_sub(int blank_mode, struct fb_info *info, boolean op_enable) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; struct msm_fb_panel_data *pdata = NULL; int ret = 0; if (!op_enable) return -EPERM; pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; if ((!pdata) || (!pdata->on) || (!pdata->off)) { printk(KERN_ERR "msm_fb_blank_sub: no panel operation detected!\n"); return -ENODEV; } switch (blank_mode) { case FB_BLANK_UNBLANK: if (!mfd->panel_power_on) { msleep(16); ret = pdata->on(mfd->pdev); if (ret == 0) { mfd->panel_power_on = TRUE; /* ToDo: possible conflict with android which doesn't expect sw refresher */ /* if (!mfd->hw_refresh) { if ((ret = msm_fb_resume_sw_refresher(mfd)) != 0) { MSM_FB_INFO("msm_fb_blank_sub: msm_fb_resume_sw_refresher failed = %d!\n",ret); } } */ } } break; case FB_BLANK_VSYNC_SUSPEND: case FB_BLANK_HSYNC_SUSPEND: case FB_BLANK_NORMAL: case FB_BLANK_POWERDOWN: default: if (mfd->panel_power_on) { int curr_pwr_state; mfd->op_enable = FALSE; curr_pwr_state = mfd->panel_power_on; mfd->panel_power_on = FALSE; cancel_delayed_work_sync(&mfd->backlight_worker); bl_updated = 0; msleep(16); ret = pdata->off(mfd->pdev); if (ret) mfd->panel_power_on = curr_pwr_state; if (mfd->timeline) { /* Adding 1 is enough when pan_display is still * a blocking call and with mutex protection. * But if it is an async call, we will still * need to add 2. Adding 2 can be safer in * order to signal all existing fences, and it * is harmless. */ sw_sync_timeline_inc(mfd->timeline, 2); mfd->timeline_value += 2; } mfd->op_enable = TRUE; } break; } return ret; } int calc_fb_offset(struct msm_fb_data_type *mfd, struct fb_info *fbi, int bpp) { struct msm_panel_info *panel_info = &mfd->panel_info; int remainder, yres, offset; if (panel_info->mode2_yres != 0) { yres = panel_info->mode2_yres; remainder = (fbi->fix.line_length*yres) & (PAGE_SIZE - 1); } else { yres = panel_info->yres; remainder = (fbi->fix.line_length*yres) & (PAGE_SIZE - 1); } if (!remainder) remainder = PAGE_SIZE; if (fbi->var.yoffset < yres) { offset = (fbi->var.xoffset * bpp); /* iBuf->buf += fbi->var.xoffset * bpp + 0 * yres * fbi->fix.line_length; */ } else if (fbi->var.yoffset >= yres && fbi->var.yoffset < 2 * yres) { offset = (fbi->var.xoffset * bpp + yres * fbi->fix.line_length + PAGE_SIZE - remainder); } else { offset = (fbi->var.xoffset * bpp + 2 * yres * fbi->fix.line_length + 2 * (PAGE_SIZE - remainder)); } return offset; } static void msm_fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; msm_fb_pan_idle(mfd); cfb_fillrect(info, rect); if (!mfd->hw_refresh && (info->var.yoffset == 0) && !mfd->sw_currently_refreshing) { struct fb_var_screeninfo var; var = info->var; var.reserved[0] = 0x54445055; var.reserved[1] = (rect->dy << 16) | (rect->dx); var.reserved[2] = ((rect->dy + rect->height) << 16) | (rect->dx + rect->width); msm_fb_pan_display(&var, info); } } static void msm_fb_copyarea(struct fb_info *info, const struct fb_copyarea *area) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; msm_fb_pan_idle(mfd); cfb_copyarea(info, area); if (!mfd->hw_refresh && (info->var.yoffset == 0) && !mfd->sw_currently_refreshing) { struct fb_var_screeninfo var; var = info->var; var.reserved[0] = 0x54445055; var.reserved[1] = (area->dy << 16) | (area->dx); var.reserved[2] = ((area->dy + area->height) << 16) | (area->dx + area->width); msm_fb_pan_display(&var, info); } } static void msm_fb_imageblit(struct fb_info *info, const struct fb_image *image) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; msm_fb_pan_idle(mfd); cfb_imageblit(info, image); if (!mfd->hw_refresh && (info->var.yoffset == 0) && !mfd->sw_currently_refreshing) { struct fb_var_screeninfo var; var = info->var; var.reserved[0] = 0x54445055; var.reserved[1] = (image->dy << 16) | (image->dx); var.reserved[2] = ((image->dy + image->height) << 16) | (image->dx + image->width); msm_fb_pan_display(&var, info); } } static int msm_fb_blank(int blank_mode, struct fb_info *info) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; msm_fb_pan_idle(mfd); return msm_fb_blank_sub(blank_mode, info, mfd->op_enable); } static int msm_fb_set_lut(struct fb_cmap *cmap, struct fb_info *info) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; if (!mfd->lut_update) return -ENODEV; mfd->lut_update(info, cmap); return 0; } /* * Custom Framebuffer mmap() function for MSM driver. * Differs from standard mmap() function by allowing for customized * page-protection. */ static int msm_fb_mmap(struct fb_info *info, struct vm_area_struct * vma) { /* Get frame buffer memory range. */ unsigned long start = info->fix.smem_start; u32 len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.smem_len); unsigned long off = vma->vm_pgoff << PAGE_SHIFT; struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; msm_fb_pan_idle(mfd); if (off >= len) { /* memory mapped io */ off -= len; if (info->var.accel_flags) { mutex_unlock(&info->lock); return -EINVAL; } start = info->fix.mmio_start; len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len); } /* Set VM flags. */ start &= PAGE_MASK; if ((vma->vm_end - vma->vm_start + off) > len) return -EINVAL; off += start; vma->vm_pgoff = off >> PAGE_SHIFT; /* This is an IO map - tell maydump to skip this VMA */ vma->vm_flags |= VM_IO | VM_RESERVED; /* Set VM page protection */ if (mfd->mdp_fb_page_protection == MDP_FB_PAGE_PROTECTION_WRITECOMBINE) vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); else if (mfd->mdp_fb_page_protection == MDP_FB_PAGE_PROTECTION_WRITETHROUGHCACHE) vma->vm_page_prot = pgprot_writethroughcache(vma->vm_page_prot); else if (mfd->mdp_fb_page_protection == MDP_FB_PAGE_PROTECTION_WRITEBACKCACHE) vma->vm_page_prot = pgprot_writebackcache(vma->vm_page_prot); else if (mfd->mdp_fb_page_protection == MDP_FB_PAGE_PROTECTION_WRITEBACKWACACHE) vma->vm_page_prot = pgprot_writebackwacache(vma->vm_page_prot); else vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); /* Remap the frame buffer I/O range */ if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN; return 0; } static struct fb_ops msm_fb_ops = { .owner = THIS_MODULE, .fb_open = msm_fb_open, .fb_release = msm_fb_release, .fb_read = NULL, .fb_write = NULL, .fb_cursor = NULL, .fb_check_var = msm_fb_check_var, /* vinfo check */ .fb_set_par = msm_fb_set_par, /* set the video mode according to info->var */ .fb_setcolreg = NULL, /* set color register */ .fb_blank = msm_fb_blank, /* blank display */ .fb_pan_display = msm_fb_pan_display, /* pan display */ .fb_fillrect = msm_fb_fillrect, /* Draws a rectangle */ .fb_copyarea = msm_fb_copyarea, /* Copy data from area to another */ .fb_imageblit = msm_fb_imageblit, /* Draws a image to the display */ .fb_rotate = NULL, .fb_sync = NULL, /* wait for blit idle, optional */ .fb_ioctl = msm_fb_ioctl, /* perform fb specific ioctl (optional) */ .fb_mmap = msm_fb_mmap, }; static __u32 msm_fb_line_length(__u32 fb_index, __u32 xres, int bpp) { /* The adreno GPU hardware requires that the pitch be aligned to 32 pixels for color buffers, so for the cases where the GPU is writing directly to fb0, the framebuffer pitch also needs to be 32 pixel aligned */ if (fb_index == 0) return ALIGN(xres, 32) * bpp; else return xres * bpp; } static int msm_fb_register(struct msm_fb_data_type *mfd) { int ret = -ENODEV; int bpp; struct msm_panel_info *panel_info = &mfd->panel_info; struct fb_info *fbi = mfd->fbi; struct fb_fix_screeninfo *fix; struct fb_var_screeninfo *var; int *id; int fbram_offset; int remainder, remainder_mode2; /* * fb info initialization */ fix = &fbi->fix; var = &fbi->var; fix->type_aux = 0; /* if type == FB_TYPE_INTERLEAVED_PLANES */ fix->visual = FB_VISUAL_TRUECOLOR; /* True Color */ fix->ywrapstep = 0; /* No support */ fix->mmio_start = 0; /* No MMIO Address */ fix->mmio_len = 0; /* No MMIO Address */ fix->accel = FB_ACCEL_NONE;/* FB_ACCEL_MSM needes to be added in fb.h */ var->xoffset = 0, /* Offset from virtual to visible */ var->yoffset = 0, /* resolution */ var->grayscale = 0, /* No graylevels */ var->nonstd = 0, /* standard pixel format */ var->activate = FB_ACTIVATE_VBL, /* activate it at vsync */ var->height = -1, /* height of picture in mm */ var->width = -1, /* width of picture in mm */ var->accel_flags = 0, /* acceleration flags */ var->sync = 0, /* see FB_SYNC_* */ var->rotate = 0, /* angle we rotate counter clockwise */ mfd->op_enable = FALSE; switch (mfd->fb_imgType) { case MDP_RGB_565: fix->type = FB_TYPE_PACKED_PIXELS; fix->xpanstep = 1; fix->ypanstep = 1; var->vmode = FB_VMODE_NONINTERLACED; var->blue.offset = 0; var->green.offset = 5; var->red.offset = 11; var->blue.length = 5; var->green.length = 6; var->red.length = 5; var->blue.msb_right = 0; var->green.msb_right = 0; var->red.msb_right = 0; var->transp.offset = 0; var->transp.length = 0; bpp = 2; break; case MDP_RGB_888: fix->type = FB_TYPE_PACKED_PIXELS; fix->xpanstep = 1; fix->ypanstep = 1; var->vmode = FB_VMODE_NONINTERLACED; var->blue.offset = 0; var->green.offset = 8; var->red.offset = 16; var->blue.length = 8; var->green.length = 8; var->red.length = 8; var->blue.msb_right = 0; var->green.msb_right = 0; var->red.msb_right = 0; var->transp.offset = 0; var->transp.length = 0; bpp = 3; break; case MDP_ARGB_8888: fix->type = FB_TYPE_PACKED_PIXELS; fix->xpanstep = 1; fix->ypanstep = 1; var->vmode = FB_VMODE_NONINTERLACED; var->blue.offset = 0; var->green.offset = 8; var->red.offset = 16; var->blue.length = 8; var->green.length = 8; var->red.length = 8; var->blue.msb_right = 0; var->green.msb_right = 0; var->red.msb_right = 0; var->transp.offset = 24; var->transp.length = 8; bpp = 4; break; case MDP_RGBA_8888: fix->type = FB_TYPE_PACKED_PIXELS; fix->xpanstep = 1; fix->ypanstep = 1; var->vmode = FB_VMODE_NONINTERLACED; var->blue.offset = 8; var->green.offset = 16; var->red.offset = 24; var->blue.length = 8; var->green.length = 8; var->red.length = 8; var->blue.msb_right = 0; var->green.msb_right = 0; var->red.msb_right = 0; var->transp.offset = 0; var->transp.length = 8; bpp = 4; break; case MDP_BGRA_8888: fix->type = FB_TYPE_PACKED_PIXELS; fix->xpanstep = 1; fix->ypanstep = 1; var->vmode = FB_VMODE_NONINTERLACED; var->blue.offset = 0; var->green.offset = 8; var->red.offset = 16; var->blue.length = 8; var->green.length = 8; var->red.length = 8; var->blue.msb_right = 0; var->green.msb_right = 0; var->red.msb_right = 0; var->transp.offset = 24; var->transp.length = 8; bpp = 4; break; case MDP_YCRYCB_H2V1: /* ToDo: need to check TV-Out YUV422i framebuffer format */ /* we might need to create new type define */ fix->type = FB_TYPE_INTERLEAVED_PLANES; fix->xpanstep = 2; fix->ypanstep = 1; var->vmode = FB_VMODE_NONINTERLACED; /* how about R/G/B offset? */ var->blue.offset = 0; var->green.offset = 5; var->red.offset = 11; var->blue.length = 5; var->green.length = 6; var->red.length = 5; var->blue.msb_right = 0; var->green.msb_right = 0; var->red.msb_right = 0; var->transp.offset = 0; var->transp.length = 0; bpp = 2; break; default: MSM_FB_ERR("msm_fb_init: fb %d unkown image type!\n", mfd->index); return ret; } fix->type = panel_info->is_3d_panel; fix->line_length = msm_fb_line_length(mfd->index, panel_info->xres, bpp); /* Make sure all buffers can be addressed on a page boundary by an x * and y offset */ remainder = (fix->line_length * panel_info->yres) & (PAGE_SIZE - 1); /* PAGE_SIZE is a power of 2 */ if (!remainder) remainder = PAGE_SIZE; remainder_mode2 = (fix->line_length * panel_info->mode2_yres) & (PAGE_SIZE - 1); if (!remainder_mode2) remainder_mode2 = PAGE_SIZE; /* * calculate smem_len based on max size of two supplied modes. * Only fb0 has mem. fb1 and fb2 don't have mem. */ if (!bf_supported || mfd->index == 0) fix->smem_len = MAX((msm_fb_line_length(mfd->index, panel_info->xres, bpp) * panel_info->yres + PAGE_SIZE - remainder) * mfd->fb_page, (msm_fb_line_length(mfd->index, panel_info->mode2_xres, bpp) * panel_info->mode2_yres + PAGE_SIZE - remainder_mode2) * mfd->fb_page); else if (mfd->index == 1 || mfd->index == 2) { pr_debug("%s:%d no memory is allocated for fb%d!\n", __func__, __LINE__, mfd->index); fix->smem_len = 0; } mfd->var_xres = panel_info->xres; mfd->var_yres = panel_info->yres; mfd->var_frame_rate = panel_info->frame_rate; var->pixclock = mfd->panel_info.clk_rate; mfd->var_pixclock = var->pixclock; var->xres = panel_info->xres; var->yres = panel_info->yres; var->xres_virtual = panel_info->xres; var->yres_virtual = panel_info->yres * mfd->fb_page + ((PAGE_SIZE - remainder)/fix->line_length) * mfd->fb_page; var->bits_per_pixel = bpp * 8; /* FrameBuffer color depth */ /* * id field for fb app */ id = (int *)&mfd->panel; switch (mdp_rev) { case MDP_REV_20: snprintf(fix->id, sizeof(fix->id), "msmfb20_%x", (__u32) *id); break; case MDP_REV_22: snprintf(fix->id, sizeof(fix->id), "msmfb22_%x", (__u32) *id); break; case MDP_REV_30: snprintf(fix->id, sizeof(fix->id), "msmfb30_%x", (__u32) *id); break; case MDP_REV_303: snprintf(fix->id, sizeof(fix->id), "msmfb303_%x", (__u32) *id); break; case MDP_REV_31: snprintf(fix->id, sizeof(fix->id), "msmfb31_%x", (__u32) *id); break; case MDP_REV_40: snprintf(fix->id, sizeof(fix->id), "msmfb40_%x", (__u32) *id); break; case MDP_REV_41: snprintf(fix->id, sizeof(fix->id), "msmfb41_%x", (__u32) *id); break; case MDP_REV_42: snprintf(fix->id, sizeof(fix->id), "msmfb42_%x", (__u32) *id); break; case MDP_REV_43: snprintf(fix->id, sizeof(fix->id), "msmfb43_%x", (__u32) *id); break; case MDP_REV_44: snprintf(fix->id, sizeof(fix->id), "msmfb44_%x", (__u32) *id); break; default: snprintf(fix->id, sizeof(fix->id), "msmfb0_%x", (__u32) *id); break; } fbi->fbops = &msm_fb_ops; fbi->flags = FBINFO_FLAG_DEFAULT; fbi->pseudo_palette = msm_fb_pseudo_palette; mfd->ref_cnt = 0; mfd->sw_currently_refreshing = FALSE; mfd->sw_refreshing_enable = TRUE; mfd->panel_power_on = FALSE; mfd->pan_waiting = FALSE; init_completion(&mfd->pan_comp); init_completion(&mfd->refresher_comp); sema_init(&mfd->sem, 1); init_timer(&mfd->msmfb_no_update_notify_timer); mfd->msmfb_no_update_notify_timer.function = msmfb_no_update_notify_timer_cb; mfd->msmfb_no_update_notify_timer.data = (unsigned long)mfd; init_completion(&mfd->msmfb_update_notify); init_completion(&mfd->msmfb_no_update_notify); init_completion(&mfd->commit_comp); mutex_init(&mfd->sync_mutex); INIT_WORK(&mfd->commit_work, msm_fb_commit_wq_handler); mfd->msm_fb_backup = kzalloc(sizeof(struct msm_fb_backup_type), GFP_KERNEL); if (mfd->msm_fb_backup == 0) { pr_err("error: not enough memory!\n"); return -ENOMEM; } fbram_offset = PAGE_ALIGN((int)fbram)-(int)fbram; fbram += fbram_offset; fbram_phys += fbram_offset; fbram_size -= fbram_offset; if (!bf_supported || mfd->index == 0) if (fbram_size < fix->smem_len) { pr_err("error: no more framebuffer memory!\n"); return -ENOMEM; } fbi->screen_base = fbram; fbi->fix.smem_start = (unsigned long)fbram_phys; msm_iommu_map_contig_buffer(fbi->fix.smem_start, DISPLAY_WRITE_DOMAIN, GEN_POOL, fbi->fix.smem_len, SZ_4K, 0, &(mfd->display_iova)); msm_iommu_map_contig_buffer(fbi->fix.smem_start, DISPLAY_READ_DOMAIN, GEN_POOL, fbi->fix.smem_len, SZ_4K, 0, &(mfd->display_iova)); msm_iommu_map_contig_buffer(fbi->fix.smem_start, ROTATOR_SRC_DOMAIN, GEN_POOL, fbi->fix.smem_len, SZ_4K, 0, &(mfd->rotator_iova)); if (!bf_supported || mfd->index == 0) memset(fbi->screen_base, 0x0, fix->smem_len); mfd->op_enable = TRUE; mfd->panel_power_on = FALSE; /* cursor memory allocation */ if (mfd->cursor_update) { unsigned long cursor_buf_iommu = 0; mfd->cursor_buf = dma_alloc_coherent(NULL, MDP_CURSOR_SIZE, (dma_addr_t *) &mfd->cursor_buf_phys, GFP_KERNEL); msm_iommu_map_contig_buffer((unsigned long)mfd->cursor_buf_phys, DISPLAY_READ_DOMAIN, GEN_POOL, MDP_CURSOR_SIZE, SZ_4K, 0, &cursor_buf_iommu); if (cursor_buf_iommu) mfd->cursor_buf_phys = (void *)cursor_buf_iommu; if (!mfd->cursor_buf) mfd->cursor_update = 0; } if (mfd->lut_update) { ret = fb_alloc_cmap(&fbi->cmap, 256, 0); if (ret) printk(KERN_ERR "%s: fb_alloc_cmap() failed!\n", __func__); } if (register_framebuffer(fbi) < 0) { if (mfd->lut_update) fb_dealloc_cmap(&fbi->cmap); if (mfd->cursor_buf) dma_free_coherent(NULL, MDP_CURSOR_SIZE, mfd->cursor_buf, (dma_addr_t) mfd->cursor_buf_phys); mfd->op_enable = FALSE; return -EPERM; } fbram += fix->smem_len; fbram_phys += fix->smem_len; fbram_size -= fix->smem_len; MSM_FB_INFO ("FrameBuffer[%d] %dx%d size=%d bytes is registered successfully!\n", mfd->index, fbi->var.xres, fbi->var.yres, fbi->fix.smem_len); #ifdef CONFIG_FB_MSM_LOGO /* Flip buffer */ if (!load_565rle_image(INIT_IMAGE_FILE, bf_supported)) ; #endif ret = 0; #ifdef CONFIG_HAS_EARLYSUSPEND if (mfd->panel_info.type != DTV_PANEL) { mfd->early_suspend.suspend = msmfb_early_suspend; mfd->early_suspend.resume = msmfb_early_resume; mfd->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 2; register_early_suspend(&mfd->early_suspend); } #endif #ifdef MSM_FB_ENABLE_DBGFS { struct dentry *root; struct dentry *sub_dir; char sub_name[2]; root = msm_fb_get_debugfs_root(); if (root != NULL) { sub_name[0] = (char)(mfd->index + 0x30); sub_name[1] = '\0'; sub_dir = debugfs_create_dir(sub_name, root); } else { sub_dir = NULL; } mfd->sub_dir = sub_dir; if (sub_dir) { msm_fb_debugfs_file_create(sub_dir, "op_enable", (u32 *) &mfd->op_enable); msm_fb_debugfs_file_create(sub_dir, "panel_power_on", (u32 *) &mfd-> panel_power_on); msm_fb_debugfs_file_create(sub_dir, "ref_cnt", (u32 *) &mfd->ref_cnt); msm_fb_debugfs_file_create(sub_dir, "fb_imgType", (u32 *) &mfd->fb_imgType); msm_fb_debugfs_file_create(sub_dir, "sw_currently_refreshing", (u32 *) &mfd-> sw_currently_refreshing); msm_fb_debugfs_file_create(sub_dir, "sw_refreshing_enable", (u32 *) &mfd-> sw_refreshing_enable); msm_fb_debugfs_file_create(sub_dir, "xres", (u32 *) &mfd->panel_info. xres); msm_fb_debugfs_file_create(sub_dir, "yres", (u32 *) &mfd->panel_info. yres); msm_fb_debugfs_file_create(sub_dir, "bpp", (u32 *) &mfd->panel_info. bpp); msm_fb_debugfs_file_create(sub_dir, "type", (u32 *) &mfd->panel_info. type); msm_fb_debugfs_file_create(sub_dir, "wait_cycle", (u32 *) &mfd->panel_info. wait_cycle); msm_fb_debugfs_file_create(sub_dir, "pdest", (u32 *) &mfd->panel_info. pdest); msm_fb_debugfs_file_create(sub_dir, "backbuff", (u32 *) &mfd->panel_info. fb_num); msm_fb_debugfs_file_create(sub_dir, "clk_rate", (u32 *) &mfd->panel_info. clk_rate); msm_fb_debugfs_file_create(sub_dir, "frame_count", (u32 *) &mfd->panel_info. frame_count); switch (mfd->dest) { case DISPLAY_LCD: msm_fb_debugfs_file_create(sub_dir, "vsync_enable", (u32 *)&mfd->panel_info.lcd.vsync_enable); msm_fb_debugfs_file_create(sub_dir, "refx100", (u32 *) &mfd->panel_info.lcd. refx100); msm_fb_debugfs_file_create(sub_dir, "v_back_porch", (u32 *) &mfd->panel_info.lcd.v_back_porch); msm_fb_debugfs_file_create(sub_dir, "v_front_porch", (u32 *) &mfd->panel_info.lcd.v_front_porch); msm_fb_debugfs_file_create(sub_dir, "v_pulse_width", (u32 *) &mfd->panel_info.lcd.v_pulse_width); msm_fb_debugfs_file_create(sub_dir, "hw_vsync_mode", (u32 *) &mfd->panel_info.lcd.hw_vsync_mode); msm_fb_debugfs_file_create(sub_dir, "vsync_notifier_period", (u32 *) &mfd->panel_info.lcd.vsync_notifier_period); break; case DISPLAY_LCDC: msm_fb_debugfs_file_create(sub_dir, "h_back_porch", (u32 *) &mfd->panel_info.lcdc.h_back_porch); msm_fb_debugfs_file_create(sub_dir, "h_front_porch", (u32 *) &mfd->panel_info.lcdc.h_front_porch); msm_fb_debugfs_file_create(sub_dir, "h_pulse_width", (u32 *) &mfd->panel_info.lcdc.h_pulse_width); msm_fb_debugfs_file_create(sub_dir, "v_back_porch", (u32 *) &mfd->panel_info.lcdc.v_back_porch); msm_fb_debugfs_file_create(sub_dir, "v_front_porch", (u32 *) &mfd->panel_info.lcdc.v_front_porch); msm_fb_debugfs_file_create(sub_dir, "v_pulse_width", (u32 *) &mfd->panel_info.lcdc.v_pulse_width); msm_fb_debugfs_file_create(sub_dir, "border_clr", (u32 *) &mfd->panel_info.lcdc.border_clr); msm_fb_debugfs_file_create(sub_dir, "underflow_clr", (u32 *) &mfd->panel_info.lcdc.underflow_clr); msm_fb_debugfs_file_create(sub_dir, "hsync_skew", (u32 *) &mfd->panel_info.lcdc.hsync_skew); break; default: break; } } } #endif /* MSM_FB_ENABLE_DBGFS */ return ret; } static int msm_fb_open(struct fb_info *info, int user) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; bool unblank = true; int result; result = pm_runtime_get_sync(info->dev); if (result < 0) { printk(KERN_ERR "pm_runtime: fail to wake up\n"); } if (info->node == 0 && !(mfd->cont_splash_done)) { /* primary */ mfd->ref_cnt++; return 0; } if (!mfd->ref_cnt) { if (!bf_supported || (info->node != 1 && info->node != 2)) mdp_set_dma_pan_info(info, NULL, TRUE); else pr_debug("%s:%d no mdp_set_dma_pan_info %d\n", __func__, __LINE__, info->node); if (mfd->is_panel_ready && !mfd->is_panel_ready()) unblank = false; if (unblank) { if (msm_fb_blank_sub(FB_BLANK_UNBLANK, info, mfd->op_enable)) { MSM_FB_ERR("%s: can't turn on display!\n", __func__); return -EPERM; } } } mfd->ref_cnt++; return 0; } static int msm_fb_release(struct fb_info *info, int user) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; int ret = 0; if (!mfd->ref_cnt) { MSM_FB_INFO("msm_fb_release: try to close unopened fb %d!\n", mfd->index); return -EINVAL; } mfd->ref_cnt--; if (!mfd->ref_cnt) { if ((ret = msm_fb_blank_sub(FB_BLANK_POWERDOWN, info, mfd->op_enable)) != 0) { printk(KERN_ERR "msm_fb_release: can't turn off display!\n"); return ret; } } pm_runtime_put(info->dev); return ret; } int msm_fb_wait_for_fence(struct msm_fb_data_type *mfd) { int i, ret = 0; /* buf sync */ for (i = 0; i < mfd->acq_fen_cnt; i++) { ret = sync_fence_wait(mfd->acq_fen[i], WAIT_FENCE_TIMEOUT); sync_fence_put(mfd->acq_fen[i]); if (ret < 0) { pr_err("%s: sync_fence_wait failed! ret = %x\n", __func__, ret); break; } } mfd->acq_fen_cnt = 0; return ret; } int msm_fb_signal_timeline(struct msm_fb_data_type *mfd) { mutex_lock(&mfd->sync_mutex); if (mfd->timeline) { sw_sync_timeline_inc(mfd->timeline, 1); mfd->timeline_value++; } mfd->last_rel_fence = mfd->cur_rel_fence; mfd->cur_rel_fence = 0; mutex_unlock(&mfd->sync_mutex); return 0; } static void bl_workqueue_handler(struct work_struct *work) { struct msm_fb_data_type *mfd = container_of(to_delayed_work(work), struct msm_fb_data_type, backlight_worker); struct msm_fb_panel_data *pdata = mfd->pdev->dev.platform_data; if ((pdata) && (pdata->set_backlight) && (!bl_updated)) { down(&mfd->sem); mfd->bl_level = unset_bl_level; pdata->set_backlight(mfd); bl_level_old = unset_bl_level; bl_updated = 1; up(&mfd->sem); } } DEFINE_SEMAPHORE(msm_fb_pan_sem); static int msm_fb_pan_idle(struct msm_fb_data_type *mfd) { int ret = 0; mutex_lock(&mfd->sync_mutex); if (mfd->is_committing) { mutex_unlock(&mfd->sync_mutex); ret = wait_for_completion_interruptible_timeout( &mfd->commit_comp, msecs_to_jiffies(WAIT_FENCE_TIMEOUT)); if (ret <= 0) ret = -ERESTARTSYS; else if (!ret) pr_err("%s wait for commit_comp timeout %d %d", __func__, ret, mfd->is_committing); } else { mutex_unlock(&mfd->sync_mutex); } return ret; } static int msm_fb_pan_display_ex(struct fb_var_screeninfo *var, struct fb_info *info, u32 wait_for_finish) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; struct msm_fb_backup_type *fb_backup; int ret = 0; /* * If framebuffer is 2, io pen display is not allowed. */ if (bf_supported && info->node == 2) { pr_err("%s: no pan display for fb%d!", __func__, info->node); return -EPERM; } if (info->node != 0 || mfd->cont_splash_done) /* primary */ if ((!mfd->op_enable) || (!mfd->panel_power_on)) return -EPERM; if (var->xoffset > (info->var.xres_virtual - info->var.xres)) return -EINVAL; if (var->yoffset > (info->var.yres_virtual - info->var.yres)) return -EINVAL; msm_fb_pan_idle(mfd); mutex_lock(&mfd->sync_mutex); if (info->fix.xpanstep) info->var.xoffset = (var->xoffset / info->fix.xpanstep) * info->fix.xpanstep; if (info->fix.ypanstep) info->var.yoffset = (var->yoffset / info->fix.ypanstep) * info->fix.ypanstep; fb_backup = (struct msm_fb_backup_type *)mfd->msm_fb_backup; memcpy(&fb_backup->info, info, sizeof(struct fb_info)); memcpy(&fb_backup->var, var, sizeof(struct fb_var_screeninfo)); mfd->is_committing = 1; INIT_COMPLETION(mfd->commit_comp); schedule_work(&mfd->commit_work); mutex_unlock(&mfd->sync_mutex); if (wait_for_finish) msm_fb_pan_idle(mfd); return ret; } static int msm_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { return msm_fb_pan_display_ex(var, info, TRUE); } static int msm_fb_pan_display_sub(struct fb_var_screeninfo *var, struct fb_info *info) { struct mdp_dirty_region dirty; struct mdp_dirty_region *dirtyPtr = NULL; struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; /* * If framebuffer is 2, io pen display is not allowed. */ if (bf_supported && info->node == 2) { pr_err("%s: no pan display for fb%d!", __func__, info->node); return -EPERM; } if (info->node != 0 || mfd->cont_splash_done) /* primary */ if ((!mfd->op_enable) || (!mfd->panel_power_on)) return -EPERM; if (var->xoffset > (info->var.xres_virtual - info->var.xres)) return -EINVAL; if (var->yoffset > (info->var.yres_virtual - info->var.yres)) return -EINVAL; if (info->fix.xpanstep) info->var.xoffset = (var->xoffset / info->fix.xpanstep) * info->fix.xpanstep; if (info->fix.ypanstep) info->var.yoffset = (var->yoffset / info->fix.ypanstep) * info->fix.ypanstep; /* "UPDT" */ if (var->reserved[0] == 0x54445055) { dirty.xoffset = var->reserved[1] & 0xffff; dirty.yoffset = (var->reserved[1] >> 16) & 0xffff; if ((var->reserved[2] & 0xffff) <= dirty.xoffset) return -EINVAL; if (((var->reserved[2] >> 16) & 0xffff) <= dirty.yoffset) return -EINVAL; dirty.width = (var->reserved[2] & 0xffff) - dirty.xoffset; dirty.height = ((var->reserved[2] >> 16) & 0xffff) - dirty.yoffset; info->var.yoffset = var->yoffset; if (dirty.xoffset < 0) return -EINVAL; if (dirty.yoffset < 0) return -EINVAL; if ((dirty.xoffset + dirty.width) > info->var.xres) return -EINVAL; if ((dirty.yoffset + dirty.height) > info->var.yres) return -EINVAL; if ((dirty.width <= 0) || (dirty.height <= 0)) return -EINVAL; dirtyPtr = &dirty; } complete(&mfd->msmfb_update_notify); mutex_lock(&msm_fb_notify_update_sem); if (mfd->msmfb_no_update_notify_timer.function) del_timer(&mfd->msmfb_no_update_notify_timer); mfd->msmfb_no_update_notify_timer.expires = jiffies + (2 * HZ); add_timer(&mfd->msmfb_no_update_notify_timer); mutex_unlock(&msm_fb_notify_update_sem); down(&msm_fb_pan_sem); msm_fb_wait_for_fence(mfd); if (info->node == 0 && !(mfd->cont_splash_done)) { /* primary */ mdp_set_dma_pan_info(info, NULL, TRUE); if (msm_fb_blank_sub(FB_BLANK_UNBLANK, info, mfd->op_enable)) { pr_err("%s: can't turn on display!\n", __func__); if (mfd->timeline) { sw_sync_timeline_inc(mfd->timeline, 2); mfd->timeline_value += 2; } return -EINVAL; } } mdp_set_dma_pan_info(info, dirtyPtr, (var->activate & FB_ACTIVATE_VBL)); /* async call */ mdp_dma_pan_update(info); msm_fb_signal_timeline(mfd); up(&msm_fb_pan_sem); if (unset_bl_level && !bl_updated) schedule_delayed_work(&mfd->backlight_worker, backlight_duration); if (info->node == 0 && (mfd->cont_splash_done)) /* primary */ mdp_free_splash_buffer(mfd); ++mfd->panel_info.frame_count; return 0; } static void msm_fb_commit_wq_handler(struct work_struct *work) { struct msm_fb_data_type *mfd; struct fb_var_screeninfo *var; struct fb_info *info; struct msm_fb_backup_type *fb_backup; mfd = container_of(work, struct msm_fb_data_type, commit_work); fb_backup = (struct msm_fb_backup_type *)mfd->msm_fb_backup; var = &fb_backup->var; info = &fb_backup->info; msm_fb_pan_display_sub(var, info); mutex_lock(&mfd->sync_mutex); mfd->is_committing = 0; complete_all(&mfd->commit_comp); mutex_unlock(&mfd->sync_mutex); } static int msm_fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; msm_fb_pan_idle(mfd); if (var->rotate != FB_ROTATE_UR) return -EINVAL; if (var->grayscale != info->var.grayscale) return -EINVAL; switch (var->bits_per_pixel) { case 16: if ((var->green.offset != 5) || !((var->blue.offset == 11) || (var->blue.offset == 0)) || !((var->red.offset == 11) || (var->red.offset == 0)) || (var->blue.length != 5) || (var->green.length != 6) || (var->red.length != 5) || (var->blue.msb_right != 0) || (var->green.msb_right != 0) || (var->red.msb_right != 0) || (var->transp.offset != 0) || (var->transp.length != 0)) return -EINVAL; break; case 24: if ((var->blue.offset != 0) || (var->green.offset != 8) || (var->red.offset != 16) || (var->blue.length != 8) || (var->green.length != 8) || (var->red.length != 8) || (var->blue.msb_right != 0) || (var->green.msb_right != 0) || (var->red.msb_right != 0) || !(((var->transp.offset == 0) && (var->transp.length == 0)) || ((var->transp.offset == 24) && (var->transp.length == 8)))) return -EINVAL; break; case 32: /* Figure out if the user meant RGBA or ARGB and verify the position of the RGB components */ if (var->transp.offset == 24) { if ((var->blue.offset != 0) || (var->green.offset != 8) || (var->red.offset != 16)) return -EINVAL; } else if (var->transp.offset == 0) { if ((var->blue.offset != 8) || (var->green.offset != 16) || (var->red.offset != 24)) return -EINVAL; } else return -EINVAL; /* Check the common values for both RGBA and ARGB */ if ((var->blue.length != 8) || (var->green.length != 8) || (var->red.length != 8) || (var->transp.length != 8) || (var->blue.msb_right != 0) || (var->green.msb_right != 0) || (var->red.msb_right != 0)) return -EINVAL; break; default: return -EINVAL; } if ((var->xres_virtual <= 0) || (var->yres_virtual <= 0)) return -EINVAL; if (!bf_supported || (info->node != 1 && info->node != 2)) if (info->fix.smem_len < (var->xres_virtual* var->yres_virtual* (var->bits_per_pixel/8))) return -EINVAL; if ((var->xres == 0) || (var->yres == 0)) return -EINVAL; if (var->xoffset > (var->xres_virtual - var->xres)) return -EINVAL; if (var->yoffset > (var->yres_virtual - var->yres)) return -EINVAL; return 0; } int msm_fb_check_frame_rate(struct msm_fb_data_type *mfd , struct fb_info *info) { int panel_height, panel_width, var_frame_rate, fps_mod; struct fb_var_screeninfo *var = &info->var; fps_mod = 0; if ((mfd->panel_info.type == DTV_PANEL) || (mfd->panel_info.type == HDMI_PANEL)) { panel_height = var->yres + var->upper_margin + var->vsync_len + var->lower_margin; panel_width = var->xres + var->right_margin + var->hsync_len + var->left_margin; var_frame_rate = ((var->pixclock)/(panel_height * panel_width)); if (mfd->var_frame_rate != var_frame_rate) { fps_mod = 1; mfd->var_frame_rate = var_frame_rate; } } return fps_mod; } static int msm_fb_set_par(struct fb_info *info) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; struct fb_var_screeninfo *var = &info->var; int old_imgType; int blank = 0; msm_fb_pan_idle(mfd); old_imgType = mfd->fb_imgType; switch (var->bits_per_pixel) { case 16: if (var->red.offset == 0) mfd->fb_imgType = MDP_BGR_565; else mfd->fb_imgType = MDP_RGB_565; break; case 24: if ((var->transp.offset == 0) && (var->transp.length == 0)) mfd->fb_imgType = MDP_RGB_888; else if ((var->transp.offset == 24) && (var->transp.length == 8)) { mfd->fb_imgType = MDP_ARGB_8888; info->var.bits_per_pixel = 32; } break; case 32: if ((var->transp.offset == 24) && (var->blue.offset == 0)) mfd->fb_imgType = MDP_BGRA_8888; else if (var->transp.offset == 24) mfd->fb_imgType = MDP_ARGB_8888; else mfd->fb_imgType = MDP_RGBA_8888; break; default: return -EINVAL; } if ((mfd->var_pixclock != var->pixclock) || (mfd->hw_refresh && ((mfd->fb_imgType != old_imgType) || (mfd->var_pixclock != var->pixclock) || (mfd->var_xres != var->xres) || (mfd->var_yres != var->yres) || (msm_fb_check_frame_rate(mfd, info))))) { mfd->var_xres = var->xres; mfd->var_yres = var->yres; mfd->var_pixclock = var->pixclock; blank = 1; } mfd->fbi->fix.line_length = msm_fb_line_length(mfd->index, var->xres, var->bits_per_pixel/8); if (blank) { msm_fb_blank_sub(FB_BLANK_POWERDOWN, info, mfd->op_enable); if (mfd->update_panel_info) mfd->update_panel_info(mfd); msm_fb_blank_sub(FB_BLANK_UNBLANK, info, mfd->op_enable); } return 0; } static int msm_fb_stop_sw_refresher(struct msm_fb_data_type *mfd) { if (mfd->hw_refresh) return -EPERM; if (mfd->sw_currently_refreshing) { down(&mfd->sem); mfd->sw_currently_refreshing = FALSE; up(&mfd->sem); /* wait until the refresher finishes the last job */ wait_for_completion_killable(&mfd->refresher_comp); } return 0; } int msm_fb_resume_sw_refresher(struct msm_fb_data_type *mfd) { boolean do_refresh; if (mfd->hw_refresh) return -EPERM; down(&mfd->sem); if ((!mfd->sw_currently_refreshing) && (mfd->sw_refreshing_enable)) { do_refresh = TRUE; mfd->sw_currently_refreshing = TRUE; } else { do_refresh = FALSE; } up(&mfd->sem); if (do_refresh) mdp_refresh_screen((unsigned long)mfd); return 0; } #if defined CONFIG_FB_MSM_MDP31 static int mdp_blit_split_height(struct fb_info *info, struct mdp_blit_req *req) { int ret; struct mdp_blit_req splitreq; int s_x_0, s_x_1, s_w_0, s_w_1, s_y_0, s_y_1, s_h_0, s_h_1; int d_x_0, d_x_1, d_w_0, d_w_1, d_y_0, d_y_1, d_h_0, d_h_1; splitreq = *req; /* break dest roi at height*/ d_x_0 = d_x_1 = req->dst_rect.x; d_w_0 = d_w_1 = req->dst_rect.w; d_y_0 = req->dst_rect.y; if (req->dst_rect.h % 32 == 3) d_h_1 = (req->dst_rect.h - 3) / 2 - 1; else if (req->dst_rect.h % 32 == 2) d_h_1 = (req->dst_rect.h - 2) / 2 - 6; else d_h_1 = (req->dst_rect.h - 1) / 2 - 1; d_h_0 = req->dst_rect.h - d_h_1; d_y_1 = d_y_0 + d_h_0; if (req->dst_rect.h == 3) { d_h_1 = 2; d_h_0 = 2; d_y_1 = d_y_0 + 1; } /* blit first region */ if (((splitreq.flags & 0x07) == 0x04) || ((splitreq.flags & 0x07) == 0x0)) { if (splitreq.flags & MDP_ROT_90) { s_y_0 = s_y_1 = req->src_rect.y; s_h_0 = s_h_1 = req->src_rect.h; s_x_0 = req->src_rect.x; s_w_1 = (req->src_rect.w * d_h_1) / req->dst_rect.h; s_w_0 = req->src_rect.w - s_w_1; s_x_1 = s_x_0 + s_w_0; if (d_h_1 >= 8 * s_w_1) { s_w_1++; s_x_1--; } } else { s_x_0 = s_x_1 = req->src_rect.x; s_w_0 = s_w_1 = req->src_rect.w; s_y_0 = req->src_rect.y; s_h_1 = (req->src_rect.h * d_h_1) / req->dst_rect.h; s_h_0 = req->src_rect.h - s_h_1; s_y_1 = s_y_0 + s_h_0; if (d_h_1 >= 8 * s_h_1) { s_h_1++; s_y_1--; } } splitreq.src_rect.h = s_h_0; splitreq.src_rect.y = s_y_0; splitreq.dst_rect.h = d_h_0; splitreq.dst_rect.y = d_y_0; splitreq.src_rect.x = s_x_0; splitreq.src_rect.w = s_w_0; splitreq.dst_rect.x = d_x_0; splitreq.dst_rect.w = d_w_0; } else { if (splitreq.flags & MDP_ROT_90) { s_y_0 = s_y_1 = req->src_rect.y; s_h_0 = s_h_1 = req->src_rect.h; s_x_0 = req->src_rect.x; s_w_1 = (req->src_rect.w * d_h_0) / req->dst_rect.h; s_w_0 = req->src_rect.w - s_w_1; s_x_1 = s_x_0 + s_w_0; if (d_h_0 >= 8 * s_w_1) { s_w_1++; s_x_1--; } } else { s_x_0 = s_x_1 = req->src_rect.x; s_w_0 = s_w_1 = req->src_rect.w; s_y_0 = req->src_rect.y; s_h_1 = (req->src_rect.h * d_h_0) / req->dst_rect.h; s_h_0 = req->src_rect.h - s_h_1; s_y_1 = s_y_0 + s_h_0; if (d_h_0 >= 8 * s_h_1) { s_h_1++; s_y_1--; } } splitreq.src_rect.h = s_h_0; splitreq.src_rect.y = s_y_0; splitreq.dst_rect.h = d_h_1; splitreq.dst_rect.y = d_y_1; splitreq.src_rect.x = s_x_0; splitreq.src_rect.w = s_w_0; splitreq.dst_rect.x = d_x_1; splitreq.dst_rect.w = d_w_1; } ret = mdp_ppp_blit(info, &splitreq); if (ret) return ret; /* blit second region */ if (((splitreq.flags & 0x07) == 0x04) || ((splitreq.flags & 0x07) == 0x0)) { splitreq.src_rect.h = s_h_1; splitreq.src_rect.y = s_y_1; splitreq.dst_rect.h = d_h_1; splitreq.dst_rect.y = d_y_1; splitreq.src_rect.x = s_x_1; splitreq.src_rect.w = s_w_1; splitreq.dst_rect.x = d_x_1; splitreq.dst_rect.w = d_w_1; } else { splitreq.src_rect.h = s_h_1; splitreq.src_rect.y = s_y_1; splitreq.dst_rect.h = d_h_0; splitreq.dst_rect.y = d_y_0; splitreq.src_rect.x = s_x_1; splitreq.src_rect.w = s_w_1; splitreq.dst_rect.x = d_x_0; splitreq.dst_rect.w = d_w_0; } ret = mdp_ppp_blit(info, &splitreq); return ret; } #endif int mdp_blit(struct fb_info *info, struct mdp_blit_req *req) { int ret; #if defined CONFIG_FB_MSM_MDP31 || defined CONFIG_FB_MSM_MDP30 unsigned int remainder = 0, is_bpp_4 = 0; struct mdp_blit_req splitreq; int s_x_0, s_x_1, s_w_0, s_w_1, s_y_0, s_y_1, s_h_0, s_h_1; int d_x_0, d_x_1, d_w_0, d_w_1, d_y_0, d_y_1, d_h_0, d_h_1; if (req->flags & MDP_ROT_90) { if (((req->dst_rect.h == 1) && ((req->src_rect.w != 1) || (req->dst_rect.w != req->src_rect.h))) || ((req->dst_rect.w == 1) && ((req->src_rect.h != 1) || (req->dst_rect.h != req->src_rect.w)))) { printk(KERN_ERR "mpd_ppp: error scaling when size is 1!\n"); return -EINVAL; } } else { if (((req->dst_rect.w == 1) && ((req->src_rect.w != 1) || (req->dst_rect.h != req->src_rect.h))) || ((req->dst_rect.h == 1) && ((req->src_rect.h != 1) || (req->dst_rect.w != req->src_rect.w)))) { printk(KERN_ERR "mpd_ppp: error scaling when size is 1!\n"); return -EINVAL; } } #endif if (unlikely(req->src_rect.h == 0 || req->src_rect.w == 0)) { printk(KERN_ERR "mpd_ppp: src img of zero size!\n"); return -EINVAL; } if (unlikely(req->dst_rect.h == 0 || req->dst_rect.w == 0)) return 0; #if defined CONFIG_FB_MSM_MDP31 /* MDP width split workaround */ remainder = (req->dst_rect.w)%32; ret = mdp_get_bytes_per_pixel(req->dst.format, (struct msm_fb_data_type *)info->par); if (ret <= 0) { printk(KERN_ERR "mdp_ppp: incorrect bpp!\n"); return -EINVAL; } is_bpp_4 = (ret == 4) ? 1 : 0; if ((is_bpp_4 && (remainder == 6 || remainder == 14 || remainder == 22 || remainder == 30)) || remainder == 3 || (remainder == 1 && req->dst_rect.w != 1) || (remainder == 2 && req->dst_rect.w != 2)) { /* make new request as provide by user */ splitreq = *req; /* break dest roi at width*/ d_y_0 = d_y_1 = req->dst_rect.y; d_h_0 = d_h_1 = req->dst_rect.h; d_x_0 = req->dst_rect.x; if (remainder == 14) d_w_1 = (req->dst_rect.w - 14) / 2 + 4; else if (remainder == 22) d_w_1 = (req->dst_rect.w - 22) / 2 + 10; else if (remainder == 30) d_w_1 = (req->dst_rect.w - 30) / 2 + 10; else if (remainder == 6) d_w_1 = req->dst_rect.w / 2 - 1; else if (remainder == 3) d_w_1 = (req->dst_rect.w - 3) / 2 - 1; else if (remainder == 2) d_w_1 = (req->dst_rect.w - 2) / 2 - 6; else d_w_1 = (req->dst_rect.w - 1) / 2 - 1; d_w_0 = req->dst_rect.w - d_w_1; d_x_1 = d_x_0 + d_w_0; if (req->dst_rect.w == 3) { d_w_1 = 2; d_w_0 = 2; d_x_1 = d_x_0 + 1; } /* blit first region */ if (((splitreq.flags & 0x07) == 0x07) || ((splitreq.flags & 0x07) == 0x0)) { if (splitreq.flags & MDP_ROT_90) { s_x_0 = s_x_1 = req->src_rect.x; s_w_0 = s_w_1 = req->src_rect.w; s_y_0 = req->src_rect.y; s_h_1 = (req->src_rect.h * d_w_1) / req->dst_rect.w; s_h_0 = req->src_rect.h - s_h_1; s_y_1 = s_y_0 + s_h_0; if (d_w_1 >= 8 * s_h_1) { s_h_1++; s_y_1--; } } else { s_y_0 = s_y_1 = req->src_rect.y; s_h_0 = s_h_1 = req->src_rect.h; s_x_0 = req->src_rect.x; s_w_1 = (req->src_rect.w * d_w_1) / req->dst_rect.w; s_w_0 = req->src_rect.w - s_w_1; s_x_1 = s_x_0 + s_w_0; if (d_w_1 >= 8 * s_w_1) { s_w_1++; s_x_1--; } } splitreq.src_rect.h = s_h_0; splitreq.src_rect.y = s_y_0; splitreq.dst_rect.h = d_h_0; splitreq.dst_rect.y = d_y_0; splitreq.src_rect.x = s_x_0; splitreq.src_rect.w = s_w_0; splitreq.dst_rect.x = d_x_0; splitreq.dst_rect.w = d_w_0; } else { if (splitreq.flags & MDP_ROT_90) { s_x_0 = s_x_1 = req->src_rect.x; s_w_0 = s_w_1 = req->src_rect.w; s_y_0 = req->src_rect.y; s_h_1 = (req->src_rect.h * d_w_0) / req->dst_rect.w; s_h_0 = req->src_rect.h - s_h_1; s_y_1 = s_y_0 + s_h_0; if (d_w_0 >= 8 * s_h_1) { s_h_1++; s_y_1--; } } else { s_y_0 = s_y_1 = req->src_rect.y; s_h_0 = s_h_1 = req->src_rect.h; s_x_0 = req->src_rect.x; s_w_1 = (req->src_rect.w * d_w_0) / req->dst_rect.w; s_w_0 = req->src_rect.w - s_w_1; s_x_1 = s_x_0 + s_w_0; if (d_w_0 >= 8 * s_w_1) { s_w_1++; s_x_1--; } } splitreq.src_rect.h = s_h_0; splitreq.src_rect.y = s_y_0; splitreq.dst_rect.h = d_h_1; splitreq.dst_rect.y = d_y_1; splitreq.src_rect.x = s_x_0; splitreq.src_rect.w = s_w_0; splitreq.dst_rect.x = d_x_1; splitreq.dst_rect.w = d_w_1; } if ((splitreq.dst_rect.h % 32 == 3) || ((req->dst_rect.h % 32) == 1 && req->dst_rect.h != 1) || ((req->dst_rect.h % 32) == 2 && req->dst_rect.h != 2)) ret = mdp_blit_split_height(info, &splitreq); else ret = mdp_ppp_blit(info, &splitreq); if (ret) return ret; /* blit second region */ if (((splitreq.flags & 0x07) == 0x07) || ((splitreq.flags & 0x07) == 0x0)) { splitreq.src_rect.h = s_h_1; splitreq.src_rect.y = s_y_1; splitreq.dst_rect.h = d_h_1; splitreq.dst_rect.y = d_y_1; splitreq.src_rect.x = s_x_1; splitreq.src_rect.w = s_w_1; splitreq.dst_rect.x = d_x_1; splitreq.dst_rect.w = d_w_1; } else { splitreq.src_rect.h = s_h_1; splitreq.src_rect.y = s_y_1; splitreq.dst_rect.h = d_h_0; splitreq.dst_rect.y = d_y_0; splitreq.src_rect.x = s_x_1; splitreq.src_rect.w = s_w_1; splitreq.dst_rect.x = d_x_0; splitreq.dst_rect.w = d_w_0; } if (((splitreq.dst_rect.h % 32) == 3) || ((req->dst_rect.h % 32) == 1 && req->dst_rect.h != 1) || ((req->dst_rect.h % 32) == 2 && req->dst_rect.h != 2)) ret = mdp_blit_split_height(info, &splitreq); else ret = mdp_ppp_blit(info, &splitreq); if (ret) return ret; } else if ((req->dst_rect.h % 32) == 3 || ((req->dst_rect.h % 32) == 1 && req->dst_rect.h != 1) || ((req->dst_rect.h % 32) == 2 && req->dst_rect.h != 2)) ret = mdp_blit_split_height(info, req); else ret = mdp_ppp_blit(info, req); return ret; #elif defined CONFIG_FB_MSM_MDP30 /* MDP width split workaround */ remainder = (req->dst_rect.w)%16; ret = mdp_get_bytes_per_pixel(req->dst.format, (struct msm_fb_data_type *)info->par); if (ret <= 0) { printk(KERN_ERR "mdp_ppp: incorrect bpp!\n"); return -EINVAL; } is_bpp_4 = (ret == 4) ? 1 : 0; if ((is_bpp_4 && (remainder == 6 || remainder == 14))) { /* make new request as provide by user */ splitreq = *req; /* break dest roi at width*/ d_y_0 = d_y_1 = req->dst_rect.y; d_h_0 = d_h_1 = req->dst_rect.h; d_x_0 = req->dst_rect.x; if (remainder == 14 || remainder == 6) d_w_1 = req->dst_rect.w / 2; else d_w_1 = (req->dst_rect.w - 1) / 2 - 1; d_w_0 = req->dst_rect.w - d_w_1; d_x_1 = d_x_0 + d_w_0; /* blit first region */ if (((splitreq.flags & 0x07) == 0x07) || ((splitreq.flags & 0x07) == 0x05) || ((splitreq.flags & 0x07) == 0x02) || ((splitreq.flags & 0x07) == 0x0)) { if (splitreq.flags & MDP_ROT_90) { s_x_0 = s_x_1 = req->src_rect.x; s_w_0 = s_w_1 = req->src_rect.w; s_y_0 = req->src_rect.y; s_h_1 = (req->src_rect.h * d_w_1) / req->dst_rect.w; s_h_0 = req->src_rect.h - s_h_1; s_y_1 = s_y_0 + s_h_0; if (d_w_1 >= 8 * s_h_1) { s_h_1++; s_y_1--; } } else { s_y_0 = s_y_1 = req->src_rect.y; s_h_0 = s_h_1 = req->src_rect.h; s_x_0 = req->src_rect.x; s_w_1 = (req->src_rect.w * d_w_1) / req->dst_rect.w; s_w_0 = req->src_rect.w - s_w_1; s_x_1 = s_x_0 + s_w_0; if (d_w_1 >= 8 * s_w_1) { s_w_1++; s_x_1--; } } splitreq.src_rect.h = s_h_0; splitreq.src_rect.y = s_y_0; splitreq.dst_rect.h = d_h_0; splitreq.dst_rect.y = d_y_0; splitreq.src_rect.x = s_x_0; splitreq.src_rect.w = s_w_0; splitreq.dst_rect.x = d_x_0; splitreq.dst_rect.w = d_w_0; } else { if (splitreq.flags & MDP_ROT_90) { s_x_0 = s_x_1 = req->src_rect.x; s_w_0 = s_w_1 = req->src_rect.w; s_y_0 = req->src_rect.y; s_h_1 = (req->src_rect.h * d_w_0) / req->dst_rect.w; s_h_0 = req->src_rect.h - s_h_1; s_y_1 = s_y_0 + s_h_0; if (d_w_0 >= 8 * s_h_1) { s_h_1++; s_y_1--; } } else { s_y_0 = s_y_1 = req->src_rect.y; s_h_0 = s_h_1 = req->src_rect.h; s_x_0 = req->src_rect.x; s_w_1 = (req->src_rect.w * d_w_0) / req->dst_rect.w; s_w_0 = req->src_rect.w - s_w_1; s_x_1 = s_x_0 + s_w_0; if (d_w_0 >= 8 * s_w_1) { s_w_1++; s_x_1--; } } splitreq.src_rect.h = s_h_0; splitreq.src_rect.y = s_y_0; splitreq.dst_rect.h = d_h_1; splitreq.dst_rect.y = d_y_1; splitreq.src_rect.x = s_x_0; splitreq.src_rect.w = s_w_0; splitreq.dst_rect.x = d_x_1; splitreq.dst_rect.w = d_w_1; } /* No need to split in height */ ret = mdp_ppp_blit(info, &splitreq); if (ret) return ret; /* blit second region */ if (((splitreq.flags & 0x07) == 0x07) || ((splitreq.flags & 0x07) == 0x05) || ((splitreq.flags & 0x07) == 0x02) || ((splitreq.flags & 0x07) == 0x0)) { splitreq.src_rect.h = s_h_1; splitreq.src_rect.y = s_y_1; splitreq.dst_rect.h = d_h_1; splitreq.dst_rect.y = d_y_1; splitreq.src_rect.x = s_x_1; splitreq.src_rect.w = s_w_1; splitreq.dst_rect.x = d_x_1; splitreq.dst_rect.w = d_w_1; } else { splitreq.src_rect.h = s_h_1; splitreq.src_rect.y = s_y_1; splitreq.dst_rect.h = d_h_0; splitreq.dst_rect.y = d_y_0; splitreq.src_rect.x = s_x_1; splitreq.src_rect.w = s_w_1; splitreq.dst_rect.x = d_x_0; splitreq.dst_rect.w = d_w_0; } /* No need to split in height ... just width */ ret = mdp_ppp_blit(info, &splitreq); if (ret) return ret; } else ret = mdp_ppp_blit(info, req); return ret; #else ret = mdp_ppp_blit(info, req); return ret; #endif } typedef void (*msm_dma_barrier_function_pointer) (void *, size_t); static inline void msm_fb_dma_barrier_for_rect(struct fb_info *info, struct mdp_img *img, struct mdp_rect *rect, msm_dma_barrier_function_pointer dma_barrier_fp ) { /* * Compute the start and end addresses of the rectangles. * NOTE: As currently implemented, the data between * the end of one row and the start of the next is * included in the address range rather than * doing multiple calls for each row. */ unsigned long start; size_t size; char * const pmem_start = info->screen_base; int bytes_per_pixel = mdp_get_bytes_per_pixel(img->format, (struct msm_fb_data_type *)info->par); if (bytes_per_pixel <= 0) { printk(KERN_ERR "%s incorrect bpp!\n", __func__); return; } start = (unsigned long)pmem_start + img->offset + (img->width * rect->y + rect->x) * bytes_per_pixel; size = (rect->h * img->width + rect->w) * bytes_per_pixel; (*dma_barrier_fp) ((void *) start, size); } static inline void msm_dma_nc_pre(void) { dmb(); } static inline void msm_dma_wt_pre(void) { dmb(); } static inline void msm_dma_todevice_wb_pre(void *start, size_t size) { dma_cache_pre_ops(start, size, DMA_TO_DEVICE); } static inline void msm_dma_fromdevice_wb_pre(void *start, size_t size) { dma_cache_pre_ops(start, size, DMA_FROM_DEVICE); } static inline void msm_dma_nc_post(void) { dmb(); } static inline void msm_dma_fromdevice_wt_post(void *start, size_t size) { dma_cache_post_ops(start, size, DMA_FROM_DEVICE); } static inline void msm_dma_todevice_wb_post(void *start, size_t size) { dma_cache_post_ops(start, size, DMA_TO_DEVICE); } static inline void msm_dma_fromdevice_wb_post(void *start, size_t size) { dma_cache_post_ops(start, size, DMA_FROM_DEVICE); } /* * Do the write barriers required to guarantee data is committed to RAM * (from CPU cache or internal buffers) before a DMA operation starts. * NOTE: As currently implemented, the data between * the end of one row and the start of the next is * included in the address range rather than * doing multiple calls for each row. */ static void msm_fb_ensure_memory_coherency_before_dma(struct fb_info *info, struct mdp_blit_req *req_list, int req_list_count) { #ifdef CONFIG_ARCH_QSD8X50 int i; /* * Normally, do the requested barriers for each address * range that corresponds to a rectangle. * * But if at least one write barrier is requested for data * going to or from the device but no address range is * needed for that barrier, then do the barrier, but do it * only once, no matter how many requests there are. */ struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; switch (mfd->mdp_fb_page_protection) { default: case MDP_FB_PAGE_PROTECTION_NONCACHED: case MDP_FB_PAGE_PROTECTION_WRITECOMBINE: /* * The following barrier is only done at most once, * since further calls would be redundant. */ for (i = 0; i < req_list_count; i++) { if (!(req_list[i].flags & MDP_NO_DMA_BARRIER_START)) { msm_dma_nc_pre(); break; } } break; case MDP_FB_PAGE_PROTECTION_WRITETHROUGHCACHE: /* * The following barrier is only done at most once, * since further calls would be redundant. */ for (i = 0; i < req_list_count; i++) { if (!(req_list[i].flags & MDP_NO_DMA_BARRIER_START)) { msm_dma_wt_pre(); break; } } break; case MDP_FB_PAGE_PROTECTION_WRITEBACKCACHE: case MDP_FB_PAGE_PROTECTION_WRITEBACKWACACHE: for (i = 0; i < req_list_count; i++) { if (!(req_list[i].flags & MDP_NO_DMA_BARRIER_START)) { msm_fb_dma_barrier_for_rect(info, &(req_list[i].src), &(req_list[i].src_rect), msm_dma_todevice_wb_pre ); msm_fb_dma_barrier_for_rect(info, &(req_list[i].dst), &(req_list[i].dst_rect), msm_dma_todevice_wb_pre ); } } break; } #else dmb(); #endif } /* * Do the write barriers required to guarantee data will be re-read from RAM by * the CPU after a DMA operation ends. * NOTE: As currently implemented, the data between * the end of one row and the start of the next is * included in the address range rather than * doing multiple calls for each row. */ static void msm_fb_ensure_memory_coherency_after_dma(struct fb_info *info, struct mdp_blit_req *req_list, int req_list_count) { #ifdef CONFIG_ARCH_QSD8X50 int i; struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; switch (mfd->mdp_fb_page_protection) { default: case MDP_FB_PAGE_PROTECTION_NONCACHED: case MDP_FB_PAGE_PROTECTION_WRITECOMBINE: /* * The following barrier is only done at most once, * since further calls would be redundant. */ for (i = 0; i < req_list_count; i++) { if (!(req_list[i].flags & MDP_NO_DMA_BARRIER_END)) { msm_dma_nc_post(); break; } } break; case MDP_FB_PAGE_PROTECTION_WRITETHROUGHCACHE: for (i = 0; i < req_list_count; i++) { if (!(req_list[i].flags & MDP_NO_DMA_BARRIER_END)) { msm_fb_dma_barrier_for_rect(info, &(req_list[i].dst), &(req_list[i].dst_rect), msm_dma_fromdevice_wt_post ); } } break; case MDP_FB_PAGE_PROTECTION_WRITEBACKCACHE: case MDP_FB_PAGE_PROTECTION_WRITEBACKWACACHE: for (i = 0; i < req_list_count; i++) { if (!(req_list[i].flags & MDP_NO_DMA_BARRIER_END)) { msm_fb_dma_barrier_for_rect(info, &(req_list[i].dst), &(req_list[i].dst_rect), msm_dma_fromdevice_wb_post ); } } break; } #else dmb(); #endif } /* * NOTE: The userspace issues blit operations in a sequence, the sequence * start with a operation marked START and ends in an operation marked * END. It is guranteed by the userspace that all the blit operations * between START and END are only within the regions of areas designated * by the START and END operations and that the userspace doesnt modify * those areas. Hence it would be enough to perform barrier/cache operations * only on the START and END operations. */ static int msmfb_blit(struct fb_info *info, void __user *p) { /* * CAUTION: The names of the struct types intentionally *DON'T* match * the names of the variables declared -- they appear to be swapped. * Read the code carefully and you should see that the variable names * make sense. */ const int MAX_LIST_WINDOW = 16; struct mdp_blit_req req_list[MAX_LIST_WINDOW]; struct mdp_blit_req_list req_list_header; int count, i, req_list_count; if (bf_supported && (info->node == 1 || info->node == 2)) { pr_err("%s: no pan display for fb%d.", __func__, info->node); return -EPERM; } /* Get the count size for the total BLIT request. */ if (copy_from_user(&req_list_header, p, sizeof(req_list_header))) return -EFAULT; p += sizeof(req_list_header); count = req_list_header.count; if (count < 0 || count >= MAX_BLIT_REQ) return -EINVAL; while (count > 0) { /* * Access the requests through a narrow window to decrease copy * overhead and make larger requests accessible to the * coherency management code. * NOTE: The window size is intended to be larger than the * typical request size, but not require more than 2 * kbytes of stack storage. */ req_list_count = count; if (req_list_count > MAX_LIST_WINDOW) req_list_count = MAX_LIST_WINDOW; if (copy_from_user(&req_list, p, sizeof(struct mdp_blit_req)*req_list_count)) return -EFAULT; /* * Ensure that any data CPU may have previously written to * internal state (but not yet committed to memory) is * guaranteed to be committed to memory now. */ msm_fb_ensure_memory_coherency_before_dma(info, req_list, req_list_count); /* * Do the blit DMA, if required -- returning early only if * there is a failure. */ for (i = 0; i < req_list_count; i++) { if (!(req_list[i].flags & MDP_NO_BLIT)) { /* Do the actual blit. */ int ret = mdp_blit(info, &(req_list[i])); /* * Note that early returns don't guarantee * memory coherency. */ if (ret) return ret; } } /* * Ensure that CPU cache and other internal CPU state is * updated to reflect any change in memory modified by MDP blit * DMA. */ msm_fb_ensure_memory_coherency_after_dma(info, req_list, req_list_count); /* Go to next window of requests. */ count -= req_list_count; p += sizeof(struct mdp_blit_req)*req_list_count; } return 0; } static int msmfb_vsync_ctrl(struct fb_info *info, void __user *argp) { int enable, ret; struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; ret = copy_from_user(&enable, argp, sizeof(enable)); if (ret) { pr_err("%s:msmfb_overlay_vsync ioctl failed", __func__); return ret; } if (mfd->vsync_ctrl) mfd->vsync_ctrl(enable); else { pr_err("%s: Vsync IOCTL not supported", __func__); return -EINVAL; } return 0; } #ifdef CONFIG_FB_MSM_OVERLAY static int msmfb_overlay_get(struct fb_info *info, void __user *p) { struct mdp_overlay req; int ret; if (copy_from_user(&req, p, sizeof(req))) return -EFAULT; ret = mdp4_overlay_get(info, &req); if (ret) { printk(KERN_ERR "%s: ioctl failed \n", __func__); return ret; } if (copy_to_user(p, &req, sizeof(req))) { printk(KERN_ERR "%s: copy2user failed \n", __func__); return -EFAULT; } return 0; } static int msmfb_overlay_set(struct fb_info *info, void __user *p) { struct mdp_overlay req; int ret; if (copy_from_user(&req, p, sizeof(req))) return -EFAULT; ret = mdp4_overlay_set(info, &req); if (ret) { printk(KERN_ERR "%s: ioctl failed, rc=%d\n", __func__, ret); return ret; } if (copy_to_user(p, &req, sizeof(req))) { printk(KERN_ERR "%s: copy2user failed \n", __func__); return -EFAULT; } return 0; } static int msmfb_overlay_unset(struct fb_info *info, unsigned long *argp) { int ret, ndx; ret = copy_from_user(&ndx, argp, sizeof(ndx)); if (ret) { printk(KERN_ERR "%s:msmfb_overlay_unset ioctl failed \n", __func__); return ret; } return mdp4_overlay_unset(info, ndx); } static int msmfb_overlay_vsync_ctrl(struct fb_info *info, void __user *argp) { int ret; int enable; ret = copy_from_user(&enable, argp, sizeof(enable)); if (ret) { pr_err("%s:msmfb_overlay_vsync ioctl failed", __func__); return ret; } ret = mdp4_overlay_vsync_ctrl(info, enable); return ret; } static int msmfb_overlay_play_wait(struct fb_info *info, unsigned long *argp) { int ret; struct msmfb_overlay_data req; struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; if (mfd->overlay_play_enable == 0) /* nothing to do */ return 0; ret = copy_from_user(&req, argp, sizeof(req)); if (ret) { pr_err("%s:msmfb_overlay_wait ioctl failed", __func__); return ret; } ret = mdp4_overlay_play_wait(info, &req); return ret; } static int msmfb_overlay_commit(struct fb_info *info) { return mdp4_overlay_commit(info); } static int msmfb_overlay_play(struct fb_info *info, unsigned long *argp) { int ret; struct msmfb_overlay_data req; struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; if (mfd->overlay_play_enable == 0) /* nothing to do */ return 0; ret = copy_from_user(&req, argp, sizeof(req)); if (ret) { printk(KERN_ERR "%s:msmfb_overlay_play ioctl failed \n", __func__); return ret; } complete(&mfd->msmfb_update_notify); mutex_lock(&msm_fb_notify_update_sem); if (mfd->msmfb_no_update_notify_timer.function) del_timer(&mfd->msmfb_no_update_notify_timer); mfd->msmfb_no_update_notify_timer.expires = jiffies + (2 * HZ); add_timer(&mfd->msmfb_no_update_notify_timer); mutex_unlock(&msm_fb_notify_update_sem); if (info->node == 0 && !(mfd->cont_splash_done)) { /* primary */ mdp_set_dma_pan_info(info, NULL, TRUE); if (msm_fb_blank_sub(FB_BLANK_UNBLANK, info, mfd->op_enable)) { pr_err("%s: can't turn on display!\n", __func__); return -EINVAL; } } ret = mdp4_overlay_play(info, &req); if (unset_bl_level && !bl_updated) schedule_delayed_work(&mfd->backlight_worker, backlight_duration); if (info->node == 0 && (mfd->cont_splash_done)) /* primary */ mdp_free_splash_buffer(mfd); return ret; } static int msmfb_overlay_play_enable(struct fb_info *info, unsigned long *argp) { int ret, enable; struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; ret = copy_from_user(&enable, argp, sizeof(enable)); if (ret) { printk(KERN_ERR "%s:msmfb_overlay_play_enable ioctl failed \n", __func__); return ret; } mfd->overlay_play_enable = enable; return 0; } static int msmfb_overlay_blt(struct fb_info *info, unsigned long *argp) { int ret; struct msmfb_overlay_blt req; ret = copy_from_user(&req, argp, sizeof(req)); if (ret) { pr_err("%s: failed\n", __func__); return ret; } ret = mdp4_overlay_blt(info, &req); return ret; } #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL static int msmfb_overlay_ioctl_writeback_init(struct fb_info *info) { return mdp4_writeback_init(info); } static int msmfb_overlay_ioctl_writeback_start( struct fb_info *info) { int ret = 0; ret = mdp4_writeback_start(info); if (ret) goto error; error: if (ret) pr_err("%s:msmfb_writeback_start " " ioctl failed\n", __func__); return ret; } static int msmfb_overlay_ioctl_writeback_stop( struct fb_info *info) { int ret = 0; ret = mdp4_writeback_stop(info); if (ret) goto error; error: if (ret) pr_err("%s:msmfb_writeback_stop ioctl failed\n", __func__); return ret; } static int msmfb_overlay_ioctl_writeback_queue_buffer( struct fb_info *info, unsigned long *argp) { int ret = 0; struct msmfb_data data; ret = copy_from_user(&data, argp, sizeof(data)); if (ret) goto error; ret = mdp4_writeback_queue_buffer(info, &data); if (ret) goto error; error: if (ret) pr_err("%s:msmfb_writeback_queue_buffer ioctl failed\n", __func__); return ret; } static int msmfb_overlay_ioctl_writeback_dequeue_buffer( struct fb_info *info, unsigned long *argp) { int ret = 0; struct msmfb_data data; ret = copy_from_user(&data, argp, sizeof(data)); if (ret) goto error; ret = mdp4_writeback_dequeue_buffer(info, &data); if (ret) goto error; ret = copy_to_user(argp, &data, sizeof(data)); if (ret) goto error; error: if (ret) pr_err("%s:msmfb_writeback_dequeue_buffer ioctl failed\n", __func__); return ret; } static int msmfb_overlay_ioctl_writeback_terminate(struct fb_info *info) { return mdp4_writeback_terminate(info); } static int msmfb_overlay_ioctl_writeback_set_mirr_hint(struct fb_info * info, void *argp) { int ret = 0, hint; if (!info) { ret = -EINVAL; goto error; } ret = copy_from_user(&hint, argp, sizeof(hint)); if (ret) goto error; ret = mdp4_writeback_set_mirroring_hint(info, hint); if (ret) goto error; error: if (ret) pr_err("%s: ioctl failed\n", __func__); return ret; } #else static int msmfb_overlay_ioctl_writeback_init(struct fb_info *info) { return -ENOTSUPP; } static int msmfb_overlay_ioctl_writeback_start( struct fb_info *info) { return -ENOTSUPP; } static int msmfb_overlay_ioctl_writeback_stop( struct fb_info *info) { return -ENOTSUPP; } static int msmfb_overlay_ioctl_writeback_queue_buffer( struct fb_info *info, unsigned long *argp) { return -ENOTSUPP; } static int msmfb_overlay_ioctl_writeback_dequeue_buffer( struct fb_info *info, unsigned long *argp) { return -ENOTSUPP; } static int msmfb_overlay_ioctl_writeback_terminate(struct fb_info *info) { return -ENOTSUPP; } static int msmfb_overlay_ioctl_writeback_set_mirr_hint(struct fb_info * info, void *argp) { return -ENOTSUPP; } #endif static int msmfb_overlay_3d_sbys(struct fb_info *info, unsigned long *argp) { int ret; struct msmfb_overlay_3d req; ret = copy_from_user(&req, argp, sizeof(req)); if (ret) { pr_err("%s:msmfb_overlay_3d_ctrl ioctl failed\n", __func__); return ret; } ret = mdp4_overlay_3d_sbys(info, &req); return ret; } static int msmfb_mixer_info(struct fb_info *info, unsigned long *argp) { int ret, cnt; struct msmfb_mixer_info_req req; ret = copy_from_user(&req, argp, sizeof(req)); if (ret) { pr_err("%s: failed\n", __func__); return ret; } cnt = mdp4_mixer_info(req.mixer_num, req.info); req.cnt = cnt; ret = copy_to_user(argp, &req, sizeof(req)); if (ret) pr_err("%s:msmfb_overlay_blt_off ioctl failed\n", __func__); return cnt; } #endif DEFINE_SEMAPHORE(msm_fb_ioctl_ppp_sem); DEFINE_SEMAPHORE(msm_fb_ioctl_vsync_sem); DEFINE_MUTEX(msm_fb_ioctl_lut_sem); /* Set color conversion matrix from user space */ #ifndef CONFIG_FB_MSM_MDP40 static void msmfb_set_color_conv(struct mdp_ccs *p) { int i; if (p->direction == MDP_CCS_RGB2YUV) { /* MDP cmd block enable */ mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); /* RGB->YUV primary forward matrix */ for (i = 0; i < MDP_CCS_SIZE; i++) writel(p->ccs[i], MDP_CSC_PFMVn(i)); #ifdef CONFIG_FB_MSM_MDP31 for (i = 0; i < MDP_BV_SIZE; i++) writel(p->bv[i], MDP_CSC_POST_BV2n(i)); #endif /* MDP cmd block disable */ mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); } else { /* MDP cmd block enable */ mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); /* YUV->RGB primary reverse matrix */ for (i = 0; i < MDP_CCS_SIZE; i++) writel(p->ccs[i], MDP_CSC_PRMVn(i)); for (i = 0; i < MDP_BV_SIZE; i++) writel(p->bv[i], MDP_CSC_PRE_BV1n(i)); /* MDP cmd block disable */ mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); } } #else static void msmfb_set_color_conv(struct mdp_csc *p) { mdp4_vg_csc_update(p); } #endif static int msmfb_notify_update(struct fb_info *info, unsigned long *argp) { int ret, notify; struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; ret = copy_from_user(&notify, argp, sizeof(int)); if (ret) { pr_err("%s:ioctl failed\n", __func__); return ret; } if (notify > NOTIFY_UPDATE_STOP) return -EINVAL; if (notify == NOTIFY_UPDATE_START) { INIT_COMPLETION(mfd->msmfb_update_notify); ret = wait_for_completion_interruptible_timeout( &mfd->msmfb_update_notify, 4*HZ); } else { INIT_COMPLETION(mfd->msmfb_no_update_notify); ret = wait_for_completion_interruptible_timeout( &mfd->msmfb_no_update_notify, 4*HZ); } if (ret == 0) ret = -ETIMEDOUT; return (ret > 0) ? 0 : ret; } static int msmfb_handle_pp_ioctl(struct msm_fb_data_type *mfd, struct msmfb_mdp_pp *pp_ptr) { int ret = -1; #ifdef CONFIG_FB_MSM_MDP40 int i = 0; #endif if (!pp_ptr) return ret; switch (pp_ptr->op) { #ifdef CONFIG_FB_MSM_MDP40 case mdp_op_csc_cfg: ret = mdp4_csc_config(&(pp_ptr->data.csc_cfg_data)); for (i = 0; i < CSC_MAX_BLOCKS; i++) { if (pp_ptr->data.csc_cfg_data.block == csc_cfg_matrix[i].block) { memcpy(&csc_cfg_matrix[i].csc_data, &(pp_ptr->data.csc_cfg_data.csc_data), sizeof(struct mdp_csc_cfg)); break; } } break; case mdp_op_pcc_cfg: ret = mdp4_pcc_cfg(&(pp_ptr->data.pcc_cfg_data)); break; case mdp_op_lut_cfg: switch (pp_ptr->data.lut_cfg_data.lut_type) { case mdp_lut_igc: ret = mdp4_igc_lut_config( (struct mdp_igc_lut_data *) &pp_ptr->data.lut_cfg_data.data); break; case mdp_lut_pgc: ret = mdp4_argc_cfg( &pp_ptr->data.lut_cfg_data.data.pgc_lut_data); break; case mdp_lut_hist: ret = mdp_hist_lut_config( (struct mdp_hist_lut_data *) &pp_ptr->data.lut_cfg_data.data); break; default: break; } break; case mdp_op_qseed_cfg: ret = mdp4_qseed_cfg((struct mdp_qseed_cfg_data *) &pp_ptr->data.qseed_cfg_data); break; case mdp_op_calib_cfg: ret = mdp4_calib_config((struct mdp_calib_config_data *) &pp_ptr->data.calib_cfg); break; #endif case mdp_bl_scale_cfg: ret = mdp_bl_scale_config(mfd, (struct mdp_bl_scale_data *) &pp_ptr->data.bl_scale_data); break; default: pr_warn("Unsupported request to MDP_PP IOCTL.\n"); ret = -EINVAL; break; } return ret; } static int msmfb_handle_metadata_ioctl(struct msm_fb_data_type *mfd, struct msmfb_metadata *metadata_ptr) { int ret; switch (metadata_ptr->op) { #ifdef CONFIG_FB_MSM_MDP40 case metadata_op_base_blend: ret = mdp4_update_base_blend(mfd, &metadata_ptr->data.blend_cfg); break; case metadata_op_wb_format: ret = mdp4_update_writeback_format(mfd, &metadata_ptr->data.mixer_cfg); break; #endif default: pr_warn("Unsupported request to MDP META IOCTL.\n"); ret = -EINVAL; break; } return ret; } static int msmfb_get_metadata(struct msm_fb_data_type *mfd, struct msmfb_metadata *metadata_ptr) { int ret = 0; switch (metadata_ptr->op) { case metadata_op_frame_rate: metadata_ptr->data.panel_frame_rate = mdp_get_panel_framerate(mfd); break; default: pr_warn("Unsupported request to MDP META IOCTL.\n"); ret = -EINVAL; break; } return ret; } static int msmfb_handle_buf_sync_ioctl(struct msm_fb_data_type *mfd, struct mdp_buf_sync *buf_sync) { int i, fence_cnt = 0, ret = 0; int acq_fen_fd[MDP_MAX_FENCE_FD]; struct sync_fence *fence; if ((buf_sync->acq_fen_fd_cnt > MDP_MAX_FENCE_FD) || (mfd->timeline == NULL)) return -EINVAL; if (buf_sync->acq_fen_fd_cnt) ret = copy_from_user(acq_fen_fd, buf_sync->acq_fen_fd, buf_sync->acq_fen_fd_cnt * sizeof(int)); if (ret) { pr_err("%s:copy_from_user failed", __func__); return ret; } mutex_lock(&mfd->sync_mutex); for (i = 0; i < buf_sync->acq_fen_fd_cnt; i++) { fence = sync_fence_fdget(acq_fen_fd[i]); if (fence == NULL) { pr_info("%s: null fence! i=%d fd=%d\n", __func__, i, acq_fen_fd[i]); ret = -EINVAL; break; } mfd->acq_fen[i] = fence; } fence_cnt = i; if (ret) goto buf_sync_err_1; mfd->acq_fen_cnt = fence_cnt; if (buf_sync->flags & MDP_BUF_SYNC_FLAG_WAIT) msm_fb_wait_for_fence(mfd); mfd->cur_rel_sync_pt = sw_sync_pt_create(mfd->timeline, mfd->timeline_value + 2); if (mfd->cur_rel_sync_pt == NULL) { pr_err("%s: cannot create sync point", __func__); ret = -ENOMEM; goto buf_sync_err_1; } /* create fence */ mfd->cur_rel_fence = sync_fence_create("mdp-fence", mfd->cur_rel_sync_pt); if (mfd->cur_rel_fence == NULL) { sync_pt_free(mfd->cur_rel_sync_pt); mfd->cur_rel_sync_pt = NULL; pr_err("%s: cannot create fence", __func__); ret = -ENOMEM; goto buf_sync_err_1; } /* create fd */ mfd->cur_rel_fen_fd = get_unused_fd_flags(0); sync_fence_install(mfd->cur_rel_fence, mfd->cur_rel_fen_fd); ret = copy_to_user(buf_sync->rel_fen_fd, &mfd->cur_rel_fen_fd, sizeof(int)); if (ret) { pr_err("%s:copy_to_user failed", __func__); goto buf_sync_err_2; } mutex_unlock(&mfd->sync_mutex); return ret; buf_sync_err_2: sync_fence_put(mfd->cur_rel_fence); put_unused_fd(mfd->cur_rel_fen_fd); mfd->cur_rel_fence = NULL; mfd->cur_rel_fen_fd = 0; buf_sync_err_1: for (i = 0; i < fence_cnt; i++) sync_fence_put(mfd->acq_fen[i]); mfd->acq_fen_cnt = 0; mutex_unlock(&mfd->sync_mutex); return ret; } static int buf_fence_process(struct msm_fb_data_type *mfd, struct mdp_buf_fence *buf_fence) { int i, fence_cnt = 0, ret; struct sync_fence *fence; if ((buf_fence->acq_fen_fd_cnt == 0) || (buf_fence->acq_fen_fd_cnt > MDP_MAX_FENCE_FD) || (mfd->timeline == NULL)) return -EINVAL; mutex_lock(&mfd->sync_mutex); for (i = 0; i < buf_fence->acq_fen_fd_cnt; i++) { fence = sync_fence_fdget(buf_fence->acq_fen_fd[i]); if (fence == NULL) { pr_info("%s: null fence! i=%d fd=%d\n", __func__, i, buf_fence->acq_fen_fd[i]); ret = -EINVAL; break; } mfd->acq_fen[i] = fence; } fence_cnt = i; if (ret) goto buf_fence_err_1; mfd->cur_rel_sync_pt = sw_sync_pt_create(mfd->timeline, mfd->timeline_value + 2); if (mfd->cur_rel_sync_pt == NULL) { pr_err("%s: cannot create sync point", __func__); ret = -ENOMEM; goto buf_fence_err_1; } /* create fence */ mfd->cur_rel_fence = sync_fence_create("mdp-fence", mfd->cur_rel_sync_pt); if (mfd->cur_rel_fence == NULL) { sync_pt_free(mfd->cur_rel_sync_pt); mfd->cur_rel_sync_pt = NULL; pr_err("%s: cannot create fence", __func__); ret = -ENOMEM; goto buf_fence_err_1; } /* create fd */ mfd->cur_rel_fen_fd = get_unused_fd_flags(0); sync_fence_install(mfd->cur_rel_fence, mfd->cur_rel_fen_fd); buf_fence->rel_fen_fd[0] = mfd->cur_rel_fen_fd; /* Only one released fd for now, -1 indicates an end */ buf_fence->rel_fen_fd[1] = -1; mfd->acq_fen_cnt = buf_fence->acq_fen_fd_cnt; mutex_unlock(&mfd->sync_mutex); return ret; buf_fence_err_1: for (i = 0; i < fence_cnt; i++) sync_fence_put(mfd->acq_fen[i]); mfd->acq_fen_cnt = 0; mutex_unlock(&mfd->sync_mutex); return ret; } static int msmfb_display_commit(struct fb_info *info, unsigned long *argp) { int ret; u32 copy_back = FALSE; struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; struct mdp_display_commit disp_commit; struct mdp_buf_fence *buf_fence; ret = copy_from_user(&disp_commit, argp, sizeof(disp_commit)); if (ret) { pr_err("%s:copy_from_user failed", __func__); return ret; } buf_fence = &disp_commit.buf_fence; if (buf_fence->acq_fen_fd_cnt > 0) ret = buf_fence_process(mfd, buf_fence); if ((!ret) && (buf_fence->rel_fen_fd[0] > 0)) copy_back = TRUE; ret = msm_fb_pan_display_ex(&disp_commit.var, info, disp_commit.wait_for_finish); if (copy_back) { ret = copy_to_user(argp, &disp_commit, sizeof(disp_commit)); if (ret) pr_err("%s:copy_to_user failed", __func__); } return ret; } static int msm_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) { struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; void __user *argp = (void __user *)arg; struct fb_cursor cursor; struct fb_cmap cmap; struct mdp_histogram_data hist; struct mdp_histogram_start_req hist_req; uint32_t block; #ifndef CONFIG_FB_MSM_MDP40 struct mdp_ccs ccs_matrix; #else struct mdp_csc csc_matrix; #endif struct mdp_page_protection fb_page_protection; struct msmfb_mdp_pp mdp_pp; struct msmfb_metadata mdp_metadata; struct mdp_buf_sync buf_sync; int ret = 0; msm_fb_pan_idle(mfd); switch (cmd) { #ifdef CONFIG_FB_MSM_OVERLAY case MSMFB_OVERLAY_GET: ret = msmfb_overlay_get(info, argp); break; case MSMFB_OVERLAY_SET: ret = msmfb_overlay_set(info, argp); break; case MSMFB_OVERLAY_UNSET: ret = msmfb_overlay_unset(info, argp); break; case MSMFB_OVERLAY_COMMIT: down(&msm_fb_ioctl_ppp_sem); ret = msmfb_overlay_commit(info); up(&msm_fb_ioctl_ppp_sem); break; case MSMFB_OVERLAY_PLAY: ret = msmfb_overlay_play(info, argp); break; case MSMFB_OVERLAY_PLAY_ENABLE: ret = msmfb_overlay_play_enable(info, argp); break; case MSMFB_OVERLAY_PLAY_WAIT: ret = msmfb_overlay_play_wait(info, argp); break; case MSMFB_OVERLAY_BLT: ret = msmfb_overlay_blt(info, argp); break; case MSMFB_OVERLAY_3D: ret = msmfb_overlay_3d_sbys(info, argp); break; case MSMFB_MIXER_INFO: ret = msmfb_mixer_info(info, argp); break; case MSMFB_WRITEBACK_INIT: ret = msmfb_overlay_ioctl_writeback_init(info); break; case MSMFB_WRITEBACK_START: ret = msmfb_overlay_ioctl_writeback_start( info); break; case MSMFB_WRITEBACK_STOP: ret = msmfb_overlay_ioctl_writeback_stop( info); break; case MSMFB_WRITEBACK_QUEUE_BUFFER: ret = msmfb_overlay_ioctl_writeback_queue_buffer( info, argp); break; case MSMFB_WRITEBACK_DEQUEUE_BUFFER: ret = msmfb_overlay_ioctl_writeback_dequeue_buffer( info, argp); break; case MSMFB_WRITEBACK_TERMINATE: ret = msmfb_overlay_ioctl_writeback_terminate(info); break; case MSMFB_WRITEBACK_SET_MIRRORING_HINT: ret = msmfb_overlay_ioctl_writeback_set_mirr_hint( info, argp); break; #endif case MSMFB_VSYNC_CTRL: case MSMFB_OVERLAY_VSYNC_CTRL: down(&msm_fb_ioctl_vsync_sem); if (mdp_rev >= MDP_REV_40) ret = msmfb_overlay_vsync_ctrl(info, argp); else ret = msmfb_vsync_ctrl(info, argp); up(&msm_fb_ioctl_vsync_sem); break; case MSMFB_BLIT: down(&msm_fb_ioctl_ppp_sem); ret = msmfb_blit(info, argp); up(&msm_fb_ioctl_ppp_sem); break; /* Ioctl for setting ccs matrix from user space */ case MSMFB_SET_CCS_MATRIX: #ifndef CONFIG_FB_MSM_MDP40 ret = copy_from_user(&ccs_matrix, argp, sizeof(ccs_matrix)); if (ret) { printk(KERN_ERR "%s:MSMFB_SET_CCS_MATRIX ioctl failed \n", __func__); return ret; } down(&msm_fb_ioctl_ppp_sem); if (ccs_matrix.direction == MDP_CCS_RGB2YUV) mdp_ccs_rgb2yuv = ccs_matrix; else mdp_ccs_yuv2rgb = ccs_matrix; msmfb_set_color_conv(&ccs_matrix) ; up(&msm_fb_ioctl_ppp_sem); #else ret = copy_from_user(&csc_matrix, argp, sizeof(csc_matrix)); if (ret) { pr_err("%s:MSMFB_SET_CSC_MATRIX ioctl failed\n", __func__); return ret; } down(&msm_fb_ioctl_ppp_sem); msmfb_set_color_conv(&csc_matrix); up(&msm_fb_ioctl_ppp_sem); #endif break; /* Ioctl for getting ccs matrix to user space */ case MSMFB_GET_CCS_MATRIX: #ifndef CONFIG_FB_MSM_MDP40 ret = copy_from_user(&ccs_matrix, argp, sizeof(ccs_matrix)) ; if (ret) { printk(KERN_ERR "%s:MSMFB_GET_CCS_MATRIX ioctl failed \n", __func__); return ret; } down(&msm_fb_ioctl_ppp_sem); if (ccs_matrix.direction == MDP_CCS_RGB2YUV) ccs_matrix = mdp_ccs_rgb2yuv; else ccs_matrix = mdp_ccs_yuv2rgb; ret = copy_to_user(argp, &ccs_matrix, sizeof(ccs_matrix)); if (ret) { printk(KERN_ERR "%s:MSMFB_GET_CCS_MATRIX ioctl failed \n", __func__); return ret ; } up(&msm_fb_ioctl_ppp_sem); #else ret = -EINVAL; #endif break; case MSMFB_GRP_DISP: #ifdef CONFIG_FB_MSM_MDP22 { unsigned long grp_id; ret = copy_from_user(&grp_id, argp, sizeof(grp_id)); if (ret) return ret; mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); writel(grp_id, MDP_FULL_BYPASS_WORD43); mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); break; } #else return -EFAULT; #endif case MSMFB_SUSPEND_SW_REFRESHER: if (!mfd->panel_power_on) return -EPERM; mfd->sw_refreshing_enable = FALSE; ret = msm_fb_stop_sw_refresher(mfd); break; case MSMFB_RESUME_SW_REFRESHER: if (!mfd->panel_power_on) return -EPERM; mfd->sw_refreshing_enable = TRUE; ret = msm_fb_resume_sw_refresher(mfd); break; case MSMFB_CURSOR: ret = copy_from_user(&cursor, argp, sizeof(cursor)); if (ret) return ret; ret = msm_fb_cursor(info, &cursor); break; case MSMFB_SET_LUT: ret = copy_from_user(&cmap, argp, sizeof(cmap)); if (ret) return ret; mutex_lock(&msm_fb_ioctl_lut_sem); ret = msm_fb_set_lut(&cmap, info); mutex_unlock(&msm_fb_ioctl_lut_sem); break; case MSMFB_HISTOGRAM: if (!mfd->panel_power_on) return -EPERM; if (!mfd->do_histogram) return -ENODEV; ret = copy_from_user(&hist, argp, sizeof(hist)); if (ret) return ret; ret = mfd->do_histogram(info, &hist); break; case MSMFB_HISTOGRAM_START: if (!mfd->panel_power_on) return -EPERM; if (!mfd->start_histogram) return -ENODEV; ret = copy_from_user(&hist_req, argp, sizeof(hist_req)); if (ret) return ret; ret = mfd->start_histogram(&hist_req); break; case MSMFB_HISTOGRAM_STOP: if (!mfd->stop_histogram) return -ENODEV; ret = copy_from_user(&block, argp, sizeof(int)); if (ret) return ret; ret = mfd->stop_histogram(info, block); break; case MSMFB_GET_PAGE_PROTECTION: fb_page_protection.page_protection = mfd->mdp_fb_page_protection; ret = copy_to_user(argp, &fb_page_protection, sizeof(fb_page_protection)); if (ret) return ret; break; case MSMFB_NOTIFY_UPDATE: ret = msmfb_notify_update(info, argp); break; case MSMFB_SET_PAGE_PROTECTION: #if defined CONFIG_ARCH_QSD8X50 || defined CONFIG_ARCH_MSM8X60 ret = copy_from_user(&fb_page_protection, argp, sizeof(fb_page_protection)); if (ret) return ret; /* Validate the proposed page protection settings. */ switch (fb_page_protection.page_protection) { case MDP_FB_PAGE_PROTECTION_NONCACHED: case MDP_FB_PAGE_PROTECTION_WRITECOMBINE: case MDP_FB_PAGE_PROTECTION_WRITETHROUGHCACHE: /* Write-back cache (read allocate) */ case MDP_FB_PAGE_PROTECTION_WRITEBACKCACHE: /* Write-back cache (write allocate) */ case MDP_FB_PAGE_PROTECTION_WRITEBACKWACACHE: mfd->mdp_fb_page_protection = fb_page_protection.page_protection; break; default: ret = -EINVAL; break; } #else /* * Don't allow caching until 7k DMA cache operations are * available. */ ret = -EINVAL; #endif break; case MSMFB_MDP_PP: ret = copy_from_user(&mdp_pp, argp, sizeof(mdp_pp)); if (ret) return ret; ret = msmfb_handle_pp_ioctl(mfd, &mdp_pp); if (ret == 1) ret = copy_to_user(argp, &mdp_pp, sizeof(mdp_pp)); break; case MSMFB_BUFFER_SYNC: ret = copy_from_user(&buf_sync, argp, sizeof(buf_sync)); if (ret) return ret; ret = msmfb_handle_buf_sync_ioctl(mfd, &buf_sync); if (!ret) ret = copy_to_user(argp, &buf_sync, sizeof(buf_sync)); break; case MSMFB_METADATA_SET: ret = copy_from_user(&mdp_metadata, argp, sizeof(mdp_metadata)); if (ret) return ret; ret = msmfb_handle_metadata_ioctl(mfd, &mdp_metadata); case MSMFB_DISPLAY_COMMIT: ret = msmfb_display_commit(info, argp); break; case MSMFB_METADATA_GET: ret = copy_from_user(&mdp_metadata, argp, sizeof(mdp_metadata)); if (ret) return ret; ret = msmfb_get_metadata(mfd, &mdp_metadata); if (!ret) ret = copy_to_user(argp, &mdp_metadata, sizeof(mdp_metadata)); break; default: MSM_FB_INFO("MDP: unknown ioctl (cmd=%x) received!\n", cmd); ret = -EINVAL; break; } return ret; } static int msm_fb_register_driver(void) { return platform_driver_register(&msm_fb_driver); } #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL struct fb_info *msm_fb_get_writeback_fb(void) { int c = 0; for (c = 0; c < fbi_list_index; ++c) { struct msm_fb_data_type *mfd; mfd = (struct msm_fb_data_type *)fbi_list[c]->par; if (mfd->panel.type == WRITEBACK_PANEL) return fbi_list[c]; } return NULL; } EXPORT_SYMBOL(msm_fb_get_writeback_fb); int msm_fb_writeback_start(struct fb_info *info) { return mdp4_writeback_start(info); } EXPORT_SYMBOL(msm_fb_writeback_start); int msm_fb_writeback_queue_buffer(struct fb_info *info, struct msmfb_data *data) { return mdp4_writeback_queue_buffer(info, data); } EXPORT_SYMBOL(msm_fb_writeback_queue_buffer); int msm_fb_writeback_dequeue_buffer(struct fb_info *info, struct msmfb_data *data) { return mdp4_writeback_dequeue_buffer(info, data); } EXPORT_SYMBOL(msm_fb_writeback_dequeue_buffer); int msm_fb_writeback_stop(struct fb_info *info) { return mdp4_writeback_stop(info); } EXPORT_SYMBOL(msm_fb_writeback_stop); int msm_fb_writeback_init(struct fb_info *info) { return mdp4_writeback_init(info); } EXPORT_SYMBOL(msm_fb_writeback_init); int msm_fb_writeback_terminate(struct fb_info *info) { return mdp4_writeback_terminate(info); } EXPORT_SYMBOL(msm_fb_writeback_terminate); #endif struct platform_device *msm_fb_add_device(struct platform_device *pdev) { struct msm_fb_panel_data *pdata; struct platform_device *this_dev = NULL; struct fb_info *fbi; struct msm_fb_data_type *mfd = NULL; u32 type, id, fb_num; if (!pdev) return NULL; id = pdev->id; pdata = pdev->dev.platform_data; if (!pdata) return NULL; type = pdata->panel_info.type; #if defined MSM_FB_NUM /* * over written fb_num which defined * at panel_info * */ if (type == HDMI_PANEL || type == DTV_PANEL || type == TV_PANEL || type == WRITEBACK_PANEL) { if (hdmi_prim_display) pdata->panel_info.fb_num = 2; else pdata->panel_info.fb_num = 1; } else pdata->panel_info.fb_num = MSM_FB_NUM; MSM_FB_INFO("setting pdata->panel_info.fb_num to %d. type: %d\n", pdata->panel_info.fb_num, type); #endif fb_num = pdata->panel_info.fb_num; if (fb_num <= 0) return NULL; if (fbi_list_index >= MAX_FBI_LIST) { printk(KERN_ERR "msm_fb: no more framebuffer info list!\n"); return NULL; } /* * alloc panel device data */ this_dev = msm_fb_device_alloc(pdata, type, id); if (!this_dev) { printk(KERN_ERR "%s: msm_fb_device_alloc failed!\n", __func__); return NULL; } /* * alloc framebuffer info + par data */ fbi = framebuffer_alloc(sizeof(struct msm_fb_data_type), NULL); if (fbi == NULL) { platform_device_put(this_dev); printk(KERN_ERR "msm_fb: can't alloca framebuffer info data!\n"); return NULL; } mfd = (struct msm_fb_data_type *)fbi->par; mfd->key = MFD_KEY; mfd->fbi = fbi; mfd->panel.type = type; mfd->panel.id = id; mfd->fb_page = fb_num; mfd->index = fbi_list_index; mfd->mdp_fb_page_protection = MDP_FB_PAGE_PROTECTION_WRITECOMBINE; mfd->iclient = iclient; /* link to the latest pdev */ mfd->pdev = this_dev; mfd_list[mfd_list_index++] = mfd; fbi_list[fbi_list_index++] = fbi; /* * set driver data */ platform_set_drvdata(this_dev, mfd); if (platform_device_add(this_dev)) { printk(KERN_ERR "msm_fb: platform_device_add failed!\n"); platform_device_put(this_dev); framebuffer_release(fbi); fbi_list_index--; return NULL; } return this_dev; } EXPORT_SYMBOL(msm_fb_add_device); int get_fb_phys_info(unsigned long *start, unsigned long *len, int fb_num, int subsys_id) { struct fb_info *info; struct msm_fb_data_type *mfd; if (fb_num > MAX_FBI_LIST || (subsys_id != DISPLAY_SUBSYSTEM_ID && subsys_id != ROTATOR_SUBSYSTEM_ID)) { pr_err("%s(): Invalid parameters\n", __func__); return -1; } info = fbi_list[fb_num]; if (!info) { pr_err("%s(): info is NULL\n", __func__); return -1; } mfd = (struct msm_fb_data_type *)info->par; if (subsys_id == DISPLAY_SUBSYSTEM_ID) { if (mfd->display_iova) *start = mfd->display_iova; else *start = info->fix.smem_start; } else { if (mfd->rotator_iova) *start = mfd->rotator_iova; else *start = info->fix.smem_start; } *len = info->fix.smem_len; return 0; } EXPORT_SYMBOL(get_fb_phys_info); int __init msm_fb_init(void) { int rc = -ENODEV; if (msm_fb_register_driver()) return rc; #ifdef MSM_FB_ENABLE_DBGFS { struct dentry *root; if ((root = msm_fb_get_debugfs_root()) != NULL) { msm_fb_debugfs_file_create(root, "msm_fb_msg_printing_level", (u32 *) &msm_fb_msg_level); msm_fb_debugfs_file_create(root, "mddi_msg_printing_level", (u32 *) &mddi_msg_level); msm_fb_debugfs_file_create(root, "msm_fb_debug_enabled", (u32 *) &msm_fb_debug_enabled); } } #endif return 0; } /* Called by v4l2 driver to enable/disable overlay pipe */ int msm_fb_v4l2_enable(struct mdp_overlay *req, bool enable, void **par) { int err = 0; #ifdef CONFIG_FB_MSM_MDP40 struct mdp4_overlay_pipe *pipe; if (enable) { err = mdp4_v4l2_overlay_set(fbi_list[0], req, &pipe); *(struct mdp4_overlay_pipe **)par = pipe; } else { pipe = *(struct mdp4_overlay_pipe **)par; mdp4_v4l2_overlay_clear(pipe); } #else #ifdef CONFIG_FB_MSM_MDP30 if (enable) err = mdp_ppp_v4l2_overlay_set(fbi_list[0], req); else err = mdp_ppp_v4l2_overlay_clear(); #else err = -EINVAL; #endif #endif return err; } EXPORT_SYMBOL(msm_fb_v4l2_enable); /* Called by v4l2 driver to provide a frame for display */ int msm_fb_v4l2_update(void *par, bool bUserPtr, unsigned long srcp0_addr, unsigned long srcp0_size, unsigned long srcp1_addr, unsigned long srcp1_size, unsigned long srcp2_addr, unsigned long srcp2_size) { #ifdef CONFIG_FB_MSM_MDP40 struct mdp4_overlay_pipe *pipe = (struct mdp4_overlay_pipe *)par; return mdp4_v4l2_overlay_play(fbi_list[0], pipe, srcp0_addr, srcp1_addr, srcp2_addr); #else #ifdef CONFIG_FB_MSM_MDP30 if (bUserPtr) return mdp_ppp_v4l2_overlay_play(fbi_list[0], true, srcp0_addr, srcp0_size, srcp1_addr, srcp1_size); else return mdp_ppp_v4l2_overlay_play(fbi_list[0], false, srcp0_addr, srcp0_size, srcp1_addr, srcp1_size); #else return -EINVAL; #endif #endif } EXPORT_SYMBOL(msm_fb_v4l2_update); module_init(msm_fb_init);
gpl-2.0
geniousisme/linux
drivers/phy/phy-s5pv210-usb2.c
1653
4490
/* * Samsung SoC USB 1.1/2.0 PHY driver - S5PV210 support * * Copyright (C) 2013 Samsung Electronics Co., Ltd. * Authors: Kamil Debski <k.debski@samsung.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/delay.h> #include <linux/io.h> #include <linux/phy/phy.h> #include "phy-samsung-usb2.h" /* Exynos USB PHY registers */ /* PHY power control */ #define S5PV210_UPHYPWR 0x0 #define S5PV210_UPHYPWR_PHY0_SUSPEND BIT(0) #define S5PV210_UPHYPWR_PHY0_PWR BIT(3) #define S5PV210_UPHYPWR_PHY0_OTG_PWR BIT(4) #define S5PV210_UPHYPWR_PHY0 ( \ S5PV210_UPHYPWR_PHY0_SUSPEND | \ S5PV210_UPHYPWR_PHY0_PWR | \ S5PV210_UPHYPWR_PHY0_OTG_PWR) #define S5PV210_UPHYPWR_PHY1_SUSPEND BIT(6) #define S5PV210_UPHYPWR_PHY1_PWR BIT(7) #define S5PV210_UPHYPWR_PHY1 ( \ S5PV210_UPHYPWR_PHY1_SUSPEND | \ S5PV210_UPHYPWR_PHY1_PWR) /* PHY clock control */ #define S5PV210_UPHYCLK 0x4 #define S5PV210_UPHYCLK_PHYFSEL_MASK (0x3 << 0) #define S5PV210_UPHYCLK_PHYFSEL_48MHZ (0x0 << 0) #define S5PV210_UPHYCLK_PHYFSEL_24MHZ (0x3 << 0) #define S5PV210_UPHYCLK_PHYFSEL_12MHZ (0x2 << 0) #define S5PV210_UPHYCLK_PHY0_ID_PULLUP BIT(2) #define S5PV210_UPHYCLK_PHY0_COMMON_ON BIT(4) #define S5PV210_UPHYCLK_PHY1_COMMON_ON BIT(7) /* PHY reset control */ #define S5PV210_UPHYRST 0x8 #define S5PV210_URSTCON_PHY0 BIT(0) #define S5PV210_URSTCON_OTG_HLINK BIT(1) #define S5PV210_URSTCON_OTG_PHYLINK BIT(2) #define S5PV210_URSTCON_PHY1_ALL BIT(3) #define S5PV210_URSTCON_HOST_LINK_ALL BIT(4) /* Isolation, configured in the power management unit */ #define S5PV210_USB_ISOL_OFFSET 0x680c #define S5PV210_USB_ISOL_DEVICE BIT(0) #define S5PV210_USB_ISOL_HOST BIT(1) enum s5pv210_phy_id { S5PV210_DEVICE, S5PV210_HOST, S5PV210_NUM_PHYS, }; /* * s5pv210_rate_to_clk() converts the supplied clock rate to the value that * can be written to the phy register. */ static int s5pv210_rate_to_clk(unsigned long rate, u32 *reg) { switch (rate) { case 12 * MHZ: *reg = S5PV210_UPHYCLK_PHYFSEL_12MHZ; break; case 24 * MHZ: *reg = S5PV210_UPHYCLK_PHYFSEL_24MHZ; break; case 48 * MHZ: *reg = S5PV210_UPHYCLK_PHYFSEL_48MHZ; break; default: return -EINVAL; } return 0; } static void s5pv210_isol(struct samsung_usb2_phy_instance *inst, bool on) { struct samsung_usb2_phy_driver *drv = inst->drv; u32 mask; switch (inst->cfg->id) { case S5PV210_DEVICE: mask = S5PV210_USB_ISOL_DEVICE; break; case S5PV210_HOST: mask = S5PV210_USB_ISOL_HOST; break; default: return; }; regmap_update_bits(drv->reg_pmu, S5PV210_USB_ISOL_OFFSET, mask, on ? 0 : mask); } static void s5pv210_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) { struct samsung_usb2_phy_driver *drv = inst->drv; u32 rstbits = 0; u32 phypwr = 0; u32 rst; u32 pwr; switch (inst->cfg->id) { case S5PV210_DEVICE: phypwr = S5PV210_UPHYPWR_PHY0; rstbits = S5PV210_URSTCON_PHY0; break; case S5PV210_HOST: phypwr = S5PV210_UPHYPWR_PHY1; rstbits = S5PV210_URSTCON_PHY1_ALL | S5PV210_URSTCON_HOST_LINK_ALL; break; }; if (on) { writel(drv->ref_reg_val, drv->reg_phy + S5PV210_UPHYCLK); pwr = readl(drv->reg_phy + S5PV210_UPHYPWR); pwr &= ~phypwr; writel(pwr, drv->reg_phy + S5PV210_UPHYPWR); rst = readl(drv->reg_phy + S5PV210_UPHYRST); rst |= rstbits; writel(rst, drv->reg_phy + S5PV210_UPHYRST); udelay(10); rst &= ~rstbits; writel(rst, drv->reg_phy + S5PV210_UPHYRST); } else { pwr = readl(drv->reg_phy + S5PV210_UPHYPWR); pwr |= phypwr; writel(pwr, drv->reg_phy + S5PV210_UPHYPWR); } } static int s5pv210_power_on(struct samsung_usb2_phy_instance *inst) { s5pv210_isol(inst, 0); s5pv210_phy_pwr(inst, 1); return 0; } static int s5pv210_power_off(struct samsung_usb2_phy_instance *inst) { s5pv210_phy_pwr(inst, 0); s5pv210_isol(inst, 1); return 0; } static const struct samsung_usb2_common_phy s5pv210_phys[S5PV210_NUM_PHYS] = { [S5PV210_DEVICE] = { .label = "device", .id = S5PV210_DEVICE, .power_on = s5pv210_power_on, .power_off = s5pv210_power_off, }, [S5PV210_HOST] = { .label = "host", .id = S5PV210_HOST, .power_on = s5pv210_power_on, .power_off = s5pv210_power_off, }, }; const struct samsung_usb2_phy_config s5pv210_usb2_phy_config = { .num_phys = ARRAY_SIZE(s5pv210_phys), .phys = s5pv210_phys, .rate_to_clk = s5pv210_rate_to_clk, };
gpl-2.0
garrikus/o3_linux
drivers/isdn/hysdn/hysdn_sched.c
1909
7131
/* $Id: hysdn_sched.c,v 1.5.6.4 2001/11/06 21:58:19 kai Exp $ * * Linux driver for HYSDN cards * scheduler routines for handling exchange card <-> pc. * * Author Werner Cornelius (werner@titro.de) for Hypercope GmbH * Copyright 1999 by Werner Cornelius (werner@titro.de) * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ #include <linux/signal.h> #include <linux/kernel.h> #include <linux/ioport.h> #include <linux/interrupt.h> #include <linux/delay.h> #include <asm/io.h> #include "hysdn_defs.h" /*****************************************************************************/ /* hysdn_sched_rx is called from the cards handler to announce new data is */ /* available from the card. The routine has to handle the data and return */ /* with a nonzero code if the data could be worked (or even thrown away), if */ /* no room to buffer the data is available a zero return tells the card */ /* to keep the data until later. */ /*****************************************************************************/ int hysdn_sched_rx(hysdn_card *card, unsigned char *buf, unsigned short len, unsigned short chan) { switch (chan) { case CHAN_NDIS_DATA: if (hynet_enable & (1 << card->myid)) { /* give packet to network handler */ hysdn_rx_netpkt(card, buf, len); } break; case CHAN_ERRLOG: hysdn_card_errlog(card, (tErrLogEntry *) buf, len); if (card->err_log_state == ERRLOG_STATE_ON) card->err_log_state = ERRLOG_STATE_START; /* start new fetch */ break; #ifdef CONFIG_HYSDN_CAPI case CHAN_CAPI: /* give packet to CAPI handler */ if (hycapi_enable & (1 << card->myid)) { hycapi_rx_capipkt(card, buf, len); } break; #endif /* CONFIG_HYSDN_CAPI */ default: printk(KERN_INFO "irq message channel %d len %d unhandled \n", chan, len); break; } /* switch rx channel */ return (1); /* always handled */ } /* hysdn_sched_rx */ /*****************************************************************************/ /* hysdn_sched_tx is called from the cards handler to announce that there is */ /* room in the tx-buffer to the card and data may be sent if needed. */ /* If the routine wants to send data it must fill buf, len and chan with the */ /* appropriate data and return a nonzero value. With a zero return no new */ /* data to send is assumed. maxlen specifies the buffer size available for */ /* sending. */ /*****************************************************************************/ int hysdn_sched_tx(hysdn_card *card, unsigned char *buf, unsigned short volatile *len, unsigned short volatile *chan, unsigned short maxlen) { struct sk_buff *skb; if (card->net_tx_busy) { card->net_tx_busy = 0; /* reset flag */ hysdn_tx_netack(card); /* acknowledge packet send */ } /* a network packet has completely been transferred */ /* first of all async requests are handled */ if (card->async_busy) { if (card->async_len <= maxlen) { memcpy(buf, card->async_data, card->async_len); *len = card->async_len; *chan = card->async_channel; card->async_busy = 0; /* reset request */ return (1); } card->async_busy = 0; /* in case of length error */ } /* async request */ if ((card->err_log_state == ERRLOG_STATE_START) && (maxlen >= ERRLOG_CMD_REQ_SIZE)) { strcpy(buf, ERRLOG_CMD_REQ); /* copy the command */ *len = ERRLOG_CMD_REQ_SIZE; /* buffer length */ *chan = CHAN_ERRLOG; /* and channel */ card->err_log_state = ERRLOG_STATE_ON; /* new state is on */ return (1); /* tell that data should be send */ } /* error log start and able to send */ if ((card->err_log_state == ERRLOG_STATE_STOP) && (maxlen >= ERRLOG_CMD_STOP_SIZE)) { strcpy(buf, ERRLOG_CMD_STOP); /* copy the command */ *len = ERRLOG_CMD_STOP_SIZE; /* buffer length */ *chan = CHAN_ERRLOG; /* and channel */ card->err_log_state = ERRLOG_STATE_OFF; /* new state is off */ return (1); /* tell that data should be send */ } /* error log start and able to send */ /* now handle network interface packets */ if ((hynet_enable & (1 << card->myid)) && (skb = hysdn_tx_netget(card)) != NULL) { if (skb->len <= maxlen) { /* copy the packet to the buffer */ skb_copy_from_linear_data(skb, buf, skb->len); *len = skb->len; *chan = CHAN_NDIS_DATA; card->net_tx_busy = 1; /* we are busy sending network data */ return (1); /* go and send the data */ } else hysdn_tx_netack(card); /* aknowledge packet -> throw away */ } /* send a network packet if available */ #ifdef CONFIG_HYSDN_CAPI if( ((hycapi_enable & (1 << card->myid))) && ((skb = hycapi_tx_capiget(card)) != NULL) ) { if (skb->len <= maxlen) { skb_copy_from_linear_data(skb, buf, skb->len); *len = skb->len; *chan = CHAN_CAPI; hycapi_tx_capiack(card); return (1); /* go and send the data */ } } #endif /* CONFIG_HYSDN_CAPI */ return (0); /* nothing to send */ } /* hysdn_sched_tx */ /*****************************************************************************/ /* send one config line to the card and return 0 if successful, otherwise a */ /* negative error code. */ /* The function works with timeouts perhaps not giving the greatest speed */ /* sending the line, but this should be meaningless beacuse only some lines */ /* are to be sent and this happens very seldom. */ /*****************************************************************************/ int hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan) { int cnt = 50; /* timeout intervalls */ unsigned long flags; if (card->debug_flags & LOG_SCHED_ASYN) hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1); while (card->async_busy) { if (card->debug_flags & LOG_SCHED_ASYN) hysdn_addlog(card, "async tx-cfg delayed"); msleep_interruptible(20); /* Timeout 20ms */ if (!--cnt) return (-ERR_ASYNC_TIME); /* timed out */ } /* wait for buffer to become free */ spin_lock_irqsave(&card->hysdn_lock, flags); strcpy(card->async_data, line); card->async_len = strlen(line) + 1; card->async_channel = chan; card->async_busy = 1; /* request transfer */ /* now queue the task */ schedule_work(&card->irq_queue); spin_unlock_irqrestore(&card->hysdn_lock, flags); if (card->debug_flags & LOG_SCHED_ASYN) hysdn_addlog(card, "async tx-cfg data queued"); cnt++; /* short delay */ while (card->async_busy) { if (card->debug_flags & LOG_SCHED_ASYN) hysdn_addlog(card, "async tx-cfg waiting for tx-ready"); msleep_interruptible(20); /* Timeout 20ms */ if (!--cnt) return (-ERR_ASYNC_TIME); /* timed out */ } /* wait for buffer to become free again */ if (card->debug_flags & LOG_SCHED_ASYN) hysdn_addlog(card, "async tx-cfg data send"); return (0); /* line send correctly */ } /* hysdn_tx_cfgline */
gpl-2.0
lilbowza1985/s6eng2
kernel/trace/trace_clock.c
1909
3492
/* * tracing clocks * * Copyright (C) 2009 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> * * Implements 3 trace clock variants, with differing scalability/precision * tradeoffs: * * - local: CPU-local trace clock * - medium: scalable global clock with some jitter * - global: globally monotonic, serialized clock * * Tracer plugins will chose a default from these clocks. */ #include <linux/spinlock.h> #include <linux/irqflags.h> #include <linux/hardirq.h> #include <linux/module.h> #include <linux/percpu.h> #include <linux/sched.h> #include <linux/ktime.h> #include <linux/trace_clock.h> /* * trace_clock_local(): the simplest and least coherent tracing clock. * * Useful for tracing that does not cross to other CPUs nor * does it go through idle events. */ u64 notrace trace_clock_local(void) { u64 clock; /* * sched_clock() is an architecture implemented, fast, scalable, * lockless clock. It is not guaranteed to be coherent across * CPUs, nor across CPU idle events. */ preempt_disable_notrace(); clock = sched_clock(); preempt_enable_notrace(); return clock; } EXPORT_SYMBOL_GPL(trace_clock_local); /* * trace_clock(): 'between' trace clock. Not completely serialized, * but not completely incorrect when crossing CPUs either. * * This is based on cpu_clock(), which will allow at most ~1 jiffy of * jitter between CPUs. So it's a pretty scalable clock, but there * can be offsets in the trace data. */ u64 notrace trace_clock(void) { return local_clock(); } /* * trace_jiffy_clock(): Simply use jiffies as a clock counter. * Note that this use of jiffies_64 is not completely safe on * 32-bit systems. But the window is tiny, and the effect if * we are affected is that we will have an obviously bogus * timestamp on a trace event - i.e. not life threatening. */ u64 notrace trace_clock_jiffies(void) { return jiffies_64_to_clock_t(jiffies_64 - INITIAL_JIFFIES); } /* * trace_clock_global(): special globally coherent trace clock * * It has higher overhead than the other trace clocks but is still * an order of magnitude faster than GTOD derived hardware clocks. * * Used by plugins that need globally coherent timestamps. */ /* keep prev_time and lock in the same cacheline. */ static struct { u64 prev_time; arch_spinlock_t lock; } trace_clock_struct ____cacheline_aligned_in_smp = { .lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED, }; u64 notrace trace_clock_global(void) { unsigned long flags; int this_cpu; u64 now; local_irq_save(flags); this_cpu = raw_smp_processor_id(); now = sched_clock_cpu(this_cpu); /* * If in an NMI context then dont risk lockups and return the * cpu_clock() time: */ if (unlikely(in_nmi())) goto out; arch_spin_lock(&trace_clock_struct.lock); /* * TODO: if this happens often then maybe we should reset * my_scd->clock to prev_time+1, to make sure * we start ticking with the local clock from now on? */ if ((s64)(now - trace_clock_struct.prev_time) < 0) now = trace_clock_struct.prev_time + 1; trace_clock_struct.prev_time = now; arch_spin_unlock(&trace_clock_struct.lock); out: local_irq_restore(flags); return now; } static atomic64_t trace_counter; /* * trace_clock_counter(): simply an atomic counter. * Use the trace_counter "counter" for cases where you do not care * about timings, but are interested in strict ordering. */ u64 notrace trace_clock_counter(void) { return atomic64_add_return(1, &trace_counter); }
gpl-2.0
nxnfufunezn/linux
sound/pci/echoaudio/indigo_express_dsp.c
2165
3287
/************************************************************************ This file is part of Echo Digital Audio's generic driver library. Copyright Echo Digital Audio Corporation (c) 1998 - 2005 All rights reserved www.echoaudio.com This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ************************************************************************* Translation from C++ and adaptation for use in ALSA-Driver were made by Giuliano Pochini <pochini@shiny.it> *************************************************************************/ static int set_sample_rate(struct echoaudio *chip, u32 rate) { u32 clock, control_reg, old_control_reg; if (wait_handshake(chip)) return -EIO; old_control_reg = le32_to_cpu(chip->comm_page->control_register); control_reg = old_control_reg & ~INDIGO_EXPRESS_CLOCK_MASK; switch (rate) { case 32000: clock = INDIGO_EXPRESS_32000; break; case 44100: clock = INDIGO_EXPRESS_44100; break; case 48000: clock = INDIGO_EXPRESS_48000; break; case 64000: clock = INDIGO_EXPRESS_32000|INDIGO_EXPRESS_DOUBLE_SPEED; break; case 88200: clock = INDIGO_EXPRESS_44100|INDIGO_EXPRESS_DOUBLE_SPEED; break; case 96000: clock = INDIGO_EXPRESS_48000|INDIGO_EXPRESS_DOUBLE_SPEED; break; default: return -EINVAL; } control_reg |= clock; if (control_reg != old_control_reg) { dev_dbg(chip->card->dev, "set_sample_rate: %d clock %d\n", rate, clock); chip->comm_page->control_register = cpu_to_le32(control_reg); chip->sample_rate = rate; clear_handshake(chip); return send_vector(chip, DSP_VC_UPDATE_CLOCKS); } return 0; } /* This function routes the sound from a virtual channel to a real output */ static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe, int gain) { int index; if (snd_BUG_ON(pipe >= num_pipes_out(chip) || output >= num_busses_out(chip))) return -EINVAL; if (wait_handshake(chip)) return -EIO; chip->vmixer_gain[output][pipe] = gain; index = output * num_pipes_out(chip) + pipe; chip->comm_page->vmixer[index] = gain; dev_dbg(chip->card->dev, "set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain); return 0; } /* Tell the DSP to read and update virtual mixer levels in comm page. */ static int update_vmixer_level(struct echoaudio *chip) { if (wait_handshake(chip)) return -EIO; clear_handshake(chip); return send_vector(chip, DSP_VC_SET_VMIXER_GAIN); } static u32 detect_input_clocks(const struct echoaudio *chip) { return ECHO_CLOCK_BIT_INTERNAL; } /* The IndigoIO has no ASIC. Just do nothing */ static int load_asic(struct echoaudio *chip) { return 0; }
gpl-2.0
hi35xx/hi3518e-buildroot
linux/linux-3.0.y/drivers/net/mlx4/eq.c
2933
21818
/* * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <linux/interrupt.h> #include <linux/slab.h> #include <linux/mm.h> #include <linux/dma-mapping.h> #include <linux/mlx4/cmd.h> #include "mlx4.h" #include "fw.h" enum { MLX4_IRQNAME_SIZE = 32 }; enum { MLX4_NUM_ASYNC_EQE = 0x100, MLX4_NUM_SPARE_EQE = 0x80, MLX4_EQ_ENTRY_SIZE = 0x20 }; /* * Must be packed because start is 64 bits but only aligned to 32 bits. */ struct mlx4_eq_context { __be32 flags; u16 reserved1[3]; __be16 page_offset; u8 log_eq_size; u8 reserved2[4]; u8 eq_period; u8 reserved3; u8 eq_max_count; u8 reserved4[3]; u8 intr; u8 log_page_size; u8 reserved5[2]; u8 mtt_base_addr_h; __be32 mtt_base_addr_l; u32 reserved6[2]; __be32 consumer_index; __be32 producer_index; u32 reserved7[4]; }; #define MLX4_EQ_STATUS_OK ( 0 << 28) #define MLX4_EQ_STATUS_WRITE_FAIL (10 << 28) #define MLX4_EQ_OWNER_SW ( 0 << 24) #define MLX4_EQ_OWNER_HW ( 1 << 24) #define MLX4_EQ_FLAG_EC ( 1 << 18) #define MLX4_EQ_FLAG_OI ( 1 << 17) #define MLX4_EQ_STATE_ARMED ( 9 << 8) #define MLX4_EQ_STATE_FIRED (10 << 8) #define MLX4_EQ_STATE_ALWAYS_ARMED (11 << 8) #define MLX4_ASYNC_EVENT_MASK ((1ull << MLX4_EVENT_TYPE_PATH_MIG) | \ (1ull << MLX4_EVENT_TYPE_COMM_EST) | \ (1ull << MLX4_EVENT_TYPE_SQ_DRAINED) | \ (1ull << MLX4_EVENT_TYPE_CQ_ERROR) | \ (1ull << MLX4_EVENT_TYPE_WQ_CATAS_ERROR) | \ (1ull << MLX4_EVENT_TYPE_EEC_CATAS_ERROR) | \ (1ull << MLX4_EVENT_TYPE_PATH_MIG_FAILED) | \ (1ull << MLX4_EVENT_TYPE_WQ_INVAL_REQ_ERROR) | \ (1ull << MLX4_EVENT_TYPE_WQ_ACCESS_ERROR) | \ (1ull << MLX4_EVENT_TYPE_PORT_CHANGE) | \ (1ull << MLX4_EVENT_TYPE_ECC_DETECT) | \ (1ull << MLX4_EVENT_TYPE_SRQ_CATAS_ERROR) | \ (1ull << MLX4_EVENT_TYPE_SRQ_QP_LAST_WQE) | \ (1ull << MLX4_EVENT_TYPE_SRQ_LIMIT) | \ (1ull << MLX4_EVENT_TYPE_CMD)) struct mlx4_eqe { u8 reserved1; u8 type; u8 reserved2; u8 subtype; union { u32 raw[6]; struct { __be32 cqn; } __packed comp; struct { u16 reserved1; __be16 token; u32 reserved2; u8 reserved3[3]; u8 status; __be64 out_param; } __packed cmd; struct { __be32 qpn; } __packed qp; struct { __be32 srqn; } __packed srq; struct { __be32 cqn; u32 reserved1; u8 reserved2[3]; u8 syndrome; } __packed cq_err; struct { u32 reserved1[2]; __be32 port; } __packed port_change; } event; u8 reserved3[3]; u8 owner; } __packed; static void eq_set_ci(struct mlx4_eq *eq, int req_not) { __raw_writel((__force u32) cpu_to_be32((eq->cons_index & 0xffffff) | req_not << 31), eq->doorbell); /* We still want ordering, just not swabbing, so add a barrier */ mb(); } static struct mlx4_eqe *get_eqe(struct mlx4_eq *eq, u32 entry) { unsigned long off = (entry & (eq->nent - 1)) * MLX4_EQ_ENTRY_SIZE; return eq->page_list[off / PAGE_SIZE].buf + off % PAGE_SIZE; } static struct mlx4_eqe *next_eqe_sw(struct mlx4_eq *eq) { struct mlx4_eqe *eqe = get_eqe(eq, eq->cons_index); return !!(eqe->owner & 0x80) ^ !!(eq->cons_index & eq->nent) ? NULL : eqe; } static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq) { struct mlx4_eqe *eqe; int cqn; int eqes_found = 0; int set_ci = 0; int port; while ((eqe = next_eqe_sw(eq))) { /* * Make sure we read EQ entry contents after we've * checked the ownership bit. */ rmb(); switch (eqe->type) { case MLX4_EVENT_TYPE_COMP: cqn = be32_to_cpu(eqe->event.comp.cqn) & 0xffffff; mlx4_cq_completion(dev, cqn); break; case MLX4_EVENT_TYPE_PATH_MIG: case MLX4_EVENT_TYPE_COMM_EST: case MLX4_EVENT_TYPE_SQ_DRAINED: case MLX4_EVENT_TYPE_SRQ_QP_LAST_WQE: case MLX4_EVENT_TYPE_WQ_CATAS_ERROR: case MLX4_EVENT_TYPE_PATH_MIG_FAILED: case MLX4_EVENT_TYPE_WQ_INVAL_REQ_ERROR: case MLX4_EVENT_TYPE_WQ_ACCESS_ERROR: mlx4_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff, eqe->type); break; case MLX4_EVENT_TYPE_SRQ_LIMIT: case MLX4_EVENT_TYPE_SRQ_CATAS_ERROR: mlx4_srq_event(dev, be32_to_cpu(eqe->event.srq.srqn) & 0xffffff, eqe->type); break; case MLX4_EVENT_TYPE_CMD: mlx4_cmd_event(dev, be16_to_cpu(eqe->event.cmd.token), eqe->event.cmd.status, be64_to_cpu(eqe->event.cmd.out_param)); break; case MLX4_EVENT_TYPE_PORT_CHANGE: port = be32_to_cpu(eqe->event.port_change.port) >> 28; if (eqe->subtype == MLX4_PORT_CHANGE_SUBTYPE_DOWN) { mlx4_dispatch_event(dev, MLX4_DEV_EVENT_PORT_DOWN, port); mlx4_priv(dev)->sense.do_sense_port[port] = 1; } else { mlx4_dispatch_event(dev, MLX4_DEV_EVENT_PORT_UP, port); mlx4_priv(dev)->sense.do_sense_port[port] = 0; } break; case MLX4_EVENT_TYPE_CQ_ERROR: mlx4_warn(dev, "CQ %s on CQN %06x\n", eqe->event.cq_err.syndrome == 1 ? "overrun" : "access violation", be32_to_cpu(eqe->event.cq_err.cqn) & 0xffffff); mlx4_cq_event(dev, be32_to_cpu(eqe->event.cq_err.cqn), eqe->type); break; case MLX4_EVENT_TYPE_EQ_OVERFLOW: mlx4_warn(dev, "EQ overrun on EQN %d\n", eq->eqn); break; case MLX4_EVENT_TYPE_EEC_CATAS_ERROR: case MLX4_EVENT_TYPE_ECC_DETECT: default: mlx4_warn(dev, "Unhandled event %02x(%02x) on EQ %d at index %u\n", eqe->type, eqe->subtype, eq->eqn, eq->cons_index); break; } ++eq->cons_index; eqes_found = 1; ++set_ci; /* * The HCA will think the queue has overflowed if we * don't tell it we've been processing events. We * create our EQs with MLX4_NUM_SPARE_EQE extra * entries, so we must update our consumer index at * least that often. */ if (unlikely(set_ci >= MLX4_NUM_SPARE_EQE)) { eq_set_ci(eq, 0); set_ci = 0; } } eq_set_ci(eq, 1); return eqes_found; } static irqreturn_t mlx4_interrupt(int irq, void *dev_ptr) { struct mlx4_dev *dev = dev_ptr; struct mlx4_priv *priv = mlx4_priv(dev); int work = 0; int i; writel(priv->eq_table.clr_mask, priv->eq_table.clr_int); for (i = 0; i < dev->caps.num_comp_vectors + 1; ++i) work |= mlx4_eq_int(dev, &priv->eq_table.eq[i]); return IRQ_RETVAL(work); } static irqreturn_t mlx4_msi_x_interrupt(int irq, void *eq_ptr) { struct mlx4_eq *eq = eq_ptr; struct mlx4_dev *dev = eq->dev; mlx4_eq_int(dev, eq); /* MSI-X vectors always belong to us */ return IRQ_HANDLED; } static int mlx4_MAP_EQ(struct mlx4_dev *dev, u64 event_mask, int unmap, int eq_num) { return mlx4_cmd(dev, event_mask, (unmap << 31) | eq_num, 0, MLX4_CMD_MAP_EQ, MLX4_CMD_TIME_CLASS_B); } static int mlx4_SW2HW_EQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, int eq_num) { return mlx4_cmd(dev, mailbox->dma, eq_num, 0, MLX4_CMD_SW2HW_EQ, MLX4_CMD_TIME_CLASS_A); } static int mlx4_HW2SW_EQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, int eq_num) { return mlx4_cmd_box(dev, 0, mailbox->dma, eq_num, 0, MLX4_CMD_HW2SW_EQ, MLX4_CMD_TIME_CLASS_A); } static int mlx4_num_eq_uar(struct mlx4_dev *dev) { /* * Each UAR holds 4 EQ doorbells. To figure out how many UARs * we need to map, take the difference of highest index and * the lowest index we'll use and add 1. */ return (dev->caps.num_comp_vectors + 1 + dev->caps.reserved_eqs + dev->caps.comp_pool)/4 - dev->caps.reserved_eqs/4 + 1; } static void __iomem *mlx4_get_eq_uar(struct mlx4_dev *dev, struct mlx4_eq *eq) { struct mlx4_priv *priv = mlx4_priv(dev); int index; index = eq->eqn / 4 - dev->caps.reserved_eqs / 4; if (!priv->eq_table.uar_map[index]) { priv->eq_table.uar_map[index] = ioremap(pci_resource_start(dev->pdev, 2) + ((eq->eqn / 4) << PAGE_SHIFT), PAGE_SIZE); if (!priv->eq_table.uar_map[index]) { mlx4_err(dev, "Couldn't map EQ doorbell for EQN 0x%06x\n", eq->eqn); return NULL; } } return priv->eq_table.uar_map[index] + 0x800 + 8 * (eq->eqn % 4); } static int mlx4_create_eq(struct mlx4_dev *dev, int nent, u8 intr, struct mlx4_eq *eq) { struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_cmd_mailbox *mailbox; struct mlx4_eq_context *eq_context; int npages; u64 *dma_list = NULL; dma_addr_t t; u64 mtt_addr; int err = -ENOMEM; int i; eq->dev = dev; eq->nent = roundup_pow_of_two(max(nent, 2)); npages = PAGE_ALIGN(eq->nent * MLX4_EQ_ENTRY_SIZE) / PAGE_SIZE; eq->page_list = kmalloc(npages * sizeof *eq->page_list, GFP_KERNEL); if (!eq->page_list) goto err_out; for (i = 0; i < npages; ++i) eq->page_list[i].buf = NULL; dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL); if (!dma_list) goto err_out_free; mailbox = mlx4_alloc_cmd_mailbox(dev); if (IS_ERR(mailbox)) goto err_out_free; eq_context = mailbox->buf; for (i = 0; i < npages; ++i) { eq->page_list[i].buf = dma_alloc_coherent(&dev->pdev->dev, PAGE_SIZE, &t, GFP_KERNEL); if (!eq->page_list[i].buf) goto err_out_free_pages; dma_list[i] = t; eq->page_list[i].map = t; memset(eq->page_list[i].buf, 0, PAGE_SIZE); } eq->eqn = mlx4_bitmap_alloc(&priv->eq_table.bitmap); if (eq->eqn == -1) goto err_out_free_pages; eq->doorbell = mlx4_get_eq_uar(dev, eq); if (!eq->doorbell) { err = -ENOMEM; goto err_out_free_eq; } err = mlx4_mtt_init(dev, npages, PAGE_SHIFT, &eq->mtt); if (err) goto err_out_free_eq; err = mlx4_write_mtt(dev, &eq->mtt, 0, npages, dma_list); if (err) goto err_out_free_mtt; memset(eq_context, 0, sizeof *eq_context); eq_context->flags = cpu_to_be32(MLX4_EQ_STATUS_OK | MLX4_EQ_STATE_ARMED); eq_context->log_eq_size = ilog2(eq->nent); eq_context->intr = intr; eq_context->log_page_size = PAGE_SHIFT - MLX4_ICM_PAGE_SHIFT; mtt_addr = mlx4_mtt_addr(dev, &eq->mtt); eq_context->mtt_base_addr_h = mtt_addr >> 32; eq_context->mtt_base_addr_l = cpu_to_be32(mtt_addr & 0xffffffff); err = mlx4_SW2HW_EQ(dev, mailbox, eq->eqn); if (err) { mlx4_warn(dev, "SW2HW_EQ failed (%d)\n", err); goto err_out_free_mtt; } kfree(dma_list); mlx4_free_cmd_mailbox(dev, mailbox); eq->cons_index = 0; return err; err_out_free_mtt: mlx4_mtt_cleanup(dev, &eq->mtt); err_out_free_eq: mlx4_bitmap_free(&priv->eq_table.bitmap, eq->eqn); err_out_free_pages: for (i = 0; i < npages; ++i) if (eq->page_list[i].buf) dma_free_coherent(&dev->pdev->dev, PAGE_SIZE, eq->page_list[i].buf, eq->page_list[i].map); mlx4_free_cmd_mailbox(dev, mailbox); err_out_free: kfree(eq->page_list); kfree(dma_list); err_out: return err; } static void mlx4_free_eq(struct mlx4_dev *dev, struct mlx4_eq *eq) { struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_cmd_mailbox *mailbox; int err; int npages = PAGE_ALIGN(MLX4_EQ_ENTRY_SIZE * eq->nent) / PAGE_SIZE; int i; mailbox = mlx4_alloc_cmd_mailbox(dev); if (IS_ERR(mailbox)) return; err = mlx4_HW2SW_EQ(dev, mailbox, eq->eqn); if (err) mlx4_warn(dev, "HW2SW_EQ failed (%d)\n", err); if (0) { mlx4_dbg(dev, "Dumping EQ context %02x:\n", eq->eqn); for (i = 0; i < sizeof (struct mlx4_eq_context) / 4; ++i) { if (i % 4 == 0) pr_cont("[%02x] ", i * 4); pr_cont(" %08x", be32_to_cpup(mailbox->buf + i * 4)); if ((i + 1) % 4 == 0) pr_cont("\n"); } } mlx4_mtt_cleanup(dev, &eq->mtt); for (i = 0; i < npages; ++i) pci_free_consistent(dev->pdev, PAGE_SIZE, eq->page_list[i].buf, eq->page_list[i].map); kfree(eq->page_list); mlx4_bitmap_free(&priv->eq_table.bitmap, eq->eqn); mlx4_free_cmd_mailbox(dev, mailbox); } static void mlx4_free_irqs(struct mlx4_dev *dev) { struct mlx4_eq_table *eq_table = &mlx4_priv(dev)->eq_table; struct mlx4_priv *priv = mlx4_priv(dev); int i, vec; if (eq_table->have_irq) free_irq(dev->pdev->irq, dev); for (i = 0; i < dev->caps.num_comp_vectors + 1; ++i) if (eq_table->eq[i].have_irq) { free_irq(eq_table->eq[i].irq, eq_table->eq + i); eq_table->eq[i].have_irq = 0; } for (i = 0; i < dev->caps.comp_pool; i++) { /* * Freeing the assigned irq's * all bits should be 0, but we need to validate */ if (priv->msix_ctl.pool_bm & 1ULL << i) { /* NO need protecting*/ vec = dev->caps.num_comp_vectors + 1 + i; free_irq(priv->eq_table.eq[vec].irq, &priv->eq_table.eq[vec]); } } kfree(eq_table->irq_names); } static int mlx4_map_clr_int(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); priv->clr_base = ioremap(pci_resource_start(dev->pdev, priv->fw.clr_int_bar) + priv->fw.clr_int_base, MLX4_CLR_INT_SIZE); if (!priv->clr_base) { mlx4_err(dev, "Couldn't map interrupt clear register, aborting.\n"); return -ENOMEM; } return 0; } static void mlx4_unmap_clr_int(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); iounmap(priv->clr_base); } int mlx4_alloc_eq_table(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); priv->eq_table.eq = kcalloc(dev->caps.num_eqs - dev->caps.reserved_eqs, sizeof *priv->eq_table.eq, GFP_KERNEL); if (!priv->eq_table.eq) return -ENOMEM; return 0; } void mlx4_free_eq_table(struct mlx4_dev *dev) { kfree(mlx4_priv(dev)->eq_table.eq); } int mlx4_init_eq_table(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); int err; int i; priv->eq_table.uar_map = kcalloc(sizeof *priv->eq_table.uar_map, mlx4_num_eq_uar(dev), GFP_KERNEL); if (!priv->eq_table.uar_map) { err = -ENOMEM; goto err_out_free; } err = mlx4_bitmap_init(&priv->eq_table.bitmap, dev->caps.num_eqs, dev->caps.num_eqs - 1, dev->caps.reserved_eqs, 0); if (err) goto err_out_free; for (i = 0; i < mlx4_num_eq_uar(dev); ++i) priv->eq_table.uar_map[i] = NULL; err = mlx4_map_clr_int(dev); if (err) goto err_out_bitmap; priv->eq_table.clr_mask = swab32(1 << (priv->eq_table.inta_pin & 31)); priv->eq_table.clr_int = priv->clr_base + (priv->eq_table.inta_pin < 32 ? 4 : 0); priv->eq_table.irq_names = kmalloc(MLX4_IRQNAME_SIZE * (dev->caps.num_comp_vectors + 1 + dev->caps.comp_pool), GFP_KERNEL); if (!priv->eq_table.irq_names) { err = -ENOMEM; goto err_out_bitmap; } for (i = 0; i < dev->caps.num_comp_vectors; ++i) { err = mlx4_create_eq(dev, dev->caps.num_cqs - dev->caps.reserved_cqs + MLX4_NUM_SPARE_EQE, (dev->flags & MLX4_FLAG_MSI_X) ? i : 0, &priv->eq_table.eq[i]); if (err) { --i; goto err_out_unmap; } } err = mlx4_create_eq(dev, MLX4_NUM_ASYNC_EQE + MLX4_NUM_SPARE_EQE, (dev->flags & MLX4_FLAG_MSI_X) ? dev->caps.num_comp_vectors : 0, &priv->eq_table.eq[dev->caps.num_comp_vectors]); if (err) goto err_out_comp; /*if additional completion vectors poolsize is 0 this loop will not run*/ for (i = dev->caps.num_comp_vectors + 1; i < dev->caps.num_comp_vectors + dev->caps.comp_pool + 1; ++i) { err = mlx4_create_eq(dev, dev->caps.num_cqs - dev->caps.reserved_cqs + MLX4_NUM_SPARE_EQE, (dev->flags & MLX4_FLAG_MSI_X) ? i : 0, &priv->eq_table.eq[i]); if (err) { --i; goto err_out_unmap; } } if (dev->flags & MLX4_FLAG_MSI_X) { const char *eq_name; for (i = 0; i < dev->caps.num_comp_vectors + 1; ++i) { if (i < dev->caps.num_comp_vectors) { snprintf(priv->eq_table.irq_names + i * MLX4_IRQNAME_SIZE, MLX4_IRQNAME_SIZE, "mlx4-comp-%d@pci:%s", i, pci_name(dev->pdev)); } else { snprintf(priv->eq_table.irq_names + i * MLX4_IRQNAME_SIZE, MLX4_IRQNAME_SIZE, "mlx4-async@pci:%s", pci_name(dev->pdev)); } eq_name = priv->eq_table.irq_names + i * MLX4_IRQNAME_SIZE; err = request_irq(priv->eq_table.eq[i].irq, mlx4_msi_x_interrupt, 0, eq_name, priv->eq_table.eq + i); if (err) goto err_out_async; priv->eq_table.eq[i].have_irq = 1; } } else { snprintf(priv->eq_table.irq_names, MLX4_IRQNAME_SIZE, DRV_NAME "@pci:%s", pci_name(dev->pdev)); err = request_irq(dev->pdev->irq, mlx4_interrupt, IRQF_SHARED, priv->eq_table.irq_names, dev); if (err) goto err_out_async; priv->eq_table.have_irq = 1; } err = mlx4_MAP_EQ(dev, MLX4_ASYNC_EVENT_MASK, 0, priv->eq_table.eq[dev->caps.num_comp_vectors].eqn); if (err) mlx4_warn(dev, "MAP_EQ for async EQ %d failed (%d)\n", priv->eq_table.eq[dev->caps.num_comp_vectors].eqn, err); for (i = 0; i < dev->caps.num_comp_vectors + 1; ++i) eq_set_ci(&priv->eq_table.eq[i], 1); return 0; err_out_async: mlx4_free_eq(dev, &priv->eq_table.eq[dev->caps.num_comp_vectors]); err_out_comp: i = dev->caps.num_comp_vectors - 1; err_out_unmap: while (i >= 0) { mlx4_free_eq(dev, &priv->eq_table.eq[i]); --i; } mlx4_unmap_clr_int(dev); mlx4_free_irqs(dev); err_out_bitmap: mlx4_bitmap_cleanup(&priv->eq_table.bitmap); err_out_free: kfree(priv->eq_table.uar_map); return err; } void mlx4_cleanup_eq_table(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); int i; mlx4_MAP_EQ(dev, MLX4_ASYNC_EVENT_MASK, 1, priv->eq_table.eq[dev->caps.num_comp_vectors].eqn); mlx4_free_irqs(dev); for (i = 0; i < dev->caps.num_comp_vectors + dev->caps.comp_pool + 1; ++i) mlx4_free_eq(dev, &priv->eq_table.eq[i]); mlx4_unmap_clr_int(dev); for (i = 0; i < mlx4_num_eq_uar(dev); ++i) if (priv->eq_table.uar_map[i]) iounmap(priv->eq_table.uar_map[i]); mlx4_bitmap_cleanup(&priv->eq_table.bitmap); kfree(priv->eq_table.uar_map); } /* A test that verifies that we can accept interrupts on all * the irq vectors of the device. * Interrupts are checked using the NOP command. */ int mlx4_test_interrupts(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); int i; int err; err = mlx4_NOP(dev); /* When not in MSI_X, there is only one irq to check */ if (!(dev->flags & MLX4_FLAG_MSI_X)) return err; /* A loop over all completion vectors, for each vector we will check * whether it works by mapping command completions to that vector * and performing a NOP command */ for(i = 0; !err && (i < dev->caps.num_comp_vectors); ++i) { /* Temporary use polling for command completions */ mlx4_cmd_use_polling(dev); /* Map the new eq to handle all asyncronous events */ err = mlx4_MAP_EQ(dev, MLX4_ASYNC_EVENT_MASK, 0, priv->eq_table.eq[i].eqn); if (err) { mlx4_warn(dev, "Failed mapping eq for interrupt test\n"); mlx4_cmd_use_events(dev); break; } /* Go back to using events */ mlx4_cmd_use_events(dev); err = mlx4_NOP(dev); } /* Return to default */ mlx4_MAP_EQ(dev, MLX4_ASYNC_EVENT_MASK, 0, priv->eq_table.eq[dev->caps.num_comp_vectors].eqn); return err; } EXPORT_SYMBOL(mlx4_test_interrupts); int mlx4_assign_eq(struct mlx4_dev *dev, char* name, int * vector) { struct mlx4_priv *priv = mlx4_priv(dev); int vec = 0, err = 0, i; spin_lock(&priv->msix_ctl.pool_lock); for (i = 0; !vec && i < dev->caps.comp_pool; i++) { if (~priv->msix_ctl.pool_bm & 1ULL << i) { priv->msix_ctl.pool_bm |= 1ULL << i; vec = dev->caps.num_comp_vectors + 1 + i; snprintf(priv->eq_table.irq_names + vec * MLX4_IRQNAME_SIZE, MLX4_IRQNAME_SIZE, "%s", name); err = request_irq(priv->eq_table.eq[vec].irq, mlx4_msi_x_interrupt, 0, &priv->eq_table.irq_names[vec<<5], priv->eq_table.eq + vec); if (err) { /*zero out bit by fliping it*/ priv->msix_ctl.pool_bm ^= 1 << i; vec = 0; continue; /*we dont want to break here*/ } eq_set_ci(&priv->eq_table.eq[vec], 1); } } spin_unlock(&priv->msix_ctl.pool_lock); if (vec) { *vector = vec; } else { *vector = 0; err = (i == dev->caps.comp_pool) ? -ENOSPC : err; } return err; } EXPORT_SYMBOL(mlx4_assign_eq); void mlx4_release_eq(struct mlx4_dev *dev, int vec) { struct mlx4_priv *priv = mlx4_priv(dev); /*bm index*/ int i = vec - dev->caps.num_comp_vectors - 1; if (likely(i >= 0)) { /*sanity check , making sure were not trying to free irq's Belonging to a legacy EQ*/ spin_lock(&priv->msix_ctl.pool_lock); if (priv->msix_ctl.pool_bm & 1ULL << i) { free_irq(priv->eq_table.eq[vec].irq, &priv->eq_table.eq[vec]); priv->msix_ctl.pool_bm &= ~(1ULL << i); } spin_unlock(&priv->msix_ctl.pool_lock); } } EXPORT_SYMBOL(mlx4_release_eq);
gpl-2.0
eugene373/Nexus_S_ICS
drivers/acpi/acpica/utglobal.c
2933
12145
/****************************************************************************** * * Module Name: utglobal - Global variables for the ACPI subsystem * *****************************************************************************/ /* * Copyright (C) 2000 - 2011, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions, and the following disclaimer, * without modification. * 2. Redistributions in binary form must reproduce at minimum a disclaimer * substantially similar to the "NO WARRANTY" disclaimer below * ("Disclaimer") and any redistribution must be conditioned upon * including a substantially similar Disclaimer requirement for further * binary redistribution. * 3. Neither the names of the above-listed copyright holders nor the names * of any contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * NO WARRANTY * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. */ #define DEFINE_ACPI_GLOBALS #include <acpi/acpi.h> #include "accommon.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME("utglobal") /******************************************************************************* * * Static global variable initialization. * ******************************************************************************/ /* * We want the debug switches statically initialized so they * are already set when the debugger is entered. */ /* Debug switch - level and trace mask */ u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; /* Debug switch - layer (component) mask */ u32 acpi_dbg_layer = 0; u32 acpi_gbl_nesting_level = 0; /* Debugger globals */ u8 acpi_gbl_db_terminate_threads = FALSE; u8 acpi_gbl_abort_method = FALSE; u8 acpi_gbl_method_executing = FALSE; /* System flags */ u32 acpi_gbl_startup_flags = 0; /* System starts uninitialized */ u8 acpi_gbl_shutdown = TRUE; const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = { "\\_S0_", "\\_S1_", "\\_S2_", "\\_S3_", "\\_S4_", "\\_S5_" }; const char *acpi_gbl_lowest_dstate_names[ACPI_NUM_sx_w_METHODS] = { "_S0W", "_S1W", "_S2W", "_S3W", "_S4W" }; const char *acpi_gbl_highest_dstate_names[ACPI_NUM_sx_d_METHODS] = { "_S1D", "_S2D", "_S3D", "_S4D" }; /******************************************************************************* * * Namespace globals * ******************************************************************************/ /* * Predefined ACPI Names (Built-in to the Interpreter) * * NOTES: * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run * during the initialization sequence. * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to * perform a Notify() operation on it. 09/2010: Changed to type Device. * This still allows notifies, but does not confuse host code that * searches for valid thermal_zone objects. */ const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, {"_SB_", ACPI_TYPE_DEVICE, NULL}, {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, {"_TZ_", ACPI_TYPE_DEVICE, NULL}, {"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL}, {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, {"_GL_", ACPI_TYPE_MUTEX, (char *)1}, #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) {"_OSI", ACPI_TYPE_METHOD, (char *)1}, #endif /* Table terminator */ {NULL, ACPI_TYPE_ANY, NULL} }; /****************************************************************************** * * Event and Hardware globals * ******************************************************************************/ struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = { /* Name Parent Register Register Bit Position Register Bit Mask */ /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE, ACPI_BITMASK_SLEEP_TYPE}, /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} }; struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = { /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, }; /******************************************************************************* * * FUNCTION: acpi_ut_init_globals * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Init library globals. All globals that require specific * initialization should be initialized here! * ******************************************************************************/ acpi_status acpi_ut_init_globals(void) { acpi_status status; u32 i; ACPI_FUNCTION_TRACE(ut_init_globals); /* Create all memory caches */ status = acpi_ut_create_caches(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* Mutex locked flags */ for (i = 0; i < ACPI_NUM_MUTEX; i++) { acpi_gbl_mutex_info[i].mutex = NULL; acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED; acpi_gbl_mutex_info[i].use_count = 0; } for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) { acpi_gbl_owner_id_mask[i] = 0; } /* Last owner_iD is never valid */ acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* GPE support */ acpi_gbl_gpe_xrupt_list_head = NULL; acpi_gbl_gpe_fadt_blocks[0] = NULL; acpi_gbl_gpe_fadt_blocks[1] = NULL; acpi_current_gpe_count = 0; acpi_gbl_all_gpes_initialized = FALSE; /* Global handlers */ acpi_gbl_system_notify.handler = NULL; acpi_gbl_device_notify.handler = NULL; acpi_gbl_exception_handler = NULL; acpi_gbl_init_handler = NULL; acpi_gbl_table_handler = NULL; acpi_gbl_interface_handler = NULL; acpi_gbl_global_event_handler = NULL; /* Global Lock support */ acpi_gbl_global_lock_semaphore = NULL; acpi_gbl_global_lock_mutex = NULL; acpi_gbl_global_lock_acquired = FALSE; acpi_gbl_global_lock_handle = 0; acpi_gbl_global_lock_present = FALSE; /* Miscellaneous variables */ acpi_gbl_DSDT = NULL; acpi_gbl_cm_single_step = FALSE; acpi_gbl_db_terminate_threads = FALSE; acpi_gbl_shutdown = FALSE; acpi_gbl_ns_lookup_count = 0; acpi_gbl_ps_find_count = 0; acpi_gbl_acpi_hardware_present = TRUE; acpi_gbl_last_owner_id_index = 0; acpi_gbl_next_owner_id_offset = 0; acpi_gbl_trace_method_name = 0; acpi_gbl_trace_dbg_level = 0; acpi_gbl_trace_dbg_layer = 0; acpi_gbl_debugger_configuration = DEBUGGER_THREADING; acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; acpi_gbl_osi_data = 0; acpi_gbl_osi_mutex = NULL; acpi_gbl_reg_methods_executed = FALSE; /* Hardware oriented */ acpi_gbl_events_initialized = FALSE; acpi_gbl_system_awake_and_running = TRUE; /* Namespace */ acpi_gbl_module_code_list = NULL; acpi_gbl_root_node = NULL; acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED; acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; acpi_gbl_root_node_struct.parent = NULL; acpi_gbl_root_node_struct.child = NULL; acpi_gbl_root_node_struct.peer = NULL; acpi_gbl_root_node_struct.object = NULL; #ifdef ACPI_DEBUG_OUTPUT acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX); #endif #ifdef ACPI_DBG_TRACK_ALLOCATIONS acpi_gbl_display_final_mem_stats = FALSE; #endif return_ACPI_STATUS(AE_OK); } ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) ACPI_EXPORT_SYMBOL(acpi_dbg_level) ACPI_EXPORT_SYMBOL(acpi_dbg_layer) ACPI_EXPORT_SYMBOL(acpi_current_gpe_count)
gpl-2.0
bilalliberty/android_kernel_HTC_ville_evita
net/netfilter/ipvs/ip_vs_ctl.c
3189
94045
/* * IPVS An implementation of the IP virtual server support for the * LINUX operating system. IPVS is now implemented as a module * over the NetFilter framework. IPVS can be used to build a * high-performance and highly available server based on a * cluster of servers. * * Authors: Wensong Zhang <wensong@linuxvirtualserver.org> * Peter Kese <peter.kese@ijs.si> * Julian Anastasov <ja@ssi.bg> * * 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. * * Changes: * */ #define KMSG_COMPONENT "IPVS" #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt #include <linux/module.h> #include <linux/init.h> #include <linux/types.h> #include <linux/capability.h> #include <linux/fs.h> #include <linux/sysctl.h> #include <linux/proc_fs.h> #include <linux/workqueue.h> #include <linux/swap.h> #include <linux/seq_file.h> #include <linux/slab.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> #include <linux/mutex.h> #include <net/net_namespace.h> #include <linux/nsproxy.h> #include <net/ip.h> #ifdef CONFIG_IP_VS_IPV6 #include <net/ipv6.h> #include <net/ip6_route.h> #endif #include <net/route.h> #include <net/sock.h> #include <net/genetlink.h> #include <asm/uaccess.h> #include <net/ip_vs.h> /* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */ static DEFINE_MUTEX(__ip_vs_mutex); /* lock for service table */ static DEFINE_RWLOCK(__ip_vs_svc_lock); /* sysctl variables */ #ifdef CONFIG_IP_VS_DEBUG static int sysctl_ip_vs_debug_level = 0; int ip_vs_get_debug_level(void) { return sysctl_ip_vs_debug_level; } #endif /* Protos */ static void __ip_vs_del_service(struct ip_vs_service *svc); #ifdef CONFIG_IP_VS_IPV6 /* Taken from rt6_fill_node() in net/ipv6/route.c, is there a better way? */ static int __ip_vs_addr_is_local_v6(struct net *net, const struct in6_addr *addr) { struct rt6_info *rt; struct flowi6 fl6 = { .daddr = *addr, }; rt = (struct rt6_info *)ip6_route_output(net, NULL, &fl6); if (rt && rt->dst.dev && (rt->dst.dev->flags & IFF_LOOPBACK)) return 1; return 0; } #endif #ifdef CONFIG_SYSCTL /* * update_defense_level is called from keventd and from sysctl, * so it needs to protect itself from softirqs */ static void update_defense_level(struct netns_ipvs *ipvs) { struct sysinfo i; static int old_secure_tcp = 0; int availmem; int nomem; int to_change = -1; /* we only count free and buffered memory (in pages) */ si_meminfo(&i); availmem = i.freeram + i.bufferram; /* however in linux 2.5 the i.bufferram is total page cache size, we need adjust it */ /* si_swapinfo(&i); */ /* availmem = availmem - (i.totalswap - i.freeswap); */ nomem = (availmem < ipvs->sysctl_amemthresh); local_bh_disable(); /* drop_entry */ spin_lock(&ipvs->dropentry_lock); switch (ipvs->sysctl_drop_entry) { case 0: atomic_set(&ipvs->dropentry, 0); break; case 1: if (nomem) { atomic_set(&ipvs->dropentry, 1); ipvs->sysctl_drop_entry = 2; } else { atomic_set(&ipvs->dropentry, 0); } break; case 2: if (nomem) { atomic_set(&ipvs->dropentry, 1); } else { atomic_set(&ipvs->dropentry, 0); ipvs->sysctl_drop_entry = 1; }; break; case 3: atomic_set(&ipvs->dropentry, 1); break; } spin_unlock(&ipvs->dropentry_lock); /* drop_packet */ spin_lock(&ipvs->droppacket_lock); switch (ipvs->sysctl_drop_packet) { case 0: ipvs->drop_rate = 0; break; case 1: if (nomem) { ipvs->drop_rate = ipvs->drop_counter = ipvs->sysctl_amemthresh / (ipvs->sysctl_amemthresh-availmem); ipvs->sysctl_drop_packet = 2; } else { ipvs->drop_rate = 0; } break; case 2: if (nomem) { ipvs->drop_rate = ipvs->drop_counter = ipvs->sysctl_amemthresh / (ipvs->sysctl_amemthresh-availmem); } else { ipvs->drop_rate = 0; ipvs->sysctl_drop_packet = 1; } break; case 3: ipvs->drop_rate = ipvs->sysctl_am_droprate; break; } spin_unlock(&ipvs->droppacket_lock); /* secure_tcp */ spin_lock(&ipvs->securetcp_lock); switch (ipvs->sysctl_secure_tcp) { case 0: if (old_secure_tcp >= 2) to_change = 0; break; case 1: if (nomem) { if (old_secure_tcp < 2) to_change = 1; ipvs->sysctl_secure_tcp = 2; } else { if (old_secure_tcp >= 2) to_change = 0; } break; case 2: if (nomem) { if (old_secure_tcp < 2) to_change = 1; } else { if (old_secure_tcp >= 2) to_change = 0; ipvs->sysctl_secure_tcp = 1; } break; case 3: if (old_secure_tcp < 2) to_change = 1; break; } old_secure_tcp = ipvs->sysctl_secure_tcp; if (to_change >= 0) ip_vs_protocol_timeout_change(ipvs, ipvs->sysctl_secure_tcp > 1); spin_unlock(&ipvs->securetcp_lock); local_bh_enable(); } /* * Timer for checking the defense */ #define DEFENSE_TIMER_PERIOD 1*HZ static void defense_work_handler(struct work_struct *work) { struct netns_ipvs *ipvs = container_of(work, struct netns_ipvs, defense_work.work); update_defense_level(ipvs); if (atomic_read(&ipvs->dropentry)) ip_vs_random_dropentry(ipvs->net); schedule_delayed_work(&ipvs->defense_work, DEFENSE_TIMER_PERIOD); } #endif int ip_vs_use_count_inc(void) { return try_module_get(THIS_MODULE); } void ip_vs_use_count_dec(void) { module_put(THIS_MODULE); } /* * Hash table: for virtual service lookups */ #define IP_VS_SVC_TAB_BITS 8 #define IP_VS_SVC_TAB_SIZE (1 << IP_VS_SVC_TAB_BITS) #define IP_VS_SVC_TAB_MASK (IP_VS_SVC_TAB_SIZE - 1) /* the service table hashed by <protocol, addr, port> */ static struct list_head ip_vs_svc_table[IP_VS_SVC_TAB_SIZE]; /* the service table hashed by fwmark */ static struct list_head ip_vs_svc_fwm_table[IP_VS_SVC_TAB_SIZE]; /* * Returns hash value for virtual service */ static inline unsigned ip_vs_svc_hashkey(struct net *net, int af, unsigned proto, const union nf_inet_addr *addr, __be16 port) { register unsigned porth = ntohs(port); __be32 addr_fold = addr->ip; #ifdef CONFIG_IP_VS_IPV6 if (af == AF_INET6) addr_fold = addr->ip6[0]^addr->ip6[1]^ addr->ip6[2]^addr->ip6[3]; #endif addr_fold ^= ((size_t)net>>8); return (proto^ntohl(addr_fold)^(porth>>IP_VS_SVC_TAB_BITS)^porth) & IP_VS_SVC_TAB_MASK; } /* * Returns hash value of fwmark for virtual service lookup */ static inline unsigned ip_vs_svc_fwm_hashkey(struct net *net, __u32 fwmark) { return (((size_t)net>>8) ^ fwmark) & IP_VS_SVC_TAB_MASK; } /* * Hashes a service in the ip_vs_svc_table by <netns,proto,addr,port> * or in the ip_vs_svc_fwm_table by fwmark. * Should be called with locked tables. */ static int ip_vs_svc_hash(struct ip_vs_service *svc) { unsigned hash; if (svc->flags & IP_VS_SVC_F_HASHED) { pr_err("%s(): request for already hashed, called from %pF\n", __func__, __builtin_return_address(0)); return 0; } if (svc->fwmark == 0) { /* * Hash it by <netns,protocol,addr,port> in ip_vs_svc_table */ hash = ip_vs_svc_hashkey(svc->net, svc->af, svc->protocol, &svc->addr, svc->port); list_add(&svc->s_list, &ip_vs_svc_table[hash]); } else { /* * Hash it by fwmark in svc_fwm_table */ hash = ip_vs_svc_fwm_hashkey(svc->net, svc->fwmark); list_add(&svc->f_list, &ip_vs_svc_fwm_table[hash]); } svc->flags |= IP_VS_SVC_F_HASHED; /* increase its refcnt because it is referenced by the svc table */ atomic_inc(&svc->refcnt); return 1; } /* * Unhashes a service from svc_table / svc_fwm_table. * Should be called with locked tables. */ static int ip_vs_svc_unhash(struct ip_vs_service *svc) { if (!(svc->flags & IP_VS_SVC_F_HASHED)) { pr_err("%s(): request for unhash flagged, called from %pF\n", __func__, __builtin_return_address(0)); return 0; } if (svc->fwmark == 0) { /* Remove it from the svc_table table */ list_del(&svc->s_list); } else { /* Remove it from the svc_fwm_table table */ list_del(&svc->f_list); } svc->flags &= ~IP_VS_SVC_F_HASHED; atomic_dec(&svc->refcnt); return 1; } /* * Get service by {netns, proto,addr,port} in the service table. */ static inline struct ip_vs_service * __ip_vs_service_find(struct net *net, int af, __u16 protocol, const union nf_inet_addr *vaddr, __be16 vport) { unsigned hash; struct ip_vs_service *svc; /* Check for "full" addressed entries */ hash = ip_vs_svc_hashkey(net, af, protocol, vaddr, vport); list_for_each_entry(svc, &ip_vs_svc_table[hash], s_list){ if ((svc->af == af) && ip_vs_addr_equal(af, &svc->addr, vaddr) && (svc->port == vport) && (svc->protocol == protocol) && net_eq(svc->net, net)) { /* HIT */ return svc; } } return NULL; } /* * Get service by {fwmark} in the service table. */ static inline struct ip_vs_service * __ip_vs_svc_fwm_find(struct net *net, int af, __u32 fwmark) { unsigned hash; struct ip_vs_service *svc; /* Check for fwmark addressed entries */ hash = ip_vs_svc_fwm_hashkey(net, fwmark); list_for_each_entry(svc, &ip_vs_svc_fwm_table[hash], f_list) { if (svc->fwmark == fwmark && svc->af == af && net_eq(svc->net, net)) { /* HIT */ return svc; } } return NULL; } struct ip_vs_service * ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol, const union nf_inet_addr *vaddr, __be16 vport) { struct ip_vs_service *svc; struct netns_ipvs *ipvs = net_ipvs(net); read_lock(&__ip_vs_svc_lock); /* * Check the table hashed by fwmark first */ if (fwmark) { svc = __ip_vs_svc_fwm_find(net, af, fwmark); if (svc) goto out; } /* * Check the table hashed by <protocol,addr,port> * for "full" addressed entries */ svc = __ip_vs_service_find(net, af, protocol, vaddr, vport); if (svc == NULL && protocol == IPPROTO_TCP && atomic_read(&ipvs->ftpsvc_counter) && (vport == FTPDATA || ntohs(vport) >= PROT_SOCK)) { /* * Check if ftp service entry exists, the packet * might belong to FTP data connections. */ svc = __ip_vs_service_find(net, af, protocol, vaddr, FTPPORT); } if (svc == NULL && atomic_read(&ipvs->nullsvc_counter)) { /* * Check if the catch-all port (port zero) exists */ svc = __ip_vs_service_find(net, af, protocol, vaddr, 0); } out: if (svc) atomic_inc(&svc->usecnt); read_unlock(&__ip_vs_svc_lock); IP_VS_DBG_BUF(9, "lookup service: fwm %u %s %s:%u %s\n", fwmark, ip_vs_proto_name(protocol), IP_VS_DBG_ADDR(af, vaddr), ntohs(vport), svc ? "hit" : "not hit"); return svc; } static inline void __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc) { atomic_inc(&svc->refcnt); dest->svc = svc; } static void __ip_vs_unbind_svc(struct ip_vs_dest *dest) { struct ip_vs_service *svc = dest->svc; dest->svc = NULL; if (atomic_dec_and_test(&svc->refcnt)) { IP_VS_DBG_BUF(3, "Removing service %u/%s:%u usecnt=%d\n", svc->fwmark, IP_VS_DBG_ADDR(svc->af, &svc->addr), ntohs(svc->port), atomic_read(&svc->usecnt)); free_percpu(svc->stats.cpustats); kfree(svc); } } /* * Returns hash value for real service */ static inline unsigned ip_vs_rs_hashkey(int af, const union nf_inet_addr *addr, __be16 port) { register unsigned porth = ntohs(port); __be32 addr_fold = addr->ip; #ifdef CONFIG_IP_VS_IPV6 if (af == AF_INET6) addr_fold = addr->ip6[0]^addr->ip6[1]^ addr->ip6[2]^addr->ip6[3]; #endif return (ntohl(addr_fold)^(porth>>IP_VS_RTAB_BITS)^porth) & IP_VS_RTAB_MASK; } /* * Hashes ip_vs_dest in rs_table by <proto,addr,port>. * should be called with locked tables. */ static int ip_vs_rs_hash(struct netns_ipvs *ipvs, struct ip_vs_dest *dest) { unsigned hash; if (!list_empty(&dest->d_list)) { return 0; } /* * Hash by proto,addr,port, * which are the parameters of the real service. */ hash = ip_vs_rs_hashkey(dest->af, &dest->addr, dest->port); list_add(&dest->d_list, &ipvs->rs_table[hash]); return 1; } /* * UNhashes ip_vs_dest from rs_table. * should be called with locked tables. */ static int ip_vs_rs_unhash(struct ip_vs_dest *dest) { /* * Remove it from the rs_table table. */ if (!list_empty(&dest->d_list)) { list_del(&dest->d_list); INIT_LIST_HEAD(&dest->d_list); } return 1; } /* * Lookup real service by <proto,addr,port> in the real service table. */ struct ip_vs_dest * ip_vs_lookup_real_service(struct net *net, int af, __u16 protocol, const union nf_inet_addr *daddr, __be16 dport) { struct netns_ipvs *ipvs = net_ipvs(net); unsigned hash; struct ip_vs_dest *dest; /* * Check for "full" addressed entries * Return the first found entry */ hash = ip_vs_rs_hashkey(af, daddr, dport); read_lock(&ipvs->rs_lock); list_for_each_entry(dest, &ipvs->rs_table[hash], d_list) { if ((dest->af == af) && ip_vs_addr_equal(af, &dest->addr, daddr) && (dest->port == dport) && ((dest->protocol == protocol) || dest->vfwmark)) { /* HIT */ read_unlock(&ipvs->rs_lock); return dest; } } read_unlock(&ipvs->rs_lock); return NULL; } /* * Lookup destination by {addr,port} in the given service */ static struct ip_vs_dest * ip_vs_lookup_dest(struct ip_vs_service *svc, const union nf_inet_addr *daddr, __be16 dport) { struct ip_vs_dest *dest; /* * Find the destination for the given service */ list_for_each_entry(dest, &svc->destinations, n_list) { if ((dest->af == svc->af) && ip_vs_addr_equal(svc->af, &dest->addr, daddr) && (dest->port == dport)) { /* HIT */ return dest; } } return NULL; } /* * Find destination by {daddr,dport,vaddr,protocol} * Cretaed to be used in ip_vs_process_message() in * the backup synchronization daemon. It finds the * destination to be bound to the received connection * on the backup. * * ip_vs_lookup_real_service() looked promissing, but * seems not working as expected. */ struct ip_vs_dest *ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr, __be16 dport, const union nf_inet_addr *vaddr, __be16 vport, __u16 protocol, __u32 fwmark, __u32 flags) { struct ip_vs_dest *dest; struct ip_vs_service *svc; __be16 port = dport; svc = ip_vs_service_get(net, af, fwmark, protocol, vaddr, vport); if (!svc) return NULL; if (fwmark && (flags & IP_VS_CONN_F_FWD_MASK) != IP_VS_CONN_F_MASQ) port = 0; dest = ip_vs_lookup_dest(svc, daddr, port); if (!dest) dest = ip_vs_lookup_dest(svc, daddr, port ^ dport); if (dest) atomic_inc(&dest->refcnt); ip_vs_service_put(svc); return dest; } /* * Lookup dest by {svc,addr,port} in the destination trash. * The destination trash is used to hold the destinations that are removed * from the service table but are still referenced by some conn entries. * The reason to add the destination trash is when the dest is temporary * down (either by administrator or by monitor program), the dest can be * picked back from the trash, the remaining connections to the dest can * continue, and the counting information of the dest is also useful for * scheduling. */ static struct ip_vs_dest * ip_vs_trash_get_dest(struct ip_vs_service *svc, const union nf_inet_addr *daddr, __be16 dport) { struct ip_vs_dest *dest, *nxt; struct netns_ipvs *ipvs = net_ipvs(svc->net); /* * Find the destination in trash */ list_for_each_entry_safe(dest, nxt, &ipvs->dest_trash, n_list) { IP_VS_DBG_BUF(3, "Destination %u/%s:%u still in trash, " "dest->refcnt=%d\n", dest->vfwmark, IP_VS_DBG_ADDR(svc->af, &dest->addr), ntohs(dest->port), atomic_read(&dest->refcnt)); if (dest->af == svc->af && ip_vs_addr_equal(svc->af, &dest->addr, daddr) && dest->port == dport && dest->vfwmark == svc->fwmark && dest->protocol == svc->protocol && (svc->fwmark || (ip_vs_addr_equal(svc->af, &dest->vaddr, &svc->addr) && dest->vport == svc->port))) { /* HIT */ return dest; } /* * Try to purge the destination from trash if not referenced */ if (atomic_read(&dest->refcnt) == 1) { IP_VS_DBG_BUF(3, "Removing destination %u/%s:%u " "from trash\n", dest->vfwmark, IP_VS_DBG_ADDR(svc->af, &dest->addr), ntohs(dest->port)); list_del(&dest->n_list); ip_vs_dst_reset(dest); __ip_vs_unbind_svc(dest); free_percpu(dest->stats.cpustats); kfree(dest); } } return NULL; } /* * Clean up all the destinations in the trash * Called by the ip_vs_control_cleanup() * * When the ip_vs_control_clearup is activated by ipvs module exit, * the service tables must have been flushed and all the connections * are expired, and the refcnt of each destination in the trash must * be 1, so we simply release them here. */ static void ip_vs_trash_cleanup(struct net *net) { struct ip_vs_dest *dest, *nxt; struct netns_ipvs *ipvs = net_ipvs(net); list_for_each_entry_safe(dest, nxt, &ipvs->dest_trash, n_list) { list_del(&dest->n_list); ip_vs_dst_reset(dest); __ip_vs_unbind_svc(dest); free_percpu(dest->stats.cpustats); kfree(dest); } } static void ip_vs_copy_stats(struct ip_vs_stats_user *dst, struct ip_vs_stats *src) { #define IP_VS_SHOW_STATS_COUNTER(c) dst->c = src->ustats.c - src->ustats0.c spin_lock_bh(&src->lock); IP_VS_SHOW_STATS_COUNTER(conns); IP_VS_SHOW_STATS_COUNTER(inpkts); IP_VS_SHOW_STATS_COUNTER(outpkts); IP_VS_SHOW_STATS_COUNTER(inbytes); IP_VS_SHOW_STATS_COUNTER(outbytes); ip_vs_read_estimator(dst, src); spin_unlock_bh(&src->lock); } static void ip_vs_zero_stats(struct ip_vs_stats *stats) { spin_lock_bh(&stats->lock); /* get current counters as zero point, rates are zeroed */ #define IP_VS_ZERO_STATS_COUNTER(c) stats->ustats0.c = stats->ustats.c IP_VS_ZERO_STATS_COUNTER(conns); IP_VS_ZERO_STATS_COUNTER(inpkts); IP_VS_ZERO_STATS_COUNTER(outpkts); IP_VS_ZERO_STATS_COUNTER(inbytes); IP_VS_ZERO_STATS_COUNTER(outbytes); ip_vs_zero_estimator(stats); spin_unlock_bh(&stats->lock); } /* * Update a destination in the given service */ static void __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest, struct ip_vs_dest_user_kern *udest, int add) { struct netns_ipvs *ipvs = net_ipvs(svc->net); int conn_flags; /* set the weight and the flags */ atomic_set(&dest->weight, udest->weight); conn_flags = udest->conn_flags & IP_VS_CONN_F_DEST_MASK; conn_flags |= IP_VS_CONN_F_INACTIVE; /* set the IP_VS_CONN_F_NOOUTPUT flag if not masquerading/NAT */ if ((conn_flags & IP_VS_CONN_F_FWD_MASK) != IP_VS_CONN_F_MASQ) { conn_flags |= IP_VS_CONN_F_NOOUTPUT; } else { /* * Put the real service in rs_table if not present. * For now only for NAT! */ write_lock_bh(&ipvs->rs_lock); ip_vs_rs_hash(ipvs, dest); write_unlock_bh(&ipvs->rs_lock); } atomic_set(&dest->conn_flags, conn_flags); /* bind the service */ if (!dest->svc) { __ip_vs_bind_svc(dest, svc); } else { if (dest->svc != svc) { __ip_vs_unbind_svc(dest); ip_vs_zero_stats(&dest->stats); __ip_vs_bind_svc(dest, svc); } } /* set the dest status flags */ dest->flags |= IP_VS_DEST_F_AVAILABLE; if (udest->u_threshold == 0 || udest->u_threshold > dest->u_threshold) dest->flags &= ~IP_VS_DEST_F_OVERLOAD; dest->u_threshold = udest->u_threshold; dest->l_threshold = udest->l_threshold; spin_lock_bh(&dest->dst_lock); ip_vs_dst_reset(dest); spin_unlock_bh(&dest->dst_lock); if (add) ip_vs_start_estimator(svc->net, &dest->stats); write_lock_bh(&__ip_vs_svc_lock); /* Wait until all other svc users go away */ IP_VS_WAIT_WHILE(atomic_read(&svc->usecnt) > 0); if (add) { list_add(&dest->n_list, &svc->destinations); svc->num_dests++; } /* call the update_service, because server weight may be changed */ if (svc->scheduler->update_service) svc->scheduler->update_service(svc); write_unlock_bh(&__ip_vs_svc_lock); } /* * Create a destination for the given service */ static int ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest, struct ip_vs_dest **dest_p) { struct ip_vs_dest *dest; unsigned atype; EnterFunction(2); #ifdef CONFIG_IP_VS_IPV6 if (svc->af == AF_INET6) { atype = ipv6_addr_type(&udest->addr.in6); if ((!(atype & IPV6_ADDR_UNICAST) || atype & IPV6_ADDR_LINKLOCAL) && !__ip_vs_addr_is_local_v6(svc->net, &udest->addr.in6)) return -EINVAL; } else #endif { atype = inet_addr_type(svc->net, udest->addr.ip); if (atype != RTN_LOCAL && atype != RTN_UNICAST) return -EINVAL; } dest = kzalloc(sizeof(struct ip_vs_dest), GFP_KERNEL); if (dest == NULL) return -ENOMEM; dest->stats.cpustats = alloc_percpu(struct ip_vs_cpu_stats); if (!dest->stats.cpustats) goto err_alloc; dest->af = svc->af; dest->protocol = svc->protocol; dest->vaddr = svc->addr; dest->vport = svc->port; dest->vfwmark = svc->fwmark; ip_vs_addr_copy(svc->af, &dest->addr, &udest->addr); dest->port = udest->port; atomic_set(&dest->activeconns, 0); atomic_set(&dest->inactconns, 0); atomic_set(&dest->persistconns, 0); atomic_set(&dest->refcnt, 1); INIT_LIST_HEAD(&dest->d_list); spin_lock_init(&dest->dst_lock); spin_lock_init(&dest->stats.lock); __ip_vs_update_dest(svc, dest, udest, 1); *dest_p = dest; LeaveFunction(2); return 0; err_alloc: kfree(dest); return -ENOMEM; } /* * Add a destination into an existing service */ static int ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest) { struct ip_vs_dest *dest; union nf_inet_addr daddr; __be16 dport = udest->port; int ret; EnterFunction(2); if (udest->weight < 0) { pr_err("%s(): server weight less than zero\n", __func__); return -ERANGE; } if (udest->l_threshold > udest->u_threshold) { pr_err("%s(): lower threshold is higher than upper threshold\n", __func__); return -ERANGE; } ip_vs_addr_copy(svc->af, &daddr, &udest->addr); /* * Check if the dest already exists in the list */ dest = ip_vs_lookup_dest(svc, &daddr, dport); if (dest != NULL) { IP_VS_DBG(1, "%s(): dest already exists\n", __func__); return -EEXIST; } /* * Check if the dest already exists in the trash and * is from the same service */ dest = ip_vs_trash_get_dest(svc, &daddr, dport); if (dest != NULL) { IP_VS_DBG_BUF(3, "Get destination %s:%u from trash, " "dest->refcnt=%d, service %u/%s:%u\n", IP_VS_DBG_ADDR(svc->af, &daddr), ntohs(dport), atomic_read(&dest->refcnt), dest->vfwmark, IP_VS_DBG_ADDR(svc->af, &dest->vaddr), ntohs(dest->vport)); /* * Get the destination from the trash */ list_del(&dest->n_list); __ip_vs_update_dest(svc, dest, udest, 1); ret = 0; } else { /* * Allocate and initialize the dest structure */ ret = ip_vs_new_dest(svc, udest, &dest); } LeaveFunction(2); return ret; } /* * Edit a destination in the given service */ static int ip_vs_edit_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest) { struct ip_vs_dest *dest; union nf_inet_addr daddr; __be16 dport = udest->port; EnterFunction(2); if (udest->weight < 0) { pr_err("%s(): server weight less than zero\n", __func__); return -ERANGE; } if (udest->l_threshold > udest->u_threshold) { pr_err("%s(): lower threshold is higher than upper threshold\n", __func__); return -ERANGE; } ip_vs_addr_copy(svc->af, &daddr, &udest->addr); /* * Lookup the destination list */ dest = ip_vs_lookup_dest(svc, &daddr, dport); if (dest == NULL) { IP_VS_DBG(1, "%s(): dest doesn't exist\n", __func__); return -ENOENT; } __ip_vs_update_dest(svc, dest, udest, 0); LeaveFunction(2); return 0; } /* * Delete a destination (must be already unlinked from the service) */ static void __ip_vs_del_dest(struct net *net, struct ip_vs_dest *dest) { struct netns_ipvs *ipvs = net_ipvs(net); ip_vs_stop_estimator(net, &dest->stats); /* * Remove it from the d-linked list with the real services. */ write_lock_bh(&ipvs->rs_lock); ip_vs_rs_unhash(dest); write_unlock_bh(&ipvs->rs_lock); /* * Decrease the refcnt of the dest, and free the dest * if nobody refers to it (refcnt=0). Otherwise, throw * the destination into the trash. */ if (atomic_dec_and_test(&dest->refcnt)) { IP_VS_DBG_BUF(3, "Removing destination %u/%s:%u\n", dest->vfwmark, IP_VS_DBG_ADDR(dest->af, &dest->addr), ntohs(dest->port)); ip_vs_dst_reset(dest); /* simply decrease svc->refcnt here, let the caller check and release the service if nobody refers to it. Only user context can release destination and service, and only one user context can update virtual service at a time, so the operation here is OK */ atomic_dec(&dest->svc->refcnt); free_percpu(dest->stats.cpustats); kfree(dest); } else { IP_VS_DBG_BUF(3, "Moving dest %s:%u into trash, " "dest->refcnt=%d\n", IP_VS_DBG_ADDR(dest->af, &dest->addr), ntohs(dest->port), atomic_read(&dest->refcnt)); list_add(&dest->n_list, &ipvs->dest_trash); atomic_inc(&dest->refcnt); } } /* * Unlink a destination from the given service */ static void __ip_vs_unlink_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest, int svcupd) { dest->flags &= ~IP_VS_DEST_F_AVAILABLE; /* * Remove it from the d-linked destination list. */ list_del(&dest->n_list); svc->num_dests--; /* * Call the update_service function of its scheduler */ if (svcupd && svc->scheduler->update_service) svc->scheduler->update_service(svc); } /* * Delete a destination server in the given service */ static int ip_vs_del_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest) { struct ip_vs_dest *dest; __be16 dport = udest->port; EnterFunction(2); dest = ip_vs_lookup_dest(svc, &udest->addr, dport); if (dest == NULL) { IP_VS_DBG(1, "%s(): destination not found!\n", __func__); return -ENOENT; } write_lock_bh(&__ip_vs_svc_lock); /* * Wait until all other svc users go away. */ IP_VS_WAIT_WHILE(atomic_read(&svc->usecnt) > 0); /* * Unlink dest from the service */ __ip_vs_unlink_dest(svc, dest, 1); write_unlock_bh(&__ip_vs_svc_lock); /* * Delete the destination */ __ip_vs_del_dest(svc->net, dest); LeaveFunction(2); return 0; } /* * Add a service into the service hash table */ static int ip_vs_add_service(struct net *net, struct ip_vs_service_user_kern *u, struct ip_vs_service **svc_p) { int ret = 0; struct ip_vs_scheduler *sched = NULL; struct ip_vs_pe *pe = NULL; struct ip_vs_service *svc = NULL; struct netns_ipvs *ipvs = net_ipvs(net); /* increase the module use count */ ip_vs_use_count_inc(); /* Lookup the scheduler by 'u->sched_name' */ sched = ip_vs_scheduler_get(u->sched_name); if (sched == NULL) { pr_info("Scheduler module ip_vs_%s not found\n", u->sched_name); ret = -ENOENT; goto out_err; } if (u->pe_name && *u->pe_name) { pe = ip_vs_pe_getbyname(u->pe_name); if (pe == NULL) { pr_info("persistence engine module ip_vs_pe_%s " "not found\n", u->pe_name); ret = -ENOENT; goto out_err; } } #ifdef CONFIG_IP_VS_IPV6 if (u->af == AF_INET6 && (u->netmask < 1 || u->netmask > 128)) { ret = -EINVAL; goto out_err; } #endif svc = kzalloc(sizeof(struct ip_vs_service), GFP_KERNEL); if (svc == NULL) { IP_VS_DBG(1, "%s(): no memory\n", __func__); ret = -ENOMEM; goto out_err; } svc->stats.cpustats = alloc_percpu(struct ip_vs_cpu_stats); if (!svc->stats.cpustats) goto out_err; /* I'm the first user of the service */ atomic_set(&svc->usecnt, 0); atomic_set(&svc->refcnt, 0); svc->af = u->af; svc->protocol = u->protocol; ip_vs_addr_copy(svc->af, &svc->addr, &u->addr); svc->port = u->port; svc->fwmark = u->fwmark; svc->flags = u->flags; svc->timeout = u->timeout * HZ; svc->netmask = u->netmask; svc->net = net; INIT_LIST_HEAD(&svc->destinations); rwlock_init(&svc->sched_lock); spin_lock_init(&svc->stats.lock); /* Bind the scheduler */ ret = ip_vs_bind_scheduler(svc, sched); if (ret) goto out_err; sched = NULL; /* Bind the ct retriever */ ip_vs_bind_pe(svc, pe); pe = NULL; /* Update the virtual service counters */ if (svc->port == FTPPORT) atomic_inc(&ipvs->ftpsvc_counter); else if (svc->port == 0) atomic_inc(&ipvs->nullsvc_counter); ip_vs_start_estimator(net, &svc->stats); /* Count only IPv4 services for old get/setsockopt interface */ if (svc->af == AF_INET) ipvs->num_services++; /* Hash the service into the service table */ write_lock_bh(&__ip_vs_svc_lock); ip_vs_svc_hash(svc); write_unlock_bh(&__ip_vs_svc_lock); *svc_p = svc; /* Now there is a service - full throttle */ ipvs->enable = 1; return 0; out_err: if (svc != NULL) { ip_vs_unbind_scheduler(svc); if (svc->inc) { local_bh_disable(); ip_vs_app_inc_put(svc->inc); local_bh_enable(); } if (svc->stats.cpustats) free_percpu(svc->stats.cpustats); kfree(svc); } ip_vs_scheduler_put(sched); ip_vs_pe_put(pe); /* decrease the module use count */ ip_vs_use_count_dec(); return ret; } /* * Edit a service and bind it with a new scheduler */ static int ip_vs_edit_service(struct ip_vs_service *svc, struct ip_vs_service_user_kern *u) { struct ip_vs_scheduler *sched, *old_sched; struct ip_vs_pe *pe = NULL, *old_pe = NULL; int ret = 0; /* * Lookup the scheduler, by 'u->sched_name' */ sched = ip_vs_scheduler_get(u->sched_name); if (sched == NULL) { pr_info("Scheduler module ip_vs_%s not found\n", u->sched_name); return -ENOENT; } old_sched = sched; if (u->pe_name && *u->pe_name) { pe = ip_vs_pe_getbyname(u->pe_name); if (pe == NULL) { pr_info("persistence engine module ip_vs_pe_%s " "not found\n", u->pe_name); ret = -ENOENT; goto out; } old_pe = pe; } #ifdef CONFIG_IP_VS_IPV6 if (u->af == AF_INET6 && (u->netmask < 1 || u->netmask > 128)) { ret = -EINVAL; goto out; } #endif write_lock_bh(&__ip_vs_svc_lock); /* * Wait until all other svc users go away. */ IP_VS_WAIT_WHILE(atomic_read(&svc->usecnt) > 0); /* * Set the flags and timeout value */ svc->flags = u->flags | IP_VS_SVC_F_HASHED; svc->timeout = u->timeout * HZ; svc->netmask = u->netmask; old_sched = svc->scheduler; if (sched != old_sched) { /* * Unbind the old scheduler */ if ((ret = ip_vs_unbind_scheduler(svc))) { old_sched = sched; goto out_unlock; } /* * Bind the new scheduler */ if ((ret = ip_vs_bind_scheduler(svc, sched))) { /* * If ip_vs_bind_scheduler fails, restore the old * scheduler. * The main reason of failure is out of memory. * * The question is if the old scheduler can be * restored all the time. TODO: if it cannot be * restored some time, we must delete the service, * otherwise the system may crash. */ ip_vs_bind_scheduler(svc, old_sched); old_sched = sched; goto out_unlock; } } old_pe = svc->pe; if (pe != old_pe) { ip_vs_unbind_pe(svc); ip_vs_bind_pe(svc, pe); } out_unlock: write_unlock_bh(&__ip_vs_svc_lock); out: ip_vs_scheduler_put(old_sched); ip_vs_pe_put(old_pe); return ret; } /* * Delete a service from the service list * - The service must be unlinked, unlocked and not referenced! * - We are called under _bh lock */ static void __ip_vs_del_service(struct ip_vs_service *svc) { struct ip_vs_dest *dest, *nxt; struct ip_vs_scheduler *old_sched; struct ip_vs_pe *old_pe; struct netns_ipvs *ipvs = net_ipvs(svc->net); pr_info("%s: enter\n", __func__); /* Count only IPv4 services for old get/setsockopt interface */ if (svc->af == AF_INET) ipvs->num_services--; ip_vs_stop_estimator(svc->net, &svc->stats); /* Unbind scheduler */ old_sched = svc->scheduler; ip_vs_unbind_scheduler(svc); ip_vs_scheduler_put(old_sched); /* Unbind persistence engine */ old_pe = svc->pe; ip_vs_unbind_pe(svc); ip_vs_pe_put(old_pe); /* Unbind app inc */ if (svc->inc) { ip_vs_app_inc_put(svc->inc); svc->inc = NULL; } /* * Unlink the whole destination list */ list_for_each_entry_safe(dest, nxt, &svc->destinations, n_list) { __ip_vs_unlink_dest(svc, dest, 0); __ip_vs_del_dest(svc->net, dest); } /* * Update the virtual service counters */ if (svc->port == FTPPORT) atomic_dec(&ipvs->ftpsvc_counter); else if (svc->port == 0) atomic_dec(&ipvs->nullsvc_counter); /* * Free the service if nobody refers to it */ if (atomic_read(&svc->refcnt) == 0) { IP_VS_DBG_BUF(3, "Removing service %u/%s:%u usecnt=%d\n", svc->fwmark, IP_VS_DBG_ADDR(svc->af, &svc->addr), ntohs(svc->port), atomic_read(&svc->usecnt)); free_percpu(svc->stats.cpustats); kfree(svc); } /* decrease the module use count */ ip_vs_use_count_dec(); } /* * Unlink a service from list and try to delete it if its refcnt reached 0 */ static void ip_vs_unlink_service(struct ip_vs_service *svc) { /* * Unhash it from the service table */ write_lock_bh(&__ip_vs_svc_lock); ip_vs_svc_unhash(svc); /* * Wait until all the svc users go away. */ IP_VS_WAIT_WHILE(atomic_read(&svc->usecnt) > 0); __ip_vs_del_service(svc); write_unlock_bh(&__ip_vs_svc_lock); } /* * Delete a service from the service list */ static int ip_vs_del_service(struct ip_vs_service *svc) { if (svc == NULL) return -EEXIST; ip_vs_unlink_service(svc); return 0; } /* * Flush all the virtual services */ static int ip_vs_flush(struct net *net) { int idx; struct ip_vs_service *svc, *nxt; /* * Flush the service table hashed by <netns,protocol,addr,port> */ for(idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { list_for_each_entry_safe(svc, nxt, &ip_vs_svc_table[idx], s_list) { if (net_eq(svc->net, net)) ip_vs_unlink_service(svc); } } /* * Flush the service table hashed by fwmark */ for(idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { list_for_each_entry_safe(svc, nxt, &ip_vs_svc_fwm_table[idx], f_list) { if (net_eq(svc->net, net)) ip_vs_unlink_service(svc); } } return 0; } /* * Delete service by {netns} in the service table. * Called by __ip_vs_cleanup() */ void ip_vs_service_net_cleanup(struct net *net) { EnterFunction(2); /* Check for "full" addressed entries */ mutex_lock(&__ip_vs_mutex); ip_vs_flush(net); mutex_unlock(&__ip_vs_mutex); LeaveFunction(2); } /* * Release dst hold by dst_cache */ static inline void __ip_vs_dev_reset(struct ip_vs_dest *dest, struct net_device *dev) { spin_lock_bh(&dest->dst_lock); if (dest->dst_cache && dest->dst_cache->dev == dev) { IP_VS_DBG_BUF(3, "Reset dev:%s dest %s:%u ,dest->refcnt=%d\n", dev->name, IP_VS_DBG_ADDR(dest->af, &dest->addr), ntohs(dest->port), atomic_read(&dest->refcnt)); ip_vs_dst_reset(dest); } spin_unlock_bh(&dest->dst_lock); } /* * Netdev event receiver * Currently only NETDEV_UNREGISTER is handled, i.e. if we hold a reference to * a device that is "unregister" it must be released. */ static int ip_vs_dst_event(struct notifier_block *this, unsigned long event, void *ptr) { struct net_device *dev = ptr; struct net *net = dev_net(dev); struct ip_vs_service *svc; struct ip_vs_dest *dest; unsigned int idx; if (event != NETDEV_UNREGISTER) return NOTIFY_DONE; IP_VS_DBG(3, "%s() dev=%s\n", __func__, dev->name); EnterFunction(2); mutex_lock(&__ip_vs_mutex); for (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { list_for_each_entry(svc, &ip_vs_svc_table[idx], s_list) { if (net_eq(svc->net, net)) { list_for_each_entry(dest, &svc->destinations, n_list) { __ip_vs_dev_reset(dest, dev); } } } list_for_each_entry(svc, &ip_vs_svc_fwm_table[idx], f_list) { if (net_eq(svc->net, net)) { list_for_each_entry(dest, &svc->destinations, n_list) { __ip_vs_dev_reset(dest, dev); } } } } list_for_each_entry(dest, &net_ipvs(net)->dest_trash, n_list) { __ip_vs_dev_reset(dest, dev); } mutex_unlock(&__ip_vs_mutex); LeaveFunction(2); return NOTIFY_DONE; } /* * Zero counters in a service or all services */ static int ip_vs_zero_service(struct ip_vs_service *svc) { struct ip_vs_dest *dest; write_lock_bh(&__ip_vs_svc_lock); list_for_each_entry(dest, &svc->destinations, n_list) { ip_vs_zero_stats(&dest->stats); } ip_vs_zero_stats(&svc->stats); write_unlock_bh(&__ip_vs_svc_lock); return 0; } static int ip_vs_zero_all(struct net *net) { int idx; struct ip_vs_service *svc; for(idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { list_for_each_entry(svc, &ip_vs_svc_table[idx], s_list) { if (net_eq(svc->net, net)) ip_vs_zero_service(svc); } } for(idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { list_for_each_entry(svc, &ip_vs_svc_fwm_table[idx], f_list) { if (net_eq(svc->net, net)) ip_vs_zero_service(svc); } } ip_vs_zero_stats(&net_ipvs(net)->tot_stats); return 0; } #ifdef CONFIG_SYSCTL static int proc_do_defense_mode(ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { struct net *net = current->nsproxy->net_ns; int *valp = table->data; int val = *valp; int rc; rc = proc_dointvec(table, write, buffer, lenp, ppos); if (write && (*valp != val)) { if ((*valp < 0) || (*valp > 3)) { /* Restore the correct value */ *valp = val; } else { update_defense_level(net_ipvs(net)); } } return rc; } static int proc_do_sync_threshold(ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { int *valp = table->data; int val[2]; int rc; /* backup the value first */ memcpy(val, valp, sizeof(val)); rc = proc_dointvec(table, write, buffer, lenp, ppos); if (write && (valp[0] < 0 || valp[1] < 0 || valp[0] >= valp[1])) { /* Restore the correct value */ memcpy(valp, val, sizeof(val)); } return rc; } static int proc_do_sync_mode(ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { int *valp = table->data; int val = *valp; int rc; rc = proc_dointvec(table, write, buffer, lenp, ppos); if (write && (*valp != val)) { if ((*valp < 0) || (*valp > 1)) { /* Restore the correct value */ *valp = val; } else { struct net *net = current->nsproxy->net_ns; ip_vs_sync_switch_mode(net, val); } } return rc; } /* * IPVS sysctl table (under the /proc/sys/net/ipv4/vs/) * Do not change order or insert new entries without * align with netns init in ip_vs_control_net_init() */ static struct ctl_table vs_vars[] = { { .procname = "amemthresh", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "am_droprate", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "drop_entry", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_do_defense_mode, }, { .procname = "drop_packet", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_do_defense_mode, }, #ifdef CONFIG_IP_VS_NFCT { .procname = "conntrack", .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_dointvec, }, #endif { .procname = "secure_tcp", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_do_defense_mode, }, { .procname = "snat_reroute", .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_dointvec, }, { .procname = "sync_version", .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_do_sync_mode, }, { .procname = "cache_bypass", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "expire_nodest_conn", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "expire_quiescent_template", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "sync_threshold", .maxlen = sizeof(((struct netns_ipvs *)0)->sysctl_sync_threshold), .mode = 0644, .proc_handler = proc_do_sync_threshold, }, { .procname = "nat_icmp_send", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, #ifdef CONFIG_IP_VS_DEBUG { .procname = "debug_level", .data = &sysctl_ip_vs_debug_level, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, #endif #if 0 { .procname = "timeout_established", .data = &vs_timeout_table_dos.timeout[IP_VS_S_ESTABLISHED], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_synsent", .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_SENT], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_synrecv", .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYN_RECV], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_finwait", .data = &vs_timeout_table_dos.timeout[IP_VS_S_FIN_WAIT], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_timewait", .data = &vs_timeout_table_dos.timeout[IP_VS_S_TIME_WAIT], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_close", .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_closewait", .data = &vs_timeout_table_dos.timeout[IP_VS_S_CLOSE_WAIT], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_lastack", .data = &vs_timeout_table_dos.timeout[IP_VS_S_LAST_ACK], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_listen", .data = &vs_timeout_table_dos.timeout[IP_VS_S_LISTEN], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_synack", .data = &vs_timeout_table_dos.timeout[IP_VS_S_SYNACK], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_udp", .data = &vs_timeout_table_dos.timeout[IP_VS_S_UDP], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "timeout_icmp", .data = &vs_timeout_table_dos.timeout[IP_VS_S_ICMP], .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, #endif { } }; const struct ctl_path net_vs_ctl_path[] = { { .procname = "net", }, { .procname = "ipv4", }, { .procname = "vs", }, { } }; EXPORT_SYMBOL_GPL(net_vs_ctl_path); #endif #ifdef CONFIG_PROC_FS struct ip_vs_iter { struct seq_net_private p; /* Do not move this, netns depends upon it*/ struct list_head *table; int bucket; }; /* * Write the contents of the VS rule table to a PROCfs file. * (It is kept just for backward compatibility) */ static inline const char *ip_vs_fwd_name(unsigned flags) { switch (flags & IP_VS_CONN_F_FWD_MASK) { case IP_VS_CONN_F_LOCALNODE: return "Local"; case IP_VS_CONN_F_TUNNEL: return "Tunnel"; case IP_VS_CONN_F_DROUTE: return "Route"; default: return "Masq"; } } /* Get the Nth entry in the two lists */ static struct ip_vs_service *ip_vs_info_array(struct seq_file *seq, loff_t pos) { struct net *net = seq_file_net(seq); struct ip_vs_iter *iter = seq->private; int idx; struct ip_vs_service *svc; /* look in hash by protocol */ for (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { list_for_each_entry(svc, &ip_vs_svc_table[idx], s_list) { if (net_eq(svc->net, net) && pos-- == 0) { iter->table = ip_vs_svc_table; iter->bucket = idx; return svc; } } } /* keep looking in fwmark */ for (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { list_for_each_entry(svc, &ip_vs_svc_fwm_table[idx], f_list) { if (net_eq(svc->net, net) && pos-- == 0) { iter->table = ip_vs_svc_fwm_table; iter->bucket = idx; return svc; } } } return NULL; } static void *ip_vs_info_seq_start(struct seq_file *seq, loff_t *pos) __acquires(__ip_vs_svc_lock) { read_lock_bh(&__ip_vs_svc_lock); return *pos ? ip_vs_info_array(seq, *pos - 1) : SEQ_START_TOKEN; } static void *ip_vs_info_seq_next(struct seq_file *seq, void *v, loff_t *pos) { struct list_head *e; struct ip_vs_iter *iter; struct ip_vs_service *svc; ++*pos; if (v == SEQ_START_TOKEN) return ip_vs_info_array(seq,0); svc = v; iter = seq->private; if (iter->table == ip_vs_svc_table) { /* next service in table hashed by protocol */ if ((e = svc->s_list.next) != &ip_vs_svc_table[iter->bucket]) return list_entry(e, struct ip_vs_service, s_list); while (++iter->bucket < IP_VS_SVC_TAB_SIZE) { list_for_each_entry(svc,&ip_vs_svc_table[iter->bucket], s_list) { return svc; } } iter->table = ip_vs_svc_fwm_table; iter->bucket = -1; goto scan_fwmark; } /* next service in hashed by fwmark */ if ((e = svc->f_list.next) != &ip_vs_svc_fwm_table[iter->bucket]) return list_entry(e, struct ip_vs_service, f_list); scan_fwmark: while (++iter->bucket < IP_VS_SVC_TAB_SIZE) { list_for_each_entry(svc, &ip_vs_svc_fwm_table[iter->bucket], f_list) return svc; } return NULL; } static void ip_vs_info_seq_stop(struct seq_file *seq, void *v) __releases(__ip_vs_svc_lock) { read_unlock_bh(&__ip_vs_svc_lock); } static int ip_vs_info_seq_show(struct seq_file *seq, void *v) { if (v == SEQ_START_TOKEN) { seq_printf(seq, "IP Virtual Server version %d.%d.%d (size=%d)\n", NVERSION(IP_VS_VERSION_CODE), ip_vs_conn_tab_size); seq_puts(seq, "Prot LocalAddress:Port Scheduler Flags\n"); seq_puts(seq, " -> RemoteAddress:Port Forward Weight ActiveConn InActConn\n"); } else { const struct ip_vs_service *svc = v; const struct ip_vs_iter *iter = seq->private; const struct ip_vs_dest *dest; if (iter->table == ip_vs_svc_table) { #ifdef CONFIG_IP_VS_IPV6 if (svc->af == AF_INET6) seq_printf(seq, "%s [%pI6]:%04X %s ", ip_vs_proto_name(svc->protocol), &svc->addr.in6, ntohs(svc->port), svc->scheduler->name); else #endif seq_printf(seq, "%s %08X:%04X %s %s ", ip_vs_proto_name(svc->protocol), ntohl(svc->addr.ip), ntohs(svc->port), svc->scheduler->name, (svc->flags & IP_VS_SVC_F_ONEPACKET)?"ops ":""); } else { seq_printf(seq, "FWM %08X %s %s", svc->fwmark, svc->scheduler->name, (svc->flags & IP_VS_SVC_F_ONEPACKET)?"ops ":""); } if (svc->flags & IP_VS_SVC_F_PERSISTENT) seq_printf(seq, "persistent %d %08X\n", svc->timeout, ntohl(svc->netmask)); else seq_putc(seq, '\n'); list_for_each_entry(dest, &svc->destinations, n_list) { #ifdef CONFIG_IP_VS_IPV6 if (dest->af == AF_INET6) seq_printf(seq, " -> [%pI6]:%04X" " %-7s %-6d %-10d %-10d\n", &dest->addr.in6, ntohs(dest->port), ip_vs_fwd_name(atomic_read(&dest->conn_flags)), atomic_read(&dest->weight), atomic_read(&dest->activeconns), atomic_read(&dest->inactconns)); else #endif seq_printf(seq, " -> %08X:%04X " "%-7s %-6d %-10d %-10d\n", ntohl(dest->addr.ip), ntohs(dest->port), ip_vs_fwd_name(atomic_read(&dest->conn_flags)), atomic_read(&dest->weight), atomic_read(&dest->activeconns), atomic_read(&dest->inactconns)); } } return 0; } static const struct seq_operations ip_vs_info_seq_ops = { .start = ip_vs_info_seq_start, .next = ip_vs_info_seq_next, .stop = ip_vs_info_seq_stop, .show = ip_vs_info_seq_show, }; static int ip_vs_info_open(struct inode *inode, struct file *file) { return seq_open_net(inode, file, &ip_vs_info_seq_ops, sizeof(struct ip_vs_iter)); } static const struct file_operations ip_vs_info_fops = { .owner = THIS_MODULE, .open = ip_vs_info_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release_net, }; static int ip_vs_stats_show(struct seq_file *seq, void *v) { struct net *net = seq_file_single_net(seq); struct ip_vs_stats_user show; /* 01234567 01234567 01234567 0123456701234567 0123456701234567 */ seq_puts(seq, " Total Incoming Outgoing Incoming Outgoing\n"); seq_printf(seq, " Conns Packets Packets Bytes Bytes\n"); ip_vs_copy_stats(&show, &net_ipvs(net)->tot_stats); seq_printf(seq, "%8X %8X %8X %16LX %16LX\n\n", show.conns, show.inpkts, show.outpkts, (unsigned long long) show.inbytes, (unsigned long long) show.outbytes); /* 01234567 01234567 01234567 0123456701234567 0123456701234567 */ seq_puts(seq, " Conns/s Pkts/s Pkts/s Bytes/s Bytes/s\n"); seq_printf(seq, "%8X %8X %8X %16X %16X\n", show.cps, show.inpps, show.outpps, show.inbps, show.outbps); return 0; } static int ip_vs_stats_seq_open(struct inode *inode, struct file *file) { return single_open_net(inode, file, ip_vs_stats_show); } static const struct file_operations ip_vs_stats_fops = { .owner = THIS_MODULE, .open = ip_vs_stats_seq_open, .read = seq_read, .llseek = seq_lseek, .release = single_release_net, }; static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v) { struct net *net = seq_file_single_net(seq); struct ip_vs_stats *tot_stats = &net_ipvs(net)->tot_stats; struct ip_vs_cpu_stats *cpustats = tot_stats->cpustats; struct ip_vs_stats_user rates; int i; /* 01234567 01234567 01234567 0123456701234567 0123456701234567 */ seq_puts(seq, " Total Incoming Outgoing Incoming Outgoing\n"); seq_printf(seq, "CPU Conns Packets Packets Bytes Bytes\n"); for_each_possible_cpu(i) { struct ip_vs_cpu_stats *u = per_cpu_ptr(cpustats, i); unsigned int start; __u64 inbytes, outbytes; do { start = u64_stats_fetch_begin_bh(&u->syncp); inbytes = u->ustats.inbytes; outbytes = u->ustats.outbytes; } while (u64_stats_fetch_retry_bh(&u->syncp, start)); seq_printf(seq, "%3X %8X %8X %8X %16LX %16LX\n", i, u->ustats.conns, u->ustats.inpkts, u->ustats.outpkts, (__u64)inbytes, (__u64)outbytes); } spin_lock_bh(&tot_stats->lock); seq_printf(seq, " ~ %8X %8X %8X %16LX %16LX\n\n", tot_stats->ustats.conns, tot_stats->ustats.inpkts, tot_stats->ustats.outpkts, (unsigned long long) tot_stats->ustats.inbytes, (unsigned long long) tot_stats->ustats.outbytes); ip_vs_read_estimator(&rates, tot_stats); spin_unlock_bh(&tot_stats->lock); /* 01234567 01234567 01234567 0123456701234567 0123456701234567 */ seq_puts(seq, " Conns/s Pkts/s Pkts/s Bytes/s Bytes/s\n"); seq_printf(seq, " %8X %8X %8X %16X %16X\n", rates.cps, rates.inpps, rates.outpps, rates.inbps, rates.outbps); return 0; } static int ip_vs_stats_percpu_seq_open(struct inode *inode, struct file *file) { return single_open_net(inode, file, ip_vs_stats_percpu_show); } static const struct file_operations ip_vs_stats_percpu_fops = { .owner = THIS_MODULE, .open = ip_vs_stats_percpu_seq_open, .read = seq_read, .llseek = seq_lseek, .release = single_release_net, }; #endif /* * Set timeout values for tcp tcpfin udp in the timeout_table. */ static int ip_vs_set_timeout(struct net *net, struct ip_vs_timeout_user *u) { #if defined(CONFIG_IP_VS_PROTO_TCP) || defined(CONFIG_IP_VS_PROTO_UDP) struct ip_vs_proto_data *pd; #endif IP_VS_DBG(2, "Setting timeout tcp:%d tcpfin:%d udp:%d\n", u->tcp_timeout, u->tcp_fin_timeout, u->udp_timeout); #ifdef CONFIG_IP_VS_PROTO_TCP if (u->tcp_timeout) { pd = ip_vs_proto_data_get(net, IPPROTO_TCP); pd->timeout_table[IP_VS_TCP_S_ESTABLISHED] = u->tcp_timeout * HZ; } if (u->tcp_fin_timeout) { pd = ip_vs_proto_data_get(net, IPPROTO_TCP); pd->timeout_table[IP_VS_TCP_S_FIN_WAIT] = u->tcp_fin_timeout * HZ; } #endif #ifdef CONFIG_IP_VS_PROTO_UDP if (u->udp_timeout) { pd = ip_vs_proto_data_get(net, IPPROTO_UDP); pd->timeout_table[IP_VS_UDP_S_NORMAL] = u->udp_timeout * HZ; } #endif return 0; } #define SET_CMDID(cmd) (cmd - IP_VS_BASE_CTL) #define SERVICE_ARG_LEN (sizeof(struct ip_vs_service_user)) #define SVCDEST_ARG_LEN (sizeof(struct ip_vs_service_user) + \ sizeof(struct ip_vs_dest_user)) #define TIMEOUT_ARG_LEN (sizeof(struct ip_vs_timeout_user)) #define DAEMON_ARG_LEN (sizeof(struct ip_vs_daemon_user)) #define MAX_ARG_LEN SVCDEST_ARG_LEN static const unsigned char set_arglen[SET_CMDID(IP_VS_SO_SET_MAX)+1] = { [SET_CMDID(IP_VS_SO_SET_ADD)] = SERVICE_ARG_LEN, [SET_CMDID(IP_VS_SO_SET_EDIT)] = SERVICE_ARG_LEN, [SET_CMDID(IP_VS_SO_SET_DEL)] = SERVICE_ARG_LEN, [SET_CMDID(IP_VS_SO_SET_FLUSH)] = 0, [SET_CMDID(IP_VS_SO_SET_ADDDEST)] = SVCDEST_ARG_LEN, [SET_CMDID(IP_VS_SO_SET_DELDEST)] = SVCDEST_ARG_LEN, [SET_CMDID(IP_VS_SO_SET_EDITDEST)] = SVCDEST_ARG_LEN, [SET_CMDID(IP_VS_SO_SET_TIMEOUT)] = TIMEOUT_ARG_LEN, [SET_CMDID(IP_VS_SO_SET_STARTDAEMON)] = DAEMON_ARG_LEN, [SET_CMDID(IP_VS_SO_SET_STOPDAEMON)] = DAEMON_ARG_LEN, [SET_CMDID(IP_VS_SO_SET_ZERO)] = SERVICE_ARG_LEN, }; static void ip_vs_copy_usvc_compat(struct ip_vs_service_user_kern *usvc, struct ip_vs_service_user *usvc_compat) { memset(usvc, 0, sizeof(*usvc)); usvc->af = AF_INET; usvc->protocol = usvc_compat->protocol; usvc->addr.ip = usvc_compat->addr; usvc->port = usvc_compat->port; usvc->fwmark = usvc_compat->fwmark; /* Deep copy of sched_name is not needed here */ usvc->sched_name = usvc_compat->sched_name; usvc->flags = usvc_compat->flags; usvc->timeout = usvc_compat->timeout; usvc->netmask = usvc_compat->netmask; } static void ip_vs_copy_udest_compat(struct ip_vs_dest_user_kern *udest, struct ip_vs_dest_user *udest_compat) { memset(udest, 0, sizeof(*udest)); udest->addr.ip = udest_compat->addr; udest->port = udest_compat->port; udest->conn_flags = udest_compat->conn_flags; udest->weight = udest_compat->weight; udest->u_threshold = udest_compat->u_threshold; udest->l_threshold = udest_compat->l_threshold; } static int do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) { struct net *net = sock_net(sk); int ret; unsigned char arg[MAX_ARG_LEN]; struct ip_vs_service_user *usvc_compat; struct ip_vs_service_user_kern usvc; struct ip_vs_service *svc; struct ip_vs_dest_user *udest_compat; struct ip_vs_dest_user_kern udest; struct netns_ipvs *ipvs = net_ipvs(net); if (!capable(CAP_NET_ADMIN)) return -EPERM; if (cmd < IP_VS_BASE_CTL || cmd > IP_VS_SO_SET_MAX) return -EINVAL; if (len < 0 || len > MAX_ARG_LEN) return -EINVAL; if (len != set_arglen[SET_CMDID(cmd)]) { pr_err("set_ctl: len %u != %u\n", len, set_arglen[SET_CMDID(cmd)]); return -EINVAL; } if (copy_from_user(arg, user, len) != 0) return -EFAULT; /* increase the module use count */ ip_vs_use_count_inc(); /* Handle daemons since they have another lock */ if (cmd == IP_VS_SO_SET_STARTDAEMON || cmd == IP_VS_SO_SET_STOPDAEMON) { struct ip_vs_daemon_user *dm = (struct ip_vs_daemon_user *)arg; if (mutex_lock_interruptible(&ipvs->sync_mutex)) { ret = -ERESTARTSYS; goto out_dec; } if (cmd == IP_VS_SO_SET_STARTDAEMON) ret = start_sync_thread(net, dm->state, dm->mcast_ifn, dm->syncid); else ret = stop_sync_thread(net, dm->state); mutex_unlock(&ipvs->sync_mutex); goto out_dec; } if (mutex_lock_interruptible(&__ip_vs_mutex)) { ret = -ERESTARTSYS; goto out_dec; } if (cmd == IP_VS_SO_SET_FLUSH) { /* Flush the virtual service */ ret = ip_vs_flush(net); goto out_unlock; } else if (cmd == IP_VS_SO_SET_TIMEOUT) { /* Set timeout values for (tcp tcpfin udp) */ ret = ip_vs_set_timeout(net, (struct ip_vs_timeout_user *)arg); goto out_unlock; } usvc_compat = (struct ip_vs_service_user *)arg; udest_compat = (struct ip_vs_dest_user *)(usvc_compat + 1); /* We only use the new structs internally, so copy userspace compat * structs to extended internal versions */ ip_vs_copy_usvc_compat(&usvc, usvc_compat); ip_vs_copy_udest_compat(&udest, udest_compat); if (cmd == IP_VS_SO_SET_ZERO) { /* if no service address is set, zero counters in all */ if (!usvc.fwmark && !usvc.addr.ip && !usvc.port) { ret = ip_vs_zero_all(net); goto out_unlock; } } /* Check for valid protocol: TCP or UDP or SCTP, even for fwmark!=0 */ if (usvc.protocol != IPPROTO_TCP && usvc.protocol != IPPROTO_UDP && usvc.protocol != IPPROTO_SCTP) { pr_err("set_ctl: invalid protocol: %d %pI4:%d %s\n", usvc.protocol, &usvc.addr.ip, ntohs(usvc.port), usvc.sched_name); ret = -EFAULT; goto out_unlock; } /* Lookup the exact service by <protocol, addr, port> or fwmark */ if (usvc.fwmark == 0) svc = __ip_vs_service_find(net, usvc.af, usvc.protocol, &usvc.addr, usvc.port); else svc = __ip_vs_svc_fwm_find(net, usvc.af, usvc.fwmark); if (cmd != IP_VS_SO_SET_ADD && (svc == NULL || svc->protocol != usvc.protocol)) { ret = -ESRCH; goto out_unlock; } switch (cmd) { case IP_VS_SO_SET_ADD: if (svc != NULL) ret = -EEXIST; else ret = ip_vs_add_service(net, &usvc, &svc); break; case IP_VS_SO_SET_EDIT: ret = ip_vs_edit_service(svc, &usvc); break; case IP_VS_SO_SET_DEL: ret = ip_vs_del_service(svc); if (!ret) goto out_unlock; break; case IP_VS_SO_SET_ZERO: ret = ip_vs_zero_service(svc); break; case IP_VS_SO_SET_ADDDEST: ret = ip_vs_add_dest(svc, &udest); break; case IP_VS_SO_SET_EDITDEST: ret = ip_vs_edit_dest(svc, &udest); break; case IP_VS_SO_SET_DELDEST: ret = ip_vs_del_dest(svc, &udest); break; default: ret = -EINVAL; } out_unlock: mutex_unlock(&__ip_vs_mutex); out_dec: /* decrease the module use count */ ip_vs_use_count_dec(); return ret; } static void ip_vs_copy_service(struct ip_vs_service_entry *dst, struct ip_vs_service *src) { dst->protocol = src->protocol; dst->addr = src->addr.ip; dst->port = src->port; dst->fwmark = src->fwmark; strlcpy(dst->sched_name, src->scheduler->name, sizeof(dst->sched_name)); dst->flags = src->flags; dst->timeout = src->timeout / HZ; dst->netmask = src->netmask; dst->num_dests = src->num_dests; ip_vs_copy_stats(&dst->stats, &src->stats); } static inline int __ip_vs_get_service_entries(struct net *net, const struct ip_vs_get_services *get, struct ip_vs_get_services __user *uptr) { int idx, count=0; struct ip_vs_service *svc; struct ip_vs_service_entry entry; int ret = 0; for (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { list_for_each_entry(svc, &ip_vs_svc_table[idx], s_list) { /* Only expose IPv4 entries to old interface */ if (svc->af != AF_INET || !net_eq(svc->net, net)) continue; if (count >= get->num_services) goto out; memset(&entry, 0, sizeof(entry)); ip_vs_copy_service(&entry, svc); if (copy_to_user(&uptr->entrytable[count], &entry, sizeof(entry))) { ret = -EFAULT; goto out; } count++; } } for (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { list_for_each_entry(svc, &ip_vs_svc_fwm_table[idx], f_list) { /* Only expose IPv4 entries to old interface */ if (svc->af != AF_INET || !net_eq(svc->net, net)) continue; if (count >= get->num_services) goto out; memset(&entry, 0, sizeof(entry)); ip_vs_copy_service(&entry, svc); if (copy_to_user(&uptr->entrytable[count], &entry, sizeof(entry))) { ret = -EFAULT; goto out; } count++; } } out: return ret; } static inline int __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get, struct ip_vs_get_dests __user *uptr) { struct ip_vs_service *svc; union nf_inet_addr addr = { .ip = get->addr }; int ret = 0; if (get->fwmark) svc = __ip_vs_svc_fwm_find(net, AF_INET, get->fwmark); else svc = __ip_vs_service_find(net, AF_INET, get->protocol, &addr, get->port); if (svc) { int count = 0; struct ip_vs_dest *dest; struct ip_vs_dest_entry entry; list_for_each_entry(dest, &svc->destinations, n_list) { if (count >= get->num_dests) break; entry.addr = dest->addr.ip; entry.port = dest->port; entry.conn_flags = atomic_read(&dest->conn_flags); entry.weight = atomic_read(&dest->weight); entry.u_threshold = dest->u_threshold; entry.l_threshold = dest->l_threshold; entry.activeconns = atomic_read(&dest->activeconns); entry.inactconns = atomic_read(&dest->inactconns); entry.persistconns = atomic_read(&dest->persistconns); ip_vs_copy_stats(&entry.stats, &dest->stats); if (copy_to_user(&uptr->entrytable[count], &entry, sizeof(entry))) { ret = -EFAULT; break; } count++; } } else ret = -ESRCH; return ret; } static inline void __ip_vs_get_timeouts(struct net *net, struct ip_vs_timeout_user *u) { #if defined(CONFIG_IP_VS_PROTO_TCP) || defined(CONFIG_IP_VS_PROTO_UDP) struct ip_vs_proto_data *pd; #endif #ifdef CONFIG_IP_VS_PROTO_TCP pd = ip_vs_proto_data_get(net, IPPROTO_TCP); u->tcp_timeout = pd->timeout_table[IP_VS_TCP_S_ESTABLISHED] / HZ; u->tcp_fin_timeout = pd->timeout_table[IP_VS_TCP_S_FIN_WAIT] / HZ; #endif #ifdef CONFIG_IP_VS_PROTO_UDP pd = ip_vs_proto_data_get(net, IPPROTO_UDP); u->udp_timeout = pd->timeout_table[IP_VS_UDP_S_NORMAL] / HZ; #endif } #define GET_CMDID(cmd) (cmd - IP_VS_BASE_CTL) #define GET_INFO_ARG_LEN (sizeof(struct ip_vs_getinfo)) #define GET_SERVICES_ARG_LEN (sizeof(struct ip_vs_get_services)) #define GET_SERVICE_ARG_LEN (sizeof(struct ip_vs_service_entry)) #define GET_DESTS_ARG_LEN (sizeof(struct ip_vs_get_dests)) #define GET_TIMEOUT_ARG_LEN (sizeof(struct ip_vs_timeout_user)) #define GET_DAEMON_ARG_LEN (sizeof(struct ip_vs_daemon_user) * 2) static const unsigned char get_arglen[GET_CMDID(IP_VS_SO_GET_MAX)+1] = { [GET_CMDID(IP_VS_SO_GET_VERSION)] = 64, [GET_CMDID(IP_VS_SO_GET_INFO)] = GET_INFO_ARG_LEN, [GET_CMDID(IP_VS_SO_GET_SERVICES)] = GET_SERVICES_ARG_LEN, [GET_CMDID(IP_VS_SO_GET_SERVICE)] = GET_SERVICE_ARG_LEN, [GET_CMDID(IP_VS_SO_GET_DESTS)] = GET_DESTS_ARG_LEN, [GET_CMDID(IP_VS_SO_GET_TIMEOUT)] = GET_TIMEOUT_ARG_LEN, [GET_CMDID(IP_VS_SO_GET_DAEMON)] = GET_DAEMON_ARG_LEN, }; static int do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) { unsigned char arg[128]; int ret = 0; unsigned int copylen; struct net *net = sock_net(sk); struct netns_ipvs *ipvs = net_ipvs(net); BUG_ON(!net); if (!capable(CAP_NET_ADMIN)) return -EPERM; if (cmd < IP_VS_BASE_CTL || cmd > IP_VS_SO_GET_MAX) return -EINVAL; if (*len < get_arglen[GET_CMDID(cmd)]) { pr_err("get_ctl: len %u < %u\n", *len, get_arglen[GET_CMDID(cmd)]); return -EINVAL; } copylen = get_arglen[GET_CMDID(cmd)]; if (copylen > 128) return -EINVAL; if (copy_from_user(arg, user, copylen) != 0) return -EFAULT; /* * Handle daemons first since it has its own locking */ if (cmd == IP_VS_SO_GET_DAEMON) { struct ip_vs_daemon_user d[2]; memset(&d, 0, sizeof(d)); if (mutex_lock_interruptible(&ipvs->sync_mutex)) return -ERESTARTSYS; if (ipvs->sync_state & IP_VS_STATE_MASTER) { d[0].state = IP_VS_STATE_MASTER; strlcpy(d[0].mcast_ifn, ipvs->master_mcast_ifn, sizeof(d[0].mcast_ifn)); d[0].syncid = ipvs->master_syncid; } if (ipvs->sync_state & IP_VS_STATE_BACKUP) { d[1].state = IP_VS_STATE_BACKUP; strlcpy(d[1].mcast_ifn, ipvs->backup_mcast_ifn, sizeof(d[1].mcast_ifn)); d[1].syncid = ipvs->backup_syncid; } if (copy_to_user(user, &d, sizeof(d)) != 0) ret = -EFAULT; mutex_unlock(&ipvs->sync_mutex); return ret; } if (mutex_lock_interruptible(&__ip_vs_mutex)) return -ERESTARTSYS; switch (cmd) { case IP_VS_SO_GET_VERSION: { char buf[64]; sprintf(buf, "IP Virtual Server version %d.%d.%d (size=%d)", NVERSION(IP_VS_VERSION_CODE), ip_vs_conn_tab_size); if (copy_to_user(user, buf, strlen(buf)+1) != 0) { ret = -EFAULT; goto out; } *len = strlen(buf)+1; } break; case IP_VS_SO_GET_INFO: { struct ip_vs_getinfo info; info.version = IP_VS_VERSION_CODE; info.size = ip_vs_conn_tab_size; info.num_services = ipvs->num_services; if (copy_to_user(user, &info, sizeof(info)) != 0) ret = -EFAULT; } break; case IP_VS_SO_GET_SERVICES: { struct ip_vs_get_services *get; int size; get = (struct ip_vs_get_services *)arg; size = sizeof(*get) + sizeof(struct ip_vs_service_entry) * get->num_services; if (*len != size) { pr_err("length: %u != %u\n", *len, size); ret = -EINVAL; goto out; } ret = __ip_vs_get_service_entries(net, get, user); } break; case IP_VS_SO_GET_SERVICE: { struct ip_vs_service_entry *entry; struct ip_vs_service *svc; union nf_inet_addr addr; entry = (struct ip_vs_service_entry *)arg; addr.ip = entry->addr; if (entry->fwmark) svc = __ip_vs_svc_fwm_find(net, AF_INET, entry->fwmark); else svc = __ip_vs_service_find(net, AF_INET, entry->protocol, &addr, entry->port); if (svc) { ip_vs_copy_service(entry, svc); if (copy_to_user(user, entry, sizeof(*entry)) != 0) ret = -EFAULT; } else ret = -ESRCH; } break; case IP_VS_SO_GET_DESTS: { struct ip_vs_get_dests *get; int size; get = (struct ip_vs_get_dests *)arg; size = sizeof(*get) + sizeof(struct ip_vs_dest_entry) * get->num_dests; if (*len != size) { pr_err("length: %u != %u\n", *len, size); ret = -EINVAL; goto out; } ret = __ip_vs_get_dest_entries(net, get, user); } break; case IP_VS_SO_GET_TIMEOUT: { struct ip_vs_timeout_user t; __ip_vs_get_timeouts(net, &t); if (copy_to_user(user, &t, sizeof(t)) != 0) ret = -EFAULT; } break; default: ret = -EINVAL; } out: mutex_unlock(&__ip_vs_mutex); return ret; } static struct nf_sockopt_ops ip_vs_sockopts = { .pf = PF_INET, .set_optmin = IP_VS_BASE_CTL, .set_optmax = IP_VS_SO_SET_MAX+1, .set = do_ip_vs_set_ctl, .get_optmin = IP_VS_BASE_CTL, .get_optmax = IP_VS_SO_GET_MAX+1, .get = do_ip_vs_get_ctl, .owner = THIS_MODULE, }; /* * Generic Netlink interface */ /* IPVS genetlink family */ static struct genl_family ip_vs_genl_family = { .id = GENL_ID_GENERATE, .hdrsize = 0, .name = IPVS_GENL_NAME, .version = IPVS_GENL_VERSION, .maxattr = IPVS_CMD_MAX, .netnsok = true, /* Make ipvsadm to work on netns */ }; /* Policy used for first-level command attributes */ static const struct nla_policy ip_vs_cmd_policy[IPVS_CMD_ATTR_MAX + 1] = { [IPVS_CMD_ATTR_SERVICE] = { .type = NLA_NESTED }, [IPVS_CMD_ATTR_DEST] = { .type = NLA_NESTED }, [IPVS_CMD_ATTR_DAEMON] = { .type = NLA_NESTED }, [IPVS_CMD_ATTR_TIMEOUT_TCP] = { .type = NLA_U32 }, [IPVS_CMD_ATTR_TIMEOUT_TCP_FIN] = { .type = NLA_U32 }, [IPVS_CMD_ATTR_TIMEOUT_UDP] = { .type = NLA_U32 }, }; /* Policy used for attributes in nested attribute IPVS_CMD_ATTR_DAEMON */ static const struct nla_policy ip_vs_daemon_policy[IPVS_DAEMON_ATTR_MAX + 1] = { [IPVS_DAEMON_ATTR_STATE] = { .type = NLA_U32 }, [IPVS_DAEMON_ATTR_MCAST_IFN] = { .type = NLA_NUL_STRING, .len = IP_VS_IFNAME_MAXLEN }, [IPVS_DAEMON_ATTR_SYNC_ID] = { .type = NLA_U32 }, }; /* Policy used for attributes in nested attribute IPVS_CMD_ATTR_SERVICE */ static const struct nla_policy ip_vs_svc_policy[IPVS_SVC_ATTR_MAX + 1] = { [IPVS_SVC_ATTR_AF] = { .type = NLA_U16 }, [IPVS_SVC_ATTR_PROTOCOL] = { .type = NLA_U16 }, [IPVS_SVC_ATTR_ADDR] = { .type = NLA_BINARY, .len = sizeof(union nf_inet_addr) }, [IPVS_SVC_ATTR_PORT] = { .type = NLA_U16 }, [IPVS_SVC_ATTR_FWMARK] = { .type = NLA_U32 }, [IPVS_SVC_ATTR_SCHED_NAME] = { .type = NLA_NUL_STRING, .len = IP_VS_SCHEDNAME_MAXLEN }, [IPVS_SVC_ATTR_PE_NAME] = { .type = NLA_NUL_STRING, .len = IP_VS_PENAME_MAXLEN }, [IPVS_SVC_ATTR_FLAGS] = { .type = NLA_BINARY, .len = sizeof(struct ip_vs_flags) }, [IPVS_SVC_ATTR_TIMEOUT] = { .type = NLA_U32 }, [IPVS_SVC_ATTR_NETMASK] = { .type = NLA_U32 }, [IPVS_SVC_ATTR_STATS] = { .type = NLA_NESTED }, }; /* Policy used for attributes in nested attribute IPVS_CMD_ATTR_DEST */ static const struct nla_policy ip_vs_dest_policy[IPVS_DEST_ATTR_MAX + 1] = { [IPVS_DEST_ATTR_ADDR] = { .type = NLA_BINARY, .len = sizeof(union nf_inet_addr) }, [IPVS_DEST_ATTR_PORT] = { .type = NLA_U16 }, [IPVS_DEST_ATTR_FWD_METHOD] = { .type = NLA_U32 }, [IPVS_DEST_ATTR_WEIGHT] = { .type = NLA_U32 }, [IPVS_DEST_ATTR_U_THRESH] = { .type = NLA_U32 }, [IPVS_DEST_ATTR_L_THRESH] = { .type = NLA_U32 }, [IPVS_DEST_ATTR_ACTIVE_CONNS] = { .type = NLA_U32 }, [IPVS_DEST_ATTR_INACT_CONNS] = { .type = NLA_U32 }, [IPVS_DEST_ATTR_PERSIST_CONNS] = { .type = NLA_U32 }, [IPVS_DEST_ATTR_STATS] = { .type = NLA_NESTED }, }; static int ip_vs_genl_fill_stats(struct sk_buff *skb, int container_type, struct ip_vs_stats *stats) { struct ip_vs_stats_user ustats; struct nlattr *nl_stats = nla_nest_start(skb, container_type); if (!nl_stats) return -EMSGSIZE; ip_vs_copy_stats(&ustats, stats); NLA_PUT_U32(skb, IPVS_STATS_ATTR_CONNS, ustats.conns); NLA_PUT_U32(skb, IPVS_STATS_ATTR_INPKTS, ustats.inpkts); NLA_PUT_U32(skb, IPVS_STATS_ATTR_OUTPKTS, ustats.outpkts); NLA_PUT_U64(skb, IPVS_STATS_ATTR_INBYTES, ustats.inbytes); NLA_PUT_U64(skb, IPVS_STATS_ATTR_OUTBYTES, ustats.outbytes); NLA_PUT_U32(skb, IPVS_STATS_ATTR_CPS, ustats.cps); NLA_PUT_U32(skb, IPVS_STATS_ATTR_INPPS, ustats.inpps); NLA_PUT_U32(skb, IPVS_STATS_ATTR_OUTPPS, ustats.outpps); NLA_PUT_U32(skb, IPVS_STATS_ATTR_INBPS, ustats.inbps); NLA_PUT_U32(skb, IPVS_STATS_ATTR_OUTBPS, ustats.outbps); nla_nest_end(skb, nl_stats); return 0; nla_put_failure: nla_nest_cancel(skb, nl_stats); return -EMSGSIZE; } static int ip_vs_genl_fill_service(struct sk_buff *skb, struct ip_vs_service *svc) { struct nlattr *nl_service; struct ip_vs_flags flags = { .flags = svc->flags, .mask = ~0 }; nl_service = nla_nest_start(skb, IPVS_CMD_ATTR_SERVICE); if (!nl_service) return -EMSGSIZE; NLA_PUT_U16(skb, IPVS_SVC_ATTR_AF, svc->af); if (svc->fwmark) { NLA_PUT_U32(skb, IPVS_SVC_ATTR_FWMARK, svc->fwmark); } else { NLA_PUT_U16(skb, IPVS_SVC_ATTR_PROTOCOL, svc->protocol); NLA_PUT(skb, IPVS_SVC_ATTR_ADDR, sizeof(svc->addr), &svc->addr); NLA_PUT_U16(skb, IPVS_SVC_ATTR_PORT, svc->port); } NLA_PUT_STRING(skb, IPVS_SVC_ATTR_SCHED_NAME, svc->scheduler->name); if (svc->pe) NLA_PUT_STRING(skb, IPVS_SVC_ATTR_PE_NAME, svc->pe->name); NLA_PUT(skb, IPVS_SVC_ATTR_FLAGS, sizeof(flags), &flags); NLA_PUT_U32(skb, IPVS_SVC_ATTR_TIMEOUT, svc->timeout / HZ); NLA_PUT_U32(skb, IPVS_SVC_ATTR_NETMASK, svc->netmask); if (ip_vs_genl_fill_stats(skb, IPVS_SVC_ATTR_STATS, &svc->stats)) goto nla_put_failure; nla_nest_end(skb, nl_service); return 0; nla_put_failure: nla_nest_cancel(skb, nl_service); return -EMSGSIZE; } static int ip_vs_genl_dump_service(struct sk_buff *skb, struct ip_vs_service *svc, struct netlink_callback *cb) { void *hdr; hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, &ip_vs_genl_family, NLM_F_MULTI, IPVS_CMD_NEW_SERVICE); if (!hdr) return -EMSGSIZE; if (ip_vs_genl_fill_service(skb, svc) < 0) goto nla_put_failure; return genlmsg_end(skb, hdr); nla_put_failure: genlmsg_cancel(skb, hdr); return -EMSGSIZE; } static int ip_vs_genl_dump_services(struct sk_buff *skb, struct netlink_callback *cb) { int idx = 0, i; int start = cb->args[0]; struct ip_vs_service *svc; struct net *net = skb_sknet(skb); mutex_lock(&__ip_vs_mutex); for (i = 0; i < IP_VS_SVC_TAB_SIZE; i++) { list_for_each_entry(svc, &ip_vs_svc_table[i], s_list) { if (++idx <= start || !net_eq(svc->net, net)) continue; if (ip_vs_genl_dump_service(skb, svc, cb) < 0) { idx--; goto nla_put_failure; } } } for (i = 0; i < IP_VS_SVC_TAB_SIZE; i++) { list_for_each_entry(svc, &ip_vs_svc_fwm_table[i], f_list) { if (++idx <= start || !net_eq(svc->net, net)) continue; if (ip_vs_genl_dump_service(skb, svc, cb) < 0) { idx--; goto nla_put_failure; } } } nla_put_failure: mutex_unlock(&__ip_vs_mutex); cb->args[0] = idx; return skb->len; } static int ip_vs_genl_parse_service(struct net *net, struct ip_vs_service_user_kern *usvc, struct nlattr *nla, int full_entry, struct ip_vs_service **ret_svc) { struct nlattr *attrs[IPVS_SVC_ATTR_MAX + 1]; struct nlattr *nla_af, *nla_port, *nla_fwmark, *nla_protocol, *nla_addr; struct ip_vs_service *svc; /* Parse mandatory identifying service fields first */ if (nla == NULL || nla_parse_nested(attrs, IPVS_SVC_ATTR_MAX, nla, ip_vs_svc_policy)) return -EINVAL; nla_af = attrs[IPVS_SVC_ATTR_AF]; nla_protocol = attrs[IPVS_SVC_ATTR_PROTOCOL]; nla_addr = attrs[IPVS_SVC_ATTR_ADDR]; nla_port = attrs[IPVS_SVC_ATTR_PORT]; nla_fwmark = attrs[IPVS_SVC_ATTR_FWMARK]; if (!(nla_af && (nla_fwmark || (nla_port && nla_protocol && nla_addr)))) return -EINVAL; memset(usvc, 0, sizeof(*usvc)); usvc->af = nla_get_u16(nla_af); #ifdef CONFIG_IP_VS_IPV6 if (usvc->af != AF_INET && usvc->af != AF_INET6) #else if (usvc->af != AF_INET) #endif return -EAFNOSUPPORT; if (nla_fwmark) { usvc->protocol = IPPROTO_TCP; usvc->fwmark = nla_get_u32(nla_fwmark); } else { usvc->protocol = nla_get_u16(nla_protocol); nla_memcpy(&usvc->addr, nla_addr, sizeof(usvc->addr)); usvc->port = nla_get_u16(nla_port); usvc->fwmark = 0; } if (usvc->fwmark) svc = __ip_vs_svc_fwm_find(net, usvc->af, usvc->fwmark); else svc = __ip_vs_service_find(net, usvc->af, usvc->protocol, &usvc->addr, usvc->port); *ret_svc = svc; /* If a full entry was requested, check for the additional fields */ if (full_entry) { struct nlattr *nla_sched, *nla_flags, *nla_pe, *nla_timeout, *nla_netmask; struct ip_vs_flags flags; nla_sched = attrs[IPVS_SVC_ATTR_SCHED_NAME]; nla_pe = attrs[IPVS_SVC_ATTR_PE_NAME]; nla_flags = attrs[IPVS_SVC_ATTR_FLAGS]; nla_timeout = attrs[IPVS_SVC_ATTR_TIMEOUT]; nla_netmask = attrs[IPVS_SVC_ATTR_NETMASK]; if (!(nla_sched && nla_flags && nla_timeout && nla_netmask)) return -EINVAL; nla_memcpy(&flags, nla_flags, sizeof(flags)); /* prefill flags from service if it already exists */ if (svc) usvc->flags = svc->flags; /* set new flags from userland */ usvc->flags = (usvc->flags & ~flags.mask) | (flags.flags & flags.mask); usvc->sched_name = nla_data(nla_sched); usvc->pe_name = nla_pe ? nla_data(nla_pe) : NULL; usvc->timeout = nla_get_u32(nla_timeout); usvc->netmask = nla_get_u32(nla_netmask); } return 0; } static struct ip_vs_service *ip_vs_genl_find_service(struct net *net, struct nlattr *nla) { struct ip_vs_service_user_kern usvc; struct ip_vs_service *svc; int ret; ret = ip_vs_genl_parse_service(net, &usvc, nla, 0, &svc); return ret ? ERR_PTR(ret) : svc; } static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest) { struct nlattr *nl_dest; nl_dest = nla_nest_start(skb, IPVS_CMD_ATTR_DEST); if (!nl_dest) return -EMSGSIZE; NLA_PUT(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr); NLA_PUT_U16(skb, IPVS_DEST_ATTR_PORT, dest->port); NLA_PUT_U32(skb, IPVS_DEST_ATTR_FWD_METHOD, atomic_read(&dest->conn_flags) & IP_VS_CONN_F_FWD_MASK); NLA_PUT_U32(skb, IPVS_DEST_ATTR_WEIGHT, atomic_read(&dest->weight)); NLA_PUT_U32(skb, IPVS_DEST_ATTR_U_THRESH, dest->u_threshold); NLA_PUT_U32(skb, IPVS_DEST_ATTR_L_THRESH, dest->l_threshold); NLA_PUT_U32(skb, IPVS_DEST_ATTR_ACTIVE_CONNS, atomic_read(&dest->activeconns)); NLA_PUT_U32(skb, IPVS_DEST_ATTR_INACT_CONNS, atomic_read(&dest->inactconns)); NLA_PUT_U32(skb, IPVS_DEST_ATTR_PERSIST_CONNS, atomic_read(&dest->persistconns)); if (ip_vs_genl_fill_stats(skb, IPVS_DEST_ATTR_STATS, &dest->stats)) goto nla_put_failure; nla_nest_end(skb, nl_dest); return 0; nla_put_failure: nla_nest_cancel(skb, nl_dest); return -EMSGSIZE; } static int ip_vs_genl_dump_dest(struct sk_buff *skb, struct ip_vs_dest *dest, struct netlink_callback *cb) { void *hdr; hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, &ip_vs_genl_family, NLM_F_MULTI, IPVS_CMD_NEW_DEST); if (!hdr) return -EMSGSIZE; if (ip_vs_genl_fill_dest(skb, dest) < 0) goto nla_put_failure; return genlmsg_end(skb, hdr); nla_put_failure: genlmsg_cancel(skb, hdr); return -EMSGSIZE; } static int ip_vs_genl_dump_dests(struct sk_buff *skb, struct netlink_callback *cb) { int idx = 0; int start = cb->args[0]; struct ip_vs_service *svc; struct ip_vs_dest *dest; struct nlattr *attrs[IPVS_CMD_ATTR_MAX + 1]; struct net *net = skb_sknet(skb); mutex_lock(&__ip_vs_mutex); /* Try to find the service for which to dump destinations */ if (nlmsg_parse(cb->nlh, GENL_HDRLEN, attrs, IPVS_CMD_ATTR_MAX, ip_vs_cmd_policy)) goto out_err; svc = ip_vs_genl_find_service(net, attrs[IPVS_CMD_ATTR_SERVICE]); if (IS_ERR(svc) || svc == NULL) goto out_err; /* Dump the destinations */ list_for_each_entry(dest, &svc->destinations, n_list) { if (++idx <= start) continue; if (ip_vs_genl_dump_dest(skb, dest, cb) < 0) { idx--; goto nla_put_failure; } } nla_put_failure: cb->args[0] = idx; out_err: mutex_unlock(&__ip_vs_mutex); return skb->len; } static int ip_vs_genl_parse_dest(struct ip_vs_dest_user_kern *udest, struct nlattr *nla, int full_entry) { struct nlattr *attrs[IPVS_DEST_ATTR_MAX + 1]; struct nlattr *nla_addr, *nla_port; /* Parse mandatory identifying destination fields first */ if (nla == NULL || nla_parse_nested(attrs, IPVS_DEST_ATTR_MAX, nla, ip_vs_dest_policy)) return -EINVAL; nla_addr = attrs[IPVS_DEST_ATTR_ADDR]; nla_port = attrs[IPVS_DEST_ATTR_PORT]; if (!(nla_addr && nla_port)) return -EINVAL; memset(udest, 0, sizeof(*udest)); nla_memcpy(&udest->addr, nla_addr, sizeof(udest->addr)); udest->port = nla_get_u16(nla_port); /* If a full entry was requested, check for the additional fields */ if (full_entry) { struct nlattr *nla_fwd, *nla_weight, *nla_u_thresh, *nla_l_thresh; nla_fwd = attrs[IPVS_DEST_ATTR_FWD_METHOD]; nla_weight = attrs[IPVS_DEST_ATTR_WEIGHT]; nla_u_thresh = attrs[IPVS_DEST_ATTR_U_THRESH]; nla_l_thresh = attrs[IPVS_DEST_ATTR_L_THRESH]; if (!(nla_fwd && nla_weight && nla_u_thresh && nla_l_thresh)) return -EINVAL; udest->conn_flags = nla_get_u32(nla_fwd) & IP_VS_CONN_F_FWD_MASK; udest->weight = nla_get_u32(nla_weight); udest->u_threshold = nla_get_u32(nla_u_thresh); udest->l_threshold = nla_get_u32(nla_l_thresh); } return 0; } static int ip_vs_genl_fill_daemon(struct sk_buff *skb, __be32 state, const char *mcast_ifn, __be32 syncid) { struct nlattr *nl_daemon; nl_daemon = nla_nest_start(skb, IPVS_CMD_ATTR_DAEMON); if (!nl_daemon) return -EMSGSIZE; NLA_PUT_U32(skb, IPVS_DAEMON_ATTR_STATE, state); NLA_PUT_STRING(skb, IPVS_DAEMON_ATTR_MCAST_IFN, mcast_ifn); NLA_PUT_U32(skb, IPVS_DAEMON_ATTR_SYNC_ID, syncid); nla_nest_end(skb, nl_daemon); return 0; nla_put_failure: nla_nest_cancel(skb, nl_daemon); return -EMSGSIZE; } static int ip_vs_genl_dump_daemon(struct sk_buff *skb, __be32 state, const char *mcast_ifn, __be32 syncid, struct netlink_callback *cb) { void *hdr; hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, &ip_vs_genl_family, NLM_F_MULTI, IPVS_CMD_NEW_DAEMON); if (!hdr) return -EMSGSIZE; if (ip_vs_genl_fill_daemon(skb, state, mcast_ifn, syncid)) goto nla_put_failure; return genlmsg_end(skb, hdr); nla_put_failure: genlmsg_cancel(skb, hdr); return -EMSGSIZE; } static int ip_vs_genl_dump_daemons(struct sk_buff *skb, struct netlink_callback *cb) { struct net *net = skb_sknet(skb); struct netns_ipvs *ipvs = net_ipvs(net); mutex_lock(&ipvs->sync_mutex); if ((ipvs->sync_state & IP_VS_STATE_MASTER) && !cb->args[0]) { if (ip_vs_genl_dump_daemon(skb, IP_VS_STATE_MASTER, ipvs->master_mcast_ifn, ipvs->master_syncid, cb) < 0) goto nla_put_failure; cb->args[0] = 1; } if ((ipvs->sync_state & IP_VS_STATE_BACKUP) && !cb->args[1]) { if (ip_vs_genl_dump_daemon(skb, IP_VS_STATE_BACKUP, ipvs->backup_mcast_ifn, ipvs->backup_syncid, cb) < 0) goto nla_put_failure; cb->args[1] = 1; } nla_put_failure: mutex_unlock(&ipvs->sync_mutex); return skb->len; } static int ip_vs_genl_new_daemon(struct net *net, struct nlattr **attrs) { if (!(attrs[IPVS_DAEMON_ATTR_STATE] && attrs[IPVS_DAEMON_ATTR_MCAST_IFN] && attrs[IPVS_DAEMON_ATTR_SYNC_ID])) return -EINVAL; return start_sync_thread(net, nla_get_u32(attrs[IPVS_DAEMON_ATTR_STATE]), nla_data(attrs[IPVS_DAEMON_ATTR_MCAST_IFN]), nla_get_u32(attrs[IPVS_DAEMON_ATTR_SYNC_ID])); } static int ip_vs_genl_del_daemon(struct net *net, struct nlattr **attrs) { if (!attrs[IPVS_DAEMON_ATTR_STATE]) return -EINVAL; return stop_sync_thread(net, nla_get_u32(attrs[IPVS_DAEMON_ATTR_STATE])); } static int ip_vs_genl_set_config(struct net *net, struct nlattr **attrs) { struct ip_vs_timeout_user t; __ip_vs_get_timeouts(net, &t); if (attrs[IPVS_CMD_ATTR_TIMEOUT_TCP]) t.tcp_timeout = nla_get_u32(attrs[IPVS_CMD_ATTR_TIMEOUT_TCP]); if (attrs[IPVS_CMD_ATTR_TIMEOUT_TCP_FIN]) t.tcp_fin_timeout = nla_get_u32(attrs[IPVS_CMD_ATTR_TIMEOUT_TCP_FIN]); if (attrs[IPVS_CMD_ATTR_TIMEOUT_UDP]) t.udp_timeout = nla_get_u32(attrs[IPVS_CMD_ATTR_TIMEOUT_UDP]); return ip_vs_set_timeout(net, &t); } static int ip_vs_genl_set_daemon(struct sk_buff *skb, struct genl_info *info) { int ret = 0, cmd; struct net *net; struct netns_ipvs *ipvs; net = skb_sknet(skb); ipvs = net_ipvs(net); cmd = info->genlhdr->cmd; if (cmd == IPVS_CMD_NEW_DAEMON || cmd == IPVS_CMD_DEL_DAEMON) { struct nlattr *daemon_attrs[IPVS_DAEMON_ATTR_MAX + 1]; mutex_lock(&ipvs->sync_mutex); if (!info->attrs[IPVS_CMD_ATTR_DAEMON] || nla_parse_nested(daemon_attrs, IPVS_DAEMON_ATTR_MAX, info->attrs[IPVS_CMD_ATTR_DAEMON], ip_vs_daemon_policy)) { ret = -EINVAL; goto out; } if (cmd == IPVS_CMD_NEW_DAEMON) ret = ip_vs_genl_new_daemon(net, daemon_attrs); else ret = ip_vs_genl_del_daemon(net, daemon_attrs); out: mutex_unlock(&ipvs->sync_mutex); } return ret; } static int ip_vs_genl_set_cmd(struct sk_buff *skb, struct genl_info *info) { struct ip_vs_service *svc = NULL; struct ip_vs_service_user_kern usvc; struct ip_vs_dest_user_kern udest; int ret = 0, cmd; int need_full_svc = 0, need_full_dest = 0; struct net *net; net = skb_sknet(skb); cmd = info->genlhdr->cmd; mutex_lock(&__ip_vs_mutex); if (cmd == IPVS_CMD_FLUSH) { ret = ip_vs_flush(net); goto out; } else if (cmd == IPVS_CMD_SET_CONFIG) { ret = ip_vs_genl_set_config(net, info->attrs); goto out; } else if (cmd == IPVS_CMD_ZERO && !info->attrs[IPVS_CMD_ATTR_SERVICE]) { ret = ip_vs_zero_all(net); goto out; } /* All following commands require a service argument, so check if we * received a valid one. We need a full service specification when * adding / editing a service. Only identifying members otherwise. */ if (cmd == IPVS_CMD_NEW_SERVICE || cmd == IPVS_CMD_SET_SERVICE) need_full_svc = 1; ret = ip_vs_genl_parse_service(net, &usvc, info->attrs[IPVS_CMD_ATTR_SERVICE], need_full_svc, &svc); if (ret) goto out; /* Unless we're adding a new service, the service must already exist */ if ((cmd != IPVS_CMD_NEW_SERVICE) && (svc == NULL)) { ret = -ESRCH; goto out; } /* Destination commands require a valid destination argument. For * adding / editing a destination, we need a full destination * specification. */ if (cmd == IPVS_CMD_NEW_DEST || cmd == IPVS_CMD_SET_DEST || cmd == IPVS_CMD_DEL_DEST) { if (cmd != IPVS_CMD_DEL_DEST) need_full_dest = 1; ret = ip_vs_genl_parse_dest(&udest, info->attrs[IPVS_CMD_ATTR_DEST], need_full_dest); if (ret) goto out; } switch (cmd) { case IPVS_CMD_NEW_SERVICE: if (svc == NULL) ret = ip_vs_add_service(net, &usvc, &svc); else ret = -EEXIST; break; case IPVS_CMD_SET_SERVICE: ret = ip_vs_edit_service(svc, &usvc); break; case IPVS_CMD_DEL_SERVICE: ret = ip_vs_del_service(svc); /* do not use svc, it can be freed */ break; case IPVS_CMD_NEW_DEST: ret = ip_vs_add_dest(svc, &udest); break; case IPVS_CMD_SET_DEST: ret = ip_vs_edit_dest(svc, &udest); break; case IPVS_CMD_DEL_DEST: ret = ip_vs_del_dest(svc, &udest); break; case IPVS_CMD_ZERO: ret = ip_vs_zero_service(svc); break; default: ret = -EINVAL; } out: mutex_unlock(&__ip_vs_mutex); return ret; } static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info) { struct sk_buff *msg; void *reply; int ret, cmd, reply_cmd; struct net *net; net = skb_sknet(skb); cmd = info->genlhdr->cmd; if (cmd == IPVS_CMD_GET_SERVICE) reply_cmd = IPVS_CMD_NEW_SERVICE; else if (cmd == IPVS_CMD_GET_INFO) reply_cmd = IPVS_CMD_SET_INFO; else if (cmd == IPVS_CMD_GET_CONFIG) reply_cmd = IPVS_CMD_SET_CONFIG; else { pr_err("unknown Generic Netlink command\n"); return -EINVAL; } msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!msg) return -ENOMEM; mutex_lock(&__ip_vs_mutex); reply = genlmsg_put_reply(msg, info, &ip_vs_genl_family, 0, reply_cmd); if (reply == NULL) goto nla_put_failure; switch (cmd) { case IPVS_CMD_GET_SERVICE: { struct ip_vs_service *svc; svc = ip_vs_genl_find_service(net, info->attrs[IPVS_CMD_ATTR_SERVICE]); if (IS_ERR(svc)) { ret = PTR_ERR(svc); goto out_err; } else if (svc) { ret = ip_vs_genl_fill_service(msg, svc); if (ret) goto nla_put_failure; } else { ret = -ESRCH; goto out_err; } break; } case IPVS_CMD_GET_CONFIG: { struct ip_vs_timeout_user t; __ip_vs_get_timeouts(net, &t); #ifdef CONFIG_IP_VS_PROTO_TCP NLA_PUT_U32(msg, IPVS_CMD_ATTR_TIMEOUT_TCP, t.tcp_timeout); NLA_PUT_U32(msg, IPVS_CMD_ATTR_TIMEOUT_TCP_FIN, t.tcp_fin_timeout); #endif #ifdef CONFIG_IP_VS_PROTO_UDP NLA_PUT_U32(msg, IPVS_CMD_ATTR_TIMEOUT_UDP, t.udp_timeout); #endif break; } case IPVS_CMD_GET_INFO: NLA_PUT_U32(msg, IPVS_INFO_ATTR_VERSION, IP_VS_VERSION_CODE); NLA_PUT_U32(msg, IPVS_INFO_ATTR_CONN_TAB_SIZE, ip_vs_conn_tab_size); break; } genlmsg_end(msg, reply); ret = genlmsg_reply(msg, info); goto out; nla_put_failure: pr_err("not enough space in Netlink message\n"); ret = -EMSGSIZE; out_err: nlmsg_free(msg); out: mutex_unlock(&__ip_vs_mutex); return ret; } static struct genl_ops ip_vs_genl_ops[] __read_mostly = { { .cmd = IPVS_CMD_NEW_SERVICE, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .doit = ip_vs_genl_set_cmd, }, { .cmd = IPVS_CMD_SET_SERVICE, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .doit = ip_vs_genl_set_cmd, }, { .cmd = IPVS_CMD_DEL_SERVICE, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .doit = ip_vs_genl_set_cmd, }, { .cmd = IPVS_CMD_GET_SERVICE, .flags = GENL_ADMIN_PERM, .doit = ip_vs_genl_get_cmd, .dumpit = ip_vs_genl_dump_services, .policy = ip_vs_cmd_policy, }, { .cmd = IPVS_CMD_NEW_DEST, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .doit = ip_vs_genl_set_cmd, }, { .cmd = IPVS_CMD_SET_DEST, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .doit = ip_vs_genl_set_cmd, }, { .cmd = IPVS_CMD_DEL_DEST, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .doit = ip_vs_genl_set_cmd, }, { .cmd = IPVS_CMD_GET_DEST, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .dumpit = ip_vs_genl_dump_dests, }, { .cmd = IPVS_CMD_NEW_DAEMON, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .doit = ip_vs_genl_set_daemon, }, { .cmd = IPVS_CMD_DEL_DAEMON, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .doit = ip_vs_genl_set_daemon, }, { .cmd = IPVS_CMD_GET_DAEMON, .flags = GENL_ADMIN_PERM, .dumpit = ip_vs_genl_dump_daemons, }, { .cmd = IPVS_CMD_SET_CONFIG, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .doit = ip_vs_genl_set_cmd, }, { .cmd = IPVS_CMD_GET_CONFIG, .flags = GENL_ADMIN_PERM, .doit = ip_vs_genl_get_cmd, }, { .cmd = IPVS_CMD_GET_INFO, .flags = GENL_ADMIN_PERM, .doit = ip_vs_genl_get_cmd, }, { .cmd = IPVS_CMD_ZERO, .flags = GENL_ADMIN_PERM, .policy = ip_vs_cmd_policy, .doit = ip_vs_genl_set_cmd, }, { .cmd = IPVS_CMD_FLUSH, .flags = GENL_ADMIN_PERM, .doit = ip_vs_genl_set_cmd, }, }; static int __init ip_vs_genl_register(void) { return genl_register_family_with_ops(&ip_vs_genl_family, ip_vs_genl_ops, ARRAY_SIZE(ip_vs_genl_ops)); } static void ip_vs_genl_unregister(void) { genl_unregister_family(&ip_vs_genl_family); } /* End of Generic Netlink interface definitions */ /* * per netns intit/exit func. */ #ifdef CONFIG_SYSCTL int __net_init ip_vs_control_net_init_sysctl(struct net *net) { int idx; struct netns_ipvs *ipvs = net_ipvs(net); struct ctl_table *tbl; atomic_set(&ipvs->dropentry, 0); spin_lock_init(&ipvs->dropentry_lock); spin_lock_init(&ipvs->droppacket_lock); spin_lock_init(&ipvs->securetcp_lock); if (!net_eq(net, &init_net)) { tbl = kmemdup(vs_vars, sizeof(vs_vars), GFP_KERNEL); if (tbl == NULL) return -ENOMEM; } else tbl = vs_vars; /* Initialize sysctl defaults */ idx = 0; ipvs->sysctl_amemthresh = 1024; tbl[idx++].data = &ipvs->sysctl_amemthresh; ipvs->sysctl_am_droprate = 10; tbl[idx++].data = &ipvs->sysctl_am_droprate; tbl[idx++].data = &ipvs->sysctl_drop_entry; tbl[idx++].data = &ipvs->sysctl_drop_packet; #ifdef CONFIG_IP_VS_NFCT tbl[idx++].data = &ipvs->sysctl_conntrack; #endif tbl[idx++].data = &ipvs->sysctl_secure_tcp; ipvs->sysctl_snat_reroute = 1; tbl[idx++].data = &ipvs->sysctl_snat_reroute; ipvs->sysctl_sync_ver = 1; tbl[idx++].data = &ipvs->sysctl_sync_ver; tbl[idx++].data = &ipvs->sysctl_cache_bypass; tbl[idx++].data = &ipvs->sysctl_expire_nodest_conn; tbl[idx++].data = &ipvs->sysctl_expire_quiescent_template; ipvs->sysctl_sync_threshold[0] = DEFAULT_SYNC_THRESHOLD; ipvs->sysctl_sync_threshold[1] = DEFAULT_SYNC_PERIOD; tbl[idx].data = &ipvs->sysctl_sync_threshold; tbl[idx++].maxlen = sizeof(ipvs->sysctl_sync_threshold); tbl[idx++].data = &ipvs->sysctl_nat_icmp_send; ipvs->sysctl_hdr = register_net_sysctl_table(net, net_vs_ctl_path, tbl); if (ipvs->sysctl_hdr == NULL) { if (!net_eq(net, &init_net)) kfree(tbl); return -ENOMEM; } ip_vs_start_estimator(net, &ipvs->tot_stats); ipvs->sysctl_tbl = tbl; /* Schedule defense work */ INIT_DELAYED_WORK(&ipvs->defense_work, defense_work_handler); schedule_delayed_work(&ipvs->defense_work, DEFENSE_TIMER_PERIOD); return 0; } void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net) { struct netns_ipvs *ipvs = net_ipvs(net); cancel_delayed_work_sync(&ipvs->defense_work); cancel_work_sync(&ipvs->defense_work.work); unregister_net_sysctl_table(ipvs->sysctl_hdr); } #else int __net_init ip_vs_control_net_init_sysctl(struct net *net) { return 0; } void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net) { } #endif static struct notifier_block ip_vs_dst_notifier = { .notifier_call = ip_vs_dst_event, }; int __net_init ip_vs_control_net_init(struct net *net) { int idx; struct netns_ipvs *ipvs = net_ipvs(net); rwlock_init(&ipvs->rs_lock); /* Initialize rs_table */ for (idx = 0; idx < IP_VS_RTAB_SIZE; idx++) INIT_LIST_HEAD(&ipvs->rs_table[idx]); INIT_LIST_HEAD(&ipvs->dest_trash); atomic_set(&ipvs->ftpsvc_counter, 0); atomic_set(&ipvs->nullsvc_counter, 0); /* procfs stats */ ipvs->tot_stats.cpustats = alloc_percpu(struct ip_vs_cpu_stats); if (!ipvs->tot_stats.cpustats) return -ENOMEM; spin_lock_init(&ipvs->tot_stats.lock); proc_net_fops_create(net, "ip_vs", 0, &ip_vs_info_fops); proc_net_fops_create(net, "ip_vs_stats", 0, &ip_vs_stats_fops); proc_net_fops_create(net, "ip_vs_stats_percpu", 0, &ip_vs_stats_percpu_fops); if (ip_vs_control_net_init_sysctl(net)) goto err; return 0; err: free_percpu(ipvs->tot_stats.cpustats); return -ENOMEM; } void __net_exit ip_vs_control_net_cleanup(struct net *net) { struct netns_ipvs *ipvs = net_ipvs(net); ip_vs_trash_cleanup(net); ip_vs_stop_estimator(net, &ipvs->tot_stats); ip_vs_control_net_cleanup_sysctl(net); proc_net_remove(net, "ip_vs_stats_percpu"); proc_net_remove(net, "ip_vs_stats"); proc_net_remove(net, "ip_vs"); free_percpu(ipvs->tot_stats.cpustats); } int __init ip_vs_register_nl_ioctl(void) { int ret; ret = nf_register_sockopt(&ip_vs_sockopts); if (ret) { pr_err("cannot register sockopt.\n"); goto err_sock; } ret = ip_vs_genl_register(); if (ret) { pr_err("cannot register Generic Netlink interface.\n"); goto err_genl; } return 0; err_genl: nf_unregister_sockopt(&ip_vs_sockopts); err_sock: return ret; } void ip_vs_unregister_nl_ioctl(void) { ip_vs_genl_unregister(); nf_unregister_sockopt(&ip_vs_sockopts); } int __init ip_vs_control_init(void) { int idx; int ret; EnterFunction(2); /* Initialize svc_table, ip_vs_svc_fwm_table, rs_table */ for (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { INIT_LIST_HEAD(&ip_vs_svc_table[idx]); INIT_LIST_HEAD(&ip_vs_svc_fwm_table[idx]); } smp_wmb(); /* Do we really need it now ? */ ret = register_netdevice_notifier(&ip_vs_dst_notifier); if (ret < 0) return ret; LeaveFunction(2); return 0; } void ip_vs_control_cleanup(void) { EnterFunction(2); unregister_netdevice_notifier(&ip_vs_dst_notifier); LeaveFunction(2); }
gpl-2.0
CaptainThrowback/kernel_android-tegra-flounder-3.10
drivers/usb/host/fhci-hub.c
3445
9038
/* * Freescale QUICC Engine USB Host Controller Driver * * Copyright (c) Freescale Semicondutor, Inc. 2006. * Shlomi Gridish <gridish@freescale.com> * Jerry Huang <Chang-Ming.Huang@freescale.com> * Copyright (c) Logic Product Development, Inc. 2007 * Peter Barada <peterb@logicpd.com> * Copyright (c) MontaVista Software, Inc. 2008. * Anton Vorontsov <avorontsov@ru.mvista.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. */ #include <linux/kernel.h> #include <linux/types.h> #include <linux/spinlock.h> #include <linux/delay.h> #include <linux/errno.h> #include <linux/io.h> #include <linux/usb.h> #include <linux/usb/hcd.h> #include <linux/gpio.h> #include <asm/qe.h> #include "fhci.h" /* virtual root hub specific descriptor */ static u8 root_hub_des[] = { 0x09, /* blength */ 0x29, /* bDescriptorType;hub-descriptor */ 0x01, /* bNbrPorts */ 0x00, /* wHubCharacteristics */ 0x00, 0x01, /* bPwrOn2pwrGood;2ms */ 0x00, /* bHubContrCurrent;0mA */ 0x00, /* DeviceRemoveable */ 0xff, /* PortPwrCtrlMask */ }; static void fhci_gpio_set_value(struct fhci_hcd *fhci, int gpio_nr, bool on) { int gpio = fhci->gpios[gpio_nr]; bool alow = fhci->alow_gpios[gpio_nr]; if (!gpio_is_valid(gpio)) return; gpio_set_value(gpio, on ^ alow); mdelay(5); } void fhci_config_transceiver(struct fhci_hcd *fhci, enum fhci_port_status status) { fhci_dbg(fhci, "-> %s: %d\n", __func__, status); switch (status) { case FHCI_PORT_POWER_OFF: fhci_gpio_set_value(fhci, GPIO_POWER, false); break; case FHCI_PORT_DISABLED: case FHCI_PORT_WAITING: fhci_gpio_set_value(fhci, GPIO_POWER, true); break; case FHCI_PORT_LOW: fhci_gpio_set_value(fhci, GPIO_SPEED, false); break; case FHCI_PORT_FULL: fhci_gpio_set_value(fhci, GPIO_SPEED, true); break; default: WARN_ON(1); break; } fhci_dbg(fhci, "<- %s: %d\n", __func__, status); } /* disable the USB port by clearing the EN bit in the USBMOD register */ void fhci_port_disable(struct fhci_hcd *fhci) { struct fhci_usb *usb = (struct fhci_usb *)fhci->usb_lld; enum fhci_port_status port_status; fhci_dbg(fhci, "-> %s\n", __func__); fhci_stop_sof_timer(fhci); fhci_flush_all_transmissions(usb); fhci_usb_disable_interrupt((struct fhci_usb *)fhci->usb_lld); port_status = usb->port_status; usb->port_status = FHCI_PORT_DISABLED; /* Enable IDLE since we want to know if something comes along */ usb->saved_msk |= USB_E_IDLE_MASK; out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk); /* check if during the disconnection process attached new device */ if (port_status == FHCI_PORT_WAITING) fhci_device_connected_interrupt(fhci); usb->vroot_hub->port.wPortStatus &= ~USB_PORT_STAT_ENABLE; usb->vroot_hub->port.wPortChange |= USB_PORT_STAT_C_ENABLE; fhci_usb_enable_interrupt((struct fhci_usb *)fhci->usb_lld); fhci_dbg(fhci, "<- %s\n", __func__); } /* enable the USB port by setting the EN bit in the USBMOD register */ void fhci_port_enable(void *lld) { struct fhci_usb *usb = (struct fhci_usb *)lld; struct fhci_hcd *fhci = usb->fhci; fhci_dbg(fhci, "-> %s\n", __func__); fhci_config_transceiver(fhci, usb->port_status); if ((usb->port_status != FHCI_PORT_FULL) && (usb->port_status != FHCI_PORT_LOW)) fhci_start_sof_timer(fhci); usb->vroot_hub->port.wPortStatus |= USB_PORT_STAT_ENABLE; usb->vroot_hub->port.wPortChange |= USB_PORT_STAT_C_ENABLE; fhci_dbg(fhci, "<- %s\n", __func__); } void fhci_io_port_generate_reset(struct fhci_hcd *fhci) { fhci_dbg(fhci, "-> %s\n", __func__); gpio_direction_output(fhci->gpios[GPIO_USBOE], 0); gpio_direction_output(fhci->gpios[GPIO_USBTP], 0); gpio_direction_output(fhci->gpios[GPIO_USBTN], 0); mdelay(5); qe_pin_set_dedicated(fhci->pins[PIN_USBOE]); qe_pin_set_dedicated(fhci->pins[PIN_USBTP]); qe_pin_set_dedicated(fhci->pins[PIN_USBTN]); fhci_dbg(fhci, "<- %s\n", __func__); } /* generate the RESET condition on the bus */ void fhci_port_reset(void *lld) { struct fhci_usb *usb = (struct fhci_usb *)lld; struct fhci_hcd *fhci = usb->fhci; u8 mode; u16 mask; fhci_dbg(fhci, "-> %s\n", __func__); fhci_stop_sof_timer(fhci); /* disable the USB controller */ mode = in_8(&fhci->regs->usb_usmod); out_8(&fhci->regs->usb_usmod, mode & (~USB_MODE_EN)); /* disable idle interrupts */ mask = in_be16(&fhci->regs->usb_usbmr); out_be16(&fhci->regs->usb_usbmr, mask & (~USB_E_IDLE_MASK)); fhci_io_port_generate_reset(fhci); /* enable interrupt on this endpoint */ out_be16(&fhci->regs->usb_usbmr, mask); /* enable the USB controller */ mode = in_8(&fhci->regs->usb_usmod); out_8(&fhci->regs->usb_usmod, mode | USB_MODE_EN); fhci_start_sof_timer(fhci); fhci_dbg(fhci, "<- %s\n", __func__); } int fhci_hub_status_data(struct usb_hcd *hcd, char *buf) { struct fhci_hcd *fhci = hcd_to_fhci(hcd); int ret = 0; unsigned long flags; fhci_dbg(fhci, "-> %s\n", __func__); spin_lock_irqsave(&fhci->lock, flags); if (fhci->vroot_hub->port.wPortChange & (USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_RESET | USB_PORT_STAT_C_OVERCURRENT)) { *buf = 1 << 1; ret = 1; fhci_dbg(fhci, "-- %s\n", __func__); } spin_unlock_irqrestore(&fhci->lock, flags); fhci_dbg(fhci, "<- %s\n", __func__); return ret; } int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength) { struct fhci_hcd *fhci = hcd_to_fhci(hcd); int retval = 0; int len = 0; struct usb_hub_status *hub_status; struct usb_port_status *port_status; unsigned long flags; spin_lock_irqsave(&fhci->lock, flags); fhci_dbg(fhci, "-> %s\n", __func__); switch (typeReq) { case ClearHubFeature: switch (wValue) { case C_HUB_LOCAL_POWER: case C_HUB_OVER_CURRENT: break; default: goto error; } break; case ClearPortFeature: fhci->vroot_hub->feature &= (1 << wValue); switch (wValue) { case USB_PORT_FEAT_ENABLE: fhci->vroot_hub->port.wPortStatus &= ~USB_PORT_STAT_ENABLE; fhci_port_disable(fhci); break; case USB_PORT_FEAT_C_ENABLE: fhci->vroot_hub->port.wPortChange &= ~USB_PORT_STAT_C_ENABLE; break; case USB_PORT_FEAT_SUSPEND: fhci->vroot_hub->port.wPortStatus &= ~USB_PORT_STAT_SUSPEND; fhci_stop_sof_timer(fhci); break; case USB_PORT_FEAT_C_SUSPEND: fhci->vroot_hub->port.wPortChange &= ~USB_PORT_STAT_C_SUSPEND; break; case USB_PORT_FEAT_POWER: fhci->vroot_hub->port.wPortStatus &= ~USB_PORT_STAT_POWER; fhci_config_transceiver(fhci, FHCI_PORT_POWER_OFF); break; case USB_PORT_FEAT_C_CONNECTION: fhci->vroot_hub->port.wPortChange &= ~USB_PORT_STAT_C_CONNECTION; break; case USB_PORT_FEAT_C_OVER_CURRENT: fhci->vroot_hub->port.wPortChange &= ~USB_PORT_STAT_C_OVERCURRENT; break; case USB_PORT_FEAT_C_RESET: fhci->vroot_hub->port.wPortChange &= ~USB_PORT_STAT_C_RESET; break; default: goto error; } break; case GetHubDescriptor: memcpy(buf, root_hub_des, sizeof(root_hub_des)); buf[3] = 0x11; /* per-port power, no ovrcrnt */ len = (buf[0] < wLength) ? buf[0] : wLength; break; case GetHubStatus: hub_status = (struct usb_hub_status *)buf; hub_status->wHubStatus = cpu_to_le16(fhci->vroot_hub->hub.wHubStatus); hub_status->wHubChange = cpu_to_le16(fhci->vroot_hub->hub.wHubChange); len = 4; break; case GetPortStatus: port_status = (struct usb_port_status *)buf; port_status->wPortStatus = cpu_to_le16(fhci->vroot_hub->port.wPortStatus); port_status->wPortChange = cpu_to_le16(fhci->vroot_hub->port.wPortChange); len = 4; break; case SetHubFeature: switch (wValue) { case C_HUB_OVER_CURRENT: case C_HUB_LOCAL_POWER: break; default: goto error; } break; case SetPortFeature: fhci->vroot_hub->feature |= (1 << wValue); switch (wValue) { case USB_PORT_FEAT_ENABLE: fhci->vroot_hub->port.wPortStatus |= USB_PORT_STAT_ENABLE; fhci_port_enable(fhci->usb_lld); break; case USB_PORT_FEAT_SUSPEND: fhci->vroot_hub->port.wPortStatus |= USB_PORT_STAT_SUSPEND; fhci_stop_sof_timer(fhci); break; case USB_PORT_FEAT_RESET: fhci->vroot_hub->port.wPortStatus |= USB_PORT_STAT_RESET; fhci_port_reset(fhci->usb_lld); fhci->vroot_hub->port.wPortStatus |= USB_PORT_STAT_ENABLE; fhci->vroot_hub->port.wPortStatus &= ~USB_PORT_STAT_RESET; break; case USB_PORT_FEAT_POWER: fhci->vroot_hub->port.wPortStatus |= USB_PORT_STAT_POWER; fhci_config_transceiver(fhci, FHCI_PORT_WAITING); break; default: goto error; } break; default: error: retval = -EPIPE; } fhci_dbg(fhci, "<- %s\n", __func__); spin_unlock_irqrestore(&fhci->lock, flags); return retval; }
gpl-2.0
Sparkey67/android_kernel_lge_g3-1
drivers/video/msm/mhl/mhl_i2c_utils.c
3445
2634
/* Copyright (c) 2012, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only 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. * */ #include <linux/i2c.h> #include <linux/mhl_8334.h> #include "mhl_i2c_utils.h" uint8_t slave_addrs[MAX_PAGES] = { DEV_PAGE_TPI_0 , DEV_PAGE_TX_L0_0 , DEV_PAGE_TX_L1_0 , DEV_PAGE_TX_2_0 , DEV_PAGE_TX_3_0 , DEV_PAGE_CBUS , DEV_PAGE_DDC_EDID , DEV_PAGE_DDC_SEGM , }; int mhl_i2c_reg_read(uint8_t slave_addr_index, uint8_t reg_offset) { struct i2c_msg msgs[2]; uint8_t buffer = 0; int ret = -1; pr_debug("MRR: Reading from slave_addr_index=[%x] and offset=[%x]\n", slave_addr_index, reg_offset); pr_debug("MRR: Addr slave_addr_index=[%x]\n", slave_addrs[slave_addr_index]); /* Slave addr */ msgs[0].addr = slave_addrs[slave_addr_index] >> 1; msgs[1].addr = slave_addrs[slave_addr_index] >> 1; /* Write Command */ msgs[0].flags = 0; msgs[1].flags = I2C_M_RD; /* Register offset for the next transaction */ msgs[0].buf = &reg_offset; msgs[1].buf = &buffer; /* Offset is 1 Byte long */ msgs[0].len = 1; msgs[1].len = 1; ret = i2c_transfer(mhl_msm_state->i2c_client->adapter, msgs, 2); if (ret < 1) { pr_err("I2C READ FAILED=[%d]\n", ret); return -EACCES; } pr_debug("Buffer is [%x]\n", buffer); return buffer; } int mhl_i2c_reg_write(uint8_t slave_addr_index, uint8_t reg_offset, uint8_t value) { return mhl_i2c_reg_write_cmds(slave_addr_index, reg_offset, &value, 1); } int mhl_i2c_reg_write_cmds(uint8_t slave_addr_index, uint8_t reg_offset, uint8_t *value, uint16_t count) { struct i2c_msg msgs[1]; uint8_t data[2]; int status = -EACCES; msgs[0].addr = slave_addrs[slave_addr_index] >> 1; msgs[0].flags = 0; msgs[0].len = 2; msgs[0].buf = data; data[0] = reg_offset; data[1] = *value; status = i2c_transfer(mhl_msm_state->i2c_client->adapter, msgs, 1); if (status < 1) { pr_err("I2C WRITE FAILED=[%d]\n", status); return -EACCES; } return status; } void mhl_i2c_reg_modify(uint8_t slave_addr_index, uint8_t reg_offset, uint8_t mask, uint8_t val) { uint8_t temp; temp = mhl_i2c_reg_read(slave_addr_index, reg_offset); temp &= (~mask); temp |= (mask & val); mhl_i2c_reg_write(slave_addr_index, reg_offset, temp); }
gpl-2.0
cjp256/ubuntu-linux
fs/autofs4/init.c
4213
1279
/* -*- c -*- --------------------------------------------------------------- * * * linux/fs/autofs/init.c * * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved * * This file is part of the Linux kernel and is made available under * the terms of the GNU General Public License, version 2, or at your * option, any later version, incorporated herein by reference. * * ------------------------------------------------------------------------- */ #include <linux/module.h> #include <linux/init.h> #include "autofs_i.h" static struct dentry *autofs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { return mount_nodev(fs_type, flags, data, autofs4_fill_super); } static struct file_system_type autofs_fs_type = { .owner = THIS_MODULE, .name = "autofs", .mount = autofs_mount, .kill_sb = autofs4_kill_sb, }; MODULE_ALIAS_FS("autofs"); static int __init init_autofs4_fs(void) { int err; autofs_dev_ioctl_init(); err = register_filesystem(&autofs_fs_type); if (err) autofs_dev_ioctl_exit(); return err; } static void __exit exit_autofs4_fs(void) { autofs_dev_ioctl_exit(); unregister_filesystem(&autofs_fs_type); } module_init(init_autofs4_fs) module_exit(exit_autofs4_fs) MODULE_LICENSE("GPL");
gpl-2.0
ElKowak/android_kernel_motorola_msm8610
net/bridge/netfilter/ebt_log.c
4981
5742
/* * ebt_log * * Authors: * Bart De Schuymer <bdschuym@pandora.be> * Harald Welte <laforge@netfilter.org> * * April, 2002 * */ #include <linux/module.h> #include <linux/ip.h> #include <linux/in.h> #include <linux/if_arp.h> #include <linux/spinlock.h> #include <net/netfilter/nf_log.h> #include <linux/ipv6.h> #include <net/ipv6.h> #include <linux/in6.h> #include <linux/netfilter/x_tables.h> #include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_log.h> #include <linux/netfilter.h> static DEFINE_SPINLOCK(ebt_log_lock); static int ebt_log_tg_check(const struct xt_tgchk_param *par) { struct ebt_log_info *info = par->targinfo; if (info->bitmask & ~EBT_LOG_MASK) return -EINVAL; if (info->loglevel >= 8) return -EINVAL; info->prefix[EBT_LOG_PREFIX_SIZE - 1] = '\0'; return 0; } struct tcpudphdr { __be16 src; __be16 dst; }; struct arppayload { unsigned char mac_src[ETH_ALEN]; unsigned char ip_src[4]; unsigned char mac_dst[ETH_ALEN]; unsigned char ip_dst[4]; }; static void print_ports(const struct sk_buff *skb, uint8_t protocol, int offset) { if (protocol == IPPROTO_TCP || protocol == IPPROTO_UDP || protocol == IPPROTO_UDPLITE || protocol == IPPROTO_SCTP || protocol == IPPROTO_DCCP) { const struct tcpudphdr *pptr; struct tcpudphdr _ports; pptr = skb_header_pointer(skb, offset, sizeof(_ports), &_ports); if (pptr == NULL) { printk(" INCOMPLETE TCP/UDP header"); return; } printk(" SPT=%u DPT=%u", ntohs(pptr->src), ntohs(pptr->dst)); } } static void ebt_log_packet(u_int8_t pf, unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, const struct nf_loginfo *loginfo, const char *prefix) { unsigned int bitmask; spin_lock_bh(&ebt_log_lock); printk("<%c>%s IN=%s OUT=%s MAC source = %pM MAC dest = %pM proto = 0x%04x", '0' + loginfo->u.log.level, prefix, in ? in->name : "", out ? out->name : "", eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest, ntohs(eth_hdr(skb)->h_proto)); if (loginfo->type == NF_LOG_TYPE_LOG) bitmask = loginfo->u.log.logflags; else bitmask = NF_LOG_MASK; if ((bitmask & EBT_LOG_IP) && eth_hdr(skb)->h_proto == htons(ETH_P_IP)){ const struct iphdr *ih; struct iphdr _iph; ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph); if (ih == NULL) { printk(" INCOMPLETE IP header"); goto out; } printk(" IP SRC=%pI4 IP DST=%pI4, IP tos=0x%02X, IP proto=%d", &ih->saddr, &ih->daddr, ih->tos, ih->protocol); print_ports(skb, ih->protocol, ih->ihl*4); goto out; } #if IS_ENABLED(CONFIG_BRIDGE_EBT_IP6) if ((bitmask & EBT_LOG_IP6) && eth_hdr(skb)->h_proto == htons(ETH_P_IPV6)) { const struct ipv6hdr *ih; struct ipv6hdr _iph; uint8_t nexthdr; __be16 frag_off; int offset_ph; ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph); if (ih == NULL) { printk(" INCOMPLETE IPv6 header"); goto out; } printk(" IPv6 SRC=%pI6 IPv6 DST=%pI6, IPv6 priority=0x%01X, Next Header=%d", &ih->saddr, &ih->daddr, ih->priority, ih->nexthdr); nexthdr = ih->nexthdr; offset_ph = ipv6_skip_exthdr(skb, sizeof(_iph), &nexthdr, &frag_off); if (offset_ph == -1) goto out; print_ports(skb, nexthdr, offset_ph); goto out; } #endif if ((bitmask & EBT_LOG_ARP) && ((eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) || (eth_hdr(skb)->h_proto == htons(ETH_P_RARP)))) { const struct arphdr *ah; struct arphdr _arph; ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph); if (ah == NULL) { printk(" INCOMPLETE ARP header"); goto out; } printk(" ARP HTYPE=%d, PTYPE=0x%04x, OPCODE=%d", ntohs(ah->ar_hrd), ntohs(ah->ar_pro), ntohs(ah->ar_op)); /* If it's for Ethernet and the lengths are OK, * then log the ARP payload */ if (ah->ar_hrd == htons(1) && ah->ar_hln == ETH_ALEN && ah->ar_pln == sizeof(__be32)) { const struct arppayload *ap; struct arppayload _arpp; ap = skb_header_pointer(skb, sizeof(_arph), sizeof(_arpp), &_arpp); if (ap == NULL) { printk(" INCOMPLETE ARP payload"); goto out; } printk(" ARP MAC SRC=%pM ARP IP SRC=%pI4 ARP MAC DST=%pM ARP IP DST=%pI4", ap->mac_src, ap->ip_src, ap->mac_dst, ap->ip_dst); } } out: printk("\n"); spin_unlock_bh(&ebt_log_lock); } static unsigned int ebt_log_tg(struct sk_buff *skb, const struct xt_action_param *par) { const struct ebt_log_info *info = par->targinfo; struct nf_loginfo li; li.type = NF_LOG_TYPE_LOG; li.u.log.level = info->loglevel; li.u.log.logflags = info->bitmask; if (info->bitmask & EBT_LOG_NFLOG) nf_log_packet(NFPROTO_BRIDGE, par->hooknum, skb, par->in, par->out, &li, "%s", info->prefix); else ebt_log_packet(NFPROTO_BRIDGE, par->hooknum, skb, par->in, par->out, &li, info->prefix); return EBT_CONTINUE; } static struct xt_target ebt_log_tg_reg __read_mostly = { .name = "log", .revision = 0, .family = NFPROTO_BRIDGE, .target = ebt_log_tg, .checkentry = ebt_log_tg_check, .targetsize = sizeof(struct ebt_log_info), .me = THIS_MODULE, }; static struct nf_logger ebt_log_logger __read_mostly = { .name = "ebt_log", .logfn = &ebt_log_packet, .me = THIS_MODULE, }; static int __init ebt_log_init(void) { int ret; ret = xt_register_target(&ebt_log_tg_reg); if (ret < 0) return ret; nf_log_register(NFPROTO_BRIDGE, &ebt_log_logger); return 0; } static void __exit ebt_log_fini(void) { nf_log_unregister(&ebt_log_logger); xt_unregister_target(&ebt_log_tg_reg); } module_init(ebt_log_init); module_exit(ebt_log_fini); MODULE_DESCRIPTION("Ebtables: Packet logging to syslog"); MODULE_LICENSE("GPL");
gpl-2.0
bilalliberty/android_kernel_htc_m4
drivers/rtc/rtc-mrst.c
4981
13113
/* * rtc-mrst.c: Driver for Moorestown virtual RTC * * (C) Copyright 2009 Intel Corporation * Author: Jacob Pan (jacob.jun.pan@intel.com) * Feng Tang (feng.tang@intel.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; version 2 * of the License. * * Note: * VRTC is emulated by system controller firmware, the real HW * RTC is located in the PMIC device. SCU FW shadows PMIC RTC * in a memory mapped IO space that is visible to the host IA * processor. * * This driver is based upon drivers/rtc/rtc-cmos.c */ /* * Note: * * vRTC only supports binary mode and 24H mode * * vRTC only support PIE and AIE, no UIE, and its PIE only happens * at 23:59:59pm everyday, no support for adjustable frequency * * Alarm function is also limited to hr/min/sec. */ #include <linux/mod_devicetable.h> #include <linux/platform_device.h> #include <linux/interrupt.h> #include <linux/spinlock.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/sfi.h> #include <asm-generic/rtc.h> #include <asm/intel_scu_ipc.h> #include <asm/mrst.h> #include <asm/mrst-vrtc.h> struct mrst_rtc { struct rtc_device *rtc; struct device *dev; int irq; struct resource *iomem; u8 enabled_wake; u8 suspend_ctrl; }; static const char driver_name[] = "rtc_mrst"; #define RTC_IRQMASK (RTC_PF | RTC_AF) static inline int is_intr(u8 rtc_intr) { if (!(rtc_intr & RTC_IRQF)) return 0; return rtc_intr & RTC_IRQMASK; } static inline unsigned char vrtc_is_updating(void) { unsigned char uip; unsigned long flags; spin_lock_irqsave(&rtc_lock, flags); uip = (vrtc_cmos_read(RTC_FREQ_SELECT) & RTC_UIP); spin_unlock_irqrestore(&rtc_lock, flags); return uip; } /* * rtc_time's year contains the increment over 1900, but vRTC's YEAR * register can't be programmed to value larger than 0x64, so vRTC * driver chose to use 1972 (1970 is UNIX time start point) as the base, * and does the translation at read/write time. * * Why not just use 1970 as the offset? it's because using 1972 will * make it consistent in leap year setting for both vrtc and low-level * physical rtc devices. Then why not use 1960 as the offset? If we use * 1960, for a device's first use, its YEAR register is 0 and the system * year will be parsed as 1960 which is not a valid UNIX time and will * cause many applications to fail mysteriously. */ static int mrst_read_time(struct device *dev, struct rtc_time *time) { unsigned long flags; if (vrtc_is_updating()) mdelay(20); spin_lock_irqsave(&rtc_lock, flags); time->tm_sec = vrtc_cmos_read(RTC_SECONDS); time->tm_min = vrtc_cmos_read(RTC_MINUTES); time->tm_hour = vrtc_cmos_read(RTC_HOURS); time->tm_mday = vrtc_cmos_read(RTC_DAY_OF_MONTH); time->tm_mon = vrtc_cmos_read(RTC_MONTH); time->tm_year = vrtc_cmos_read(RTC_YEAR); spin_unlock_irqrestore(&rtc_lock, flags); /* Adjust for the 1972/1900 */ time->tm_year += 72; time->tm_mon--; return rtc_valid_tm(time); } static int mrst_set_time(struct device *dev, struct rtc_time *time) { int ret; unsigned long flags; unsigned char mon, day, hrs, min, sec; unsigned int yrs; yrs = time->tm_year; mon = time->tm_mon + 1; /* tm_mon starts at zero */ day = time->tm_mday; hrs = time->tm_hour; min = time->tm_min; sec = time->tm_sec; if (yrs < 72 || yrs > 138) return -EINVAL; yrs -= 72; spin_lock_irqsave(&rtc_lock, flags); vrtc_cmos_write(yrs, RTC_YEAR); vrtc_cmos_write(mon, RTC_MONTH); vrtc_cmos_write(day, RTC_DAY_OF_MONTH); vrtc_cmos_write(hrs, RTC_HOURS); vrtc_cmos_write(min, RTC_MINUTES); vrtc_cmos_write(sec, RTC_SECONDS); spin_unlock_irqrestore(&rtc_lock, flags); ret = intel_scu_ipc_simple_command(IPCMSG_VRTC, IPC_CMD_VRTC_SETTIME); return ret; } static int mrst_read_alarm(struct device *dev, struct rtc_wkalrm *t) { struct mrst_rtc *mrst = dev_get_drvdata(dev); unsigned char rtc_control; if (mrst->irq <= 0) return -EIO; /* Basic alarms only support hour, minute, and seconds fields. * Some also support day and month, for alarms up to a year in * the future. */ t->time.tm_mday = -1; t->time.tm_mon = -1; t->time.tm_year = -1; /* vRTC only supports binary mode */ spin_lock_irq(&rtc_lock); t->time.tm_sec = vrtc_cmos_read(RTC_SECONDS_ALARM); t->time.tm_min = vrtc_cmos_read(RTC_MINUTES_ALARM); t->time.tm_hour = vrtc_cmos_read(RTC_HOURS_ALARM); rtc_control = vrtc_cmos_read(RTC_CONTROL); spin_unlock_irq(&rtc_lock); t->enabled = !!(rtc_control & RTC_AIE); t->pending = 0; return 0; } static void mrst_checkintr(struct mrst_rtc *mrst, unsigned char rtc_control) { unsigned char rtc_intr; /* * NOTE after changing RTC_xIE bits we always read INTR_FLAGS; * allegedly some older rtcs need that to handle irqs properly */ rtc_intr = vrtc_cmos_read(RTC_INTR_FLAGS); rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; if (is_intr(rtc_intr)) rtc_update_irq(mrst->rtc, 1, rtc_intr); } static void mrst_irq_enable(struct mrst_rtc *mrst, unsigned char mask) { unsigned char rtc_control; /* * Flush any pending IRQ status, notably for update irqs, * before we enable new IRQs */ rtc_control = vrtc_cmos_read(RTC_CONTROL); mrst_checkintr(mrst, rtc_control); rtc_control |= mask; vrtc_cmos_write(rtc_control, RTC_CONTROL); mrst_checkintr(mrst, rtc_control); } static void mrst_irq_disable(struct mrst_rtc *mrst, unsigned char mask) { unsigned char rtc_control; rtc_control = vrtc_cmos_read(RTC_CONTROL); rtc_control &= ~mask; vrtc_cmos_write(rtc_control, RTC_CONTROL); mrst_checkintr(mrst, rtc_control); } static int mrst_set_alarm(struct device *dev, struct rtc_wkalrm *t) { struct mrst_rtc *mrst = dev_get_drvdata(dev); unsigned char hrs, min, sec; int ret = 0; if (!mrst->irq) return -EIO; hrs = t->time.tm_hour; min = t->time.tm_min; sec = t->time.tm_sec; spin_lock_irq(&rtc_lock); /* Next rtc irq must not be from previous alarm setting */ mrst_irq_disable(mrst, RTC_AIE); /* Update alarm */ vrtc_cmos_write(hrs, RTC_HOURS_ALARM); vrtc_cmos_write(min, RTC_MINUTES_ALARM); vrtc_cmos_write(sec, RTC_SECONDS_ALARM); spin_unlock_irq(&rtc_lock); ret = intel_scu_ipc_simple_command(IPCMSG_VRTC, IPC_CMD_VRTC_SETALARM); if (ret) return ret; spin_lock_irq(&rtc_lock); if (t->enabled) mrst_irq_enable(mrst, RTC_AIE); spin_unlock_irq(&rtc_lock); return 0; } /* Currently, the vRTC doesn't support UIE ON/OFF */ static int mrst_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) { struct mrst_rtc *mrst = dev_get_drvdata(dev); unsigned long flags; spin_lock_irqsave(&rtc_lock, flags); if (enabled) mrst_irq_enable(mrst, RTC_AIE); else mrst_irq_disable(mrst, RTC_AIE); spin_unlock_irqrestore(&rtc_lock, flags); return 0; } #if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE) static int mrst_procfs(struct device *dev, struct seq_file *seq) { unsigned char rtc_control, valid; spin_lock_irq(&rtc_lock); rtc_control = vrtc_cmos_read(RTC_CONTROL); valid = vrtc_cmos_read(RTC_VALID); spin_unlock_irq(&rtc_lock); return seq_printf(seq, "periodic_IRQ\t: %s\n" "alarm\t\t: %s\n" "BCD\t\t: no\n" "periodic_freq\t: daily (not adjustable)\n", (rtc_control & RTC_PIE) ? "on" : "off", (rtc_control & RTC_AIE) ? "on" : "off"); } #else #define mrst_procfs NULL #endif static const struct rtc_class_ops mrst_rtc_ops = { .read_time = mrst_read_time, .set_time = mrst_set_time, .read_alarm = mrst_read_alarm, .set_alarm = mrst_set_alarm, .proc = mrst_procfs, .alarm_irq_enable = mrst_rtc_alarm_irq_enable, }; static struct mrst_rtc mrst_rtc; /* * When vRTC IRQ is captured by SCU FW, FW will clear the AIE bit in * Reg B, so no need for this driver to clear it */ static irqreturn_t mrst_rtc_irq(int irq, void *p) { u8 irqstat; spin_lock(&rtc_lock); /* This read will clear all IRQ flags inside Reg C */ irqstat = vrtc_cmos_read(RTC_INTR_FLAGS); spin_unlock(&rtc_lock); irqstat &= RTC_IRQMASK | RTC_IRQF; if (is_intr(irqstat)) { rtc_update_irq(p, 1, irqstat); return IRQ_HANDLED; } return IRQ_NONE; } static int __devinit vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, int rtc_irq) { int retval = 0; unsigned char rtc_control; /* There can be only one ... */ if (mrst_rtc.dev) return -EBUSY; if (!iomem) return -ENODEV; iomem = request_mem_region(iomem->start, resource_size(iomem), driver_name); if (!iomem) { dev_dbg(dev, "i/o mem already in use.\n"); return -EBUSY; } mrst_rtc.irq = rtc_irq; mrst_rtc.iomem = iomem; mrst_rtc.dev = dev; dev_set_drvdata(dev, &mrst_rtc); mrst_rtc.rtc = rtc_device_register(driver_name, dev, &mrst_rtc_ops, THIS_MODULE); if (IS_ERR(mrst_rtc.rtc)) { retval = PTR_ERR(mrst_rtc.rtc); goto cleanup0; } rename_region(iomem, dev_name(&mrst_rtc.rtc->dev)); spin_lock_irq(&rtc_lock); mrst_irq_disable(&mrst_rtc, RTC_PIE | RTC_AIE); rtc_control = vrtc_cmos_read(RTC_CONTROL); spin_unlock_irq(&rtc_lock); if (!(rtc_control & RTC_24H) || (rtc_control & (RTC_DM_BINARY))) dev_dbg(dev, "TODO: support more than 24-hr BCD mode\n"); if (rtc_irq) { retval = request_irq(rtc_irq, mrst_rtc_irq, 0, dev_name(&mrst_rtc.rtc->dev), mrst_rtc.rtc); if (retval < 0) { dev_dbg(dev, "IRQ %d is already in use, err %d\n", rtc_irq, retval); goto cleanup1; } } dev_dbg(dev, "initialised\n"); return 0; cleanup1: rtc_device_unregister(mrst_rtc.rtc); cleanup0: dev_set_drvdata(dev, NULL); mrst_rtc.dev = NULL; release_mem_region(iomem->start, resource_size(iomem)); dev_err(dev, "rtc-mrst: unable to initialise\n"); return retval; } static void rtc_mrst_do_shutdown(void) { spin_lock_irq(&rtc_lock); mrst_irq_disable(&mrst_rtc, RTC_IRQMASK); spin_unlock_irq(&rtc_lock); } static void __devexit rtc_mrst_do_remove(struct device *dev) { struct mrst_rtc *mrst = dev_get_drvdata(dev); struct resource *iomem; rtc_mrst_do_shutdown(); if (mrst->irq) free_irq(mrst->irq, mrst->rtc); rtc_device_unregister(mrst->rtc); mrst->rtc = NULL; iomem = mrst->iomem; release_mem_region(iomem->start, resource_size(iomem)); mrst->iomem = NULL; mrst->dev = NULL; dev_set_drvdata(dev, NULL); } #ifdef CONFIG_PM static int mrst_suspend(struct device *dev, pm_message_t mesg) { struct mrst_rtc *mrst = dev_get_drvdata(dev); unsigned char tmp; /* Only the alarm might be a wakeup event source */ spin_lock_irq(&rtc_lock); mrst->suspend_ctrl = tmp = vrtc_cmos_read(RTC_CONTROL); if (tmp & (RTC_PIE | RTC_AIE)) { unsigned char mask; if (device_may_wakeup(dev)) mask = RTC_IRQMASK & ~RTC_AIE; else mask = RTC_IRQMASK; tmp &= ~mask; vrtc_cmos_write(tmp, RTC_CONTROL); mrst_checkintr(mrst, tmp); } spin_unlock_irq(&rtc_lock); if (tmp & RTC_AIE) { mrst->enabled_wake = 1; enable_irq_wake(mrst->irq); } dev_dbg(&mrst_rtc.rtc->dev, "suspend%s, ctrl %02x\n", (tmp & RTC_AIE) ? ", alarm may wake" : "", tmp); return 0; } /* * We want RTC alarms to wake us from the deep power saving state */ static inline int mrst_poweroff(struct device *dev) { return mrst_suspend(dev, PMSG_HIBERNATE); } static int mrst_resume(struct device *dev) { struct mrst_rtc *mrst = dev_get_drvdata(dev); unsigned char tmp = mrst->suspend_ctrl; /* Re-enable any irqs previously active */ if (tmp & RTC_IRQMASK) { unsigned char mask; if (mrst->enabled_wake) { disable_irq_wake(mrst->irq); mrst->enabled_wake = 0; } spin_lock_irq(&rtc_lock); do { vrtc_cmos_write(tmp, RTC_CONTROL); mask = vrtc_cmos_read(RTC_INTR_FLAGS); mask &= (tmp & RTC_IRQMASK) | RTC_IRQF; if (!is_intr(mask)) break; rtc_update_irq(mrst->rtc, 1, mask); tmp &= ~RTC_AIE; } while (mask & RTC_AIE); spin_unlock_irq(&rtc_lock); } dev_dbg(&mrst_rtc.rtc->dev, "resume, ctrl %02x\n", tmp); return 0; } #else #define mrst_suspend NULL #define mrst_resume NULL static inline int mrst_poweroff(struct device *dev) { return -ENOSYS; } #endif static int __devinit vrtc_mrst_platform_probe(struct platform_device *pdev) { return vrtc_mrst_do_probe(&pdev->dev, platform_get_resource(pdev, IORESOURCE_MEM, 0), platform_get_irq(pdev, 0)); } static int __devexit vrtc_mrst_platform_remove(struct platform_device *pdev) { rtc_mrst_do_remove(&pdev->dev); return 0; } static void vrtc_mrst_platform_shutdown(struct platform_device *pdev) { if (system_state == SYSTEM_POWER_OFF && !mrst_poweroff(&pdev->dev)) return; rtc_mrst_do_shutdown(); } MODULE_ALIAS("platform:vrtc_mrst"); static struct platform_driver vrtc_mrst_platform_driver = { .probe = vrtc_mrst_platform_probe, .remove = __devexit_p(vrtc_mrst_platform_remove), .shutdown = vrtc_mrst_platform_shutdown, .driver = { .name = (char *) driver_name, .suspend = mrst_suspend, .resume = mrst_resume, } }; module_platform_driver(vrtc_mrst_platform_driver); MODULE_AUTHOR("Jacob Pan; Feng Tang"); MODULE_DESCRIPTION("Driver for Moorestown virtual RTC"); MODULE_LICENSE("GPL");
gpl-2.0
widz4rd/WIDzard_Kernel_N900_KK
drivers/net/ethernet/amd/sunlance.c
4981
41036
/* $Id: sunlance.c,v 1.112 2002/01/15 06:48:55 davem Exp $ * lance.c: Linux/Sparc/Lance driver * * Written 1995, 1996 by Miguel de Icaza * Sources: * The Linux depca driver * The Linux lance driver. * The Linux skeleton driver. * The NetBSD Sparc/Lance driver. * Theo de Raadt (deraadt@openbsd.org) * NCR92C990 Lan Controller manual * * 1.4: * Added support to run with a ledma on the Sun4m * * 1.5: * Added multiple card detection. * * 4/17/96: Burst sizes and tpe selection on sun4m by Eddie C. Dost * (ecd@skynet.be) * * 5/15/96: auto carrier detection on sun4m by Eddie C. Dost * (ecd@skynet.be) * * 5/17/96: lebuffer on scsi/ether cards now work David S. Miller * (davem@caip.rutgers.edu) * * 5/29/96: override option 'tpe-link-test?', if it is 'false', as * this disables auto carrier detection on sun4m. Eddie C. Dost * (ecd@skynet.be) * * 1.7: * 6/26/96: Bug fix for multiple ledmas, miguel. * * 1.8: * Stole multicast code from depca.c, fixed lance_tx. * * 1.9: * 8/21/96: Fixed the multicast code (Pedro Roque) * * 8/28/96: Send fake packet in lance_open() if auto_select is true, * so we can detect the carrier loss condition in time. * Eddie C. Dost (ecd@skynet.be) * * 9/15/96: Align rx_buf so that eth_copy_and_sum() won't cause an * MNA trap during chksum_partial_copy(). (ecd@skynet.be) * * 11/17/96: Handle LE_C0_MERR in lance_interrupt(). (ecd@skynet.be) * * 12/22/96: Don't loop forever in lance_rx() on incomplete packets. * This was the sun4c killer. Shit, stupid bug. * (ecd@skynet.be) * * 1.10: * 1/26/97: Modularize driver. (ecd@skynet.be) * * 1.11: * 12/27/97: Added sun4d support. (jj@sunsite.mff.cuni.cz) * * 1.12: * 11/3/99: Fixed SMP race in lance_start_xmit found by davem. * Anton Blanchard (anton@progsoc.uts.edu.au) * 2.00: 11/9/99: Massive overhaul and port to new SBUS driver interfaces. * David S. Miller (davem@redhat.com) * 2.01: * 11/08/01: Use library crc32 functions (Matt_Domsch@dell.com) * */ #undef DEBUG_DRIVER static char lancestr[] = "LANCE"; #include <linux/module.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/fcntl.h> #include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/in.h> #include <linux/string.h> #include <linux/delay.h> #include <linux/init.h> #include <linux/crc32.h> #include <linux/errno.h> #include <linux/socket.h> /* Used for the temporal inet entries and routing */ #include <linux/route.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> #include <linux/ethtool.h> #include <linux/bitops.h> #include <linux/dma-mapping.h> #include <linux/of.h> #include <linux/of_device.h> #include <linux/gfp.h> #include <asm/io.h> #include <asm/dma.h> #include <asm/pgtable.h> #include <asm/byteorder.h> /* Used by the checksum routines */ #include <asm/idprom.h> #include <asm/prom.h> #include <asm/auxio.h> /* For tpe-link-test? setting */ #include <asm/irq.h> #define DRV_NAME "sunlance" #define DRV_VERSION "2.02" #define DRV_RELDATE "8/24/03" #define DRV_AUTHOR "Miguel de Icaza (miguel@nuclecu.unam.mx)" static char version[] = DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; MODULE_VERSION(DRV_VERSION); MODULE_AUTHOR(DRV_AUTHOR); MODULE_DESCRIPTION("Sun Lance ethernet driver"); MODULE_LICENSE("GPL"); /* Define: 2^4 Tx buffers and 2^4 Rx buffers */ #ifndef LANCE_LOG_TX_BUFFERS #define LANCE_LOG_TX_BUFFERS 4 #define LANCE_LOG_RX_BUFFERS 4 #endif #define LE_CSR0 0 #define LE_CSR1 1 #define LE_CSR2 2 #define LE_CSR3 3 #define LE_MO_PROM 0x8000 /* Enable promiscuous mode */ #define LE_C0_ERR 0x8000 /* Error: set if BAB, SQE, MISS or ME is set */ #define LE_C0_BABL 0x4000 /* BAB: Babble: tx timeout. */ #define LE_C0_CERR 0x2000 /* SQE: Signal quality error */ #define LE_C0_MISS 0x1000 /* MISS: Missed a packet */ #define LE_C0_MERR 0x0800 /* ME: Memory error */ #define LE_C0_RINT 0x0400 /* Received interrupt */ #define LE_C0_TINT 0x0200 /* Transmitter Interrupt */ #define LE_C0_IDON 0x0100 /* IFIN: Init finished. */ #define LE_C0_INTR 0x0080 /* Interrupt or error */ #define LE_C0_INEA 0x0040 /* Interrupt enable */ #define LE_C0_RXON 0x0020 /* Receiver on */ #define LE_C0_TXON 0x0010 /* Transmitter on */ #define LE_C0_TDMD 0x0008 /* Transmitter demand */ #define LE_C0_STOP 0x0004 /* Stop the card */ #define LE_C0_STRT 0x0002 /* Start the card */ #define LE_C0_INIT 0x0001 /* Init the card */ #define LE_C3_BSWP 0x4 /* SWAP */ #define LE_C3_ACON 0x2 /* ALE Control */ #define LE_C3_BCON 0x1 /* Byte control */ /* Receive message descriptor 1 */ #define LE_R1_OWN 0x80 /* Who owns the entry */ #define LE_R1_ERR 0x40 /* Error: if FRA, OFL, CRC or BUF is set */ #define LE_R1_FRA 0x20 /* FRA: Frame error */ #define LE_R1_OFL 0x10 /* OFL: Frame overflow */ #define LE_R1_CRC 0x08 /* CRC error */ #define LE_R1_BUF 0x04 /* BUF: Buffer error */ #define LE_R1_SOP 0x02 /* Start of packet */ #define LE_R1_EOP 0x01 /* End of packet */ #define LE_R1_POK 0x03 /* Packet is complete: SOP + EOP */ #define LE_T1_OWN 0x80 /* Lance owns the packet */ #define LE_T1_ERR 0x40 /* Error summary */ #define LE_T1_EMORE 0x10 /* Error: more than one retry needed */ #define LE_T1_EONE 0x08 /* Error: one retry needed */ #define LE_T1_EDEF 0x04 /* Error: deferred */ #define LE_T1_SOP 0x02 /* Start of packet */ #define LE_T1_EOP 0x01 /* End of packet */ #define LE_T1_POK 0x03 /* Packet is complete: SOP + EOP */ #define LE_T3_BUF 0x8000 /* Buffer error */ #define LE_T3_UFL 0x4000 /* Error underflow */ #define LE_T3_LCOL 0x1000 /* Error late collision */ #define LE_T3_CLOS 0x0800 /* Error carrier loss */ #define LE_T3_RTY 0x0400 /* Error retry */ #define LE_T3_TDR 0x03ff /* Time Domain Reflectometry counter */ #define TX_RING_SIZE (1 << (LANCE_LOG_TX_BUFFERS)) #define TX_RING_MOD_MASK (TX_RING_SIZE - 1) #define TX_RING_LEN_BITS ((LANCE_LOG_TX_BUFFERS) << 29) #define TX_NEXT(__x) (((__x)+1) & TX_RING_MOD_MASK) #define RX_RING_SIZE (1 << (LANCE_LOG_RX_BUFFERS)) #define RX_RING_MOD_MASK (RX_RING_SIZE - 1) #define RX_RING_LEN_BITS ((LANCE_LOG_RX_BUFFERS) << 29) #define RX_NEXT(__x) (((__x)+1) & RX_RING_MOD_MASK) #define PKT_BUF_SZ 1544 #define RX_BUFF_SIZE PKT_BUF_SZ #define TX_BUFF_SIZE PKT_BUF_SZ struct lance_rx_desc { u16 rmd0; /* low address of packet */ u8 rmd1_bits; /* descriptor bits */ u8 rmd1_hadr; /* high address of packet */ s16 length; /* This length is 2s complement (negative)! * Buffer length */ u16 mblength; /* This is the actual number of bytes received */ }; struct lance_tx_desc { u16 tmd0; /* low address of packet */ u8 tmd1_bits; /* descriptor bits */ u8 tmd1_hadr; /* high address of packet */ s16 length; /* Length is 2s complement (negative)! */ u16 misc; }; /* The LANCE initialization block, described in databook. */ /* On the Sparc, this block should be on a DMA region */ struct lance_init_block { u16 mode; /* Pre-set mode (reg. 15) */ u8 phys_addr[6]; /* Physical ethernet address */ u32 filter[2]; /* Multicast filter. */ /* Receive and transmit ring base, along with extra bits. */ u16 rx_ptr; /* receive descriptor addr */ u16 rx_len; /* receive len and high addr */ u16 tx_ptr; /* transmit descriptor addr */ u16 tx_len; /* transmit len and high addr */ /* The Tx and Rx ring entries must aligned on 8-byte boundaries. */ struct lance_rx_desc brx_ring[RX_RING_SIZE]; struct lance_tx_desc btx_ring[TX_RING_SIZE]; u8 tx_buf [TX_RING_SIZE][TX_BUFF_SIZE]; u8 pad[2]; /* align rx_buf for copy_and_sum(). */ u8 rx_buf [RX_RING_SIZE][RX_BUFF_SIZE]; }; #define libdesc_offset(rt, elem) \ ((__u32)(((unsigned long)(&(((struct lance_init_block *)0)->rt[elem]))))) #define libbuff_offset(rt, elem) \ ((__u32)(((unsigned long)(&(((struct lance_init_block *)0)->rt[elem][0]))))) struct lance_private { void __iomem *lregs; /* Lance RAP/RDP regs. */ void __iomem *dregs; /* DMA controller regs. */ struct lance_init_block __iomem *init_block_iomem; struct lance_init_block *init_block_mem; spinlock_t lock; int rx_new, tx_new; int rx_old, tx_old; struct platform_device *ledma; /* If set this points to ledma */ char tpe; /* cable-selection is TPE */ char auto_select; /* cable-selection by carrier */ char burst_sizes; /* ledma SBus burst sizes */ char pio_buffer; /* init block in PIO space? */ unsigned short busmaster_regval; void (*init_ring)(struct net_device *); void (*rx)(struct net_device *); void (*tx)(struct net_device *); char *name; dma_addr_t init_block_dvma; struct net_device *dev; /* Backpointer */ struct platform_device *op; struct platform_device *lebuffer; struct timer_list multicast_timer; }; #define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\ lp->tx_old+TX_RING_MOD_MASK-lp->tx_new:\ lp->tx_old - lp->tx_new-1) /* Lance registers. */ #define RDP 0x00UL /* register data port */ #define RAP 0x02UL /* register address port */ #define LANCE_REG_SIZE 0x04UL #define STOP_LANCE(__lp) \ do { void __iomem *__base = (__lp)->lregs; \ sbus_writew(LE_CSR0, __base + RAP); \ sbus_writew(LE_C0_STOP, __base + RDP); \ } while (0) int sparc_lance_debug = 2; /* The Lance uses 24 bit addresses */ /* On the Sun4c the DVMA will provide the remaining bytes for us */ /* On the Sun4m we have to instruct the ledma to provide them */ /* Even worse, on scsi/ether SBUS cards, the init block and the * transmit/receive buffers are addresses as offsets from absolute * zero on the lebuffer PIO area. -DaveM */ #define LANCE_ADDR(x) ((long)(x) & ~0xff000000) /* Load the CSR registers */ static void load_csrs(struct lance_private *lp) { u32 leptr; if (lp->pio_buffer) leptr = 0; else leptr = LANCE_ADDR(lp->init_block_dvma); sbus_writew(LE_CSR1, lp->lregs + RAP); sbus_writew(leptr & 0xffff, lp->lregs + RDP); sbus_writew(LE_CSR2, lp->lregs + RAP); sbus_writew(leptr >> 16, lp->lregs + RDP); sbus_writew(LE_CSR3, lp->lregs + RAP); sbus_writew(lp->busmaster_regval, lp->lregs + RDP); /* Point back to csr0 */ sbus_writew(LE_CSR0, lp->lregs + RAP); } /* Setup the Lance Rx and Tx rings */ static void lance_init_ring_dvma(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); struct lance_init_block *ib = lp->init_block_mem; dma_addr_t aib = lp->init_block_dvma; __u32 leptr; int i; /* Lock out other processes while setting up hardware */ netif_stop_queue(dev); lp->rx_new = lp->tx_new = 0; lp->rx_old = lp->tx_old = 0; /* Copy the ethernet address to the lance init block * Note that on the sparc you need to swap the ethernet address. */ ib->phys_addr [0] = dev->dev_addr [1]; ib->phys_addr [1] = dev->dev_addr [0]; ib->phys_addr [2] = dev->dev_addr [3]; ib->phys_addr [3] = dev->dev_addr [2]; ib->phys_addr [4] = dev->dev_addr [5]; ib->phys_addr [5] = dev->dev_addr [4]; /* Setup the Tx ring entries */ for (i = 0; i < TX_RING_SIZE; i++) { leptr = LANCE_ADDR(aib + libbuff_offset(tx_buf, i)); ib->btx_ring [i].tmd0 = leptr; ib->btx_ring [i].tmd1_hadr = leptr >> 16; ib->btx_ring [i].tmd1_bits = 0; ib->btx_ring [i].length = 0xf000; /* The ones required by tmd2 */ ib->btx_ring [i].misc = 0; } /* Setup the Rx ring entries */ for (i = 0; i < RX_RING_SIZE; i++) { leptr = LANCE_ADDR(aib + libbuff_offset(rx_buf, i)); ib->brx_ring [i].rmd0 = leptr; ib->brx_ring [i].rmd1_hadr = leptr >> 16; ib->brx_ring [i].rmd1_bits = LE_R1_OWN; ib->brx_ring [i].length = -RX_BUFF_SIZE | 0xf000; ib->brx_ring [i].mblength = 0; } /* Setup the initialization block */ /* Setup rx descriptor pointer */ leptr = LANCE_ADDR(aib + libdesc_offset(brx_ring, 0)); ib->rx_len = (LANCE_LOG_RX_BUFFERS << 13) | (leptr >> 16); ib->rx_ptr = leptr; /* Setup tx descriptor pointer */ leptr = LANCE_ADDR(aib + libdesc_offset(btx_ring, 0)); ib->tx_len = (LANCE_LOG_TX_BUFFERS << 13) | (leptr >> 16); ib->tx_ptr = leptr; } static void lance_init_ring_pio(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); struct lance_init_block __iomem *ib = lp->init_block_iomem; u32 leptr; int i; /* Lock out other processes while setting up hardware */ netif_stop_queue(dev); lp->rx_new = lp->tx_new = 0; lp->rx_old = lp->tx_old = 0; /* Copy the ethernet address to the lance init block * Note that on the sparc you need to swap the ethernet address. */ sbus_writeb(dev->dev_addr[1], &ib->phys_addr[0]); sbus_writeb(dev->dev_addr[0], &ib->phys_addr[1]); sbus_writeb(dev->dev_addr[3], &ib->phys_addr[2]); sbus_writeb(dev->dev_addr[2], &ib->phys_addr[3]); sbus_writeb(dev->dev_addr[5], &ib->phys_addr[4]); sbus_writeb(dev->dev_addr[4], &ib->phys_addr[5]); /* Setup the Tx ring entries */ for (i = 0; i < TX_RING_SIZE; i++) { leptr = libbuff_offset(tx_buf, i); sbus_writew(leptr, &ib->btx_ring [i].tmd0); sbus_writeb(leptr >> 16,&ib->btx_ring [i].tmd1_hadr); sbus_writeb(0, &ib->btx_ring [i].tmd1_bits); /* The ones required by tmd2 */ sbus_writew(0xf000, &ib->btx_ring [i].length); sbus_writew(0, &ib->btx_ring [i].misc); } /* Setup the Rx ring entries */ for (i = 0; i < RX_RING_SIZE; i++) { leptr = libbuff_offset(rx_buf, i); sbus_writew(leptr, &ib->brx_ring [i].rmd0); sbus_writeb(leptr >> 16,&ib->brx_ring [i].rmd1_hadr); sbus_writeb(LE_R1_OWN, &ib->brx_ring [i].rmd1_bits); sbus_writew(-RX_BUFF_SIZE|0xf000, &ib->brx_ring [i].length); sbus_writew(0, &ib->brx_ring [i].mblength); } /* Setup the initialization block */ /* Setup rx descriptor pointer */ leptr = libdesc_offset(brx_ring, 0); sbus_writew((LANCE_LOG_RX_BUFFERS << 13) | (leptr >> 16), &ib->rx_len); sbus_writew(leptr, &ib->rx_ptr); /* Setup tx descriptor pointer */ leptr = libdesc_offset(btx_ring, 0); sbus_writew((LANCE_LOG_TX_BUFFERS << 13) | (leptr >> 16), &ib->tx_len); sbus_writew(leptr, &ib->tx_ptr); } static void init_restart_ledma(struct lance_private *lp) { u32 csr = sbus_readl(lp->dregs + DMA_CSR); if (!(csr & DMA_HNDL_ERROR)) { /* E-Cache draining */ while (sbus_readl(lp->dregs + DMA_CSR) & DMA_FIFO_ISDRAIN) barrier(); } csr = sbus_readl(lp->dregs + DMA_CSR); csr &= ~DMA_E_BURSTS; if (lp->burst_sizes & DMA_BURST32) csr |= DMA_E_BURST32; else csr |= DMA_E_BURST16; csr |= (DMA_DSBL_RD_DRN | DMA_DSBL_WR_INV | DMA_FIFO_INV); if (lp->tpe) csr |= DMA_EN_ENETAUI; else csr &= ~DMA_EN_ENETAUI; udelay(20); sbus_writel(csr, lp->dregs + DMA_CSR); udelay(200); } static int init_restart_lance(struct lance_private *lp) { u16 regval = 0; int i; if (lp->dregs) init_restart_ledma(lp); sbus_writew(LE_CSR0, lp->lregs + RAP); sbus_writew(LE_C0_INIT, lp->lregs + RDP); /* Wait for the lance to complete initialization */ for (i = 0; i < 100; i++) { regval = sbus_readw(lp->lregs + RDP); if (regval & (LE_C0_ERR | LE_C0_IDON)) break; barrier(); } if (i == 100 || (regval & LE_C0_ERR)) { printk(KERN_ERR "LANCE unopened after %d ticks, csr0=%4.4x.\n", i, regval); if (lp->dregs) printk("dcsr=%8.8x\n", sbus_readl(lp->dregs + DMA_CSR)); return -1; } /* Clear IDON by writing a "1", enable interrupts and start lance */ sbus_writew(LE_C0_IDON, lp->lregs + RDP); sbus_writew(LE_C0_INEA | LE_C0_STRT, lp->lregs + RDP); if (lp->dregs) { u32 csr = sbus_readl(lp->dregs + DMA_CSR); csr |= DMA_INT_ENAB; sbus_writel(csr, lp->dregs + DMA_CSR); } return 0; } static void lance_rx_dvma(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); struct lance_init_block *ib = lp->init_block_mem; struct lance_rx_desc *rd; u8 bits; int len, entry = lp->rx_new; struct sk_buff *skb; for (rd = &ib->brx_ring [entry]; !((bits = rd->rmd1_bits) & LE_R1_OWN); rd = &ib->brx_ring [entry]) { /* We got an incomplete frame? */ if ((bits & LE_R1_POK) != LE_R1_POK) { dev->stats.rx_over_errors++; dev->stats.rx_errors++; } else if (bits & LE_R1_ERR) { /* Count only the end frame as a rx error, * not the beginning */ if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++; if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++; if (bits & LE_R1_OFL) dev->stats.rx_over_errors++; if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++; if (bits & LE_R1_EOP) dev->stats.rx_errors++; } else { len = (rd->mblength & 0xfff) - 4; skb = netdev_alloc_skb(dev, len + 2); if (skb == NULL) { printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n", dev->name); dev->stats.rx_dropped++; rd->mblength = 0; rd->rmd1_bits = LE_R1_OWN; lp->rx_new = RX_NEXT(entry); return; } dev->stats.rx_bytes += len; skb_reserve(skb, 2); /* 16 byte align */ skb_put(skb, len); /* make room */ skb_copy_to_linear_data(skb, (unsigned char *)&(ib->rx_buf [entry][0]), len); skb->protocol = eth_type_trans(skb, dev); netif_rx(skb); dev->stats.rx_packets++; } /* Return the packet to the pool */ rd->mblength = 0; rd->rmd1_bits = LE_R1_OWN; entry = RX_NEXT(entry); } lp->rx_new = entry; } static void lance_tx_dvma(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); struct lance_init_block *ib = lp->init_block_mem; int i, j; spin_lock(&lp->lock); j = lp->tx_old; for (i = j; i != lp->tx_new; i = j) { struct lance_tx_desc *td = &ib->btx_ring [i]; u8 bits = td->tmd1_bits; /* If we hit a packet not owned by us, stop */ if (bits & LE_T1_OWN) break; if (bits & LE_T1_ERR) { u16 status = td->misc; dev->stats.tx_errors++; if (status & LE_T3_RTY) dev->stats.tx_aborted_errors++; if (status & LE_T3_LCOL) dev->stats.tx_window_errors++; if (status & LE_T3_CLOS) { dev->stats.tx_carrier_errors++; if (lp->auto_select) { lp->tpe = 1 - lp->tpe; printk(KERN_NOTICE "%s: Carrier Lost, trying %s\n", dev->name, lp->tpe?"TPE":"AUI"); STOP_LANCE(lp); lp->init_ring(dev); load_csrs(lp); init_restart_lance(lp); goto out; } } /* Buffer errors and underflows turn off the * transmitter, restart the adapter. */ if (status & (LE_T3_BUF|LE_T3_UFL)) { dev->stats.tx_fifo_errors++; printk(KERN_ERR "%s: Tx: ERR_BUF|ERR_UFL, restarting\n", dev->name); STOP_LANCE(lp); lp->init_ring(dev); load_csrs(lp); init_restart_lance(lp); goto out; } } else if ((bits & LE_T1_POK) == LE_T1_POK) { /* * So we don't count the packet more than once. */ td->tmd1_bits = bits & ~(LE_T1_POK); /* One collision before packet was sent. */ if (bits & LE_T1_EONE) dev->stats.collisions++; /* More than one collision, be optimistic. */ if (bits & LE_T1_EMORE) dev->stats.collisions += 2; dev->stats.tx_packets++; } j = TX_NEXT(j); } lp->tx_old = j; out: if (netif_queue_stopped(dev) && TX_BUFFS_AVAIL > 0) netif_wake_queue(dev); spin_unlock(&lp->lock); } static void lance_piocopy_to_skb(struct sk_buff *skb, void __iomem *piobuf, int len) { u16 *p16 = (u16 *) skb->data; u32 *p32; u8 *p8; void __iomem *pbuf = piobuf; /* We know here that both src and dest are on a 16bit boundary. */ *p16++ = sbus_readw(pbuf); p32 = (u32 *) p16; pbuf += 2; len -= 2; while (len >= 4) { *p32++ = sbus_readl(pbuf); pbuf += 4; len -= 4; } p8 = (u8 *) p32; if (len >= 2) { p16 = (u16 *) p32; *p16++ = sbus_readw(pbuf); pbuf += 2; len -= 2; p8 = (u8 *) p16; } if (len >= 1) *p8 = sbus_readb(pbuf); } static void lance_rx_pio(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); struct lance_init_block __iomem *ib = lp->init_block_iomem; struct lance_rx_desc __iomem *rd; unsigned char bits; int len, entry; struct sk_buff *skb; entry = lp->rx_new; for (rd = &ib->brx_ring [entry]; !((bits = sbus_readb(&rd->rmd1_bits)) & LE_R1_OWN); rd = &ib->brx_ring [entry]) { /* We got an incomplete frame? */ if ((bits & LE_R1_POK) != LE_R1_POK) { dev->stats.rx_over_errors++; dev->stats.rx_errors++; } else if (bits & LE_R1_ERR) { /* Count only the end frame as a rx error, * not the beginning */ if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++; if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++; if (bits & LE_R1_OFL) dev->stats.rx_over_errors++; if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++; if (bits & LE_R1_EOP) dev->stats.rx_errors++; } else { len = (sbus_readw(&rd->mblength) & 0xfff) - 4; skb = netdev_alloc_skb(dev, len + 2); if (skb == NULL) { printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n", dev->name); dev->stats.rx_dropped++; sbus_writew(0, &rd->mblength); sbus_writeb(LE_R1_OWN, &rd->rmd1_bits); lp->rx_new = RX_NEXT(entry); return; } dev->stats.rx_bytes += len; skb_reserve (skb, 2); /* 16 byte align */ skb_put(skb, len); /* make room */ lance_piocopy_to_skb(skb, &(ib->rx_buf[entry][0]), len); skb->protocol = eth_type_trans(skb, dev); netif_rx(skb); dev->stats.rx_packets++; } /* Return the packet to the pool */ sbus_writew(0, &rd->mblength); sbus_writeb(LE_R1_OWN, &rd->rmd1_bits); entry = RX_NEXT(entry); } lp->rx_new = entry; } static void lance_tx_pio(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); struct lance_init_block __iomem *ib = lp->init_block_iomem; int i, j; spin_lock(&lp->lock); j = lp->tx_old; for (i = j; i != lp->tx_new; i = j) { struct lance_tx_desc __iomem *td = &ib->btx_ring [i]; u8 bits = sbus_readb(&td->tmd1_bits); /* If we hit a packet not owned by us, stop */ if (bits & LE_T1_OWN) break; if (bits & LE_T1_ERR) { u16 status = sbus_readw(&td->misc); dev->stats.tx_errors++; if (status & LE_T3_RTY) dev->stats.tx_aborted_errors++; if (status & LE_T3_LCOL) dev->stats.tx_window_errors++; if (status & LE_T3_CLOS) { dev->stats.tx_carrier_errors++; if (lp->auto_select) { lp->tpe = 1 - lp->tpe; printk(KERN_NOTICE "%s: Carrier Lost, trying %s\n", dev->name, lp->tpe?"TPE":"AUI"); STOP_LANCE(lp); lp->init_ring(dev); load_csrs(lp); init_restart_lance(lp); goto out; } } /* Buffer errors and underflows turn off the * transmitter, restart the adapter. */ if (status & (LE_T3_BUF|LE_T3_UFL)) { dev->stats.tx_fifo_errors++; printk(KERN_ERR "%s: Tx: ERR_BUF|ERR_UFL, restarting\n", dev->name); STOP_LANCE(lp); lp->init_ring(dev); load_csrs(lp); init_restart_lance(lp); goto out; } } else if ((bits & LE_T1_POK) == LE_T1_POK) { /* * So we don't count the packet more than once. */ sbus_writeb(bits & ~(LE_T1_POK), &td->tmd1_bits); /* One collision before packet was sent. */ if (bits & LE_T1_EONE) dev->stats.collisions++; /* More than one collision, be optimistic. */ if (bits & LE_T1_EMORE) dev->stats.collisions += 2; dev->stats.tx_packets++; } j = TX_NEXT(j); } lp->tx_old = j; if (netif_queue_stopped(dev) && TX_BUFFS_AVAIL > 0) netif_wake_queue(dev); out: spin_unlock(&lp->lock); } static irqreturn_t lance_interrupt(int irq, void *dev_id) { struct net_device *dev = dev_id; struct lance_private *lp = netdev_priv(dev); int csr0; sbus_writew(LE_CSR0, lp->lregs + RAP); csr0 = sbus_readw(lp->lregs + RDP); /* Acknowledge all the interrupt sources ASAP */ sbus_writew(csr0 & (LE_C0_INTR | LE_C0_TINT | LE_C0_RINT), lp->lregs + RDP); if ((csr0 & LE_C0_ERR) != 0) { /* Clear the error condition */ sbus_writew((LE_C0_BABL | LE_C0_ERR | LE_C0_MISS | LE_C0_CERR | LE_C0_MERR), lp->lregs + RDP); } if (csr0 & LE_C0_RINT) lp->rx(dev); if (csr0 & LE_C0_TINT) lp->tx(dev); if (csr0 & LE_C0_BABL) dev->stats.tx_errors++; if (csr0 & LE_C0_MISS) dev->stats.rx_errors++; if (csr0 & LE_C0_MERR) { if (lp->dregs) { u32 addr = sbus_readl(lp->dregs + DMA_ADDR); printk(KERN_ERR "%s: Memory error, status %04x, addr %06x\n", dev->name, csr0, addr & 0xffffff); } else { printk(KERN_ERR "%s: Memory error, status %04x\n", dev->name, csr0); } sbus_writew(LE_C0_STOP, lp->lregs + RDP); if (lp->dregs) { u32 dma_csr = sbus_readl(lp->dregs + DMA_CSR); dma_csr |= DMA_FIFO_INV; sbus_writel(dma_csr, lp->dregs + DMA_CSR); } lp->init_ring(dev); load_csrs(lp); init_restart_lance(lp); netif_wake_queue(dev); } sbus_writew(LE_C0_INEA, lp->lregs + RDP); return IRQ_HANDLED; } /* Build a fake network packet and send it to ourselves. */ static void build_fake_packet(struct lance_private *lp) { struct net_device *dev = lp->dev; int i, entry; entry = lp->tx_new & TX_RING_MOD_MASK; if (lp->pio_buffer) { struct lance_init_block __iomem *ib = lp->init_block_iomem; u16 __iomem *packet = (u16 __iomem *) &(ib->tx_buf[entry][0]); struct ethhdr __iomem *eth = (struct ethhdr __iomem *) packet; for (i = 0; i < (ETH_ZLEN / sizeof(u16)); i++) sbus_writew(0, &packet[i]); for (i = 0; i < 6; i++) { sbus_writeb(dev->dev_addr[i], &eth->h_dest[i]); sbus_writeb(dev->dev_addr[i], &eth->h_source[i]); } sbus_writew((-ETH_ZLEN) | 0xf000, &ib->btx_ring[entry].length); sbus_writew(0, &ib->btx_ring[entry].misc); sbus_writeb(LE_T1_POK|LE_T1_OWN, &ib->btx_ring[entry].tmd1_bits); } else { struct lance_init_block *ib = lp->init_block_mem; u16 *packet = (u16 *) &(ib->tx_buf[entry][0]); struct ethhdr *eth = (struct ethhdr *) packet; memset(packet, 0, ETH_ZLEN); for (i = 0; i < 6; i++) { eth->h_dest[i] = dev->dev_addr[i]; eth->h_source[i] = dev->dev_addr[i]; } ib->btx_ring[entry].length = (-ETH_ZLEN) | 0xf000; ib->btx_ring[entry].misc = 0; ib->btx_ring[entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN); } lp->tx_new = TX_NEXT(entry); } static int lance_open(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); int status = 0; STOP_LANCE(lp); if (request_irq(dev->irq, lance_interrupt, IRQF_SHARED, lancestr, (void *) dev)) { printk(KERN_ERR "Lance: Can't get irq %d\n", dev->irq); return -EAGAIN; } /* On the 4m, setup the ledma to provide the upper bits for buffers */ if (lp->dregs) { u32 regval = lp->init_block_dvma & 0xff000000; sbus_writel(regval, lp->dregs + DMA_TEST); } /* Set mode and clear multicast filter only at device open, * so that lance_init_ring() called at any error will not * forget multicast filters. * * BTW it is common bug in all lance drivers! --ANK */ if (lp->pio_buffer) { struct lance_init_block __iomem *ib = lp->init_block_iomem; sbus_writew(0, &ib->mode); sbus_writel(0, &ib->filter[0]); sbus_writel(0, &ib->filter[1]); } else { struct lance_init_block *ib = lp->init_block_mem; ib->mode = 0; ib->filter [0] = 0; ib->filter [1] = 0; } lp->init_ring(dev); load_csrs(lp); netif_start_queue(dev); status = init_restart_lance(lp); if (!status && lp->auto_select) { build_fake_packet(lp); sbus_writew(LE_C0_INEA | LE_C0_TDMD, lp->lregs + RDP); } return status; } static int lance_close(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); netif_stop_queue(dev); del_timer_sync(&lp->multicast_timer); STOP_LANCE(lp); free_irq(dev->irq, (void *) dev); return 0; } static int lance_reset(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); int status; STOP_LANCE(lp); /* On the 4m, reset the dma too */ if (lp->dregs) { u32 csr, addr; printk(KERN_ERR "resetting ledma\n"); csr = sbus_readl(lp->dregs + DMA_CSR); sbus_writel(csr | DMA_RST_ENET, lp->dregs + DMA_CSR); udelay(200); sbus_writel(csr & ~DMA_RST_ENET, lp->dregs + DMA_CSR); addr = lp->init_block_dvma & 0xff000000; sbus_writel(addr, lp->dregs + DMA_TEST); } lp->init_ring(dev); load_csrs(lp); dev->trans_start = jiffies; /* prevent tx timeout */ status = init_restart_lance(lp); return status; } static void lance_piocopy_from_skb(void __iomem *dest, unsigned char *src, int len) { void __iomem *piobuf = dest; u32 *p32; u16 *p16; u8 *p8; switch ((unsigned long)src & 0x3) { case 0: p32 = (u32 *) src; while (len >= 4) { sbus_writel(*p32, piobuf); p32++; piobuf += 4; len -= 4; } src = (char *) p32; break; case 1: case 3: p8 = (u8 *) src; while (len >= 4) { u32 val; val = p8[0] << 24; val |= p8[1] << 16; val |= p8[2] << 8; val |= p8[3]; sbus_writel(val, piobuf); p8 += 4; piobuf += 4; len -= 4; } src = (char *) p8; break; case 2: p16 = (u16 *) src; while (len >= 4) { u32 val = p16[0]<<16 | p16[1]; sbus_writel(val, piobuf); p16 += 2; piobuf += 4; len -= 4; } src = (char *) p16; break; } if (len >= 2) { u16 val = src[0] << 8 | src[1]; sbus_writew(val, piobuf); src += 2; piobuf += 2; len -= 2; } if (len >= 1) sbus_writeb(src[0], piobuf); } static void lance_piozero(void __iomem *dest, int len) { void __iomem *piobuf = dest; if ((unsigned long)piobuf & 1) { sbus_writeb(0, piobuf); piobuf += 1; len -= 1; if (len == 0) return; } if (len == 1) { sbus_writeb(0, piobuf); return; } if ((unsigned long)piobuf & 2) { sbus_writew(0, piobuf); piobuf += 2; len -= 2; if (len == 0) return; } while (len >= 4) { sbus_writel(0, piobuf); piobuf += 4; len -= 4; } if (len >= 2) { sbus_writew(0, piobuf); piobuf += 2; len -= 2; } if (len >= 1) sbus_writeb(0, piobuf); } static void lance_tx_timeout(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); printk(KERN_ERR "%s: transmit timed out, status %04x, reset\n", dev->name, sbus_readw(lp->lregs + RDP)); lance_reset(dev); netif_wake_queue(dev); } static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); int entry, skblen, len; skblen = skb->len; len = (skblen <= ETH_ZLEN) ? ETH_ZLEN : skblen; spin_lock_irq(&lp->lock); dev->stats.tx_bytes += len; entry = lp->tx_new & TX_RING_MOD_MASK; if (lp->pio_buffer) { struct lance_init_block __iomem *ib = lp->init_block_iomem; sbus_writew((-len) | 0xf000, &ib->btx_ring[entry].length); sbus_writew(0, &ib->btx_ring[entry].misc); lance_piocopy_from_skb(&ib->tx_buf[entry][0], skb->data, skblen); if (len != skblen) lance_piozero(&ib->tx_buf[entry][skblen], len - skblen); sbus_writeb(LE_T1_POK | LE_T1_OWN, &ib->btx_ring[entry].tmd1_bits); } else { struct lance_init_block *ib = lp->init_block_mem; ib->btx_ring [entry].length = (-len) | 0xf000; ib->btx_ring [entry].misc = 0; skb_copy_from_linear_data(skb, &ib->tx_buf [entry][0], skblen); if (len != skblen) memset((char *) &ib->tx_buf [entry][skblen], 0, len - skblen); ib->btx_ring [entry].tmd1_bits = (LE_T1_POK | LE_T1_OWN); } lp->tx_new = TX_NEXT(entry); if (TX_BUFFS_AVAIL <= 0) netif_stop_queue(dev); /* Kick the lance: transmit now */ sbus_writew(LE_C0_INEA | LE_C0_TDMD, lp->lregs + RDP); /* Read back CSR to invalidate the E-Cache. * This is needed, because DMA_DSBL_WR_INV is set. */ if (lp->dregs) sbus_readw(lp->lregs + RDP); spin_unlock_irq(&lp->lock); dev_kfree_skb(skb); return NETDEV_TX_OK; } /* taken from the depca driver */ static void lance_load_multicast(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); struct netdev_hw_addr *ha; u32 crc; u32 val; /* set all multicast bits */ if (dev->flags & IFF_ALLMULTI) val = ~0; else val = 0; if (lp->pio_buffer) { struct lance_init_block __iomem *ib = lp->init_block_iomem; sbus_writel(val, &ib->filter[0]); sbus_writel(val, &ib->filter[1]); } else { struct lance_init_block *ib = lp->init_block_mem; ib->filter [0] = val; ib->filter [1] = val; } if (dev->flags & IFF_ALLMULTI) return; /* Add addresses */ netdev_for_each_mc_addr(ha, dev) { crc = ether_crc_le(6, ha->addr); crc = crc >> 26; if (lp->pio_buffer) { struct lance_init_block __iomem *ib = lp->init_block_iomem; u16 __iomem *mcast_table = (u16 __iomem *) &ib->filter; u16 tmp = sbus_readw(&mcast_table[crc>>4]); tmp |= 1 << (crc & 0xf); sbus_writew(tmp, &mcast_table[crc>>4]); } else { struct lance_init_block *ib = lp->init_block_mem; u16 *mcast_table = (u16 *) &ib->filter; mcast_table [crc >> 4] |= 1 << (crc & 0xf); } } } static void lance_set_multicast(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); struct lance_init_block *ib_mem = lp->init_block_mem; struct lance_init_block __iomem *ib_iomem = lp->init_block_iomem; u16 mode; if (!netif_running(dev)) return; if (lp->tx_old != lp->tx_new) { mod_timer(&lp->multicast_timer, jiffies + 4); netif_wake_queue(dev); return; } netif_stop_queue(dev); STOP_LANCE(lp); lp->init_ring(dev); if (lp->pio_buffer) mode = sbus_readw(&ib_iomem->mode); else mode = ib_mem->mode; if (dev->flags & IFF_PROMISC) { mode |= LE_MO_PROM; if (lp->pio_buffer) sbus_writew(mode, &ib_iomem->mode); else ib_mem->mode = mode; } else { mode &= ~LE_MO_PROM; if (lp->pio_buffer) sbus_writew(mode, &ib_iomem->mode); else ib_mem->mode = mode; lance_load_multicast(dev); } load_csrs(lp); init_restart_lance(lp); netif_wake_queue(dev); } static void lance_set_multicast_retry(unsigned long _opaque) { struct net_device *dev = (struct net_device *) _opaque; lance_set_multicast(dev); } static void lance_free_hwresources(struct lance_private *lp) { if (lp->lregs) of_iounmap(&lp->op->resource[0], lp->lregs, LANCE_REG_SIZE); if (lp->dregs) { struct platform_device *ledma = lp->ledma; of_iounmap(&ledma->resource[0], lp->dregs, resource_size(&ledma->resource[0])); } if (lp->init_block_iomem) { of_iounmap(&lp->lebuffer->resource[0], lp->init_block_iomem, sizeof(struct lance_init_block)); } else if (lp->init_block_mem) { dma_free_coherent(&lp->op->dev, sizeof(struct lance_init_block), lp->init_block_mem, lp->init_block_dvma); } } /* Ethtool support... */ static void sparc_lance_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strcpy(info->driver, "sunlance"); strcpy(info->version, "2.02"); } static const struct ethtool_ops sparc_lance_ethtool_ops = { .get_drvinfo = sparc_lance_get_drvinfo, .get_link = ethtool_op_get_link, }; static const struct net_device_ops sparc_lance_ops = { .ndo_open = lance_open, .ndo_stop = lance_close, .ndo_start_xmit = lance_start_xmit, .ndo_set_rx_mode = lance_set_multicast, .ndo_tx_timeout = lance_tx_timeout, .ndo_change_mtu = eth_change_mtu, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, }; static int __devinit sparc_lance_probe_one(struct platform_device *op, struct platform_device *ledma, struct platform_device *lebuffer) { struct device_node *dp = op->dev.of_node; static unsigned version_printed; struct lance_private *lp; struct net_device *dev; int i; dev = alloc_etherdev(sizeof(struct lance_private) + 8); if (!dev) return -ENOMEM; lp = netdev_priv(dev); if (sparc_lance_debug && version_printed++ == 0) printk (KERN_INFO "%s", version); spin_lock_init(&lp->lock); /* Copy the IDPROM ethernet address to the device structure, later we * will copy the address in the device structure to the lance * initialization block. */ for (i = 0; i < 6; i++) dev->dev_addr[i] = idprom->id_ethaddr[i]; /* Get the IO region */ lp->lregs = of_ioremap(&op->resource[0], 0, LANCE_REG_SIZE, lancestr); if (!lp->lregs) { printk(KERN_ERR "SunLance: Cannot map registers.\n"); goto fail; } lp->ledma = ledma; if (lp->ledma) { lp->dregs = of_ioremap(&ledma->resource[0], 0, resource_size(&ledma->resource[0]), "ledma"); if (!lp->dregs) { printk(KERN_ERR "SunLance: Cannot map " "ledma registers.\n"); goto fail; } } lp->op = op; lp->lebuffer = lebuffer; if (lebuffer) { /* sanity check */ if (lebuffer->resource[0].start & 7) { printk(KERN_ERR "SunLance: ERROR: Rx and Tx rings not on even boundary.\n"); goto fail; } lp->init_block_iomem = of_ioremap(&lebuffer->resource[0], 0, sizeof(struct lance_init_block), "lebuffer"); if (!lp->init_block_iomem) { printk(KERN_ERR "SunLance: Cannot map PIO buffer.\n"); goto fail; } lp->init_block_dvma = 0; lp->pio_buffer = 1; lp->init_ring = lance_init_ring_pio; lp->rx = lance_rx_pio; lp->tx = lance_tx_pio; } else { lp->init_block_mem = dma_alloc_coherent(&op->dev, sizeof(struct lance_init_block), &lp->init_block_dvma, GFP_ATOMIC); if (!lp->init_block_mem) { printk(KERN_ERR "SunLance: Cannot allocate consistent DMA memory.\n"); goto fail; } lp->pio_buffer = 0; lp->init_ring = lance_init_ring_dvma; lp->rx = lance_rx_dvma; lp->tx = lance_tx_dvma; } lp->busmaster_regval = of_getintprop_default(dp, "busmaster-regval", (LE_C3_BSWP | LE_C3_ACON | LE_C3_BCON)); lp->name = lancestr; lp->burst_sizes = 0; if (lp->ledma) { struct device_node *ledma_dp = ledma->dev.of_node; struct device_node *sbus_dp; unsigned int sbmask; const char *prop; u32 csr; /* Find burst-size property for ledma */ lp->burst_sizes = of_getintprop_default(ledma_dp, "burst-sizes", 0); /* ledma may be capable of fast bursts, but sbus may not. */ sbus_dp = ledma_dp->parent; sbmask = of_getintprop_default(sbus_dp, "burst-sizes", DMA_BURSTBITS); lp->burst_sizes &= sbmask; /* Get the cable-selection property */ prop = of_get_property(ledma_dp, "cable-selection", NULL); if (!prop || prop[0] == '\0') { struct device_node *nd; printk(KERN_INFO "SunLance: using " "auto-carrier-detection.\n"); nd = of_find_node_by_path("/options"); if (!nd) goto no_link_test; prop = of_get_property(nd, "tpe-link-test?", NULL); if (!prop) goto no_link_test; if (strcmp(prop, "true")) { printk(KERN_NOTICE "SunLance: warning: overriding option " "'tpe-link-test?'\n"); printk(KERN_NOTICE "SunLance: warning: mail any problems " "to ecd@skynet.be\n"); auxio_set_lte(AUXIO_LTE_ON); } no_link_test: lp->auto_select = 1; lp->tpe = 0; } else if (!strcmp(prop, "aui")) { lp->auto_select = 0; lp->tpe = 0; } else { lp->auto_select = 0; lp->tpe = 1; } /* Reset ledma */ csr = sbus_readl(lp->dregs + DMA_CSR); sbus_writel(csr | DMA_RST_ENET, lp->dregs + DMA_CSR); udelay(200); sbus_writel(csr & ~DMA_RST_ENET, lp->dregs + DMA_CSR); } else lp->dregs = NULL; lp->dev = dev; SET_NETDEV_DEV(dev, &op->dev); dev->watchdog_timeo = 5*HZ; dev->ethtool_ops = &sparc_lance_ethtool_ops; dev->netdev_ops = &sparc_lance_ops; dev->irq = op->archdata.irqs[0]; /* We cannot sleep if the chip is busy during a * multicast list update event, because such events * can occur from interrupts (ex. IPv6). So we * use a timer to try again later when necessary. -DaveM */ init_timer(&lp->multicast_timer); lp->multicast_timer.data = (unsigned long) dev; lp->multicast_timer.function = lance_set_multicast_retry; if (register_netdev(dev)) { printk(KERN_ERR "SunLance: Cannot register device.\n"); goto fail; } dev_set_drvdata(&op->dev, lp); printk(KERN_INFO "%s: LANCE %pM\n", dev->name, dev->dev_addr); return 0; fail: lance_free_hwresources(lp); free_netdev(dev); return -ENODEV; } static int __devinit sunlance_sbus_probe(struct platform_device *op) { struct platform_device *parent = to_platform_device(op->dev.parent); struct device_node *parent_dp = parent->dev.of_node; int err; if (!strcmp(parent_dp->name, "ledma")) { err = sparc_lance_probe_one(op, parent, NULL); } else if (!strcmp(parent_dp->name, "lebuffer")) { err = sparc_lance_probe_one(op, NULL, parent); } else err = sparc_lance_probe_one(op, NULL, NULL); return err; } static int __devexit sunlance_sbus_remove(struct platform_device *op) { struct lance_private *lp = dev_get_drvdata(&op->dev); struct net_device *net_dev = lp->dev; unregister_netdev(net_dev); lance_free_hwresources(lp); free_netdev(net_dev); dev_set_drvdata(&op->dev, NULL); return 0; } static const struct of_device_id sunlance_sbus_match[] = { { .name = "le", }, {}, }; MODULE_DEVICE_TABLE(of, sunlance_sbus_match); static struct platform_driver sunlance_sbus_driver = { .driver = { .name = "sunlance", .owner = THIS_MODULE, .of_match_table = sunlance_sbus_match, }, .probe = sunlance_sbus_probe, .remove = __devexit_p(sunlance_sbus_remove), }; module_platform_driver(sunlance_sbus_driver);
gpl-2.0
cherifyass/s4-gpe-kernel
fs/dlm/memory.c
5493
2128
/****************************************************************************** ******************************************************************************* ** ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. ** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. ** ** This copyrighted material is made available to anyone wishing to use, ** modify, copy, or redistribute it subject to the terms and conditions ** of the GNU General Public License v.2. ** ******************************************************************************* ******************************************************************************/ #include "dlm_internal.h" #include "config.h" #include "memory.h" static struct kmem_cache *lkb_cache; static struct kmem_cache *rsb_cache; int __init dlm_memory_init(void) { int ret = 0; lkb_cache = kmem_cache_create("dlm_lkb", sizeof(struct dlm_lkb), __alignof__(struct dlm_lkb), 0, NULL); if (!lkb_cache) ret = -ENOMEM; rsb_cache = kmem_cache_create("dlm_rsb", sizeof(struct dlm_rsb), __alignof__(struct dlm_rsb), 0, NULL); if (!rsb_cache) { kmem_cache_destroy(lkb_cache); ret = -ENOMEM; } return ret; } void dlm_memory_exit(void) { if (lkb_cache) kmem_cache_destroy(lkb_cache); if (rsb_cache) kmem_cache_destroy(rsb_cache); } char *dlm_allocate_lvb(struct dlm_ls *ls) { char *p; p = kzalloc(ls->ls_lvblen, GFP_NOFS); return p; } void dlm_free_lvb(char *p) { kfree(p); } struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls) { struct dlm_rsb *r; r = kmem_cache_zalloc(rsb_cache, GFP_NOFS); return r; } void dlm_free_rsb(struct dlm_rsb *r) { if (r->res_lvbptr) dlm_free_lvb(r->res_lvbptr); kmem_cache_free(rsb_cache, r); } struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls) { struct dlm_lkb *lkb; lkb = kmem_cache_zalloc(lkb_cache, GFP_NOFS); return lkb; } void dlm_free_lkb(struct dlm_lkb *lkb) { if (lkb->lkb_flags & DLM_IFL_USER) { struct dlm_user_args *ua; ua = lkb->lkb_ua; if (ua) { if (ua->lksb.sb_lvbptr) kfree(ua->lksb.sb_lvbptr); kfree(ua); } } kmem_cache_free(lkb_cache, lkb); }
gpl-2.0
androidbftab1/bf-kernel-3.4
drivers/mtd/chips/map_ram.c
8309
3692
/* * Common code to handle map devices which are simple RAM * (C) 2000 Red Hat. GPL'd. */ #include <linux/module.h> #include <linux/types.h> #include <linux/kernel.h> #include <asm/io.h> #include <asm/byteorder.h> #include <linux/errno.h> #include <linux/slab.h> #include <linux/init.h> #include <linux/mtd/mtd.h> #include <linux/mtd/map.h> static int mapram_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); static int mapram_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *); static int mapram_erase (struct mtd_info *, struct erase_info *); static void mapram_nop (struct mtd_info *); static struct mtd_info *map_ram_probe(struct map_info *map); static unsigned long mapram_unmapped_area(struct mtd_info *, unsigned long, unsigned long, unsigned long); static struct mtd_chip_driver mapram_chipdrv = { .probe = map_ram_probe, .name = "map_ram", .module = THIS_MODULE }; static struct mtd_info *map_ram_probe(struct map_info *map) { struct mtd_info *mtd; /* Check the first byte is RAM */ #if 0 map_write8(map, 0x55, 0); if (map_read8(map, 0) != 0x55) return NULL; map_write8(map, 0xAA, 0); if (map_read8(map, 0) != 0xAA) return NULL; /* Check the last byte is RAM */ map_write8(map, 0x55, map->size-1); if (map_read8(map, map->size-1) != 0x55) return NULL; map_write8(map, 0xAA, map->size-1); if (map_read8(map, map->size-1) != 0xAA) return NULL; #endif /* OK. It seems to be RAM. */ mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); if (!mtd) return NULL; map->fldrv = &mapram_chipdrv; mtd->priv = map; mtd->name = map->name; mtd->type = MTD_RAM; mtd->size = map->size; mtd->_erase = mapram_erase; mtd->_get_unmapped_area = mapram_unmapped_area; mtd->_read = mapram_read; mtd->_write = mapram_write; mtd->_sync = mapram_nop; mtd->flags = MTD_CAP_RAM; mtd->writesize = 1; mtd->erasesize = PAGE_SIZE; while(mtd->size & (mtd->erasesize - 1)) mtd->erasesize >>= 1; __module_get(THIS_MODULE); return mtd; } /* * Allow NOMMU mmap() to directly map the device (if not NULL) * - return the address to which the offset maps * - return -ENOSYS to indicate refusal to do the mapping */ static unsigned long mapram_unmapped_area(struct mtd_info *mtd, unsigned long len, unsigned long offset, unsigned long flags) { struct map_info *map = mtd->priv; return (unsigned long) map->virt + offset; } static int mapram_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { struct map_info *map = mtd->priv; map_copy_from(map, buf, from, len); *retlen = len; return 0; } static int mapram_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { struct map_info *map = mtd->priv; map_copy_to(map, to, buf, len); *retlen = len; return 0; } static int mapram_erase (struct mtd_info *mtd, struct erase_info *instr) { /* Yeah, it's inefficient. Who cares? It's faster than a _real_ flash erase. */ struct map_info *map = mtd->priv; map_word allff; unsigned long i; allff = map_word_ff(map); for (i=0; i<instr->len; i += map_bankwidth(map)) map_write(map, allff, instr->addr + i); instr->state = MTD_ERASE_DONE; mtd_erase_callback(instr); return 0; } static void mapram_nop(struct mtd_info *mtd) { /* Nothing to see here */ } static int __init map_ram_init(void) { register_mtd_chip_driver(&mapram_chipdrv); return 0; } static void __exit map_ram_exit(void) { unregister_mtd_chip_driver(&mapram_chipdrv); } module_init(map_ram_init); module_exit(map_ram_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); MODULE_DESCRIPTION("MTD chip driver for RAM chips");
gpl-2.0
cmvienneau/android_kernel_htc_m4
sound/pci/oxygen/oxygen_pcm.c
8565
22254
/* * C-Media CMI8788 driver - PCM code * * Copyright (c) Clemens Ladisch <clemens@ladisch.de> * * * This driver is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2. * * This driver 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 driver; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/pci.h> #include <sound/control.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include "oxygen.h" /* most DMA channels have a 16-bit counter for 32-bit words */ #define BUFFER_BYTES_MAX ((1 << 16) * 4) /* the multichannel DMA channel has a 24-bit counter */ #define BUFFER_BYTES_MAX_MULTICH ((1 << 24) * 4) #define PERIOD_BYTES_MIN 64 #define DEFAULT_BUFFER_BYTES (BUFFER_BYTES_MAX / 2) #define DEFAULT_BUFFER_BYTES_MULTICH (1024 * 1024) static const struct snd_pcm_hardware oxygen_stereo_hardware = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_SYNC_START | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, .rate_min = 32000, .rate_max = 192000, .channels_min = 2, .channels_max = 2, .buffer_bytes_max = BUFFER_BYTES_MAX, .period_bytes_min = PERIOD_BYTES_MIN, .period_bytes_max = BUFFER_BYTES_MAX, .periods_min = 1, .periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN, }; static const struct snd_pcm_hardware oxygen_multichannel_hardware = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_SYNC_START | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, .rate_min = 32000, .rate_max = 192000, .channels_min = 2, .channels_max = 8, .buffer_bytes_max = BUFFER_BYTES_MAX_MULTICH, .period_bytes_min = PERIOD_BYTES_MIN, .period_bytes_max = BUFFER_BYTES_MAX_MULTICH, .periods_min = 1, .periods_max = BUFFER_BYTES_MAX_MULTICH / PERIOD_BYTES_MIN, }; static const struct snd_pcm_hardware oxygen_ac97_hardware = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_SYNC_START | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_48000, .rate_min = 48000, .rate_max = 48000, .channels_min = 2, .channels_max = 2, .buffer_bytes_max = BUFFER_BYTES_MAX, .period_bytes_min = PERIOD_BYTES_MIN, .period_bytes_max = BUFFER_BYTES_MAX, .periods_min = 1, .periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN, }; static const struct snd_pcm_hardware *const oxygen_hardware[PCM_COUNT] = { [PCM_A] = &oxygen_stereo_hardware, [PCM_B] = &oxygen_stereo_hardware, [PCM_C] = &oxygen_stereo_hardware, [PCM_SPDIF] = &oxygen_stereo_hardware, [PCM_MULTICH] = &oxygen_multichannel_hardware, [PCM_AC97] = &oxygen_ac97_hardware, }; static inline unsigned int oxygen_substream_channel(struct snd_pcm_substream *substream) { return (unsigned int)(uintptr_t)substream->runtime->private_data; } static int oxygen_open(struct snd_pcm_substream *substream, unsigned int channel) { struct oxygen *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; int err; runtime->private_data = (void *)(uintptr_t)channel; if (channel == PCM_B && chip->has_ac97_1 && (chip->model.device_config & CAPTURE_2_FROM_AC97_1)) runtime->hw = oxygen_ac97_hardware; else runtime->hw = *oxygen_hardware[channel]; switch (channel) { case PCM_C: runtime->hw.rates &= ~(SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_64000); runtime->hw.rate_min = 44100; break; case PCM_MULTICH: runtime->hw.channels_max = chip->model.dac_channels_pcm; break; } if (chip->model.pcm_hardware_filter) chip->model.pcm_hardware_filter(channel, &runtime->hw); err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); if (err < 0) return err; err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32); if (err < 0) return err; if (runtime->hw.formats & SNDRV_PCM_FMTBIT_S32_LE) { err = snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); if (err < 0) return err; } if (runtime->hw.channels_max > 2) { err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 2); if (err < 0) return err; } snd_pcm_set_sync(substream); chip->streams[channel] = substream; mutex_lock(&chip->mutex); chip->pcm_active |= 1 << channel; if (channel == PCM_SPDIF) { chip->spdif_pcm_bits = chip->spdif_bits; chip->controls[CONTROL_SPDIF_PCM]->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO, &chip->controls[CONTROL_SPDIF_PCM]->id); } mutex_unlock(&chip->mutex); return 0; } static int oxygen_rec_a_open(struct snd_pcm_substream *substream) { return oxygen_open(substream, PCM_A); } static int oxygen_rec_b_open(struct snd_pcm_substream *substream) { return oxygen_open(substream, PCM_B); } static int oxygen_rec_c_open(struct snd_pcm_substream *substream) { return oxygen_open(substream, PCM_C); } static int oxygen_spdif_open(struct snd_pcm_substream *substream) { return oxygen_open(substream, PCM_SPDIF); } static int oxygen_multich_open(struct snd_pcm_substream *substream) { return oxygen_open(substream, PCM_MULTICH); } static int oxygen_ac97_open(struct snd_pcm_substream *substream) { return oxygen_open(substream, PCM_AC97); } static int oxygen_close(struct snd_pcm_substream *substream) { struct oxygen *chip = snd_pcm_substream_chip(substream); unsigned int channel = oxygen_substream_channel(substream); mutex_lock(&chip->mutex); chip->pcm_active &= ~(1 << channel); if (channel == PCM_SPDIF) { chip->controls[CONTROL_SPDIF_PCM]->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO, &chip->controls[CONTROL_SPDIF_PCM]->id); } if (channel == PCM_SPDIF || channel == PCM_MULTICH) oxygen_update_spdif_source(chip); mutex_unlock(&chip->mutex); chip->streams[channel] = NULL; return 0; } static unsigned int oxygen_format(struct snd_pcm_hw_params *hw_params) { if (params_format(hw_params) == SNDRV_PCM_FORMAT_S32_LE) return OXYGEN_FORMAT_24; else return OXYGEN_FORMAT_16; } static unsigned int oxygen_rate(struct snd_pcm_hw_params *hw_params) { switch (params_rate(hw_params)) { case 32000: return OXYGEN_RATE_32000; case 44100: return OXYGEN_RATE_44100; default: /* 48000 */ return OXYGEN_RATE_48000; case 64000: return OXYGEN_RATE_64000; case 88200: return OXYGEN_RATE_88200; case 96000: return OXYGEN_RATE_96000; case 176400: return OXYGEN_RATE_176400; case 192000: return OXYGEN_RATE_192000; } } static unsigned int oxygen_i2s_bits(struct snd_pcm_hw_params *hw_params) { if (params_format(hw_params) == SNDRV_PCM_FORMAT_S32_LE) return OXYGEN_I2S_BITS_24; else return OXYGEN_I2S_BITS_16; } static unsigned int oxygen_play_channels(struct snd_pcm_hw_params *hw_params) { switch (params_channels(hw_params)) { default: /* 2 */ return OXYGEN_PLAY_CHANNELS_2; case 4: return OXYGEN_PLAY_CHANNELS_4; case 6: return OXYGEN_PLAY_CHANNELS_6; case 8: return OXYGEN_PLAY_CHANNELS_8; } } static const unsigned int channel_base_registers[PCM_COUNT] = { [PCM_A] = OXYGEN_DMA_A_ADDRESS, [PCM_B] = OXYGEN_DMA_B_ADDRESS, [PCM_C] = OXYGEN_DMA_C_ADDRESS, [PCM_SPDIF] = OXYGEN_DMA_SPDIF_ADDRESS, [PCM_MULTICH] = OXYGEN_DMA_MULTICH_ADDRESS, [PCM_AC97] = OXYGEN_DMA_AC97_ADDRESS, }; static int oxygen_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct oxygen *chip = snd_pcm_substream_chip(substream); unsigned int channel = oxygen_substream_channel(substream); int err; err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); if (err < 0) return err; oxygen_write32(chip, channel_base_registers[channel], (u32)substream->runtime->dma_addr); if (channel == PCM_MULTICH) { oxygen_write32(chip, OXYGEN_DMA_MULTICH_COUNT, params_buffer_bytes(hw_params) / 4 - 1); oxygen_write32(chip, OXYGEN_DMA_MULTICH_TCOUNT, params_period_bytes(hw_params) / 4 - 1); } else { oxygen_write16(chip, channel_base_registers[channel] + 4, params_buffer_bytes(hw_params) / 4 - 1); oxygen_write16(chip, channel_base_registers[channel] + 6, params_period_bytes(hw_params) / 4 - 1); } return 0; } static u16 get_mclk(struct oxygen *chip, unsigned int channel, struct snd_pcm_hw_params *params) { unsigned int mclks, shift; if (channel == PCM_MULTICH) mclks = chip->model.dac_mclks; else mclks = chip->model.adc_mclks; if (params_rate(params) <= 48000) shift = 0; else if (params_rate(params) <= 96000) shift = 2; else shift = 4; return OXYGEN_I2S_MCLK(mclks >> shift); } static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct oxygen *chip = snd_pcm_substream_chip(substream); int err; err = oxygen_hw_params(substream, hw_params); if (err < 0) return err; spin_lock_irq(&chip->reg_lock); oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, oxygen_format(hw_params) << OXYGEN_REC_FORMAT_A_SHIFT, OXYGEN_REC_FORMAT_A_MASK); oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, oxygen_rate(hw_params) | chip->model.adc_i2s_format | get_mclk(chip, PCM_A, hw_params) | oxygen_i2s_bits(hw_params), OXYGEN_I2S_RATE_MASK | OXYGEN_I2S_FORMAT_MASK | OXYGEN_I2S_MCLK_MASK | OXYGEN_I2S_BITS_MASK); spin_unlock_irq(&chip->reg_lock); mutex_lock(&chip->mutex); chip->model.set_adc_params(chip, hw_params); mutex_unlock(&chip->mutex); return 0; } static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct oxygen *chip = snd_pcm_substream_chip(substream); int is_ac97; int err; err = oxygen_hw_params(substream, hw_params); if (err < 0) return err; is_ac97 = chip->has_ac97_1 && (chip->model.device_config & CAPTURE_2_FROM_AC97_1); spin_lock_irq(&chip->reg_lock); oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, oxygen_format(hw_params) << OXYGEN_REC_FORMAT_B_SHIFT, OXYGEN_REC_FORMAT_B_MASK); if (!is_ac97) oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT, oxygen_rate(hw_params) | chip->model.adc_i2s_format | get_mclk(chip, PCM_B, hw_params) | oxygen_i2s_bits(hw_params), OXYGEN_I2S_RATE_MASK | OXYGEN_I2S_FORMAT_MASK | OXYGEN_I2S_MCLK_MASK | OXYGEN_I2S_BITS_MASK); spin_unlock_irq(&chip->reg_lock); if (!is_ac97) { mutex_lock(&chip->mutex); chip->model.set_adc_params(chip, hw_params); mutex_unlock(&chip->mutex); } return 0; } static int oxygen_rec_c_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct oxygen *chip = snd_pcm_substream_chip(substream); int err; err = oxygen_hw_params(substream, hw_params); if (err < 0) return err; spin_lock_irq(&chip->reg_lock); oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, oxygen_format(hw_params) << OXYGEN_REC_FORMAT_C_SHIFT, OXYGEN_REC_FORMAT_C_MASK); spin_unlock_irq(&chip->reg_lock); return 0; } static int oxygen_spdif_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct oxygen *chip = snd_pcm_substream_chip(substream); int err; err = oxygen_hw_params(substream, hw_params); if (err < 0) return err; mutex_lock(&chip->mutex); spin_lock_irq(&chip->reg_lock); oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, OXYGEN_SPDIF_OUT_ENABLE); oxygen_write8_masked(chip, OXYGEN_PLAY_FORMAT, oxygen_format(hw_params) << OXYGEN_SPDIF_FORMAT_SHIFT, OXYGEN_SPDIF_FORMAT_MASK); oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL, oxygen_rate(hw_params) << OXYGEN_SPDIF_OUT_RATE_SHIFT, OXYGEN_SPDIF_OUT_RATE_MASK); oxygen_update_spdif_source(chip); spin_unlock_irq(&chip->reg_lock); mutex_unlock(&chip->mutex); return 0; } static int oxygen_multich_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct oxygen *chip = snd_pcm_substream_chip(substream); int err; err = oxygen_hw_params(substream, hw_params); if (err < 0) return err; mutex_lock(&chip->mutex); spin_lock_irq(&chip->reg_lock); oxygen_write8_masked(chip, OXYGEN_PLAY_CHANNELS, oxygen_play_channels(hw_params), OXYGEN_PLAY_CHANNELS_MASK); oxygen_write8_masked(chip, OXYGEN_PLAY_FORMAT, oxygen_format(hw_params) << OXYGEN_MULTICH_FORMAT_SHIFT, OXYGEN_MULTICH_FORMAT_MASK); oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, oxygen_rate(hw_params) | chip->model.dac_i2s_format | get_mclk(chip, PCM_MULTICH, hw_params) | oxygen_i2s_bits(hw_params), OXYGEN_I2S_RATE_MASK | OXYGEN_I2S_FORMAT_MASK | OXYGEN_I2S_MCLK_MASK | OXYGEN_I2S_BITS_MASK); oxygen_update_spdif_source(chip); spin_unlock_irq(&chip->reg_lock); chip->model.set_dac_params(chip, hw_params); oxygen_update_dac_routing(chip); mutex_unlock(&chip->mutex); return 0; } static int oxygen_hw_free(struct snd_pcm_substream *substream) { struct oxygen *chip = snd_pcm_substream_chip(substream); unsigned int channel = oxygen_substream_channel(substream); unsigned int channel_mask = 1 << channel; spin_lock_irq(&chip->reg_lock); chip->interrupt_mask &= ~channel_mask; oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask); oxygen_set_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask); oxygen_clear_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask); spin_unlock_irq(&chip->reg_lock); return snd_pcm_lib_free_pages(substream); } static int oxygen_spdif_hw_free(struct snd_pcm_substream *substream) { struct oxygen *chip = snd_pcm_substream_chip(substream); spin_lock_irq(&chip->reg_lock); oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, OXYGEN_SPDIF_OUT_ENABLE); spin_unlock_irq(&chip->reg_lock); return oxygen_hw_free(substream); } static int oxygen_prepare(struct snd_pcm_substream *substream) { struct oxygen *chip = snd_pcm_substream_chip(substream); unsigned int channel = oxygen_substream_channel(substream); unsigned int channel_mask = 1 << channel; spin_lock_irq(&chip->reg_lock); oxygen_set_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask); oxygen_clear_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask); if (substream->runtime->no_period_wakeup) chip->interrupt_mask &= ~channel_mask; else chip->interrupt_mask |= channel_mask; oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask); spin_unlock_irq(&chip->reg_lock); return 0; } static int oxygen_trigger(struct snd_pcm_substream *substream, int cmd) { struct oxygen *chip = snd_pcm_substream_chip(substream); struct snd_pcm_substream *s; unsigned int mask = 0; int pausing; switch (cmd) { case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_SUSPEND: pausing = 0; break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: pausing = 1; break; default: return -EINVAL; } snd_pcm_group_for_each_entry(s, substream) { if (snd_pcm_substream_chip(s) == chip) { mask |= 1 << oxygen_substream_channel(s); snd_pcm_trigger_done(s, substream); } } spin_lock(&chip->reg_lock); if (!pausing) { if (cmd == SNDRV_PCM_TRIGGER_START) chip->pcm_running |= mask; else chip->pcm_running &= ~mask; oxygen_write8(chip, OXYGEN_DMA_STATUS, chip->pcm_running); } else { if (cmd == SNDRV_PCM_TRIGGER_PAUSE_PUSH) oxygen_set_bits8(chip, OXYGEN_DMA_PAUSE, mask); else oxygen_clear_bits8(chip, OXYGEN_DMA_PAUSE, mask); } spin_unlock(&chip->reg_lock); return 0; } static snd_pcm_uframes_t oxygen_pointer(struct snd_pcm_substream *substream) { struct oxygen *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; unsigned int channel = oxygen_substream_channel(substream); u32 curr_addr; /* no spinlock, this read should be atomic */ curr_addr = oxygen_read32(chip, channel_base_registers[channel]); return bytes_to_frames(runtime, curr_addr - (u32)runtime->dma_addr); } static struct snd_pcm_ops oxygen_rec_a_ops = { .open = oxygen_rec_a_open, .close = oxygen_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_rec_a_hw_params, .hw_free = oxygen_hw_free, .prepare = oxygen_prepare, .trigger = oxygen_trigger, .pointer = oxygen_pointer, }; static struct snd_pcm_ops oxygen_rec_b_ops = { .open = oxygen_rec_b_open, .close = oxygen_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_rec_b_hw_params, .hw_free = oxygen_hw_free, .prepare = oxygen_prepare, .trigger = oxygen_trigger, .pointer = oxygen_pointer, }; static struct snd_pcm_ops oxygen_rec_c_ops = { .open = oxygen_rec_c_open, .close = oxygen_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_rec_c_hw_params, .hw_free = oxygen_hw_free, .prepare = oxygen_prepare, .trigger = oxygen_trigger, .pointer = oxygen_pointer, }; static struct snd_pcm_ops oxygen_spdif_ops = { .open = oxygen_spdif_open, .close = oxygen_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_spdif_hw_params, .hw_free = oxygen_spdif_hw_free, .prepare = oxygen_prepare, .trigger = oxygen_trigger, .pointer = oxygen_pointer, }; static struct snd_pcm_ops oxygen_multich_ops = { .open = oxygen_multich_open, .close = oxygen_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_multich_hw_params, .hw_free = oxygen_hw_free, .prepare = oxygen_prepare, .trigger = oxygen_trigger, .pointer = oxygen_pointer, }; static struct snd_pcm_ops oxygen_ac97_ops = { .open = oxygen_ac97_open, .close = oxygen_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_hw_params, .hw_free = oxygen_hw_free, .prepare = oxygen_prepare, .trigger = oxygen_trigger, .pointer = oxygen_pointer, }; static void oxygen_pcm_free(struct snd_pcm *pcm) { snd_pcm_lib_preallocate_free_for_all(pcm); } int oxygen_pcm_init(struct oxygen *chip) { struct snd_pcm *pcm; int outs, ins; int err; outs = !!(chip->model.device_config & PLAYBACK_0_TO_I2S); ins = !!(chip->model.device_config & (CAPTURE_0_FROM_I2S_1 | CAPTURE_0_FROM_I2S_2)); if (outs | ins) { err = snd_pcm_new(chip->card, "Multichannel", 0, outs, ins, &pcm); if (err < 0) return err; if (outs) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &oxygen_multich_ops); if (chip->model.device_config & CAPTURE_0_FROM_I2S_1) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &oxygen_rec_a_ops); else if (chip->model.device_config & CAPTURE_0_FROM_I2S_2) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &oxygen_rec_b_ops); pcm->private_data = chip; pcm->private_free = oxygen_pcm_free; strcpy(pcm->name, "Multichannel"); if (outs) snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), DEFAULT_BUFFER_BYTES_MULTICH, BUFFER_BYTES_MAX_MULTICH); if (ins) snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), DEFAULT_BUFFER_BYTES, BUFFER_BYTES_MAX); } outs = !!(chip->model.device_config & PLAYBACK_1_TO_SPDIF); ins = !!(chip->model.device_config & CAPTURE_1_FROM_SPDIF); if (outs | ins) { err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm); if (err < 0) return err; if (outs) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &oxygen_spdif_ops); if (ins) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &oxygen_rec_c_ops); pcm->private_data = chip; pcm->private_free = oxygen_pcm_free; strcpy(pcm->name, "Digital"); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), DEFAULT_BUFFER_BYTES, BUFFER_BYTES_MAX); } if (chip->has_ac97_1) { outs = !!(chip->model.device_config & PLAYBACK_2_TO_AC97_1); ins = !!(chip->model.device_config & CAPTURE_2_FROM_AC97_1); } else { outs = 0; ins = !!(chip->model.device_config & CAPTURE_2_FROM_I2S_2); } if (outs | ins) { err = snd_pcm_new(chip->card, outs ? "AC97" : "Analog2", 2, outs, ins, &pcm); if (err < 0) return err; if (outs) { snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &oxygen_ac97_ops); oxygen_write8_masked(chip, OXYGEN_REC_ROUTING, OXYGEN_REC_B_ROUTE_AC97_1, OXYGEN_REC_B_ROUTE_MASK); } if (ins) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &oxygen_rec_b_ops); pcm->private_data = chip; pcm->private_free = oxygen_pcm_free; strcpy(pcm->name, outs ? "Front Panel" : "Analog 2"); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), DEFAULT_BUFFER_BYTES, BUFFER_BYTES_MAX); } return 0; }
gpl-2.0
KarthikNayak/linux
drivers/iio/accel/ssp_accel_sensor.c
118
4579
/* * Copyright (C) 2014, Samsung Electronics Co. Ltd. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #include <linux/iio/common/ssp_sensors.h> #include <linux/iio/iio.h> #include <linux/iio/kfifo_buf.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/slab.h> #include "../common/ssp_sensors/ssp_iio_sensor.h" #define SSP_CHANNEL_COUNT 3 #define SSP_ACCEL_NAME "ssp-accelerometer" static const char ssp_accel_device_name[] = SSP_ACCEL_NAME; enum ssp_accel_3d_channel { SSP_CHANNEL_SCAN_INDEX_X, SSP_CHANNEL_SCAN_INDEX_Y, SSP_CHANNEL_SCAN_INDEX_Z, SSP_CHANNEL_SCAN_INDEX_TIME, }; static int ssp_accel_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { u32 t; struct ssp_data *data = dev_get_drvdata(indio_dev->dev.parent->parent); switch (mask) { case IIO_CHAN_INFO_SAMP_FREQ: t = ssp_get_sensor_delay(data, SSP_ACCELEROMETER_SENSOR); ssp_convert_to_freq(t, val, val2); return IIO_VAL_INT_PLUS_MICRO; default: break; } return -EINVAL; } static int ssp_accel_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) { int ret; struct ssp_data *data = dev_get_drvdata(indio_dev->dev.parent->parent); switch (mask) { case IIO_CHAN_INFO_SAMP_FREQ: ret = ssp_convert_to_time(val, val2); ret = ssp_change_delay(data, SSP_ACCELEROMETER_SENSOR, ret); if (ret < 0) dev_err(&indio_dev->dev, "accel sensor enable fail\n"); return ret; default: break; } return -EINVAL; } static const struct iio_info ssp_accel_iio_info = { .read_raw = &ssp_accel_read_raw, .write_raw = &ssp_accel_write_raw, }; static const unsigned long ssp_accel_scan_mask[] = { 0x7, 0, }; static const struct iio_chan_spec ssp_acc_channels[] = { SSP_CHANNEL_AG(IIO_ACCEL, IIO_MOD_X, SSP_CHANNEL_SCAN_INDEX_X), SSP_CHANNEL_AG(IIO_ACCEL, IIO_MOD_Y, SSP_CHANNEL_SCAN_INDEX_Y), SSP_CHANNEL_AG(IIO_ACCEL, IIO_MOD_Z, SSP_CHANNEL_SCAN_INDEX_Z), SSP_CHAN_TIMESTAMP(SSP_CHANNEL_SCAN_INDEX_TIME), }; static int ssp_process_accel_data(struct iio_dev *indio_dev, void *buf, int64_t timestamp) { return ssp_common_process_data(indio_dev, buf, SSP_ACCELEROMETER_SIZE, timestamp); } static const struct iio_buffer_setup_ops ssp_accel_buffer_ops = { .postenable = &ssp_common_buffer_postenable, .postdisable = &ssp_common_buffer_postdisable, }; static int ssp_accel_probe(struct platform_device *pdev) { int ret; struct iio_dev *indio_dev; struct ssp_sensor_data *spd; struct iio_buffer *buffer; indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*spd)); if (!indio_dev) return -ENOMEM; spd = iio_priv(indio_dev); spd->process_data = ssp_process_accel_data; spd->type = SSP_ACCELEROMETER_SENSOR; indio_dev->name = ssp_accel_device_name; indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &ssp_accel_iio_info; indio_dev->modes = INDIO_BUFFER_SOFTWARE; indio_dev->channels = ssp_acc_channels; indio_dev->num_channels = ARRAY_SIZE(ssp_acc_channels); indio_dev->available_scan_masks = ssp_accel_scan_mask; buffer = devm_iio_kfifo_allocate(&pdev->dev); if (!buffer) return -ENOMEM; iio_device_attach_buffer(indio_dev, buffer); indio_dev->setup_ops = &ssp_accel_buffer_ops; platform_set_drvdata(pdev, indio_dev); ret = iio_device_register(indio_dev); if (ret < 0) return ret; /* ssp registering should be done after all iio setup */ ssp_register_consumer(indio_dev, SSP_ACCELEROMETER_SENSOR); return 0; } static int ssp_accel_remove(struct platform_device *pdev) { struct iio_dev *indio_dev = platform_get_drvdata(pdev); iio_device_unregister(indio_dev); return 0; } static struct platform_driver ssp_accel_driver = { .driver = { .name = SSP_ACCEL_NAME, }, .probe = ssp_accel_probe, .remove = ssp_accel_remove, }; module_platform_driver(ssp_accel_driver); MODULE_AUTHOR("Karol Wrona <k.wrona@samsung.com>"); MODULE_DESCRIPTION("Samsung sensorhub accelerometers driver"); MODULE_LICENSE("GPL");
gpl-2.0
lexi6725/linux-3.14.26
arch/x86/kernel/alternative.c
374
17055
#define pr_fmt(fmt) "SMP alternatives: " fmt #include <linux/module.h> #include <linux/sched.h> #include <linux/mutex.h> #include <linux/list.h> #include <linux/stringify.h> #include <linux/kprobes.h> #include <linux/mm.h> #include <linux/vmalloc.h> #include <linux/memory.h> #include <linux/stop_machine.h> #include <linux/slab.h> #include <linux/kdebug.h> #include <asm/alternative.h> #include <asm/sections.h> #include <asm/pgtable.h> #include <asm/mce.h> #include <asm/nmi.h> #include <asm/cacheflush.h> #include <asm/tlbflush.h> #include <asm/io.h> #include <asm/fixmap.h> #define MAX_PATCH_LEN (255-1) static int __initdata_or_module debug_alternative; static int __init debug_alt(char *str) { debug_alternative = 1; return 1; } __setup("debug-alternative", debug_alt); static int noreplace_smp; static int __init setup_noreplace_smp(char *str) { noreplace_smp = 1; return 1; } __setup("noreplace-smp", setup_noreplace_smp); #ifdef CONFIG_PARAVIRT static int __initdata_or_module noreplace_paravirt = 0; static int __init setup_noreplace_paravirt(char *str) { noreplace_paravirt = 1; return 1; } __setup("noreplace-paravirt", setup_noreplace_paravirt); #endif #define DPRINTK(fmt, ...) \ do { \ if (debug_alternative) \ printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ } while (0) /* * Each GENERIC_NOPX is of X bytes, and defined as an array of bytes * that correspond to that nop. Getting from one nop to the next, we * add to the array the offset that is equal to the sum of all sizes of * nops preceding the one we are after. * * Note: The GENERIC_NOP5_ATOMIC is at the end, as it breaks the * nice symmetry of sizes of the previous nops. */ #if defined(GENERIC_NOP1) && !defined(CONFIG_X86_64) static const unsigned char intelnops[] = { GENERIC_NOP1, GENERIC_NOP2, GENERIC_NOP3, GENERIC_NOP4, GENERIC_NOP5, GENERIC_NOP6, GENERIC_NOP7, GENERIC_NOP8, GENERIC_NOP5_ATOMIC }; static const unsigned char * const intel_nops[ASM_NOP_MAX+2] = { NULL, intelnops, intelnops + 1, intelnops + 1 + 2, intelnops + 1 + 2 + 3, intelnops + 1 + 2 + 3 + 4, intelnops + 1 + 2 + 3 + 4 + 5, intelnops + 1 + 2 + 3 + 4 + 5 + 6, intelnops + 1 + 2 + 3 + 4 + 5 + 6 + 7, intelnops + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8, }; #endif #ifdef K8_NOP1 static const unsigned char k8nops[] = { K8_NOP1, K8_NOP2, K8_NOP3, K8_NOP4, K8_NOP5, K8_NOP6, K8_NOP7, K8_NOP8, K8_NOP5_ATOMIC }; static const unsigned char * const k8_nops[ASM_NOP_MAX+2] = { NULL, k8nops, k8nops + 1, k8nops + 1 + 2, k8nops + 1 + 2 + 3, k8nops + 1 + 2 + 3 + 4, k8nops + 1 + 2 + 3 + 4 + 5, k8nops + 1 + 2 + 3 + 4 + 5 + 6, k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7, k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8, }; #endif #if defined(K7_NOP1) && !defined(CONFIG_X86_64) static const unsigned char k7nops[] = { K7_NOP1, K7_NOP2, K7_NOP3, K7_NOP4, K7_NOP5, K7_NOP6, K7_NOP7, K7_NOP8, K7_NOP5_ATOMIC }; static const unsigned char * const k7_nops[ASM_NOP_MAX+2] = { NULL, k7nops, k7nops + 1, k7nops + 1 + 2, k7nops + 1 + 2 + 3, k7nops + 1 + 2 + 3 + 4, k7nops + 1 + 2 + 3 + 4 + 5, k7nops + 1 + 2 + 3 + 4 + 5 + 6, k7nops + 1 + 2 + 3 + 4 + 5 + 6 + 7, k7nops + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8, }; #endif #ifdef P6_NOP1 static const unsigned char p6nops[] = { P6_NOP1, P6_NOP2, P6_NOP3, P6_NOP4, P6_NOP5, P6_NOP6, P6_NOP7, P6_NOP8, P6_NOP5_ATOMIC }; static const unsigned char * const p6_nops[ASM_NOP_MAX+2] = { NULL, p6nops, p6nops + 1, p6nops + 1 + 2, p6nops + 1 + 2 + 3, p6nops + 1 + 2 + 3 + 4, p6nops + 1 + 2 + 3 + 4 + 5, p6nops + 1 + 2 + 3 + 4 + 5 + 6, p6nops + 1 + 2 + 3 + 4 + 5 + 6 + 7, p6nops + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8, }; #endif /* Initialize these to a safe default */ #ifdef CONFIG_X86_64 const unsigned char * const *ideal_nops = p6_nops; #else const unsigned char * const *ideal_nops = intel_nops; #endif void __init arch_init_ideal_nops(void) { switch (boot_cpu_data.x86_vendor) { case X86_VENDOR_INTEL: /* * Due to a decoder implementation quirk, some * specific Intel CPUs actually perform better with * the "k8_nops" than with the SDM-recommended NOPs. */ if (boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model >= 0x0f && boot_cpu_data.x86_model != 0x1c && boot_cpu_data.x86_model != 0x26 && boot_cpu_data.x86_model != 0x27 && boot_cpu_data.x86_model < 0x30) { ideal_nops = k8_nops; } else if (boot_cpu_has(X86_FEATURE_NOPL)) { ideal_nops = p6_nops; } else { #ifdef CONFIG_X86_64 ideal_nops = k8_nops; #else ideal_nops = intel_nops; #endif } break; default: #ifdef CONFIG_X86_64 ideal_nops = k8_nops; #else if (boot_cpu_has(X86_FEATURE_K8)) ideal_nops = k8_nops; else if (boot_cpu_has(X86_FEATURE_K7)) ideal_nops = k7_nops; else ideal_nops = intel_nops; #endif } } /* Use this to add nops to a buffer, then text_poke the whole buffer. */ static void __init_or_module add_nops(void *insns, unsigned int len) { while (len > 0) { unsigned int noplen = len; if (noplen > ASM_NOP_MAX) noplen = ASM_NOP_MAX; memcpy(insns, ideal_nops[noplen], noplen); insns += noplen; len -= noplen; } } extern struct alt_instr __alt_instructions[], __alt_instructions_end[]; extern s32 __smp_locks[], __smp_locks_end[]; void *text_poke_early(void *addr, const void *opcode, size_t len); /* Replace instructions with better alternatives for this CPU type. This runs before SMP is initialized to avoid SMP problems with self modifying code. This implies that asymmetric systems where APs have less capabilities than the boot processor are not handled. Tough. Make sure you disable such features by hand. */ void __init_or_module apply_alternatives(struct alt_instr *start, struct alt_instr *end) { struct alt_instr *a; u8 *instr, *replacement; u8 insnbuf[MAX_PATCH_LEN]; DPRINTK("%s: alt table %p -> %p\n", __func__, start, end); /* * The scan order should be from start to end. A later scanned * alternative code can overwrite a previous scanned alternative code. * Some kernel functions (e.g. memcpy, memset, etc) use this order to * patch code. * * So be careful if you want to change the scan order to any other * order. */ for (a = start; a < end; a++) { instr = (u8 *)&a->instr_offset + a->instr_offset; replacement = (u8 *)&a->repl_offset + a->repl_offset; BUG_ON(a->replacementlen > a->instrlen); BUG_ON(a->instrlen > sizeof(insnbuf)); BUG_ON(a->cpuid >= (NCAPINTS + NBUGINTS) * 32); if (!boot_cpu_has(a->cpuid)) continue; memcpy(insnbuf, replacement, a->replacementlen); /* 0xe8 is a relative jump; fix the offset. */ if (*insnbuf == 0xe8 && a->replacementlen == 5) *(s32 *)(insnbuf + 1) += replacement - instr; add_nops(insnbuf + a->replacementlen, a->instrlen - a->replacementlen); text_poke_early(instr, insnbuf, a->instrlen); } } #ifdef CONFIG_SMP static void alternatives_smp_lock(const s32 *start, const s32 *end, u8 *text, u8 *text_end) { const s32 *poff; mutex_lock(&text_mutex); for (poff = start; poff < end; poff++) { u8 *ptr = (u8 *)poff + *poff; if (!*poff || ptr < text || ptr >= text_end) continue; /* turn DS segment override prefix into lock prefix */ if (*ptr == 0x3e) text_poke(ptr, ((unsigned char []){0xf0}), 1); } mutex_unlock(&text_mutex); } static void alternatives_smp_unlock(const s32 *start, const s32 *end, u8 *text, u8 *text_end) { const s32 *poff; mutex_lock(&text_mutex); for (poff = start; poff < end; poff++) { u8 *ptr = (u8 *)poff + *poff; if (!*poff || ptr < text || ptr >= text_end) continue; /* turn lock prefix into DS segment override prefix */ if (*ptr == 0xf0) text_poke(ptr, ((unsigned char []){0x3E}), 1); } mutex_unlock(&text_mutex); } struct smp_alt_module { /* what is this ??? */ struct module *mod; char *name; /* ptrs to lock prefixes */ const s32 *locks; const s32 *locks_end; /* .text segment, needed to avoid patching init code ;) */ u8 *text; u8 *text_end; struct list_head next; }; static LIST_HEAD(smp_alt_modules); static DEFINE_MUTEX(smp_alt); static bool uniproc_patched = false; /* protected by smp_alt */ void __init_or_module alternatives_smp_module_add(struct module *mod, char *name, void *locks, void *locks_end, void *text, void *text_end) { struct smp_alt_module *smp; mutex_lock(&smp_alt); if (!uniproc_patched) goto unlock; if (num_possible_cpus() == 1) /* Don't bother remembering, we'll never have to undo it. */ goto smp_unlock; smp = kzalloc(sizeof(*smp), GFP_KERNEL); if (NULL == smp) /* we'll run the (safe but slow) SMP code then ... */ goto unlock; smp->mod = mod; smp->name = name; smp->locks = locks; smp->locks_end = locks_end; smp->text = text; smp->text_end = text_end; DPRINTK("%s: locks %p -> %p, text %p -> %p, name %s\n", __func__, smp->locks, smp->locks_end, smp->text, smp->text_end, smp->name); list_add_tail(&smp->next, &smp_alt_modules); smp_unlock: alternatives_smp_unlock(locks, locks_end, text, text_end); unlock: mutex_unlock(&smp_alt); } void __init_or_module alternatives_smp_module_del(struct module *mod) { struct smp_alt_module *item; mutex_lock(&smp_alt); list_for_each_entry(item, &smp_alt_modules, next) { if (mod != item->mod) continue; list_del(&item->next); kfree(item); break; } mutex_unlock(&smp_alt); } void alternatives_enable_smp(void) { struct smp_alt_module *mod; /* Why bother if there are no other CPUs? */ BUG_ON(num_possible_cpus() == 1); mutex_lock(&smp_alt); if (uniproc_patched) { pr_info("switching to SMP code\n"); BUG_ON(num_online_cpus() != 1); clear_cpu_cap(&boot_cpu_data, X86_FEATURE_UP); clear_cpu_cap(&cpu_data(0), X86_FEATURE_UP); list_for_each_entry(mod, &smp_alt_modules, next) alternatives_smp_lock(mod->locks, mod->locks_end, mod->text, mod->text_end); uniproc_patched = false; } mutex_unlock(&smp_alt); } /* Return 1 if the address range is reserved for smp-alternatives */ int alternatives_text_reserved(void *start, void *end) { struct smp_alt_module *mod; const s32 *poff; u8 *text_start = start; u8 *text_end = end; list_for_each_entry(mod, &smp_alt_modules, next) { if (mod->text > text_end || mod->text_end < text_start) continue; for (poff = mod->locks; poff < mod->locks_end; poff++) { const u8 *ptr = (const u8 *)poff + *poff; if (text_start <= ptr && text_end > ptr) return 1; } } return 0; } #endif #ifdef CONFIG_PARAVIRT void __init_or_module apply_paravirt(struct paravirt_patch_site *start, struct paravirt_patch_site *end) { struct paravirt_patch_site *p; char insnbuf[MAX_PATCH_LEN]; if (noreplace_paravirt) return; for (p = start; p < end; p++) { unsigned int used; BUG_ON(p->len > MAX_PATCH_LEN); /* prep the buffer with the original instructions */ memcpy(insnbuf, p->instr, p->len); used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf, (unsigned long)p->instr, p->len); BUG_ON(used > p->len); /* Pad the rest with nops */ add_nops(insnbuf + used, p->len - used); text_poke_early(p->instr, insnbuf, p->len); } } extern struct paravirt_patch_site __start_parainstructions[], __stop_parainstructions[]; #endif /* CONFIG_PARAVIRT */ void __init alternative_instructions(void) { /* The patching is not fully atomic, so try to avoid local interruptions that might execute the to be patched code. Other CPUs are not running. */ stop_nmi(); /* * Don't stop machine check exceptions while patching. * MCEs only happen when something got corrupted and in this * case we must do something about the corruption. * Ignoring it is worse than a unlikely patching race. * Also machine checks tend to be broadcast and if one CPU * goes into machine check the others follow quickly, so we don't * expect a machine check to cause undue problems during to code * patching. */ apply_alternatives(__alt_instructions, __alt_instructions_end); #ifdef CONFIG_SMP /* Patch to UP if other cpus not imminent. */ if (!noreplace_smp && (num_present_cpus() == 1 || setup_max_cpus <= 1)) { uniproc_patched = true; alternatives_smp_module_add(NULL, "core kernel", __smp_locks, __smp_locks_end, _text, _etext); } if (!uniproc_patched || num_possible_cpus() == 1) free_init_pages("SMP alternatives", (unsigned long)__smp_locks, (unsigned long)__smp_locks_end); #endif apply_paravirt(__parainstructions, __parainstructions_end); restart_nmi(); } /** * text_poke_early - Update instructions on a live kernel at boot time * @addr: address to modify * @opcode: source of the copy * @len: length to copy * * When you use this code to patch more than one byte of an instruction * you need to make sure that other CPUs cannot execute this code in parallel. * Also no thread must be currently preempted in the middle of these * instructions. And on the local CPU you need to be protected again NMI or MCE * handlers seeing an inconsistent instruction while you patch. */ void *__init_or_module text_poke_early(void *addr, const void *opcode, size_t len) { unsigned long flags; local_irq_save(flags); memcpy(addr, opcode, len); sync_core(); local_irq_restore(flags); /* Could also do a CLFLUSH here to speed up CPU recovery; but that causes hangs on some VIA CPUs. */ return addr; } /** * text_poke - Update instructions on a live kernel * @addr: address to modify * @opcode: source of the copy * @len: length to copy * * Only atomic text poke/set should be allowed when not doing early patching. * It means the size must be writable atomically and the address must be aligned * in a way that permits an atomic write. It also makes sure we fit on a single * page. * * Note: Must be called under text_mutex. */ void *__kprobes text_poke(void *addr, const void *opcode, size_t len) { unsigned long flags; char *vaddr; struct page *pages[2]; int i; if (!core_kernel_text((unsigned long)addr)) { pages[0] = vmalloc_to_page(addr); pages[1] = vmalloc_to_page(addr + PAGE_SIZE); } else { pages[0] = virt_to_page(addr); WARN_ON(!PageReserved(pages[0])); pages[1] = virt_to_page(addr + PAGE_SIZE); } BUG_ON(!pages[0]); local_irq_save(flags); set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0])); if (pages[1]) set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1])); vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0); memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len); clear_fixmap(FIX_TEXT_POKE0); if (pages[1]) clear_fixmap(FIX_TEXT_POKE1); local_flush_tlb(); sync_core(); /* Could also do a CLFLUSH here to speed up CPU recovery; but that causes hangs on some VIA CPUs. */ for (i = 0; i < len; i++) BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]); local_irq_restore(flags); return addr; } static void do_sync_core(void *info) { sync_core(); } static bool bp_patching_in_progress; static void *bp_int3_handler, *bp_int3_addr; int poke_int3_handler(struct pt_regs *regs) { /* bp_patching_in_progress */ smp_rmb(); if (likely(!bp_patching_in_progress)) return 0; if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr) return 0; /* set up the specified breakpoint handler */ regs->ip = (unsigned long) bp_int3_handler; return 1; } /** * text_poke_bp() -- update instructions on live kernel on SMP * @addr: address to patch * @opcode: opcode of new instruction * @len: length to copy * @handler: address to jump to when the temporary breakpoint is hit * * Modify multi-byte instruction by using int3 breakpoint on SMP. * We completely avoid stop_machine() here, and achieve the * synchronization using int3 breakpoint. * * The way it is done: * - add a int3 trap to the address that will be patched * - sync cores * - update all but the first byte of the patched range * - sync cores * - replace the first byte (int3) by the first byte of * replacing opcode * - sync cores * * Note: must be called under text_mutex. */ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler) { unsigned char int3 = 0xcc; bp_int3_handler = handler; bp_int3_addr = (u8 *)addr + sizeof(int3); bp_patching_in_progress = true; /* * Corresponding read barrier in int3 notifier for * making sure the in_progress flags is correctly ordered wrt. * patching */ smp_wmb(); text_poke(addr, &int3, sizeof(int3)); on_each_cpu(do_sync_core, NULL, 1); if (len - sizeof(int3) > 0) { /* patch all but the first byte */ text_poke((char *)addr + sizeof(int3), (const char *) opcode + sizeof(int3), len - sizeof(int3)); /* * According to Intel, this core syncing is very likely * not necessary and we'd be safe even without it. But * better safe than sorry (plus there's not only Intel). */ on_each_cpu(do_sync_core, NULL, 1); } /* patch the first byte */ text_poke(addr, opcode, sizeof(int3)); on_each_cpu(do_sync_core, NULL, 1); bp_patching_in_progress = false; smp_wmb(); return addr; }
gpl-2.0
EmbeddedAndroid/linaro-android-3.1
drivers/net/bnx2x/bnx2x_main.c
374
315028
/* bnx2x_main.c: Broadcom Everest network driver. * * Copyright (c) 2007-2011 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation. * * Maintained by: Eilon Greenstein <eilong@broadcom.com> * Written by: Eliezer Tamir * Based on code from Michael Chan's bnx2 driver * UDP CSUM errata workaround by Arik Gendelman * Slowpath and fastpath rework by Vladislav Zolotarov * Statistics and Link management by Yitchak Gertner * */ #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kernel.h> #include <linux/device.h> /* for dev_info() */ #include <linux/timer.h> #include <linux/errno.h> #include <linux/ioport.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/pci.h> #include <linux/init.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> #include <linux/dma-mapping.h> #include <linux/bitops.h> #include <linux/irq.h> #include <linux/delay.h> #include <asm/byteorder.h> #include <linux/time.h> #include <linux/ethtool.h> #include <linux/mii.h> #include <linux/if_vlan.h> #include <net/ip.h> #include <net/ipv6.h> #include <net/tcp.h> #include <net/checksum.h> #include <net/ip6_checksum.h> #include <linux/workqueue.h> #include <linux/crc32.h> #include <linux/crc32c.h> #include <linux/prefetch.h> #include <linux/zlib.h> #include <linux/io.h> #include <linux/stringify.h> #include <linux/vmalloc.h> #include "bnx2x.h" #include "bnx2x_init.h" #include "bnx2x_init_ops.h" #include "bnx2x_cmn.h" #include "bnx2x_dcb.h" #include "bnx2x_sp.h" #include <linux/firmware.h> #include "bnx2x_fw_file_hdr.h" /* FW files */ #define FW_FILE_VERSION \ __stringify(BCM_5710_FW_MAJOR_VERSION) "." \ __stringify(BCM_5710_FW_MINOR_VERSION) "." \ __stringify(BCM_5710_FW_REVISION_VERSION) "." \ __stringify(BCM_5710_FW_ENGINEERING_VERSION) #define FW_FILE_NAME_E1 "bnx2x/bnx2x-e1-" FW_FILE_VERSION ".fw" #define FW_FILE_NAME_E1H "bnx2x/bnx2x-e1h-" FW_FILE_VERSION ".fw" #define FW_FILE_NAME_E2 "bnx2x/bnx2x-e2-" FW_FILE_VERSION ".fw" /* Time in jiffies before concluding the transmitter is hung */ #define TX_TIMEOUT (5*HZ) static char version[] __devinitdata = "Broadcom NetXtreme II 5771x/578xx 10/20-Gigabit Ethernet Driver " DRV_MODULE_NAME " " DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; MODULE_AUTHOR("Eliezer Tamir"); MODULE_DESCRIPTION("Broadcom NetXtreme II " "BCM57710/57711/57711E/" "57712/57712_MF/57800/57800_MF/57810/57810_MF/" "57840/57840_MF Driver"); MODULE_LICENSE("GPL"); MODULE_VERSION(DRV_MODULE_VERSION); MODULE_FIRMWARE(FW_FILE_NAME_E1); MODULE_FIRMWARE(FW_FILE_NAME_E1H); MODULE_FIRMWARE(FW_FILE_NAME_E2); static int multi_mode = 1; module_param(multi_mode, int, 0); MODULE_PARM_DESC(multi_mode, " Multi queue mode " "(0 Disable; 1 Enable (default))"); int num_queues; module_param(num_queues, int, 0); MODULE_PARM_DESC(num_queues, " Number of queues for multi_mode=1" " (default is as a number of CPUs)"); static int disable_tpa; module_param(disable_tpa, int, 0); MODULE_PARM_DESC(disable_tpa, " Disable the TPA (LRO) feature"); #define INT_MODE_INTx 1 #define INT_MODE_MSI 2 static int int_mode; module_param(int_mode, int, 0); MODULE_PARM_DESC(int_mode, " Force interrupt mode other than MSI-X " "(1 INT#x; 2 MSI)"); static int dropless_fc; module_param(dropless_fc, int, 0); MODULE_PARM_DESC(dropless_fc, " Pause on exhausted host ring"); static int poll; module_param(poll, int, 0); MODULE_PARM_DESC(poll, " Use polling (for debug)"); static int mrrs = -1; module_param(mrrs, int, 0); MODULE_PARM_DESC(mrrs, " Force Max Read Req Size (0..3) (for debug)"); static int debug; module_param(debug, int, 0); MODULE_PARM_DESC(debug, " Default debug msglevel"); struct workqueue_struct *bnx2x_wq; enum bnx2x_board_type { BCM57710 = 0, BCM57711, BCM57711E, BCM57712, BCM57712_MF, BCM57800, BCM57800_MF, BCM57810, BCM57810_MF, BCM57840, BCM57840_MF }; /* indexed by board_type, above */ static struct { char *name; } board_info[] __devinitdata = { { "Broadcom NetXtreme II BCM57710 10 Gigabit PCIe [Everest]" }, { "Broadcom NetXtreme II BCM57711 10 Gigabit PCIe" }, { "Broadcom NetXtreme II BCM57711E 10 Gigabit PCIe" }, { "Broadcom NetXtreme II BCM57712 10 Gigabit Ethernet" }, { "Broadcom NetXtreme II BCM57712 10 Gigabit Ethernet Multi Function" }, { "Broadcom NetXtreme II BCM57800 10 Gigabit Ethernet" }, { "Broadcom NetXtreme II BCM57800 10 Gigabit Ethernet Multi Function" }, { "Broadcom NetXtreme II BCM57810 10 Gigabit Ethernet" }, { "Broadcom NetXtreme II BCM57810 10 Gigabit Ethernet Multi Function" }, { "Broadcom NetXtreme II BCM57840 10/20 Gigabit Ethernet" }, { "Broadcom NetXtreme II BCM57840 10/20 Gigabit " "Ethernet Multi Function"} }; #ifndef PCI_DEVICE_ID_NX2_57710 #define PCI_DEVICE_ID_NX2_57710 CHIP_NUM_57710 #endif #ifndef PCI_DEVICE_ID_NX2_57711 #define PCI_DEVICE_ID_NX2_57711 CHIP_NUM_57711 #endif #ifndef PCI_DEVICE_ID_NX2_57711E #define PCI_DEVICE_ID_NX2_57711E CHIP_NUM_57711E #endif #ifndef PCI_DEVICE_ID_NX2_57712 #define PCI_DEVICE_ID_NX2_57712 CHIP_NUM_57712 #endif #ifndef PCI_DEVICE_ID_NX2_57712_MF #define PCI_DEVICE_ID_NX2_57712_MF CHIP_NUM_57712_MF #endif #ifndef PCI_DEVICE_ID_NX2_57800 #define PCI_DEVICE_ID_NX2_57800 CHIP_NUM_57800 #endif #ifndef PCI_DEVICE_ID_NX2_57800_MF #define PCI_DEVICE_ID_NX2_57800_MF CHIP_NUM_57800_MF #endif #ifndef PCI_DEVICE_ID_NX2_57810 #define PCI_DEVICE_ID_NX2_57810 CHIP_NUM_57810 #endif #ifndef PCI_DEVICE_ID_NX2_57810_MF #define PCI_DEVICE_ID_NX2_57810_MF CHIP_NUM_57810_MF #endif #ifndef PCI_DEVICE_ID_NX2_57840 #define PCI_DEVICE_ID_NX2_57840 CHIP_NUM_57840 #endif #ifndef PCI_DEVICE_ID_NX2_57840_MF #define PCI_DEVICE_ID_NX2_57840_MF CHIP_NUM_57840_MF #endif static DEFINE_PCI_DEVICE_TABLE(bnx2x_pci_tbl) = { { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57710), BCM57710 }, { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57711), BCM57711 }, { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57711E), BCM57711E }, { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57712), BCM57712 }, { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57712_MF), BCM57712_MF }, { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57800), BCM57800 }, { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57800_MF), BCM57800_MF }, { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57810), BCM57810 }, { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57810_MF), BCM57810_MF }, { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57840), BCM57840 }, { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57840_MF), BCM57840_MF }, { 0 } }; MODULE_DEVICE_TABLE(pci, bnx2x_pci_tbl); /**************************************************************************** * General service functions ****************************************************************************/ static inline void __storm_memset_dma_mapping(struct bnx2x *bp, u32 addr, dma_addr_t mapping) { REG_WR(bp, addr, U64_LO(mapping)); REG_WR(bp, addr + 4, U64_HI(mapping)); } static inline void storm_memset_spq_addr(struct bnx2x *bp, dma_addr_t mapping, u16 abs_fid) { u32 addr = XSEM_REG_FAST_MEMORY + XSTORM_SPQ_PAGE_BASE_OFFSET(abs_fid); __storm_memset_dma_mapping(bp, addr, mapping); } static inline void storm_memset_vf_to_pf(struct bnx2x *bp, u16 abs_fid, u16 pf_id) { REG_WR8(bp, BAR_XSTRORM_INTMEM + XSTORM_VF_TO_PF_OFFSET(abs_fid), pf_id); REG_WR8(bp, BAR_CSTRORM_INTMEM + CSTORM_VF_TO_PF_OFFSET(abs_fid), pf_id); REG_WR8(bp, BAR_TSTRORM_INTMEM + TSTORM_VF_TO_PF_OFFSET(abs_fid), pf_id); REG_WR8(bp, BAR_USTRORM_INTMEM + USTORM_VF_TO_PF_OFFSET(abs_fid), pf_id); } static inline void storm_memset_func_en(struct bnx2x *bp, u16 abs_fid, u8 enable) { REG_WR8(bp, BAR_XSTRORM_INTMEM + XSTORM_FUNC_EN_OFFSET(abs_fid), enable); REG_WR8(bp, BAR_CSTRORM_INTMEM + CSTORM_FUNC_EN_OFFSET(abs_fid), enable); REG_WR8(bp, BAR_TSTRORM_INTMEM + TSTORM_FUNC_EN_OFFSET(abs_fid), enable); REG_WR8(bp, BAR_USTRORM_INTMEM + USTORM_FUNC_EN_OFFSET(abs_fid), enable); } static inline void storm_memset_eq_data(struct bnx2x *bp, struct event_ring_data *eq_data, u16 pfid) { size_t size = sizeof(struct event_ring_data); u32 addr = BAR_CSTRORM_INTMEM + CSTORM_EVENT_RING_DATA_OFFSET(pfid); __storm_memset_struct(bp, addr, size, (u32 *)eq_data); } static inline void storm_memset_eq_prod(struct bnx2x *bp, u16 eq_prod, u16 pfid) { u32 addr = BAR_CSTRORM_INTMEM + CSTORM_EVENT_RING_PROD_OFFSET(pfid); REG_WR16(bp, addr, eq_prod); } /* used only at init * locking is done by mcp */ static void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val) { pci_write_config_dword(bp->pdev, PCICFG_GRC_ADDRESS, addr); pci_write_config_dword(bp->pdev, PCICFG_GRC_DATA, val); pci_write_config_dword(bp->pdev, PCICFG_GRC_ADDRESS, PCICFG_VENDOR_ID_OFFSET); } static u32 bnx2x_reg_rd_ind(struct bnx2x *bp, u32 addr) { u32 val; pci_write_config_dword(bp->pdev, PCICFG_GRC_ADDRESS, addr); pci_read_config_dword(bp->pdev, PCICFG_GRC_DATA, &val); pci_write_config_dword(bp->pdev, PCICFG_GRC_ADDRESS, PCICFG_VENDOR_ID_OFFSET); return val; } #define DMAE_DP_SRC_GRC "grc src_addr [%08x]" #define DMAE_DP_SRC_PCI "pci src_addr [%x:%08x]" #define DMAE_DP_DST_GRC "grc dst_addr [%08x]" #define DMAE_DP_DST_PCI "pci dst_addr [%x:%08x]" #define DMAE_DP_DST_NONE "dst_addr [none]" static void bnx2x_dp_dmae(struct bnx2x *bp, struct dmae_command *dmae, int msglvl) { u32 src_type = dmae->opcode & DMAE_COMMAND_SRC; switch (dmae->opcode & DMAE_COMMAND_DST) { case DMAE_CMD_DST_PCI: if (src_type == DMAE_CMD_SRC_PCI) DP(msglvl, "DMAE: opcode 0x%08x\n" "src [%x:%08x], len [%d*4], dst [%x:%08x]\n" "comp_addr [%x:%08x], comp_val 0x%08x\n", dmae->opcode, dmae->src_addr_hi, dmae->src_addr_lo, dmae->len, dmae->dst_addr_hi, dmae->dst_addr_lo, dmae->comp_addr_hi, dmae->comp_addr_lo, dmae->comp_val); else DP(msglvl, "DMAE: opcode 0x%08x\n" "src [%08x], len [%d*4], dst [%x:%08x]\n" "comp_addr [%x:%08x], comp_val 0x%08x\n", dmae->opcode, dmae->src_addr_lo >> 2, dmae->len, dmae->dst_addr_hi, dmae->dst_addr_lo, dmae->comp_addr_hi, dmae->comp_addr_lo, dmae->comp_val); break; case DMAE_CMD_DST_GRC: if (src_type == DMAE_CMD_SRC_PCI) DP(msglvl, "DMAE: opcode 0x%08x\n" "src [%x:%08x], len [%d*4], dst_addr [%08x]\n" "comp_addr [%x:%08x], comp_val 0x%08x\n", dmae->opcode, dmae->src_addr_hi, dmae->src_addr_lo, dmae->len, dmae->dst_addr_lo >> 2, dmae->comp_addr_hi, dmae->comp_addr_lo, dmae->comp_val); else DP(msglvl, "DMAE: opcode 0x%08x\n" "src [%08x], len [%d*4], dst [%08x]\n" "comp_addr [%x:%08x], comp_val 0x%08x\n", dmae->opcode, dmae->src_addr_lo >> 2, dmae->len, dmae->dst_addr_lo >> 2, dmae->comp_addr_hi, dmae->comp_addr_lo, dmae->comp_val); break; default: if (src_type == DMAE_CMD_SRC_PCI) DP(msglvl, "DMAE: opcode 0x%08x\n" DP_LEVEL "src_addr [%x:%08x] len [%d * 4] " "dst_addr [none]\n" DP_LEVEL "comp_addr [%x:%08x] comp_val 0x%08x\n", dmae->opcode, dmae->src_addr_hi, dmae->src_addr_lo, dmae->len, dmae->comp_addr_hi, dmae->comp_addr_lo, dmae->comp_val); else DP(msglvl, "DMAE: opcode 0x%08x\n" DP_LEVEL "src_addr [%08x] len [%d * 4] " "dst_addr [none]\n" DP_LEVEL "comp_addr [%x:%08x] comp_val 0x%08x\n", dmae->opcode, dmae->src_addr_lo >> 2, dmae->len, dmae->comp_addr_hi, dmae->comp_addr_lo, dmae->comp_val); break; } } /* copy command into DMAE command memory and set DMAE command go */ void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx) { u32 cmd_offset; int i; cmd_offset = (DMAE_REG_CMD_MEM + sizeof(struct dmae_command) * idx); for (i = 0; i < (sizeof(struct dmae_command)/4); i++) { REG_WR(bp, cmd_offset + i*4, *(((u32 *)dmae) + i)); DP(BNX2X_MSG_OFF, "DMAE cmd[%d].%d (0x%08x) : 0x%08x\n", idx, i, cmd_offset + i*4, *(((u32 *)dmae) + i)); } REG_WR(bp, dmae_reg_go_c[idx], 1); } u32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type) { return opcode | ((comp_type << DMAE_COMMAND_C_DST_SHIFT) | DMAE_CMD_C_ENABLE); } u32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode) { return opcode & ~DMAE_CMD_SRC_RESET; } u32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type, bool with_comp, u8 comp_type) { u32 opcode = 0; opcode |= ((src_type << DMAE_COMMAND_SRC_SHIFT) | (dst_type << DMAE_COMMAND_DST_SHIFT)); opcode |= (DMAE_CMD_SRC_RESET | DMAE_CMD_DST_RESET); opcode |= (BP_PORT(bp) ? DMAE_CMD_PORT_1 : DMAE_CMD_PORT_0); opcode |= ((BP_VN(bp) << DMAE_CMD_E1HVN_SHIFT) | (BP_VN(bp) << DMAE_COMMAND_DST_VN_SHIFT)); opcode |= (DMAE_COM_SET_ERR << DMAE_COMMAND_ERR_POLICY_SHIFT); #ifdef __BIG_ENDIAN opcode |= DMAE_CMD_ENDIANITY_B_DW_SWAP; #else opcode |= DMAE_CMD_ENDIANITY_DW_SWAP; #endif if (with_comp) opcode = bnx2x_dmae_opcode_add_comp(opcode, comp_type); return opcode; } static void bnx2x_prep_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae, u8 src_type, u8 dst_type) { memset(dmae, 0, sizeof(struct dmae_command)); /* set the opcode */ dmae->opcode = bnx2x_dmae_opcode(bp, src_type, dst_type, true, DMAE_COMP_PCI); /* fill in the completion parameters */ dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, wb_comp)); dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, wb_comp)); dmae->comp_val = DMAE_COMP_VAL; } /* issue a dmae command over the init-channel and wailt for completion */ static int bnx2x_issue_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae) { u32 *wb_comp = bnx2x_sp(bp, wb_comp); int cnt = CHIP_REV_IS_SLOW(bp) ? (400000) : 4000; int rc = 0; DP(BNX2X_MSG_OFF, "data before [0x%08x 0x%08x 0x%08x 0x%08x]\n", bp->slowpath->wb_data[0], bp->slowpath->wb_data[1], bp->slowpath->wb_data[2], bp->slowpath->wb_data[3]); /* * Lock the dmae channel. Disable BHs to prevent a dead-lock * as long as this code is called both from syscall context and * from ndo_set_rx_mode() flow that may be called from BH. */ spin_lock_bh(&bp->dmae_lock); /* reset completion */ *wb_comp = 0; /* post the command on the channel used for initializations */ bnx2x_post_dmae(bp, dmae, INIT_DMAE_C(bp)); /* wait for completion */ udelay(5); while ((*wb_comp & ~DMAE_PCI_ERR_FLAG) != DMAE_COMP_VAL) { DP(BNX2X_MSG_OFF, "wb_comp 0x%08x\n", *wb_comp); if (!cnt) { BNX2X_ERR("DMAE timeout!\n"); rc = DMAE_TIMEOUT; goto unlock; } cnt--; udelay(50); } if (*wb_comp & DMAE_PCI_ERR_FLAG) { BNX2X_ERR("DMAE PCI error!\n"); rc = DMAE_PCI_ERROR; } DP(BNX2X_MSG_OFF, "data after [0x%08x 0x%08x 0x%08x 0x%08x]\n", bp->slowpath->wb_data[0], bp->slowpath->wb_data[1], bp->slowpath->wb_data[2], bp->slowpath->wb_data[3]); unlock: spin_unlock_bh(&bp->dmae_lock); return rc; } void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr, u32 len32) { struct dmae_command dmae; if (!bp->dmae_ready) { u32 *data = bnx2x_sp(bp, wb_data[0]); DP(BNX2X_MSG_OFF, "DMAE is not ready (dst_addr %08x len32 %d)" " using indirect\n", dst_addr, len32); bnx2x_init_ind_wr(bp, dst_addr, data, len32); return; } /* set opcode and fixed command fields */ bnx2x_prep_dmae_with_comp(bp, &dmae, DMAE_SRC_PCI, DMAE_DST_GRC); /* fill in addresses and len */ dmae.src_addr_lo = U64_LO(dma_addr); dmae.src_addr_hi = U64_HI(dma_addr); dmae.dst_addr_lo = dst_addr >> 2; dmae.dst_addr_hi = 0; dmae.len = len32; bnx2x_dp_dmae(bp, &dmae, BNX2X_MSG_OFF); /* issue the command and wait for completion */ bnx2x_issue_dmae_with_comp(bp, &dmae); } void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32) { struct dmae_command dmae; if (!bp->dmae_ready) { u32 *data = bnx2x_sp(bp, wb_data[0]); int i; DP(BNX2X_MSG_OFF, "DMAE is not ready (src_addr %08x len32 %d)" " using indirect\n", src_addr, len32); for (i = 0; i < len32; i++) data[i] = bnx2x_reg_rd_ind(bp, src_addr + i*4); return; } /* set opcode and fixed command fields */ bnx2x_prep_dmae_with_comp(bp, &dmae, DMAE_SRC_GRC, DMAE_DST_PCI); /* fill in addresses and len */ dmae.src_addr_lo = src_addr >> 2; dmae.src_addr_hi = 0; dmae.dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, wb_data)); dmae.dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, wb_data)); dmae.len = len32; bnx2x_dp_dmae(bp, &dmae, BNX2X_MSG_OFF); /* issue the command and wait for completion */ bnx2x_issue_dmae_with_comp(bp, &dmae); } static void bnx2x_write_dmae_phys_len(struct bnx2x *bp, dma_addr_t phys_addr, u32 addr, u32 len) { int dmae_wr_max = DMAE_LEN32_WR_MAX(bp); int offset = 0; while (len > dmae_wr_max) { bnx2x_write_dmae(bp, phys_addr + offset, addr + offset, dmae_wr_max); offset += dmae_wr_max * 4; len -= dmae_wr_max; } bnx2x_write_dmae(bp, phys_addr + offset, addr + offset, len); } /* used only for slowpath so not inlined */ static void bnx2x_wb_wr(struct bnx2x *bp, int reg, u32 val_hi, u32 val_lo) { u32 wb_write[2]; wb_write[0] = val_hi; wb_write[1] = val_lo; REG_WR_DMAE(bp, reg, wb_write, 2); } #ifdef USE_WB_RD static u64 bnx2x_wb_rd(struct bnx2x *bp, int reg) { u32 wb_data[2]; REG_RD_DMAE(bp, reg, wb_data, 2); return HILO_U64(wb_data[0], wb_data[1]); } #endif static int bnx2x_mc_assert(struct bnx2x *bp) { char last_idx; int i, rc = 0; u32 row0, row1, row2, row3; /* XSTORM */ last_idx = REG_RD8(bp, BAR_XSTRORM_INTMEM + XSTORM_ASSERT_LIST_INDEX_OFFSET); if (last_idx) BNX2X_ERR("XSTORM_ASSERT_LIST_INDEX 0x%x\n", last_idx); /* print the asserts */ for (i = 0; i < STROM_ASSERT_ARRAY_SIZE; i++) { row0 = REG_RD(bp, BAR_XSTRORM_INTMEM + XSTORM_ASSERT_LIST_OFFSET(i)); row1 = REG_RD(bp, BAR_XSTRORM_INTMEM + XSTORM_ASSERT_LIST_OFFSET(i) + 4); row2 = REG_RD(bp, BAR_XSTRORM_INTMEM + XSTORM_ASSERT_LIST_OFFSET(i) + 8); row3 = REG_RD(bp, BAR_XSTRORM_INTMEM + XSTORM_ASSERT_LIST_OFFSET(i) + 12); if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) { BNX2X_ERR("XSTORM_ASSERT_INDEX 0x%x = 0x%08x" " 0x%08x 0x%08x 0x%08x\n", i, row3, row2, row1, row0); rc++; } else { break; } } /* TSTORM */ last_idx = REG_RD8(bp, BAR_TSTRORM_INTMEM + TSTORM_ASSERT_LIST_INDEX_OFFSET); if (last_idx) BNX2X_ERR("TSTORM_ASSERT_LIST_INDEX 0x%x\n", last_idx); /* print the asserts */ for (i = 0; i < STROM_ASSERT_ARRAY_SIZE; i++) { row0 = REG_RD(bp, BAR_TSTRORM_INTMEM + TSTORM_ASSERT_LIST_OFFSET(i)); row1 = REG_RD(bp, BAR_TSTRORM_INTMEM + TSTORM_ASSERT_LIST_OFFSET(i) + 4); row2 = REG_RD(bp, BAR_TSTRORM_INTMEM + TSTORM_ASSERT_LIST_OFFSET(i) + 8); row3 = REG_RD(bp, BAR_TSTRORM_INTMEM + TSTORM_ASSERT_LIST_OFFSET(i) + 12); if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) { BNX2X_ERR("TSTORM_ASSERT_INDEX 0x%x = 0x%08x" " 0x%08x 0x%08x 0x%08x\n", i, row3, row2, row1, row0); rc++; } else { break; } } /* CSTORM */ last_idx = REG_RD8(bp, BAR_CSTRORM_INTMEM + CSTORM_ASSERT_LIST_INDEX_OFFSET); if (last_idx) BNX2X_ERR("CSTORM_ASSERT_LIST_INDEX 0x%x\n", last_idx); /* print the asserts */ for (i = 0; i < STROM_ASSERT_ARRAY_SIZE; i++) { row0 = REG_RD(bp, BAR_CSTRORM_INTMEM + CSTORM_ASSERT_LIST_OFFSET(i)); row1 = REG_RD(bp, BAR_CSTRORM_INTMEM + CSTORM_ASSERT_LIST_OFFSET(i) + 4); row2 = REG_RD(bp, BAR_CSTRORM_INTMEM + CSTORM_ASSERT_LIST_OFFSET(i) + 8); row3 = REG_RD(bp, BAR_CSTRORM_INTMEM + CSTORM_ASSERT_LIST_OFFSET(i) + 12); if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) { BNX2X_ERR("CSTORM_ASSERT_INDEX 0x%x = 0x%08x" " 0x%08x 0x%08x 0x%08x\n", i, row3, row2, row1, row0); rc++; } else { break; } } /* USTORM */ last_idx = REG_RD8(bp, BAR_USTRORM_INTMEM + USTORM_ASSERT_LIST_INDEX_OFFSET); if (last_idx) BNX2X_ERR("USTORM_ASSERT_LIST_INDEX 0x%x\n", last_idx); /* print the asserts */ for (i = 0; i < STROM_ASSERT_ARRAY_SIZE; i++) { row0 = REG_RD(bp, BAR_USTRORM_INTMEM + USTORM_ASSERT_LIST_OFFSET(i)); row1 = REG_RD(bp, BAR_USTRORM_INTMEM + USTORM_ASSERT_LIST_OFFSET(i) + 4); row2 = REG_RD(bp, BAR_USTRORM_INTMEM + USTORM_ASSERT_LIST_OFFSET(i) + 8); row3 = REG_RD(bp, BAR_USTRORM_INTMEM + USTORM_ASSERT_LIST_OFFSET(i) + 12); if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) { BNX2X_ERR("USTORM_ASSERT_INDEX 0x%x = 0x%08x" " 0x%08x 0x%08x 0x%08x\n", i, row3, row2, row1, row0); rc++; } else { break; } } return rc; } void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl) { u32 addr, val; u32 mark, offset; __be32 data[9]; int word; u32 trace_shmem_base; if (BP_NOMCP(bp)) { BNX2X_ERR("NO MCP - can not dump\n"); return; } netdev_printk(lvl, bp->dev, "bc %d.%d.%d\n", (bp->common.bc_ver & 0xff0000) >> 16, (bp->common.bc_ver & 0xff00) >> 8, (bp->common.bc_ver & 0xff)); val = REG_RD(bp, MCP_REG_MCPR_CPU_PROGRAM_COUNTER); if (val == REG_RD(bp, MCP_REG_MCPR_CPU_PROGRAM_COUNTER)) printk("%s" "MCP PC at 0x%x\n", lvl, val); if (BP_PATH(bp) == 0) trace_shmem_base = bp->common.shmem_base; else trace_shmem_base = SHMEM2_RD(bp, other_shmem_base_addr); addr = trace_shmem_base - 0x0800 + 4; mark = REG_RD(bp, addr); mark = (CHIP_IS_E1x(bp) ? MCP_REG_MCPR_SCRATCH : MCP_A_REG_MCPR_SCRATCH) + ((mark + 0x3) & ~0x3) - 0x08000000; printk("%s" "begin fw dump (mark 0x%x)\n", lvl, mark); printk("%s", lvl); for (offset = mark; offset <= trace_shmem_base; offset += 0x8*4) { for (word = 0; word < 8; word++) data[word] = htonl(REG_RD(bp, offset + 4*word)); data[8] = 0x0; pr_cont("%s", (char *)data); } for (offset = addr + 4; offset <= mark; offset += 0x8*4) { for (word = 0; word < 8; word++) data[word] = htonl(REG_RD(bp, offset + 4*word)); data[8] = 0x0; pr_cont("%s", (char *)data); } printk("%s" "end of fw dump\n", lvl); } static inline void bnx2x_fw_dump(struct bnx2x *bp) { bnx2x_fw_dump_lvl(bp, KERN_ERR); } void bnx2x_panic_dump(struct bnx2x *bp) { int i; u16 j; struct hc_sp_status_block_data sp_sb_data; int func = BP_FUNC(bp); #ifdef BNX2X_STOP_ON_ERROR u16 start = 0, end = 0; u8 cos; #endif bp->stats_state = STATS_STATE_DISABLED; DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n"); BNX2X_ERR("begin crash dump -----------------\n"); /* Indices */ /* Common */ BNX2X_ERR("def_idx(0x%x) def_att_idx(0x%x) attn_state(0x%x)" " spq_prod_idx(0x%x) next_stats_cnt(0x%x)\n", bp->def_idx, bp->def_att_idx, bp->attn_state, bp->spq_prod_idx, bp->stats_counter); BNX2X_ERR("DSB: attn bits(0x%x) ack(0x%x) id(0x%x) idx(0x%x)\n", bp->def_status_blk->atten_status_block.attn_bits, bp->def_status_blk->atten_status_block.attn_bits_ack, bp->def_status_blk->atten_status_block.status_block_id, bp->def_status_blk->atten_status_block.attn_bits_index); BNX2X_ERR(" def ("); for (i = 0; i < HC_SP_SB_MAX_INDICES; i++) pr_cont("0x%x%s", bp->def_status_blk->sp_sb.index_values[i], (i == HC_SP_SB_MAX_INDICES - 1) ? ") " : " "); for (i = 0; i < sizeof(struct hc_sp_status_block_data)/sizeof(u32); i++) *((u32 *)&sp_sb_data + i) = REG_RD(bp, BAR_CSTRORM_INTMEM + CSTORM_SP_STATUS_BLOCK_DATA_OFFSET(func) + i*sizeof(u32)); pr_cont("igu_sb_id(0x%x) igu_seg_id(0x%x) " "pf_id(0x%x) vnic_id(0x%x) " "vf_id(0x%x) vf_valid (0x%x) " "state(0x%x)\n", sp_sb_data.igu_sb_id, sp_sb_data.igu_seg_id, sp_sb_data.p_func.pf_id, sp_sb_data.p_func.vnic_id, sp_sb_data.p_func.vf_id, sp_sb_data.p_func.vf_valid, sp_sb_data.state); for_each_eth_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; int loop; struct hc_status_block_data_e2 sb_data_e2; struct hc_status_block_data_e1x sb_data_e1x; struct hc_status_block_sm *hc_sm_p = CHIP_IS_E1x(bp) ? sb_data_e1x.common.state_machine : sb_data_e2.common.state_machine; struct hc_index_data *hc_index_p = CHIP_IS_E1x(bp) ? sb_data_e1x.index_data : sb_data_e2.index_data; u8 data_size, cos; u32 *sb_data_p; struct bnx2x_fp_txdata txdata; /* Rx */ BNX2X_ERR("fp%d: rx_bd_prod(0x%x) rx_bd_cons(0x%x)" " rx_comp_prod(0x%x)" " rx_comp_cons(0x%x) *rx_cons_sb(0x%x)\n", i, fp->rx_bd_prod, fp->rx_bd_cons, fp->rx_comp_prod, fp->rx_comp_cons, le16_to_cpu(*fp->rx_cons_sb)); BNX2X_ERR(" rx_sge_prod(0x%x) last_max_sge(0x%x)" " fp_hc_idx(0x%x)\n", fp->rx_sge_prod, fp->last_max_sge, le16_to_cpu(fp->fp_hc_idx)); /* Tx */ for_each_cos_in_tx_queue(fp, cos) { txdata = fp->txdata[cos]; BNX2X_ERR("fp%d: tx_pkt_prod(0x%x) tx_pkt_cons(0x%x)" " tx_bd_prod(0x%x) tx_bd_cons(0x%x)" " *tx_cons_sb(0x%x)\n", i, txdata.tx_pkt_prod, txdata.tx_pkt_cons, txdata.tx_bd_prod, txdata.tx_bd_cons, le16_to_cpu(*txdata.tx_cons_sb)); } loop = CHIP_IS_E1x(bp) ? HC_SB_MAX_INDICES_E1X : HC_SB_MAX_INDICES_E2; /* host sb data */ #ifdef BCM_CNIC if (IS_FCOE_FP(fp)) continue; #endif BNX2X_ERR(" run indexes ("); for (j = 0; j < HC_SB_MAX_SM; j++) pr_cont("0x%x%s", fp->sb_running_index[j], (j == HC_SB_MAX_SM - 1) ? ")" : " "); BNX2X_ERR(" indexes ("); for (j = 0; j < loop; j++) pr_cont("0x%x%s", fp->sb_index_values[j], (j == loop - 1) ? ")" : " "); /* fw sb data */ data_size = CHIP_IS_E1x(bp) ? sizeof(struct hc_status_block_data_e1x) : sizeof(struct hc_status_block_data_e2); data_size /= sizeof(u32); sb_data_p = CHIP_IS_E1x(bp) ? (u32 *)&sb_data_e1x : (u32 *)&sb_data_e2; /* copy sb data in here */ for (j = 0; j < data_size; j++) *(sb_data_p + j) = REG_RD(bp, BAR_CSTRORM_INTMEM + CSTORM_STATUS_BLOCK_DATA_OFFSET(fp->fw_sb_id) + j * sizeof(u32)); if (!CHIP_IS_E1x(bp)) { pr_cont("pf_id(0x%x) vf_id(0x%x) vf_valid(0x%x) " "vnic_id(0x%x) same_igu_sb_1b(0x%x) " "state(0x%x)\n", sb_data_e2.common.p_func.pf_id, sb_data_e2.common.p_func.vf_id, sb_data_e2.common.p_func.vf_valid, sb_data_e2.common.p_func.vnic_id, sb_data_e2.common.same_igu_sb_1b, sb_data_e2.common.state); } else { pr_cont("pf_id(0x%x) vf_id(0x%x) vf_valid(0x%x) " "vnic_id(0x%x) same_igu_sb_1b(0x%x) " "state(0x%x)\n", sb_data_e1x.common.p_func.pf_id, sb_data_e1x.common.p_func.vf_id, sb_data_e1x.common.p_func.vf_valid, sb_data_e1x.common.p_func.vnic_id, sb_data_e1x.common.same_igu_sb_1b, sb_data_e1x.common.state); } /* SB_SMs data */ for (j = 0; j < HC_SB_MAX_SM; j++) { pr_cont("SM[%d] __flags (0x%x) " "igu_sb_id (0x%x) igu_seg_id(0x%x) " "time_to_expire (0x%x) " "timer_value(0x%x)\n", j, hc_sm_p[j].__flags, hc_sm_p[j].igu_sb_id, hc_sm_p[j].igu_seg_id, hc_sm_p[j].time_to_expire, hc_sm_p[j].timer_value); } /* Indecies data */ for (j = 0; j < loop; j++) { pr_cont("INDEX[%d] flags (0x%x) " "timeout (0x%x)\n", j, hc_index_p[j].flags, hc_index_p[j].timeout); } } #ifdef BNX2X_STOP_ON_ERROR /* Rings */ /* Rx */ for_each_rx_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; start = RX_BD(le16_to_cpu(*fp->rx_cons_sb) - 10); end = RX_BD(le16_to_cpu(*fp->rx_cons_sb) + 503); for (j = start; j != end; j = RX_BD(j + 1)) { u32 *rx_bd = (u32 *)&fp->rx_desc_ring[j]; struct sw_rx_bd *sw_bd = &fp->rx_buf_ring[j]; BNX2X_ERR("fp%d: rx_bd[%x]=[%x:%x] sw_bd=[%p]\n", i, j, rx_bd[1], rx_bd[0], sw_bd->skb); } start = RX_SGE(fp->rx_sge_prod); end = RX_SGE(fp->last_max_sge); for (j = start; j != end; j = RX_SGE(j + 1)) { u32 *rx_sge = (u32 *)&fp->rx_sge_ring[j]; struct sw_rx_page *sw_page = &fp->rx_page_ring[j]; BNX2X_ERR("fp%d: rx_sge[%x]=[%x:%x] sw_page=[%p]\n", i, j, rx_sge[1], rx_sge[0], sw_page->page); } start = RCQ_BD(fp->rx_comp_cons - 10); end = RCQ_BD(fp->rx_comp_cons + 503); for (j = start; j != end; j = RCQ_BD(j + 1)) { u32 *cqe = (u32 *)&fp->rx_comp_ring[j]; BNX2X_ERR("fp%d: cqe[%x]=[%x:%x:%x:%x]\n", i, j, cqe[0], cqe[1], cqe[2], cqe[3]); } } /* Tx */ for_each_tx_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; for_each_cos_in_tx_queue(fp, cos) { struct bnx2x_fp_txdata *txdata = &fp->txdata[cos]; start = TX_BD(le16_to_cpu(*txdata->tx_cons_sb) - 10); end = TX_BD(le16_to_cpu(*txdata->tx_cons_sb) + 245); for (j = start; j != end; j = TX_BD(j + 1)) { struct sw_tx_bd *sw_bd = &txdata->tx_buf_ring[j]; BNX2X_ERR("fp%d: txdata %d, " "packet[%x]=[%p,%x]\n", i, cos, j, sw_bd->skb, sw_bd->first_bd); } start = TX_BD(txdata->tx_bd_cons - 10); end = TX_BD(txdata->tx_bd_cons + 254); for (j = start; j != end; j = TX_BD(j + 1)) { u32 *tx_bd = (u32 *)&txdata->tx_desc_ring[j]; BNX2X_ERR("fp%d: txdata %d, tx_bd[%x]=" "[%x:%x:%x:%x]\n", i, cos, j, tx_bd[0], tx_bd[1], tx_bd[2], tx_bd[3]); } } } #endif bnx2x_fw_dump(bp); bnx2x_mc_assert(bp); BNX2X_ERR("end crash dump -----------------\n"); } /* * FLR Support for E2 * * bnx2x_pf_flr_clnup() is called during nic_load in the per function HW * initialization. */ #define FLR_WAIT_USEC 10000 /* 10 miliseconds */ #define FLR_WAIT_INTERAVAL 50 /* usec */ #define FLR_POLL_CNT (FLR_WAIT_USEC/FLR_WAIT_INTERAVAL) /* 200 */ struct pbf_pN_buf_regs { int pN; u32 init_crd; u32 crd; u32 crd_freed; }; struct pbf_pN_cmd_regs { int pN; u32 lines_occup; u32 lines_freed; }; static void bnx2x_pbf_pN_buf_flushed(struct bnx2x *bp, struct pbf_pN_buf_regs *regs, u32 poll_count) { u32 init_crd, crd, crd_start, crd_freed, crd_freed_start; u32 cur_cnt = poll_count; crd_freed = crd_freed_start = REG_RD(bp, regs->crd_freed); crd = crd_start = REG_RD(bp, regs->crd); init_crd = REG_RD(bp, regs->init_crd); DP(BNX2X_MSG_SP, "INIT CREDIT[%d] : %x\n", regs->pN, init_crd); DP(BNX2X_MSG_SP, "CREDIT[%d] : s:%x\n", regs->pN, crd); DP(BNX2X_MSG_SP, "CREDIT_FREED[%d]: s:%x\n", regs->pN, crd_freed); while ((crd != init_crd) && ((u32)SUB_S32(crd_freed, crd_freed_start) < (init_crd - crd_start))) { if (cur_cnt--) { udelay(FLR_WAIT_INTERAVAL); crd = REG_RD(bp, regs->crd); crd_freed = REG_RD(bp, regs->crd_freed); } else { DP(BNX2X_MSG_SP, "PBF tx buffer[%d] timed out\n", regs->pN); DP(BNX2X_MSG_SP, "CREDIT[%d] : c:%x\n", regs->pN, crd); DP(BNX2X_MSG_SP, "CREDIT_FREED[%d]: c:%x\n", regs->pN, crd_freed); break; } } DP(BNX2X_MSG_SP, "Waited %d*%d usec for PBF tx buffer[%d]\n", poll_count-cur_cnt, FLR_WAIT_INTERAVAL, regs->pN); } static void bnx2x_pbf_pN_cmd_flushed(struct bnx2x *bp, struct pbf_pN_cmd_regs *regs, u32 poll_count) { u32 occup, to_free, freed, freed_start; u32 cur_cnt = poll_count; occup = to_free = REG_RD(bp, regs->lines_occup); freed = freed_start = REG_RD(bp, regs->lines_freed); DP(BNX2X_MSG_SP, "OCCUPANCY[%d] : s:%x\n", regs->pN, occup); DP(BNX2X_MSG_SP, "LINES_FREED[%d] : s:%x\n", regs->pN, freed); while (occup && ((u32)SUB_S32(freed, freed_start) < to_free)) { if (cur_cnt--) { udelay(FLR_WAIT_INTERAVAL); occup = REG_RD(bp, regs->lines_occup); freed = REG_RD(bp, regs->lines_freed); } else { DP(BNX2X_MSG_SP, "PBF cmd queue[%d] timed out\n", regs->pN); DP(BNX2X_MSG_SP, "OCCUPANCY[%d] : s:%x\n", regs->pN, occup); DP(BNX2X_MSG_SP, "LINES_FREED[%d] : s:%x\n", regs->pN, freed); break; } } DP(BNX2X_MSG_SP, "Waited %d*%d usec for PBF cmd queue[%d]\n", poll_count-cur_cnt, FLR_WAIT_INTERAVAL, regs->pN); } static inline u32 bnx2x_flr_clnup_reg_poll(struct bnx2x *bp, u32 reg, u32 expected, u32 poll_count) { u32 cur_cnt = poll_count; u32 val; while ((val = REG_RD(bp, reg)) != expected && cur_cnt--) udelay(FLR_WAIT_INTERAVAL); return val; } static inline int bnx2x_flr_clnup_poll_hw_counter(struct bnx2x *bp, u32 reg, char *msg, u32 poll_cnt) { u32 val = bnx2x_flr_clnup_reg_poll(bp, reg, 0, poll_cnt); if (val != 0) { BNX2X_ERR("%s usage count=%d\n", msg, val); return 1; } return 0; } static u32 bnx2x_flr_clnup_poll_count(struct bnx2x *bp) { /* adjust polling timeout */ if (CHIP_REV_IS_EMUL(bp)) return FLR_POLL_CNT * 2000; if (CHIP_REV_IS_FPGA(bp)) return FLR_POLL_CNT * 120; return FLR_POLL_CNT; } static void bnx2x_tx_hw_flushed(struct bnx2x *bp, u32 poll_count) { struct pbf_pN_cmd_regs cmd_regs[] = { {0, (CHIP_IS_E3B0(bp)) ? PBF_REG_TQ_OCCUPANCY_Q0 : PBF_REG_P0_TQ_OCCUPANCY, (CHIP_IS_E3B0(bp)) ? PBF_REG_TQ_LINES_FREED_CNT_Q0 : PBF_REG_P0_TQ_LINES_FREED_CNT}, {1, (CHIP_IS_E3B0(bp)) ? PBF_REG_TQ_OCCUPANCY_Q1 : PBF_REG_P1_TQ_OCCUPANCY, (CHIP_IS_E3B0(bp)) ? PBF_REG_TQ_LINES_FREED_CNT_Q1 : PBF_REG_P1_TQ_LINES_FREED_CNT}, {4, (CHIP_IS_E3B0(bp)) ? PBF_REG_TQ_OCCUPANCY_LB_Q : PBF_REG_P4_TQ_OCCUPANCY, (CHIP_IS_E3B0(bp)) ? PBF_REG_TQ_LINES_FREED_CNT_LB_Q : PBF_REG_P4_TQ_LINES_FREED_CNT} }; struct pbf_pN_buf_regs buf_regs[] = { {0, (CHIP_IS_E3B0(bp)) ? PBF_REG_INIT_CRD_Q0 : PBF_REG_P0_INIT_CRD , (CHIP_IS_E3B0(bp)) ? PBF_REG_CREDIT_Q0 : PBF_REG_P0_CREDIT, (CHIP_IS_E3B0(bp)) ? PBF_REG_INTERNAL_CRD_FREED_CNT_Q0 : PBF_REG_P0_INTERNAL_CRD_FREED_CNT}, {1, (CHIP_IS_E3B0(bp)) ? PBF_REG_INIT_CRD_Q1 : PBF_REG_P1_INIT_CRD, (CHIP_IS_E3B0(bp)) ? PBF_REG_CREDIT_Q1 : PBF_REG_P1_CREDIT, (CHIP_IS_E3B0(bp)) ? PBF_REG_INTERNAL_CRD_FREED_CNT_Q1 : PBF_REG_P1_INTERNAL_CRD_FREED_CNT}, {4, (CHIP_IS_E3B0(bp)) ? PBF_REG_INIT_CRD_LB_Q : PBF_REG_P4_INIT_CRD, (CHIP_IS_E3B0(bp)) ? PBF_REG_CREDIT_LB_Q : PBF_REG_P4_CREDIT, (CHIP_IS_E3B0(bp)) ? PBF_REG_INTERNAL_CRD_FREED_CNT_LB_Q : PBF_REG_P4_INTERNAL_CRD_FREED_CNT}, }; int i; /* Verify the command queues are flushed P0, P1, P4 */ for (i = 0; i < ARRAY_SIZE(cmd_regs); i++) bnx2x_pbf_pN_cmd_flushed(bp, &cmd_regs[i], poll_count); /* Verify the transmission buffers are flushed P0, P1, P4 */ for (i = 0; i < ARRAY_SIZE(buf_regs); i++) bnx2x_pbf_pN_buf_flushed(bp, &buf_regs[i], poll_count); } #define OP_GEN_PARAM(param) \ (((param) << SDM_OP_GEN_COMP_PARAM_SHIFT) & SDM_OP_GEN_COMP_PARAM) #define OP_GEN_TYPE(type) \ (((type) << SDM_OP_GEN_COMP_TYPE_SHIFT) & SDM_OP_GEN_COMP_TYPE) #define OP_GEN_AGG_VECT(index) \ (((index) << SDM_OP_GEN_AGG_VECT_IDX_SHIFT) & SDM_OP_GEN_AGG_VECT_IDX) static inline int bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func, u32 poll_cnt) { struct sdm_op_gen op_gen = {0}; u32 comp_addr = BAR_CSTRORM_INTMEM + CSTORM_FINAL_CLEANUP_COMPLETE_OFFSET(clnup_func); int ret = 0; if (REG_RD(bp, comp_addr)) { BNX2X_ERR("Cleanup complete is not 0\n"); return 1; } op_gen.command |= OP_GEN_PARAM(XSTORM_AGG_INT_FINAL_CLEANUP_INDEX); op_gen.command |= OP_GEN_TYPE(XSTORM_AGG_INT_FINAL_CLEANUP_COMP_TYPE); op_gen.command |= OP_GEN_AGG_VECT(clnup_func); op_gen.command |= 1 << SDM_OP_GEN_AGG_VECT_IDX_VALID_SHIFT; DP(BNX2X_MSG_SP, "FW Final cleanup\n"); REG_WR(bp, XSDM_REG_OPERATION_GEN, op_gen.command); if (bnx2x_flr_clnup_reg_poll(bp, comp_addr, 1, poll_cnt) != 1) { BNX2X_ERR("FW final cleanup did not succeed\n"); ret = 1; } /* Zero completion for nxt FLR */ REG_WR(bp, comp_addr, 0); return ret; } static inline u8 bnx2x_is_pcie_pending(struct pci_dev *dev) { int pos; u16 status; pos = pci_pcie_cap(dev); if (!pos) return false; pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &status); return status & PCI_EXP_DEVSTA_TRPND; } /* PF FLR specific routines */ static int bnx2x_poll_hw_usage_counters(struct bnx2x *bp, u32 poll_cnt) { /* wait for CFC PF usage-counter to zero (includes all the VFs) */ if (bnx2x_flr_clnup_poll_hw_counter(bp, CFC_REG_NUM_LCIDS_INSIDE_PF, "CFC PF usage counter timed out", poll_cnt)) return 1; /* Wait for DQ PF usage-counter to zero (until DQ cleanup) */ if (bnx2x_flr_clnup_poll_hw_counter(bp, DORQ_REG_PF_USAGE_CNT, "DQ PF usage counter timed out", poll_cnt)) return 1; /* Wait for QM PF usage-counter to zero (until DQ cleanup) */ if (bnx2x_flr_clnup_poll_hw_counter(bp, QM_REG_PF_USG_CNT_0 + 4*BP_FUNC(bp), "QM PF usage counter timed out", poll_cnt)) return 1; /* Wait for Timer PF usage-counters to zero (until DQ cleanup) */ if (bnx2x_flr_clnup_poll_hw_counter(bp, TM_REG_LIN0_VNIC_UC + 4*BP_PORT(bp), "Timers VNIC usage counter timed out", poll_cnt)) return 1; if (bnx2x_flr_clnup_poll_hw_counter(bp, TM_REG_LIN0_NUM_SCANS + 4*BP_PORT(bp), "Timers NUM_SCANS usage counter timed out", poll_cnt)) return 1; /* Wait DMAE PF usage counter to zero */ if (bnx2x_flr_clnup_poll_hw_counter(bp, dmae_reg_go_c[INIT_DMAE_C(bp)], "DMAE dommand register timed out", poll_cnt)) return 1; return 0; } static void bnx2x_hw_enable_status(struct bnx2x *bp) { u32 val; val = REG_RD(bp, CFC_REG_WEAK_ENABLE_PF); DP(BNX2X_MSG_SP, "CFC_REG_WEAK_ENABLE_PF is 0x%x\n", val); val = REG_RD(bp, PBF_REG_DISABLE_PF); DP(BNX2X_MSG_SP, "PBF_REG_DISABLE_PF is 0x%x\n", val); val = REG_RD(bp, IGU_REG_PCI_PF_MSI_EN); DP(BNX2X_MSG_SP, "IGU_REG_PCI_PF_MSI_EN is 0x%x\n", val); val = REG_RD(bp, IGU_REG_PCI_PF_MSIX_EN); DP(BNX2X_MSG_SP, "IGU_REG_PCI_PF_MSIX_EN is 0x%x\n", val); val = REG_RD(bp, IGU_REG_PCI_PF_MSIX_FUNC_MASK); DP(BNX2X_MSG_SP, "IGU_REG_PCI_PF_MSIX_FUNC_MASK is 0x%x\n", val); val = REG_RD(bp, PGLUE_B_REG_SHADOW_BME_PF_7_0_CLR); DP(BNX2X_MSG_SP, "PGLUE_B_REG_SHADOW_BME_PF_7_0_CLR is 0x%x\n", val); val = REG_RD(bp, PGLUE_B_REG_FLR_REQUEST_PF_7_0_CLR); DP(BNX2X_MSG_SP, "PGLUE_B_REG_FLR_REQUEST_PF_7_0_CLR is 0x%x\n", val); val = REG_RD(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER); DP(BNX2X_MSG_SP, "PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER is 0x%x\n", val); } static int bnx2x_pf_flr_clnup(struct bnx2x *bp) { u32 poll_cnt = bnx2x_flr_clnup_poll_count(bp); DP(BNX2X_MSG_SP, "Cleanup after FLR PF[%d]\n", BP_ABS_FUNC(bp)); /* Re-enable PF target read access */ REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1); /* Poll HW usage counters */ if (bnx2x_poll_hw_usage_counters(bp, poll_cnt)) return -EBUSY; /* Zero the igu 'trailing edge' and 'leading edge' */ /* Send the FW cleanup command */ if (bnx2x_send_final_clnup(bp, (u8)BP_FUNC(bp), poll_cnt)) return -EBUSY; /* ATC cleanup */ /* Verify TX hw is flushed */ bnx2x_tx_hw_flushed(bp, poll_cnt); /* Wait 100ms (not adjusted according to platform) */ msleep(100); /* Verify no pending pci transactions */ if (bnx2x_is_pcie_pending(bp->pdev)) BNX2X_ERR("PCIE Transactions still pending\n"); /* Debug */ bnx2x_hw_enable_status(bp); /* * Master enable - Due to WB DMAE writes performed before this * register is re-initialized as part of the regular function init */ REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 1); return 0; } static void bnx2x_hc_int_enable(struct bnx2x *bp) { int port = BP_PORT(bp); u32 addr = port ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0; u32 val = REG_RD(bp, addr); int msix = (bp->flags & USING_MSIX_FLAG) ? 1 : 0; int msi = (bp->flags & USING_MSI_FLAG) ? 1 : 0; if (msix) { val &= ~(HC_CONFIG_0_REG_SINGLE_ISR_EN_0 | HC_CONFIG_0_REG_INT_LINE_EN_0); val |= (HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); } else if (msi) { val &= ~HC_CONFIG_0_REG_INT_LINE_EN_0; val |= (HC_CONFIG_0_REG_SINGLE_ISR_EN_0 | HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); } else { val |= (HC_CONFIG_0_REG_SINGLE_ISR_EN_0 | HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 | HC_CONFIG_0_REG_INT_LINE_EN_0 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); if (!CHIP_IS_E1(bp)) { DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x)\n", val, port, addr); REG_WR(bp, addr, val); val &= ~HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0; } } if (CHIP_IS_E1(bp)) REG_WR(bp, HC_REG_INT_MASK + port*4, 0x1FFFF); DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x) mode %s\n", val, port, addr, (msix ? "MSI-X" : (msi ? "MSI" : "INTx"))); REG_WR(bp, addr, val); /* * Ensure that HC_CONFIG is written before leading/trailing edge config */ mmiowb(); barrier(); if (!CHIP_IS_E1(bp)) { /* init leading/trailing edge */ if (IS_MF(bp)) { val = (0xee0f | (1 << (BP_VN(bp) + 4))); if (bp->port.pmf) /* enable nig and gpio3 attention */ val |= 0x1100; } else val = 0xffff; REG_WR(bp, HC_REG_TRAILING_EDGE_0 + port*8, val); REG_WR(bp, HC_REG_LEADING_EDGE_0 + port*8, val); } /* Make sure that interrupts are indeed enabled from here on */ mmiowb(); } static void bnx2x_igu_int_enable(struct bnx2x *bp) { u32 val; int msix = (bp->flags & USING_MSIX_FLAG) ? 1 : 0; int msi = (bp->flags & USING_MSI_FLAG) ? 1 : 0; val = REG_RD(bp, IGU_REG_PF_CONFIGURATION); if (msix) { val &= ~(IGU_PF_CONF_INT_LINE_EN | IGU_PF_CONF_SINGLE_ISR_EN); val |= (IGU_PF_CONF_FUNC_EN | IGU_PF_CONF_MSI_MSIX_EN | IGU_PF_CONF_ATTN_BIT_EN); } else if (msi) { val &= ~IGU_PF_CONF_INT_LINE_EN; val |= (IGU_PF_CONF_FUNC_EN | IGU_PF_CONF_MSI_MSIX_EN | IGU_PF_CONF_ATTN_BIT_EN | IGU_PF_CONF_SINGLE_ISR_EN); } else { val &= ~IGU_PF_CONF_MSI_MSIX_EN; val |= (IGU_PF_CONF_FUNC_EN | IGU_PF_CONF_INT_LINE_EN | IGU_PF_CONF_ATTN_BIT_EN | IGU_PF_CONF_SINGLE_ISR_EN); } DP(NETIF_MSG_INTR, "write 0x%x to IGU mode %s\n", val, (msix ? "MSI-X" : (msi ? "MSI" : "INTx"))); REG_WR(bp, IGU_REG_PF_CONFIGURATION, val); barrier(); /* init leading/trailing edge */ if (IS_MF(bp)) { val = (0xee0f | (1 << (BP_VN(bp) + 4))); if (bp->port.pmf) /* enable nig and gpio3 attention */ val |= 0x1100; } else val = 0xffff; REG_WR(bp, IGU_REG_TRAILING_EDGE_LATCH, val); REG_WR(bp, IGU_REG_LEADING_EDGE_LATCH, val); /* Make sure that interrupts are indeed enabled from here on */ mmiowb(); } void bnx2x_int_enable(struct bnx2x *bp) { if (bp->common.int_block == INT_BLOCK_HC) bnx2x_hc_int_enable(bp); else bnx2x_igu_int_enable(bp); } static void bnx2x_hc_int_disable(struct bnx2x *bp) { int port = BP_PORT(bp); u32 addr = port ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0; u32 val = REG_RD(bp, addr); /* * in E1 we must use only PCI configuration space to disable * MSI/MSIX capablility * It's forbitten to disable IGU_PF_CONF_MSI_MSIX_EN in HC block */ if (CHIP_IS_E1(bp)) { /* Since IGU_PF_CONF_MSI_MSIX_EN still always on * Use mask register to prevent from HC sending interrupts * after we exit the function */ REG_WR(bp, HC_REG_INT_MASK + port*4, 0); val &= ~(HC_CONFIG_0_REG_SINGLE_ISR_EN_0 | HC_CONFIG_0_REG_INT_LINE_EN_0 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); } else val &= ~(HC_CONFIG_0_REG_SINGLE_ISR_EN_0 | HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 | HC_CONFIG_0_REG_INT_LINE_EN_0 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x)\n", val, port, addr); /* flush all outstanding writes */ mmiowb(); REG_WR(bp, addr, val); if (REG_RD(bp, addr) != val) BNX2X_ERR("BUG! proper val not read from IGU!\n"); } static void bnx2x_igu_int_disable(struct bnx2x *bp) { u32 val = REG_RD(bp, IGU_REG_PF_CONFIGURATION); val &= ~(IGU_PF_CONF_MSI_MSIX_EN | IGU_PF_CONF_INT_LINE_EN | IGU_PF_CONF_ATTN_BIT_EN); DP(NETIF_MSG_INTR, "write %x to IGU\n", val); /* flush all outstanding writes */ mmiowb(); REG_WR(bp, IGU_REG_PF_CONFIGURATION, val); if (REG_RD(bp, IGU_REG_PF_CONFIGURATION) != val) BNX2X_ERR("BUG! proper val not read from IGU!\n"); } void bnx2x_int_disable(struct bnx2x *bp) { if (bp->common.int_block == INT_BLOCK_HC) bnx2x_hc_int_disable(bp); else bnx2x_igu_int_disable(bp); } void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw) { int msix = (bp->flags & USING_MSIX_FLAG) ? 1 : 0; int i, offset; if (disable_hw) /* prevent the HW from sending interrupts */ bnx2x_int_disable(bp); /* make sure all ISRs are done */ if (msix) { synchronize_irq(bp->msix_table[0].vector); offset = 1; #ifdef BCM_CNIC offset++; #endif for_each_eth_queue(bp, i) synchronize_irq(bp->msix_table[offset++].vector); } else synchronize_irq(bp->pdev->irq); /* make sure sp_task is not running */ cancel_delayed_work(&bp->sp_task); cancel_delayed_work(&bp->period_task); flush_workqueue(bnx2x_wq); } /* fast path */ /* * General service functions */ /* Return true if succeeded to acquire the lock */ static bool bnx2x_trylock_hw_lock(struct bnx2x *bp, u32 resource) { u32 lock_status; u32 resource_bit = (1 << resource); int func = BP_FUNC(bp); u32 hw_lock_control_reg; DP(NETIF_MSG_HW, "Trying to take a lock on resource %d\n", resource); /* Validating that the resource is within range */ if (resource > HW_LOCK_MAX_RESOURCE_VALUE) { DP(NETIF_MSG_HW, "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)\n", resource, HW_LOCK_MAX_RESOURCE_VALUE); return false; } if (func <= 5) hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_1 + func*8); else hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_7 + (func - 6)*8); /* Try to acquire the lock */ REG_WR(bp, hw_lock_control_reg + 4, resource_bit); lock_status = REG_RD(bp, hw_lock_control_reg); if (lock_status & resource_bit) return true; DP(NETIF_MSG_HW, "Failed to get a lock on resource %d\n", resource); return false; } /** * bnx2x_get_leader_lock_resource - get the recovery leader resource id * * @bp: driver handle * * Returns the recovery leader resource id according to the engine this function * belongs to. Currently only only 2 engines is supported. */ static inline int bnx2x_get_leader_lock_resource(struct bnx2x *bp) { if (BP_PATH(bp)) return HW_LOCK_RESOURCE_RECOVERY_LEADER_1; else return HW_LOCK_RESOURCE_RECOVERY_LEADER_0; } /** * bnx2x_trylock_leader_lock- try to aquire a leader lock. * * @bp: driver handle * * Tries to aquire a leader lock for cuurent engine. */ static inline bool bnx2x_trylock_leader_lock(struct bnx2x *bp) { return bnx2x_trylock_hw_lock(bp, bnx2x_get_leader_lock_resource(bp)); } #ifdef BCM_CNIC static void bnx2x_cnic_cfc_comp(struct bnx2x *bp, int cid, u8 err); #endif void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe) { struct bnx2x *bp = fp->bp; int cid = SW_CID(rr_cqe->ramrod_cqe.conn_and_cmd_data); int command = CQE_CMD(rr_cqe->ramrod_cqe.conn_and_cmd_data); enum bnx2x_queue_cmd drv_cmd = BNX2X_Q_CMD_MAX; struct bnx2x_queue_sp_obj *q_obj = &fp->q_obj; DP(BNX2X_MSG_SP, "fp %d cid %d got ramrod #%d state is %x type is %d\n", fp->index, cid, command, bp->state, rr_cqe->ramrod_cqe.ramrod_type); switch (command) { case (RAMROD_CMD_ID_ETH_CLIENT_UPDATE): DP(BNX2X_MSG_SP, "got UPDATE ramrod. CID %d\n", cid); drv_cmd = BNX2X_Q_CMD_UPDATE; break; case (RAMROD_CMD_ID_ETH_CLIENT_SETUP): DP(BNX2X_MSG_SP, "got MULTI[%d] setup ramrod\n", cid); drv_cmd = BNX2X_Q_CMD_SETUP; break; case (RAMROD_CMD_ID_ETH_TX_QUEUE_SETUP): DP(NETIF_MSG_IFUP, "got MULTI[%d] tx-only setup ramrod\n", cid); drv_cmd = BNX2X_Q_CMD_SETUP_TX_ONLY; break; case (RAMROD_CMD_ID_ETH_HALT): DP(BNX2X_MSG_SP, "got MULTI[%d] halt ramrod\n", cid); drv_cmd = BNX2X_Q_CMD_HALT; break; case (RAMROD_CMD_ID_ETH_TERMINATE): DP(BNX2X_MSG_SP, "got MULTI[%d] teminate ramrod\n", cid); drv_cmd = BNX2X_Q_CMD_TERMINATE; break; case (RAMROD_CMD_ID_ETH_EMPTY): DP(BNX2X_MSG_SP, "got MULTI[%d] empty ramrod\n", cid); drv_cmd = BNX2X_Q_CMD_EMPTY; break; default: BNX2X_ERR("unexpected MC reply (%d) on fp[%d]\n", command, fp->index); return; } if ((drv_cmd != BNX2X_Q_CMD_MAX) && q_obj->complete_cmd(bp, q_obj, drv_cmd)) /* q_obj->complete_cmd() failure means that this was * an unexpected completion. * * In this case we don't want to increase the bp->spq_left * because apparently we haven't sent this command the first * place. */ #ifdef BNX2X_STOP_ON_ERROR bnx2x_panic(); #else return; #endif smp_mb__before_atomic_inc(); atomic_inc(&bp->cq_spq_left); /* push the change in bp->spq_left and towards the memory */ smp_mb__after_atomic_inc(); DP(BNX2X_MSG_SP, "bp->cq_spq_left %x\n", atomic_read(&bp->cq_spq_left)); return; } void bnx2x_update_rx_prod(struct bnx2x *bp, struct bnx2x_fastpath *fp, u16 bd_prod, u16 rx_comp_prod, u16 rx_sge_prod) { u32 start = BAR_USTRORM_INTMEM + fp->ustorm_rx_prods_offset; bnx2x_update_rx_prod_gen(bp, fp, bd_prod, rx_comp_prod, rx_sge_prod, start); } irqreturn_t bnx2x_interrupt(int irq, void *dev_instance) { struct bnx2x *bp = netdev_priv(dev_instance); u16 status = bnx2x_ack_int(bp); u16 mask; int i; u8 cos; /* Return here if interrupt is shared and it's not for us */ if (unlikely(status == 0)) { DP(NETIF_MSG_INTR, "not our interrupt!\n"); return IRQ_NONE; } DP(NETIF_MSG_INTR, "got an interrupt status 0x%x\n", status); #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return IRQ_HANDLED; #endif for_each_eth_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; mask = 0x2 << (fp->index + CNIC_PRESENT); if (status & mask) { /* Handle Rx or Tx according to SB id */ prefetch(fp->rx_cons_sb); for_each_cos_in_tx_queue(fp, cos) prefetch(fp->txdata[cos].tx_cons_sb); prefetch(&fp->sb_running_index[SM_RX_ID]); napi_schedule(&bnx2x_fp(bp, fp->index, napi)); status &= ~mask; } } #ifdef BCM_CNIC mask = 0x2; if (status & (mask | 0x1)) { struct cnic_ops *c_ops = NULL; if (likely(bp->state == BNX2X_STATE_OPEN)) { rcu_read_lock(); c_ops = rcu_dereference(bp->cnic_ops); if (c_ops) c_ops->cnic_handler(bp->cnic_data, NULL); rcu_read_unlock(); } status &= ~mask; } #endif if (unlikely(status & 0x1)) { queue_delayed_work(bnx2x_wq, &bp->sp_task, 0); status &= ~0x1; if (!status) return IRQ_HANDLED; } if (unlikely(status)) DP(NETIF_MSG_INTR, "got an unknown interrupt! (status 0x%x)\n", status); return IRQ_HANDLED; } /* Link */ /* * General service functions */ int bnx2x_acquire_hw_lock(struct bnx2x *bp, u32 resource) { u32 lock_status; u32 resource_bit = (1 << resource); int func = BP_FUNC(bp); u32 hw_lock_control_reg; int cnt; /* Validating that the resource is within range */ if (resource > HW_LOCK_MAX_RESOURCE_VALUE) { DP(NETIF_MSG_HW, "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)\n", resource, HW_LOCK_MAX_RESOURCE_VALUE); return -EINVAL; } if (func <= 5) { hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_1 + func*8); } else { hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_7 + (func - 6)*8); } /* Validating that the resource is not already taken */ lock_status = REG_RD(bp, hw_lock_control_reg); if (lock_status & resource_bit) { DP(NETIF_MSG_HW, "lock_status 0x%x resource_bit 0x%x\n", lock_status, resource_bit); return -EEXIST; } /* Try for 5 second every 5ms */ for (cnt = 0; cnt < 1000; cnt++) { /* Try to acquire the lock */ REG_WR(bp, hw_lock_control_reg + 4, resource_bit); lock_status = REG_RD(bp, hw_lock_control_reg); if (lock_status & resource_bit) return 0; msleep(5); } DP(NETIF_MSG_HW, "Timeout\n"); return -EAGAIN; } int bnx2x_release_leader_lock(struct bnx2x *bp) { return bnx2x_release_hw_lock(bp, bnx2x_get_leader_lock_resource(bp)); } int bnx2x_release_hw_lock(struct bnx2x *bp, u32 resource) { u32 lock_status; u32 resource_bit = (1 << resource); int func = BP_FUNC(bp); u32 hw_lock_control_reg; DP(NETIF_MSG_HW, "Releasing a lock on resource %d\n", resource); /* Validating that the resource is within range */ if (resource > HW_LOCK_MAX_RESOURCE_VALUE) { DP(NETIF_MSG_HW, "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)\n", resource, HW_LOCK_MAX_RESOURCE_VALUE); return -EINVAL; } if (func <= 5) { hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_1 + func*8); } else { hw_lock_control_reg = (MISC_REG_DRIVER_CONTROL_7 + (func - 6)*8); } /* Validating that the resource is currently taken */ lock_status = REG_RD(bp, hw_lock_control_reg); if (!(lock_status & resource_bit)) { DP(NETIF_MSG_HW, "lock_status 0x%x resource_bit 0x%x\n", lock_status, resource_bit); return -EFAULT; } REG_WR(bp, hw_lock_control_reg, resource_bit); return 0; } int bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port) { /* The GPIO should be swapped if swap register is set and active */ int gpio_port = (REG_RD(bp, NIG_REG_PORT_SWAP) && REG_RD(bp, NIG_REG_STRAP_OVERRIDE)) ^ port; int gpio_shift = gpio_num + (gpio_port ? MISC_REGISTERS_GPIO_PORT_SHIFT : 0); u32 gpio_mask = (1 << gpio_shift); u32 gpio_reg; int value; if (gpio_num > MISC_REGISTERS_GPIO_3) { BNX2X_ERR("Invalid GPIO %d\n", gpio_num); return -EINVAL; } /* read GPIO value */ gpio_reg = REG_RD(bp, MISC_REG_GPIO); /* get the requested pin value */ if ((gpio_reg & gpio_mask) == gpio_mask) value = 1; else value = 0; DP(NETIF_MSG_LINK, "pin %d value 0x%x\n", gpio_num, value); return value; } int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port) { /* The GPIO should be swapped if swap register is set and active */ int gpio_port = (REG_RD(bp, NIG_REG_PORT_SWAP) && REG_RD(bp, NIG_REG_STRAP_OVERRIDE)) ^ port; int gpio_shift = gpio_num + (gpio_port ? MISC_REGISTERS_GPIO_PORT_SHIFT : 0); u32 gpio_mask = (1 << gpio_shift); u32 gpio_reg; if (gpio_num > MISC_REGISTERS_GPIO_3) { BNX2X_ERR("Invalid GPIO %d\n", gpio_num); return -EINVAL; } bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_GPIO); /* read GPIO and mask except the float bits */ gpio_reg = (REG_RD(bp, MISC_REG_GPIO) & MISC_REGISTERS_GPIO_FLOAT); switch (mode) { case MISC_REGISTERS_GPIO_OUTPUT_LOW: DP(NETIF_MSG_LINK, "Set GPIO %d (shift %d) -> output low\n", gpio_num, gpio_shift); /* clear FLOAT and set CLR */ gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS); gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_CLR_POS); break; case MISC_REGISTERS_GPIO_OUTPUT_HIGH: DP(NETIF_MSG_LINK, "Set GPIO %d (shift %d) -> output high\n", gpio_num, gpio_shift); /* clear FLOAT and set SET */ gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS); gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_SET_POS); break; case MISC_REGISTERS_GPIO_INPUT_HI_Z: DP(NETIF_MSG_LINK, "Set GPIO %d (shift %d) -> input\n", gpio_num, gpio_shift); /* set FLOAT */ gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS); break; default: break; } REG_WR(bp, MISC_REG_GPIO, gpio_reg); bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_GPIO); return 0; } int bnx2x_set_mult_gpio(struct bnx2x *bp, u8 pins, u32 mode) { u32 gpio_reg = 0; int rc = 0; /* Any port swapping should be handled by caller. */ bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_GPIO); /* read GPIO and mask except the float bits */ gpio_reg = REG_RD(bp, MISC_REG_GPIO); gpio_reg &= ~(pins << MISC_REGISTERS_GPIO_FLOAT_POS); gpio_reg &= ~(pins << MISC_REGISTERS_GPIO_CLR_POS); gpio_reg &= ~(pins << MISC_REGISTERS_GPIO_SET_POS); switch (mode) { case MISC_REGISTERS_GPIO_OUTPUT_LOW: DP(NETIF_MSG_LINK, "Set GPIO 0x%x -> output low\n", pins); /* set CLR */ gpio_reg |= (pins << MISC_REGISTERS_GPIO_CLR_POS); break; case MISC_REGISTERS_GPIO_OUTPUT_HIGH: DP(NETIF_MSG_LINK, "Set GPIO 0x%x -> output high\n", pins); /* set SET */ gpio_reg |= (pins << MISC_REGISTERS_GPIO_SET_POS); break; case MISC_REGISTERS_GPIO_INPUT_HI_Z: DP(NETIF_MSG_LINK, "Set GPIO 0x%x -> input\n", pins); /* set FLOAT */ gpio_reg |= (pins << MISC_REGISTERS_GPIO_FLOAT_POS); break; default: BNX2X_ERR("Invalid GPIO mode assignment %d\n", mode); rc = -EINVAL; break; } if (rc == 0) REG_WR(bp, MISC_REG_GPIO, gpio_reg); bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_GPIO); return rc; } int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port) { /* The GPIO should be swapped if swap register is set and active */ int gpio_port = (REG_RD(bp, NIG_REG_PORT_SWAP) && REG_RD(bp, NIG_REG_STRAP_OVERRIDE)) ^ port; int gpio_shift = gpio_num + (gpio_port ? MISC_REGISTERS_GPIO_PORT_SHIFT : 0); u32 gpio_mask = (1 << gpio_shift); u32 gpio_reg; if (gpio_num > MISC_REGISTERS_GPIO_3) { BNX2X_ERR("Invalid GPIO %d\n", gpio_num); return -EINVAL; } bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_GPIO); /* read GPIO int */ gpio_reg = REG_RD(bp, MISC_REG_GPIO_INT); switch (mode) { case MISC_REGISTERS_GPIO_INT_OUTPUT_CLR: DP(NETIF_MSG_LINK, "Clear GPIO INT %d (shift %d) -> " "output low\n", gpio_num, gpio_shift); /* clear SET and set CLR */ gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_INT_SET_POS); gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_INT_CLR_POS); break; case MISC_REGISTERS_GPIO_INT_OUTPUT_SET: DP(NETIF_MSG_LINK, "Set GPIO INT %d (shift %d) -> " "output high\n", gpio_num, gpio_shift); /* clear CLR and set SET */ gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_INT_CLR_POS); gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_INT_SET_POS); break; default: break; } REG_WR(bp, MISC_REG_GPIO_INT, gpio_reg); bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_GPIO); return 0; } static int bnx2x_set_spio(struct bnx2x *bp, int spio_num, u32 mode) { u32 spio_mask = (1 << spio_num); u32 spio_reg; if ((spio_num < MISC_REGISTERS_SPIO_4) || (spio_num > MISC_REGISTERS_SPIO_7)) { BNX2X_ERR("Invalid SPIO %d\n", spio_num); return -EINVAL; } bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_SPIO); /* read SPIO and mask except the float bits */ spio_reg = (REG_RD(bp, MISC_REG_SPIO) & MISC_REGISTERS_SPIO_FLOAT); switch (mode) { case MISC_REGISTERS_SPIO_OUTPUT_LOW: DP(NETIF_MSG_LINK, "Set SPIO %d -> output low\n", spio_num); /* clear FLOAT and set CLR */ spio_reg &= ~(spio_mask << MISC_REGISTERS_SPIO_FLOAT_POS); spio_reg |= (spio_mask << MISC_REGISTERS_SPIO_CLR_POS); break; case MISC_REGISTERS_SPIO_OUTPUT_HIGH: DP(NETIF_MSG_LINK, "Set SPIO %d -> output high\n", spio_num); /* clear FLOAT and set SET */ spio_reg &= ~(spio_mask << MISC_REGISTERS_SPIO_FLOAT_POS); spio_reg |= (spio_mask << MISC_REGISTERS_SPIO_SET_POS); break; case MISC_REGISTERS_SPIO_INPUT_HI_Z: DP(NETIF_MSG_LINK, "Set SPIO %d -> input\n", spio_num); /* set FLOAT */ spio_reg |= (spio_mask << MISC_REGISTERS_SPIO_FLOAT_POS); break; default: break; } REG_WR(bp, MISC_REG_SPIO, spio_reg); bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_SPIO); return 0; } void bnx2x_calc_fc_adv(struct bnx2x *bp) { u8 cfg_idx = bnx2x_get_link_cfg_idx(bp); switch (bp->link_vars.ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK) { case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE: bp->port.advertising[cfg_idx] &= ~(ADVERTISED_Asym_Pause | ADVERTISED_Pause); break; case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH: bp->port.advertising[cfg_idx] |= (ADVERTISED_Asym_Pause | ADVERTISED_Pause); break; case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC: bp->port.advertising[cfg_idx] |= ADVERTISED_Asym_Pause; break; default: bp->port.advertising[cfg_idx] &= ~(ADVERTISED_Asym_Pause | ADVERTISED_Pause); break; } } u8 bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode) { if (!BP_NOMCP(bp)) { u8 rc; int cfx_idx = bnx2x_get_link_cfg_idx(bp); u16 req_line_speed = bp->link_params.req_line_speed[cfx_idx]; /* * Initialize link parameters structure variables * It is recommended to turn off RX FC for jumbo frames * for better performance */ if (CHIP_IS_E1x(bp) && (bp->dev->mtu > 5000)) bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_TX; else bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_BOTH; bnx2x_acquire_phy_lock(bp); if (load_mode == LOAD_DIAG) { struct link_params *lp = &bp->link_params; lp->loopback_mode = LOOPBACK_XGXS; /* do PHY loopback at 10G speed, if possible */ if (lp->req_line_speed[cfx_idx] < SPEED_10000) { if (lp->speed_cap_mask[cfx_idx] & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) lp->req_line_speed[cfx_idx] = SPEED_10000; else lp->req_line_speed[cfx_idx] = SPEED_1000; } } rc = bnx2x_phy_init(&bp->link_params, &bp->link_vars); bnx2x_release_phy_lock(bp); bnx2x_calc_fc_adv(bp); if (CHIP_REV_IS_SLOW(bp) && bp->link_vars.link_up) { bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP); bnx2x_link_report(bp); } else queue_delayed_work(bnx2x_wq, &bp->period_task, 0); bp->link_params.req_line_speed[cfx_idx] = req_line_speed; return rc; } BNX2X_ERR("Bootcode is missing - can not initialize link\n"); return -EINVAL; } void bnx2x_link_set(struct bnx2x *bp) { if (!BP_NOMCP(bp)) { bnx2x_acquire_phy_lock(bp); bnx2x_link_reset(&bp->link_params, &bp->link_vars, 1); bnx2x_phy_init(&bp->link_params, &bp->link_vars); bnx2x_release_phy_lock(bp); bnx2x_calc_fc_adv(bp); } else BNX2X_ERR("Bootcode is missing - can not set link\n"); } static void bnx2x__link_reset(struct bnx2x *bp) { if (!BP_NOMCP(bp)) { bnx2x_acquire_phy_lock(bp); bnx2x_link_reset(&bp->link_params, &bp->link_vars, 1); bnx2x_release_phy_lock(bp); } else BNX2X_ERR("Bootcode is missing - can not reset link\n"); } u8 bnx2x_link_test(struct bnx2x *bp, u8 is_serdes) { u8 rc = 0; if (!BP_NOMCP(bp)) { bnx2x_acquire_phy_lock(bp); rc = bnx2x_test_link(&bp->link_params, &bp->link_vars, is_serdes); bnx2x_release_phy_lock(bp); } else BNX2X_ERR("Bootcode is missing - can not test link\n"); return rc; } static void bnx2x_init_port_minmax(struct bnx2x *bp) { u32 r_param = bp->link_vars.line_speed / 8; u32 fair_periodic_timeout_usec; u32 t_fair; memset(&(bp->cmng.rs_vars), 0, sizeof(struct rate_shaping_vars_per_port)); memset(&(bp->cmng.fair_vars), 0, sizeof(struct fairness_vars_per_port)); /* 100 usec in SDM ticks = 25 since each tick is 4 usec */ bp->cmng.rs_vars.rs_periodic_timeout = RS_PERIODIC_TIMEOUT_USEC / 4; /* this is the threshold below which no timer arming will occur 1.25 coefficient is for the threshold to be a little bigger than the real time, to compensate for timer in-accuracy */ bp->cmng.rs_vars.rs_threshold = (RS_PERIODIC_TIMEOUT_USEC * r_param * 5) / 4; /* resolution of fairness timer */ fair_periodic_timeout_usec = QM_ARB_BYTES / r_param; /* for 10G it is 1000usec. for 1G it is 10000usec. */ t_fair = T_FAIR_COEF / bp->link_vars.line_speed; /* this is the threshold below which we won't arm the timer anymore */ bp->cmng.fair_vars.fair_threshold = QM_ARB_BYTES; /* we multiply by 1e3/8 to get bytes/msec. We don't want the credits to pass a credit of the t_fair*FAIR_MEM (algorithm resolution) */ bp->cmng.fair_vars.upper_bound = r_param * t_fair * FAIR_MEM; /* since each tick is 4 usec */ bp->cmng.fair_vars.fairness_timeout = fair_periodic_timeout_usec / 4; } /* Calculates the sum of vn_min_rates. It's needed for further normalizing of the min_rates. Returns: sum of vn_min_rates. or 0 - if all the min_rates are 0. In the later case fainess algorithm should be deactivated. If not all min_rates are zero then those that are zeroes will be set to 1. */ static void bnx2x_calc_vn_weight_sum(struct bnx2x *bp) { int all_zero = 1; int vn; bp->vn_weight_sum = 0; for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) { u32 vn_cfg = bp->mf_config[vn]; u32 vn_min_rate = ((vn_cfg & FUNC_MF_CFG_MIN_BW_MASK) >> FUNC_MF_CFG_MIN_BW_SHIFT) * 100; /* Skip hidden vns */ if (vn_cfg & FUNC_MF_CFG_FUNC_HIDE) continue; /* If min rate is zero - set it to 1 */ if (!vn_min_rate) vn_min_rate = DEF_MIN_RATE; else all_zero = 0; bp->vn_weight_sum += vn_min_rate; } /* if ETS or all min rates are zeros - disable fairness */ if (BNX2X_IS_ETS_ENABLED(bp)) { bp->cmng.flags.cmng_enables &= ~CMNG_FLAGS_PER_PORT_FAIRNESS_VN; DP(NETIF_MSG_IFUP, "Fairness will be disabled due to ETS\n"); } else if (all_zero) { bp->cmng.flags.cmng_enables &= ~CMNG_FLAGS_PER_PORT_FAIRNESS_VN; DP(NETIF_MSG_IFUP, "All MIN values are zeroes" " fairness will be disabled\n"); } else bp->cmng.flags.cmng_enables |= CMNG_FLAGS_PER_PORT_FAIRNESS_VN; } /* returns func by VN for current port */ static inline int func_by_vn(struct bnx2x *bp, int vn) { return 2 * vn + BP_PORT(bp); } static void bnx2x_init_vn_minmax(struct bnx2x *bp, int vn) { struct rate_shaping_vars_per_vn m_rs_vn; struct fairness_vars_per_vn m_fair_vn; u32 vn_cfg = bp->mf_config[vn]; int func = func_by_vn(bp, vn); u16 vn_min_rate, vn_max_rate; int i; /* If function is hidden - set min and max to zeroes */ if (vn_cfg & FUNC_MF_CFG_FUNC_HIDE) { vn_min_rate = 0; vn_max_rate = 0; } else { u32 maxCfg = bnx2x_extract_max_cfg(bp, vn_cfg); vn_min_rate = ((vn_cfg & FUNC_MF_CFG_MIN_BW_MASK) >> FUNC_MF_CFG_MIN_BW_SHIFT) * 100; /* If fairness is enabled (not all min rates are zeroes) and if current min rate is zero - set it to 1. This is a requirement of the algorithm. */ if (bp->vn_weight_sum && (vn_min_rate == 0)) vn_min_rate = DEF_MIN_RATE; if (IS_MF_SI(bp)) /* maxCfg in percents of linkspeed */ vn_max_rate = (bp->link_vars.line_speed * maxCfg) / 100; else /* maxCfg is absolute in 100Mb units */ vn_max_rate = maxCfg * 100; } DP(NETIF_MSG_IFUP, "func %d: vn_min_rate %d vn_max_rate %d vn_weight_sum %d\n", func, vn_min_rate, vn_max_rate, bp->vn_weight_sum); memset(&m_rs_vn, 0, sizeof(struct rate_shaping_vars_per_vn)); memset(&m_fair_vn, 0, sizeof(struct fairness_vars_per_vn)); /* global vn counter - maximal Mbps for this vn */ m_rs_vn.vn_counter.rate = vn_max_rate; /* quota - number of bytes transmitted in this period */ m_rs_vn.vn_counter.quota = (vn_max_rate * RS_PERIODIC_TIMEOUT_USEC) / 8; if (bp->vn_weight_sum) { /* credit for each period of the fairness algorithm: number of bytes in T_FAIR (the vn share the port rate). vn_weight_sum should not be larger than 10000, thus T_FAIR_COEF / (8 * vn_weight_sum) will always be greater than zero */ m_fair_vn.vn_credit_delta = max_t(u32, (vn_min_rate * (T_FAIR_COEF / (8 * bp->vn_weight_sum))), (bp->cmng.fair_vars.fair_threshold + MIN_ABOVE_THRESH)); DP(NETIF_MSG_IFUP, "m_fair_vn.vn_credit_delta %d\n", m_fair_vn.vn_credit_delta); } /* Store it to internal memory */ for (i = 0; i < sizeof(struct rate_shaping_vars_per_vn)/4; i++) REG_WR(bp, BAR_XSTRORM_INTMEM + XSTORM_RATE_SHAPING_PER_VN_VARS_OFFSET(func) + i * 4, ((u32 *)(&m_rs_vn))[i]); for (i = 0; i < sizeof(struct fairness_vars_per_vn)/4; i++) REG_WR(bp, BAR_XSTRORM_INTMEM + XSTORM_FAIRNESS_PER_VN_VARS_OFFSET(func) + i * 4, ((u32 *)(&m_fair_vn))[i]); } static int bnx2x_get_cmng_fns_mode(struct bnx2x *bp) { if (CHIP_REV_IS_SLOW(bp)) return CMNG_FNS_NONE; if (IS_MF(bp)) return CMNG_FNS_MINMAX; return CMNG_FNS_NONE; } void bnx2x_read_mf_cfg(struct bnx2x *bp) { int vn, n = (CHIP_MODE_IS_4_PORT(bp) ? 2 : 1); if (BP_NOMCP(bp)) return; /* what should be the default bvalue in this case */ /* For 2 port configuration the absolute function number formula * is: * abs_func = 2 * vn + BP_PORT + BP_PATH * * and there are 4 functions per port * * For 4 port configuration it is * abs_func = 4 * vn + 2 * BP_PORT + BP_PATH * * and there are 2 functions per port */ for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) { int /*abs*/func = n * (2 * vn + BP_PORT(bp)) + BP_PATH(bp); if (func >= E1H_FUNC_MAX) break; bp->mf_config[vn] = MF_CFG_RD(bp, func_mf_config[func].config); } } static void bnx2x_cmng_fns_init(struct bnx2x *bp, u8 read_cfg, u8 cmng_type) { if (cmng_type == CMNG_FNS_MINMAX) { int vn; /* clear cmng_enables */ bp->cmng.flags.cmng_enables = 0; /* read mf conf from shmem */ if (read_cfg) bnx2x_read_mf_cfg(bp); /* Init rate shaping and fairness contexts */ bnx2x_init_port_minmax(bp); /* vn_weight_sum and enable fairness if not 0 */ bnx2x_calc_vn_weight_sum(bp); /* calculate and set min-max rate for each vn */ if (bp->port.pmf) for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) bnx2x_init_vn_minmax(bp, vn); /* always enable rate shaping and fairness */ bp->cmng.flags.cmng_enables |= CMNG_FLAGS_PER_PORT_RATE_SHAPING_VN; if (!bp->vn_weight_sum) DP(NETIF_MSG_IFUP, "All MIN values are zeroes" " fairness will be disabled\n"); return; } /* rate shaping and fairness are disabled */ DP(NETIF_MSG_IFUP, "rate shaping and fairness are disabled\n"); } static inline void bnx2x_link_sync_notify(struct bnx2x *bp) { int func; int vn; /* Set the attention towards other drivers on the same port */ for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) { if (vn == BP_VN(bp)) continue; func = func_by_vn(bp, vn); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_0 + (LINK_SYNC_ATTENTION_BIT_FUNC_0 + func)*4, 1); } } /* This function is called upon link interrupt */ static void bnx2x_link_attn(struct bnx2x *bp) { /* Make sure that we are synced with the current statistics */ bnx2x_stats_handle(bp, STATS_EVENT_STOP); bnx2x_link_update(&bp->link_params, &bp->link_vars); if (bp->link_vars.link_up) { /* dropless flow control */ if (!CHIP_IS_E1(bp) && bp->dropless_fc) { int port = BP_PORT(bp); u32 pause_enabled = 0; if (bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_TX) pause_enabled = 1; REG_WR(bp, BAR_USTRORM_INTMEM + USTORM_ETH_PAUSE_ENABLED_OFFSET(port), pause_enabled); } if (bp->link_vars.mac_type != MAC_TYPE_EMAC) { struct host_port_stats *pstats; pstats = bnx2x_sp(bp, port_stats); /* reset old mac stats */ memset(&(pstats->mac_stx[0]), 0, sizeof(struct mac_stx)); } if (bp->state == BNX2X_STATE_OPEN) bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP); } if (bp->link_vars.link_up && bp->link_vars.line_speed) { int cmng_fns = bnx2x_get_cmng_fns_mode(bp); if (cmng_fns != CMNG_FNS_NONE) { bnx2x_cmng_fns_init(bp, false, cmng_fns); storm_memset_cmng(bp, &bp->cmng, BP_PORT(bp)); } else /* rate shaping and fairness are disabled */ DP(NETIF_MSG_IFUP, "single function mode without fairness\n"); } __bnx2x_link_report(bp); if (IS_MF(bp)) bnx2x_link_sync_notify(bp); } void bnx2x__link_status_update(struct bnx2x *bp) { if (bp->state != BNX2X_STATE_OPEN) return; bnx2x_link_status_update(&bp->link_params, &bp->link_vars); if (bp->link_vars.link_up) bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP); else bnx2x_stats_handle(bp, STATS_EVENT_STOP); /* indicate link status */ bnx2x_link_report(bp); } static void bnx2x_pmf_update(struct bnx2x *bp) { int port = BP_PORT(bp); u32 val; bp->port.pmf = 1; DP(NETIF_MSG_LINK, "pmf %d\n", bp->port.pmf); /* * We need the mb() to ensure the ordering between the writing to * bp->port.pmf here and reading it from the bnx2x_periodic_task(). */ smp_mb(); /* queue a periodic task */ queue_delayed_work(bnx2x_wq, &bp->period_task, 0); bnx2x_dcbx_pmf_update(bp); /* enable nig attention */ val = (0xff0f | (1 << (BP_VN(bp) + 4))); if (bp->common.int_block == INT_BLOCK_HC) { REG_WR(bp, HC_REG_TRAILING_EDGE_0 + port*8, val); REG_WR(bp, HC_REG_LEADING_EDGE_0 + port*8, val); } else if (!CHIP_IS_E1x(bp)) { REG_WR(bp, IGU_REG_TRAILING_EDGE_LATCH, val); REG_WR(bp, IGU_REG_LEADING_EDGE_LATCH, val); } bnx2x_stats_handle(bp, STATS_EVENT_PMF); } /* end of Link */ /* slow path */ /* * General service functions */ /* send the MCP a request, block until there is a reply */ u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param) { int mb_idx = BP_FW_MB_IDX(bp); u32 seq; u32 rc = 0; u32 cnt = 1; u8 delay = CHIP_REV_IS_SLOW(bp) ? 100 : 10; mutex_lock(&bp->fw_mb_mutex); seq = ++bp->fw_seq; SHMEM_WR(bp, func_mb[mb_idx].drv_mb_param, param); SHMEM_WR(bp, func_mb[mb_idx].drv_mb_header, (command | seq)); DP(BNX2X_MSG_MCP, "wrote command (%x) to FW MB param 0x%08x\n", (command | seq), param); do { /* let the FW do it's magic ... */ msleep(delay); rc = SHMEM_RD(bp, func_mb[mb_idx].fw_mb_header); /* Give the FW up to 5 second (500*10ms) */ } while ((seq != (rc & FW_MSG_SEQ_NUMBER_MASK)) && (cnt++ < 500)); DP(BNX2X_MSG_MCP, "[after %d ms] read (%x) seq is (%x) from FW MB\n", cnt*delay, rc, seq); /* is this a reply to our command? */ if (seq == (rc & FW_MSG_SEQ_NUMBER_MASK)) rc &= FW_MSG_CODE_MASK; else { /* FW BUG! */ BNX2X_ERR("FW failed to respond!\n"); bnx2x_fw_dump(bp); rc = 0; } mutex_unlock(&bp->fw_mb_mutex); return rc; } static u8 stat_counter_valid(struct bnx2x *bp, struct bnx2x_fastpath *fp) { #ifdef BCM_CNIC /* Statistics are not supported for CNIC Clients at the moment */ if (IS_FCOE_FP(fp)) return false; #endif return true; } void bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p) { if (CHIP_IS_E1x(bp)) { struct tstorm_eth_function_common_config tcfg = {0}; storm_memset_func_cfg(bp, &tcfg, p->func_id); } /* Enable the function in the FW */ storm_memset_vf_to_pf(bp, p->func_id, p->pf_id); storm_memset_func_en(bp, p->func_id, 1); /* spq */ if (p->func_flgs & FUNC_FLG_SPQ) { storm_memset_spq_addr(bp, p->spq_map, p->func_id); REG_WR(bp, XSEM_REG_FAST_MEMORY + XSTORM_SPQ_PROD_OFFSET(p->func_id), p->spq_prod); } } /** * bnx2x_get_tx_only_flags - Return common flags * * @bp device handle * @fp queue handle * @zero_stats TRUE if statistics zeroing is needed * * Return the flags that are common for the Tx-only and not normal connections. */ static inline unsigned long bnx2x_get_common_flags(struct bnx2x *bp, struct bnx2x_fastpath *fp, bool zero_stats) { unsigned long flags = 0; /* PF driver will always initialize the Queue to an ACTIVE state */ __set_bit(BNX2X_Q_FLG_ACTIVE, &flags); /* tx only connections collect statistics (on the same index as the * parent connection). The statistics are zeroed when the parent * connection is initialized. */ if (stat_counter_valid(bp, fp)) { __set_bit(BNX2X_Q_FLG_STATS, &flags); if (zero_stats) __set_bit(BNX2X_Q_FLG_ZERO_STATS, &flags); } return flags; } static inline unsigned long bnx2x_get_q_flags(struct bnx2x *bp, struct bnx2x_fastpath *fp, bool leading) { unsigned long flags = 0; /* calculate other queue flags */ if (IS_MF_SD(bp)) __set_bit(BNX2X_Q_FLG_OV, &flags); if (IS_FCOE_FP(fp)) __set_bit(BNX2X_Q_FLG_FCOE, &flags); if (!fp->disable_tpa) { __set_bit(BNX2X_Q_FLG_TPA, &flags); __set_bit(BNX2X_Q_FLG_TPA_IPV6, &flags); } if (leading) { __set_bit(BNX2X_Q_FLG_LEADING_RSS, &flags); __set_bit(BNX2X_Q_FLG_MCAST, &flags); } /* Always set HW VLAN stripping */ __set_bit(BNX2X_Q_FLG_VLAN, &flags); return flags | bnx2x_get_common_flags(bp, fp, true); } static void bnx2x_pf_q_prep_general(struct bnx2x *bp, struct bnx2x_fastpath *fp, struct bnx2x_general_setup_params *gen_init, u8 cos) { gen_init->stat_id = bnx2x_stats_id(fp); gen_init->spcl_id = fp->cl_id; /* Always use mini-jumbo MTU for FCoE L2 ring */ if (IS_FCOE_FP(fp)) gen_init->mtu = BNX2X_FCOE_MINI_JUMBO_MTU; else gen_init->mtu = bp->dev->mtu; gen_init->cos = cos; } static void bnx2x_pf_rx_q_prep(struct bnx2x *bp, struct bnx2x_fastpath *fp, struct rxq_pause_params *pause, struct bnx2x_rxq_setup_params *rxq_init) { u8 max_sge = 0; u16 sge_sz = 0; u16 tpa_agg_size = 0; if (!fp->disable_tpa) { pause->sge_th_lo = SGE_TH_LO(bp); pause->sge_th_hi = SGE_TH_HI(bp); /* validate SGE ring has enough to cross high threshold */ WARN_ON(bp->dropless_fc && pause->sge_th_hi + FW_PREFETCH_CNT > MAX_RX_SGE_CNT * NUM_RX_SGE_PAGES); tpa_agg_size = min_t(u32, (min_t(u32, 8, MAX_SKB_FRAGS) * SGE_PAGE_SIZE * PAGES_PER_SGE), 0xffff); max_sge = SGE_PAGE_ALIGN(bp->dev->mtu) >> SGE_PAGE_SHIFT; max_sge = ((max_sge + PAGES_PER_SGE - 1) & (~(PAGES_PER_SGE-1))) >> PAGES_PER_SGE_SHIFT; sge_sz = (u16)min_t(u32, SGE_PAGE_SIZE * PAGES_PER_SGE, 0xffff); } /* pause - not for e1 */ if (!CHIP_IS_E1(bp)) { pause->bd_th_lo = BD_TH_LO(bp); pause->bd_th_hi = BD_TH_HI(bp); pause->rcq_th_lo = RCQ_TH_LO(bp); pause->rcq_th_hi = RCQ_TH_HI(bp); /* * validate that rings have enough entries to cross * high thresholds */ WARN_ON(bp->dropless_fc && pause->bd_th_hi + FW_PREFETCH_CNT > bp->rx_ring_size); WARN_ON(bp->dropless_fc && pause->rcq_th_hi + FW_PREFETCH_CNT > NUM_RCQ_RINGS * MAX_RCQ_DESC_CNT); pause->pri_map = 1; } /* rxq setup */ rxq_init->dscr_map = fp->rx_desc_mapping; rxq_init->sge_map = fp->rx_sge_mapping; rxq_init->rcq_map = fp->rx_comp_mapping; rxq_init->rcq_np_map = fp->rx_comp_mapping + BCM_PAGE_SIZE; /* This should be a maximum number of data bytes that may be * placed on the BD (not including paddings). */ rxq_init->buf_sz = fp->rx_buf_size - BNX2X_FW_RX_ALIGN - IP_HEADER_ALIGNMENT_PADDING; rxq_init->cl_qzone_id = fp->cl_qzone_id; rxq_init->tpa_agg_sz = tpa_agg_size; rxq_init->sge_buf_sz = sge_sz; rxq_init->max_sges_pkt = max_sge; rxq_init->rss_engine_id = BP_FUNC(bp); /* Maximum number or simultaneous TPA aggregation for this Queue. * * For PF Clients it should be the maximum avaliable number. * VF driver(s) may want to define it to a smaller value. */ rxq_init->max_tpa_queues = MAX_AGG_QS(bp); rxq_init->cache_line_log = BNX2X_RX_ALIGN_SHIFT; rxq_init->fw_sb_id = fp->fw_sb_id; if (IS_FCOE_FP(fp)) rxq_init->sb_cq_index = HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS; else rxq_init->sb_cq_index = HC_INDEX_ETH_RX_CQ_CONS; } static void bnx2x_pf_tx_q_prep(struct bnx2x *bp, struct bnx2x_fastpath *fp, struct bnx2x_txq_setup_params *txq_init, u8 cos) { txq_init->dscr_map = fp->txdata[cos].tx_desc_mapping; txq_init->sb_cq_index = HC_INDEX_ETH_FIRST_TX_CQ_CONS + cos; txq_init->traffic_type = LLFC_TRAFFIC_TYPE_NW; txq_init->fw_sb_id = fp->fw_sb_id; /* * set the tss leading client id for TX classfication == * leading RSS client id */ txq_init->tss_leading_cl_id = bnx2x_fp(bp, 0, cl_id); if (IS_FCOE_FP(fp)) { txq_init->sb_cq_index = HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS; txq_init->traffic_type = LLFC_TRAFFIC_TYPE_FCOE; } } static void bnx2x_pf_init(struct bnx2x *bp) { struct bnx2x_func_init_params func_init = {0}; struct event_ring_data eq_data = { {0} }; u16 flags; if (!CHIP_IS_E1x(bp)) { /* reset IGU PF statistics: MSIX + ATTN */ /* PF */ REG_WR(bp, IGU_REG_STATISTIC_NUM_MESSAGE_SENT + BNX2X_IGU_STAS_MSG_VF_CNT*4 + (CHIP_MODE_IS_4_PORT(bp) ? BP_FUNC(bp) : BP_VN(bp))*4, 0); /* ATTN */ REG_WR(bp, IGU_REG_STATISTIC_NUM_MESSAGE_SENT + BNX2X_IGU_STAS_MSG_VF_CNT*4 + BNX2X_IGU_STAS_MSG_PF_CNT*4 + (CHIP_MODE_IS_4_PORT(bp) ? BP_FUNC(bp) : BP_VN(bp))*4, 0); } /* function setup flags */ flags = (FUNC_FLG_STATS | FUNC_FLG_LEADING | FUNC_FLG_SPQ); /* This flag is relevant for E1x only. * E2 doesn't have a TPA configuration in a function level. */ flags |= (bp->flags & TPA_ENABLE_FLAG) ? FUNC_FLG_TPA : 0; func_init.func_flgs = flags; func_init.pf_id = BP_FUNC(bp); func_init.func_id = BP_FUNC(bp); func_init.spq_map = bp->spq_mapping; func_init.spq_prod = bp->spq_prod_idx; bnx2x_func_init(bp, &func_init); memset(&(bp->cmng), 0, sizeof(struct cmng_struct_per_port)); /* * Congestion management values depend on the link rate * There is no active link so initial link rate is set to 10 Gbps. * When the link comes up The congestion management values are * re-calculated according to the actual link rate. */ bp->link_vars.line_speed = SPEED_10000; bnx2x_cmng_fns_init(bp, true, bnx2x_get_cmng_fns_mode(bp)); /* Only the PMF sets the HW */ if (bp->port.pmf) storm_memset_cmng(bp, &bp->cmng, BP_PORT(bp)); /* init Event Queue */ eq_data.base_addr.hi = U64_HI(bp->eq_mapping); eq_data.base_addr.lo = U64_LO(bp->eq_mapping); eq_data.producer = bp->eq_prod; eq_data.index_id = HC_SP_INDEX_EQ_CONS; eq_data.sb_id = DEF_SB_ID; storm_memset_eq_data(bp, &eq_data, BP_FUNC(bp)); } static void bnx2x_e1h_disable(struct bnx2x *bp) { int port = BP_PORT(bp); bnx2x_tx_disable(bp); REG_WR(bp, NIG_REG_LLH0_FUNC_EN + port*8, 0); } static void bnx2x_e1h_enable(struct bnx2x *bp) { int port = BP_PORT(bp); REG_WR(bp, NIG_REG_LLH0_FUNC_EN + port*8, 1); /* Tx queue should be only reenabled */ netif_tx_wake_all_queues(bp->dev); /* * Should not call netif_carrier_on since it will be called if the link * is up when checking for link state */ } /* called due to MCP event (on pmf): * reread new bandwidth configuration * configure FW * notify others function about the change */ static inline void bnx2x_config_mf_bw(struct bnx2x *bp) { if (bp->link_vars.link_up) { bnx2x_cmng_fns_init(bp, true, CMNG_FNS_MINMAX); bnx2x_link_sync_notify(bp); } storm_memset_cmng(bp, &bp->cmng, BP_PORT(bp)); } static inline void bnx2x_set_mf_bw(struct bnx2x *bp) { bnx2x_config_mf_bw(bp); bnx2x_fw_command(bp, DRV_MSG_CODE_SET_MF_BW_ACK, 0); } static void bnx2x_dcc_event(struct bnx2x *bp, u32 dcc_event) { DP(BNX2X_MSG_MCP, "dcc_event 0x%x\n", dcc_event); if (dcc_event & DRV_STATUS_DCC_DISABLE_ENABLE_PF) { /* * This is the only place besides the function initialization * where the bp->flags can change so it is done without any * locks */ if (bp->mf_config[BP_VN(bp)] & FUNC_MF_CFG_FUNC_DISABLED) { DP(NETIF_MSG_IFDOWN, "mf_cfg function disabled\n"); bp->flags |= MF_FUNC_DIS; bnx2x_e1h_disable(bp); } else { DP(NETIF_MSG_IFUP, "mf_cfg function enabled\n"); bp->flags &= ~MF_FUNC_DIS; bnx2x_e1h_enable(bp); } dcc_event &= ~DRV_STATUS_DCC_DISABLE_ENABLE_PF; } if (dcc_event & DRV_STATUS_DCC_BANDWIDTH_ALLOCATION) { bnx2x_config_mf_bw(bp); dcc_event &= ~DRV_STATUS_DCC_BANDWIDTH_ALLOCATION; } /* Report results to MCP */ if (dcc_event) bnx2x_fw_command(bp, DRV_MSG_CODE_DCC_FAILURE, 0); else bnx2x_fw_command(bp, DRV_MSG_CODE_DCC_OK, 0); } /* must be called under the spq lock */ static inline struct eth_spe *bnx2x_sp_get_next(struct bnx2x *bp) { struct eth_spe *next_spe = bp->spq_prod_bd; if (bp->spq_prod_bd == bp->spq_last_bd) { bp->spq_prod_bd = bp->spq; bp->spq_prod_idx = 0; DP(NETIF_MSG_TIMER, "end of spq\n"); } else { bp->spq_prod_bd++; bp->spq_prod_idx++; } return next_spe; } /* must be called under the spq lock */ static inline void bnx2x_sp_prod_update(struct bnx2x *bp) { int func = BP_FUNC(bp); /* * Make sure that BD data is updated before writing the producer: * BD data is written to the memory, the producer is read from the * memory, thus we need a full memory barrier to ensure the ordering. */ mb(); REG_WR16(bp, BAR_XSTRORM_INTMEM + XSTORM_SPQ_PROD_OFFSET(func), bp->spq_prod_idx); mmiowb(); } /** * bnx2x_is_contextless_ramrod - check if the current command ends on EQ * * @cmd: command to check * @cmd_type: command type */ static inline bool bnx2x_is_contextless_ramrod(int cmd, int cmd_type) { if ((cmd_type == NONE_CONNECTION_TYPE) || (cmd == RAMROD_CMD_ID_ETH_FORWARD_SETUP) || (cmd == RAMROD_CMD_ID_ETH_CLASSIFICATION_RULES) || (cmd == RAMROD_CMD_ID_ETH_FILTER_RULES) || (cmd == RAMROD_CMD_ID_ETH_MULTICAST_RULES) || (cmd == RAMROD_CMD_ID_ETH_SET_MAC) || (cmd == RAMROD_CMD_ID_ETH_RSS_UPDATE)) return true; else return false; } /** * bnx2x_sp_post - place a single command on an SP ring * * @bp: driver handle * @command: command to place (e.g. SETUP, FILTER_RULES, etc.) * @cid: SW CID the command is related to * @data_hi: command private data address (high 32 bits) * @data_lo: command private data address (low 32 bits) * @cmd_type: command type (e.g. NONE, ETH) * * SP data is handled as if it's always an address pair, thus data fields are * not swapped to little endian in upper functions. Instead this function swaps * data as if it's two u32 fields. */ int bnx2x_sp_post(struct bnx2x *bp, int command, int cid, u32 data_hi, u32 data_lo, int cmd_type) { struct eth_spe *spe; u16 type; bool common = bnx2x_is_contextless_ramrod(command, cmd_type); #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return -EIO; #endif spin_lock_bh(&bp->spq_lock); if (common) { if (!atomic_read(&bp->eq_spq_left)) { BNX2X_ERR("BUG! EQ ring full!\n"); spin_unlock_bh(&bp->spq_lock); bnx2x_panic(); return -EBUSY; } } else if (!atomic_read(&bp->cq_spq_left)) { BNX2X_ERR("BUG! SPQ ring full!\n"); spin_unlock_bh(&bp->spq_lock); bnx2x_panic(); return -EBUSY; } spe = bnx2x_sp_get_next(bp); /* CID needs port number to be encoded int it */ spe->hdr.conn_and_cmd_data = cpu_to_le32((command << SPE_HDR_CMD_ID_SHIFT) | HW_CID(bp, cid)); type = (cmd_type << SPE_HDR_CONN_TYPE_SHIFT) & SPE_HDR_CONN_TYPE; type |= ((BP_FUNC(bp) << SPE_HDR_FUNCTION_ID_SHIFT) & SPE_HDR_FUNCTION_ID); spe->hdr.type = cpu_to_le16(type); spe->data.update_data_addr.hi = cpu_to_le32(data_hi); spe->data.update_data_addr.lo = cpu_to_le32(data_lo); /* * It's ok if the actual decrement is issued towards the memory * somewhere between the spin_lock and spin_unlock. Thus no * more explict memory barrier is needed. */ if (common) atomic_dec(&bp->eq_spq_left); else atomic_dec(&bp->cq_spq_left); DP(BNX2X_MSG_SP/*NETIF_MSG_TIMER*/, "SPQE[%x] (%x:%x) (cmd, common?) (%d,%d) hw_cid %x data (%x:%x) " "type(0x%x) left (CQ, EQ) (%x,%x)\n", bp->spq_prod_idx, (u32)U64_HI(bp->spq_mapping), (u32)(U64_LO(bp->spq_mapping) + (void *)bp->spq_prod_bd - (void *)bp->spq), command, common, HW_CID(bp, cid), data_hi, data_lo, type, atomic_read(&bp->cq_spq_left), atomic_read(&bp->eq_spq_left)); bnx2x_sp_prod_update(bp); spin_unlock_bh(&bp->spq_lock); return 0; } /* acquire split MCP access lock register */ static int bnx2x_acquire_alr(struct bnx2x *bp) { u32 j, val; int rc = 0; might_sleep(); for (j = 0; j < 1000; j++) { val = (1UL << 31); REG_WR(bp, GRCBASE_MCP + 0x9c, val); val = REG_RD(bp, GRCBASE_MCP + 0x9c); if (val & (1L << 31)) break; msleep(5); } if (!(val & (1L << 31))) { BNX2X_ERR("Cannot acquire MCP access lock register\n"); rc = -EBUSY; } return rc; } /* release split MCP access lock register */ static void bnx2x_release_alr(struct bnx2x *bp) { REG_WR(bp, GRCBASE_MCP + 0x9c, 0); } #define BNX2X_DEF_SB_ATT_IDX 0x0001 #define BNX2X_DEF_SB_IDX 0x0002 static inline u16 bnx2x_update_dsb_idx(struct bnx2x *bp) { struct host_sp_status_block *def_sb = bp->def_status_blk; u16 rc = 0; barrier(); /* status block is written to by the chip */ if (bp->def_att_idx != def_sb->atten_status_block.attn_bits_index) { bp->def_att_idx = def_sb->atten_status_block.attn_bits_index; rc |= BNX2X_DEF_SB_ATT_IDX; } if (bp->def_idx != def_sb->sp_sb.running_index) { bp->def_idx = def_sb->sp_sb.running_index; rc |= BNX2X_DEF_SB_IDX; } /* Do not reorder: indecies reading should complete before handling */ barrier(); return rc; } /* * slow path service functions */ static void bnx2x_attn_int_asserted(struct bnx2x *bp, u32 asserted) { int port = BP_PORT(bp); u32 aeu_addr = port ? MISC_REG_AEU_MASK_ATTN_FUNC_1 : MISC_REG_AEU_MASK_ATTN_FUNC_0; u32 nig_int_mask_addr = port ? NIG_REG_MASK_INTERRUPT_PORT1 : NIG_REG_MASK_INTERRUPT_PORT0; u32 aeu_mask; u32 nig_mask = 0; u32 reg_addr; if (bp->attn_state & asserted) BNX2X_ERR("IGU ERROR\n"); bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_PORT0_ATT_MASK + port); aeu_mask = REG_RD(bp, aeu_addr); DP(NETIF_MSG_HW, "aeu_mask %x newly asserted %x\n", aeu_mask, asserted); aeu_mask &= ~(asserted & 0x3ff); DP(NETIF_MSG_HW, "new mask %x\n", aeu_mask); REG_WR(bp, aeu_addr, aeu_mask); bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_PORT0_ATT_MASK + port); DP(NETIF_MSG_HW, "attn_state %x\n", bp->attn_state); bp->attn_state |= asserted; DP(NETIF_MSG_HW, "new state %x\n", bp->attn_state); if (asserted & ATTN_HARD_WIRED_MASK) { if (asserted & ATTN_NIG_FOR_FUNC) { bnx2x_acquire_phy_lock(bp); /* save nig interrupt mask */ nig_mask = REG_RD(bp, nig_int_mask_addr); /* If nig_mask is not set, no need to call the update * function. */ if (nig_mask) { REG_WR(bp, nig_int_mask_addr, 0); bnx2x_link_attn(bp); } /* handle unicore attn? */ } if (asserted & ATTN_SW_TIMER_4_FUNC) DP(NETIF_MSG_HW, "ATTN_SW_TIMER_4_FUNC!\n"); if (asserted & GPIO_2_FUNC) DP(NETIF_MSG_HW, "GPIO_2_FUNC!\n"); if (asserted & GPIO_3_FUNC) DP(NETIF_MSG_HW, "GPIO_3_FUNC!\n"); if (asserted & GPIO_4_FUNC) DP(NETIF_MSG_HW, "GPIO_4_FUNC!\n"); if (port == 0) { if (asserted & ATTN_GENERAL_ATTN_1) { DP(NETIF_MSG_HW, "ATTN_GENERAL_ATTN_1!\n"); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_1, 0x0); } if (asserted & ATTN_GENERAL_ATTN_2) { DP(NETIF_MSG_HW, "ATTN_GENERAL_ATTN_2!\n"); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_2, 0x0); } if (asserted & ATTN_GENERAL_ATTN_3) { DP(NETIF_MSG_HW, "ATTN_GENERAL_ATTN_3!\n"); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_3, 0x0); } } else { if (asserted & ATTN_GENERAL_ATTN_4) { DP(NETIF_MSG_HW, "ATTN_GENERAL_ATTN_4!\n"); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_4, 0x0); } if (asserted & ATTN_GENERAL_ATTN_5) { DP(NETIF_MSG_HW, "ATTN_GENERAL_ATTN_5!\n"); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_5, 0x0); } if (asserted & ATTN_GENERAL_ATTN_6) { DP(NETIF_MSG_HW, "ATTN_GENERAL_ATTN_6!\n"); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_6, 0x0); } } } /* if hardwired */ if (bp->common.int_block == INT_BLOCK_HC) reg_addr = (HC_REG_COMMAND_REG + port*32 + COMMAND_REG_ATTN_BITS_SET); else reg_addr = (BAR_IGU_INTMEM + IGU_CMD_ATTN_BIT_SET_UPPER*8); DP(NETIF_MSG_HW, "about to mask 0x%08x at %s addr 0x%x\n", asserted, (bp->common.int_block == INT_BLOCK_HC) ? "HC" : "IGU", reg_addr); REG_WR(bp, reg_addr, asserted); /* now set back the mask */ if (asserted & ATTN_NIG_FOR_FUNC) { REG_WR(bp, nig_int_mask_addr, nig_mask); bnx2x_release_phy_lock(bp); } } static inline void bnx2x_fan_failure(struct bnx2x *bp) { int port = BP_PORT(bp); u32 ext_phy_config; /* mark the failure */ ext_phy_config = SHMEM_RD(bp, dev_info.port_hw_config[port].external_phy_config); ext_phy_config &= ~PORT_HW_CFG_XGXS_EXT_PHY_TYPE_MASK; ext_phy_config |= PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE; SHMEM_WR(bp, dev_info.port_hw_config[port].external_phy_config, ext_phy_config); /* log the failure */ netdev_err(bp->dev, "Fan Failure on Network Controller has caused" " the driver to shutdown the card to prevent permanent" " damage. Please contact OEM Support for assistance\n"); } static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn) { int port = BP_PORT(bp); int reg_offset; u32 val; reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 : MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0); if (attn & AEU_INPUTS_ATTN_BITS_SPIO5) { val = REG_RD(bp, reg_offset); val &= ~AEU_INPUTS_ATTN_BITS_SPIO5; REG_WR(bp, reg_offset, val); BNX2X_ERR("SPIO5 hw attention\n"); /* Fan failure attention */ bnx2x_hw_reset_phy(&bp->link_params); bnx2x_fan_failure(bp); } if ((attn & bp->link_vars.aeu_int_mask) && bp->port.pmf) { bnx2x_acquire_phy_lock(bp); bnx2x_handle_module_detect_int(&bp->link_params); bnx2x_release_phy_lock(bp); } if (attn & HW_INTERRUT_ASSERT_SET_0) { val = REG_RD(bp, reg_offset); val &= ~(attn & HW_INTERRUT_ASSERT_SET_0); REG_WR(bp, reg_offset, val); BNX2X_ERR("FATAL HW block attention set0 0x%x\n", (u32)(attn & HW_INTERRUT_ASSERT_SET_0)); bnx2x_panic(); } } static inline void bnx2x_attn_int_deasserted1(struct bnx2x *bp, u32 attn) { u32 val; if (attn & AEU_INPUTS_ATTN_BITS_DOORBELLQ_HW_INTERRUPT) { val = REG_RD(bp, DORQ_REG_DORQ_INT_STS_CLR); BNX2X_ERR("DB hw attention 0x%x\n", val); /* DORQ discard attention */ if (val & 0x2) BNX2X_ERR("FATAL error from DORQ\n"); } if (attn & HW_INTERRUT_ASSERT_SET_1) { int port = BP_PORT(bp); int reg_offset; reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_1 : MISC_REG_AEU_ENABLE1_FUNC_0_OUT_1); val = REG_RD(bp, reg_offset); val &= ~(attn & HW_INTERRUT_ASSERT_SET_1); REG_WR(bp, reg_offset, val); BNX2X_ERR("FATAL HW block attention set1 0x%x\n", (u32)(attn & HW_INTERRUT_ASSERT_SET_1)); bnx2x_panic(); } } static inline void bnx2x_attn_int_deasserted2(struct bnx2x *bp, u32 attn) { u32 val; if (attn & AEU_INPUTS_ATTN_BITS_CFC_HW_INTERRUPT) { val = REG_RD(bp, CFC_REG_CFC_INT_STS_CLR); BNX2X_ERR("CFC hw attention 0x%x\n", val); /* CFC error attention */ if (val & 0x2) BNX2X_ERR("FATAL error from CFC\n"); } if (attn & AEU_INPUTS_ATTN_BITS_PXP_HW_INTERRUPT) { val = REG_RD(bp, PXP_REG_PXP_INT_STS_CLR_0); BNX2X_ERR("PXP hw attention-0 0x%x\n", val); /* RQ_USDMDP_FIFO_OVERFLOW */ if (val & 0x18000) BNX2X_ERR("FATAL error from PXP\n"); if (!CHIP_IS_E1x(bp)) { val = REG_RD(bp, PXP_REG_PXP_INT_STS_CLR_1); BNX2X_ERR("PXP hw attention-1 0x%x\n", val); } } if (attn & HW_INTERRUT_ASSERT_SET_2) { int port = BP_PORT(bp); int reg_offset; reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_2 : MISC_REG_AEU_ENABLE1_FUNC_0_OUT_2); val = REG_RD(bp, reg_offset); val &= ~(attn & HW_INTERRUT_ASSERT_SET_2); REG_WR(bp, reg_offset, val); BNX2X_ERR("FATAL HW block attention set2 0x%x\n", (u32)(attn & HW_INTERRUT_ASSERT_SET_2)); bnx2x_panic(); } } static inline void bnx2x_attn_int_deasserted3(struct bnx2x *bp, u32 attn) { u32 val; if (attn & EVEREST_GEN_ATTN_IN_USE_MASK) { if (attn & BNX2X_PMF_LINK_ASSERT) { int func = BP_FUNC(bp); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_12 + func*4, 0); bp->mf_config[BP_VN(bp)] = MF_CFG_RD(bp, func_mf_config[BP_ABS_FUNC(bp)].config); val = SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_status); if (val & DRV_STATUS_DCC_EVENT_MASK) bnx2x_dcc_event(bp, (val & DRV_STATUS_DCC_EVENT_MASK)); if (val & DRV_STATUS_SET_MF_BW) bnx2x_set_mf_bw(bp); if ((bp->port.pmf == 0) && (val & DRV_STATUS_PMF)) bnx2x_pmf_update(bp); if (bp->port.pmf && (val & DRV_STATUS_DCBX_NEGOTIATION_RESULTS) && bp->dcbx_enabled > 0) /* start dcbx state machine */ bnx2x_dcbx_set_params(bp, BNX2X_DCBX_STATE_NEG_RECEIVED); if (bp->link_vars.periodic_flags & PERIODIC_FLAGS_LINK_EVENT) { /* sync with link */ bnx2x_acquire_phy_lock(bp); bp->link_vars.periodic_flags &= ~PERIODIC_FLAGS_LINK_EVENT; bnx2x_release_phy_lock(bp); if (IS_MF(bp)) bnx2x_link_sync_notify(bp); bnx2x_link_report(bp); } /* Always call it here: bnx2x_link_report() will * prevent the link indication duplication. */ bnx2x__link_status_update(bp); } else if (attn & BNX2X_MC_ASSERT_BITS) { BNX2X_ERR("MC assert!\n"); bnx2x_mc_assert(bp); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_10, 0); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_9, 0); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_8, 0); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_7, 0); bnx2x_panic(); } else if (attn & BNX2X_MCP_ASSERT) { BNX2X_ERR("MCP assert!\n"); REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_11, 0); bnx2x_fw_dump(bp); } else BNX2X_ERR("Unknown HW assert! (attn 0x%x)\n", attn); } if (attn & EVEREST_LATCHED_ATTN_IN_USE_MASK) { BNX2X_ERR("LATCHED attention 0x%08x (masked)\n", attn); if (attn & BNX2X_GRC_TIMEOUT) { val = CHIP_IS_E1(bp) ? 0 : REG_RD(bp, MISC_REG_GRC_TIMEOUT_ATTN); BNX2X_ERR("GRC time-out 0x%08x\n", val); } if (attn & BNX2X_GRC_RSV) { val = CHIP_IS_E1(bp) ? 0 : REG_RD(bp, MISC_REG_GRC_RSV_ATTN); BNX2X_ERR("GRC reserved 0x%08x\n", val); } REG_WR(bp, MISC_REG_AEU_CLR_LATCH_SIGNAL, 0x7ff); } } /* * Bits map: * 0-7 - Engine0 load counter. * 8-15 - Engine1 load counter. * 16 - Engine0 RESET_IN_PROGRESS bit. * 17 - Engine1 RESET_IN_PROGRESS bit. * 18 - Engine0 ONE_IS_LOADED. Set when there is at least one active function * on the engine * 19 - Engine1 ONE_IS_LOADED. * 20 - Chip reset flow bit. When set none-leader must wait for both engines * leader to complete (check for both RESET_IN_PROGRESS bits and not for * just the one belonging to its engine). * */ #define BNX2X_RECOVERY_GLOB_REG MISC_REG_GENERIC_POR_1 #define BNX2X_PATH0_LOAD_CNT_MASK 0x000000ff #define BNX2X_PATH0_LOAD_CNT_SHIFT 0 #define BNX2X_PATH1_LOAD_CNT_MASK 0x0000ff00 #define BNX2X_PATH1_LOAD_CNT_SHIFT 8 #define BNX2X_PATH0_RST_IN_PROG_BIT 0x00010000 #define BNX2X_PATH1_RST_IN_PROG_BIT 0x00020000 #define BNX2X_GLOBAL_RESET_BIT 0x00040000 /* * Set the GLOBAL_RESET bit. * * Should be run under rtnl lock */ void bnx2x_set_reset_global(struct bnx2x *bp) { u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val | BNX2X_GLOBAL_RESET_BIT); barrier(); mmiowb(); } /* * Clear the GLOBAL_RESET bit. * * Should be run under rtnl lock */ static inline void bnx2x_clear_reset_global(struct bnx2x *bp) { u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val & (~BNX2X_GLOBAL_RESET_BIT)); barrier(); mmiowb(); } /* * Checks the GLOBAL_RESET bit. * * should be run under rtnl lock */ static inline bool bnx2x_reset_is_global(struct bnx2x *bp) { u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); DP(NETIF_MSG_HW, "GEN_REG_VAL=0x%08x\n", val); return (val & BNX2X_GLOBAL_RESET_BIT) ? true : false; } /* * Clear RESET_IN_PROGRESS bit for the current engine. * * Should be run under rtnl lock */ static inline void bnx2x_set_reset_done(struct bnx2x *bp) { u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); u32 bit = BP_PATH(bp) ? BNX2X_PATH1_RST_IN_PROG_BIT : BNX2X_PATH0_RST_IN_PROG_BIT; /* Clear the bit */ val &= ~bit; REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); barrier(); mmiowb(); } /* * Set RESET_IN_PROGRESS for the current engine. * * should be run under rtnl lock */ void bnx2x_set_reset_in_progress(struct bnx2x *bp) { u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); u32 bit = BP_PATH(bp) ? BNX2X_PATH1_RST_IN_PROG_BIT : BNX2X_PATH0_RST_IN_PROG_BIT; /* Set the bit */ val |= bit; REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); barrier(); mmiowb(); } /* * Checks the RESET_IN_PROGRESS bit for the given engine. * should be run under rtnl lock */ bool bnx2x_reset_is_done(struct bnx2x *bp, int engine) { u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); u32 bit = engine ? BNX2X_PATH1_RST_IN_PROG_BIT : BNX2X_PATH0_RST_IN_PROG_BIT; /* return false if bit is set */ return (val & bit) ? false : true; } /* * Increment the load counter for the current engine. * * should be run under rtnl lock */ void bnx2x_inc_load_cnt(struct bnx2x *bp) { u32 val1, val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); u32 mask = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : BNX2X_PATH0_LOAD_CNT_MASK; u32 shift = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_SHIFT : BNX2X_PATH0_LOAD_CNT_SHIFT; DP(NETIF_MSG_HW, "Old GEN_REG_VAL=0x%08x\n", val); /* get the current counter value */ val1 = (val & mask) >> shift; /* increment... */ val1++; /* clear the old value */ val &= ~mask; /* set the new one */ val |= ((val1 << shift) & mask); REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); barrier(); mmiowb(); } /** * bnx2x_dec_load_cnt - decrement the load counter * * @bp: driver handle * * Should be run under rtnl lock. * Decrements the load counter for the current engine. Returns * the new counter value. */ u32 bnx2x_dec_load_cnt(struct bnx2x *bp) { u32 val1, val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); u32 mask = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : BNX2X_PATH0_LOAD_CNT_MASK; u32 shift = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_SHIFT : BNX2X_PATH0_LOAD_CNT_SHIFT; DP(NETIF_MSG_HW, "Old GEN_REG_VAL=0x%08x\n", val); /* get the current counter value */ val1 = (val & mask) >> shift; /* decrement... */ val1--; /* clear the old value */ val &= ~mask; /* set the new one */ val |= ((val1 << shift) & mask); REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); barrier(); mmiowb(); return val1; } /* * Read the load counter for the current engine. * * should be run under rtnl lock */ static inline u32 bnx2x_get_load_cnt(struct bnx2x *bp, int engine) { u32 mask = (engine ? BNX2X_PATH1_LOAD_CNT_MASK : BNX2X_PATH0_LOAD_CNT_MASK); u32 shift = (engine ? BNX2X_PATH1_LOAD_CNT_SHIFT : BNX2X_PATH0_LOAD_CNT_SHIFT); u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); DP(NETIF_MSG_HW, "GLOB_REG=0x%08x\n", val); val = (val & mask) >> shift; DP(NETIF_MSG_HW, "load_cnt for engine %d = %d\n", engine, val); return val; } /* * Reset the load counter for the current engine. * * should be run under rtnl lock */ static inline void bnx2x_clear_load_cnt(struct bnx2x *bp) { u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); u32 mask = (BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : BNX2X_PATH0_LOAD_CNT_MASK); REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val & (~mask)); } static inline void _print_next_block(int idx, const char *blk) { if (idx) pr_cont(", "); pr_cont("%s", blk); } static inline int bnx2x_check_blocks_with_parity0(u32 sig, int par_num, bool print) { int i = 0; u32 cur_bit = 0; for (i = 0; sig; i++) { cur_bit = ((u32)0x1 << i); if (sig & cur_bit) { switch (cur_bit) { case AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR: if (print) _print_next_block(par_num++, "BRB"); break; case AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR: if (print) _print_next_block(par_num++, "PARSER"); break; case AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR: if (print) _print_next_block(par_num++, "TSDM"); break; case AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR: if (print) _print_next_block(par_num++, "SEARCHER"); break; case AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR: if (print) _print_next_block(par_num++, "TCM"); break; case AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR: if (print) _print_next_block(par_num++, "TSEMI"); break; case AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR: if (print) _print_next_block(par_num++, "XPB"); break; } /* Clear the bit */ sig &= ~cur_bit; } } return par_num; } static inline int bnx2x_check_blocks_with_parity1(u32 sig, int par_num, bool *global, bool print) { int i = 0; u32 cur_bit = 0; for (i = 0; sig; i++) { cur_bit = ((u32)0x1 << i); if (sig & cur_bit) { switch (cur_bit) { case AEU_INPUTS_ATTN_BITS_PBF_PARITY_ERROR: if (print) _print_next_block(par_num++, "PBF"); break; case AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR: if (print) _print_next_block(par_num++, "QM"); break; case AEU_INPUTS_ATTN_BITS_TIMERS_PARITY_ERROR: if (print) _print_next_block(par_num++, "TM"); break; case AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR: if (print) _print_next_block(par_num++, "XSDM"); break; case AEU_INPUTS_ATTN_BITS_XCM_PARITY_ERROR: if (print) _print_next_block(par_num++, "XCM"); break; case AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR: if (print) _print_next_block(par_num++, "XSEMI"); break; case AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR: if (print) _print_next_block(par_num++, "DOORBELLQ"); break; case AEU_INPUTS_ATTN_BITS_NIG_PARITY_ERROR: if (print) _print_next_block(par_num++, "NIG"); break; case AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR: if (print) _print_next_block(par_num++, "VAUX PCI CORE"); *global = true; break; case AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR: if (print) _print_next_block(par_num++, "DEBUG"); break; case AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR: if (print) _print_next_block(par_num++, "USDM"); break; case AEU_INPUTS_ATTN_BITS_UCM_PARITY_ERROR: if (print) _print_next_block(par_num++, "UCM"); break; case AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR: if (print) _print_next_block(par_num++, "USEMI"); break; case AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR: if (print) _print_next_block(par_num++, "UPB"); break; case AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR: if (print) _print_next_block(par_num++, "CSDM"); break; case AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR: if (print) _print_next_block(par_num++, "CCM"); break; } /* Clear the bit */ sig &= ~cur_bit; } } return par_num; } static inline int bnx2x_check_blocks_with_parity2(u32 sig, int par_num, bool print) { int i = 0; u32 cur_bit = 0; for (i = 0; sig; i++) { cur_bit = ((u32)0x1 << i); if (sig & cur_bit) { switch (cur_bit) { case AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR: if (print) _print_next_block(par_num++, "CSEMI"); break; case AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR: if (print) _print_next_block(par_num++, "PXP"); break; case AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR: if (print) _print_next_block(par_num++, "PXPPCICLOCKCLIENT"); break; case AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR: if (print) _print_next_block(par_num++, "CFC"); break; case AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR: if (print) _print_next_block(par_num++, "CDU"); break; case AEU_INPUTS_ATTN_BITS_DMAE_PARITY_ERROR: if (print) _print_next_block(par_num++, "DMAE"); break; case AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR: if (print) _print_next_block(par_num++, "IGU"); break; case AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR: if (print) _print_next_block(par_num++, "MISC"); break; } /* Clear the bit */ sig &= ~cur_bit; } } return par_num; } static inline int bnx2x_check_blocks_with_parity3(u32 sig, int par_num, bool *global, bool print) { int i = 0; u32 cur_bit = 0; for (i = 0; sig; i++) { cur_bit = ((u32)0x1 << i); if (sig & cur_bit) { switch (cur_bit) { case AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY: if (print) _print_next_block(par_num++, "MCP ROM"); *global = true; break; case AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY: if (print) _print_next_block(par_num++, "MCP UMP RX"); *global = true; break; case AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY: if (print) _print_next_block(par_num++, "MCP UMP TX"); *global = true; break; case AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY: if (print) _print_next_block(par_num++, "MCP SCPAD"); *global = true; break; } /* Clear the bit */ sig &= ~cur_bit; } } return par_num; } static inline int bnx2x_check_blocks_with_parity4(u32 sig, int par_num, bool print) { int i = 0; u32 cur_bit = 0; for (i = 0; sig; i++) { cur_bit = ((u32)0x1 << i); if (sig & cur_bit) { switch (cur_bit) { case AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR: if (print) _print_next_block(par_num++, "PGLUE_B"); break; case AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR: if (print) _print_next_block(par_num++, "ATC"); break; } /* Clear the bit */ sig &= ~cur_bit; } } return par_num; } static inline bool bnx2x_parity_attn(struct bnx2x *bp, bool *global, bool print, u32 *sig) { if ((sig[0] & HW_PRTY_ASSERT_SET_0) || (sig[1] & HW_PRTY_ASSERT_SET_1) || (sig[2] & HW_PRTY_ASSERT_SET_2) || (sig[3] & HW_PRTY_ASSERT_SET_3) || (sig[4] & HW_PRTY_ASSERT_SET_4)) { int par_num = 0; DP(NETIF_MSG_HW, "Was parity error: HW block parity attention: " "[0]:0x%08x [1]:0x%08x [2]:0x%08x [3]:0x%08x " "[4]:0x%08x\n", sig[0] & HW_PRTY_ASSERT_SET_0, sig[1] & HW_PRTY_ASSERT_SET_1, sig[2] & HW_PRTY_ASSERT_SET_2, sig[3] & HW_PRTY_ASSERT_SET_3, sig[4] & HW_PRTY_ASSERT_SET_4); if (print) netdev_err(bp->dev, "Parity errors detected in blocks: "); par_num = bnx2x_check_blocks_with_parity0( sig[0] & HW_PRTY_ASSERT_SET_0, par_num, print); par_num = bnx2x_check_blocks_with_parity1( sig[1] & HW_PRTY_ASSERT_SET_1, par_num, global, print); par_num = bnx2x_check_blocks_with_parity2( sig[2] & HW_PRTY_ASSERT_SET_2, par_num, print); par_num = bnx2x_check_blocks_with_parity3( sig[3] & HW_PRTY_ASSERT_SET_3, par_num, global, print); par_num = bnx2x_check_blocks_with_parity4( sig[4] & HW_PRTY_ASSERT_SET_4, par_num, print); if (print) pr_cont("\n"); return true; } else return false; } /** * bnx2x_chk_parity_attn - checks for parity attentions. * * @bp: driver handle * @global: true if there was a global attention * @print: show parity attention in syslog */ bool bnx2x_chk_parity_attn(struct bnx2x *bp, bool *global, bool print) { struct attn_route attn = { {0} }; int port = BP_PORT(bp); attn.sig[0] = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_1_FUNC_0 + port*4); attn.sig[1] = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_2_FUNC_0 + port*4); attn.sig[2] = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_3_FUNC_0 + port*4); attn.sig[3] = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_4_FUNC_0 + port*4); if (!CHIP_IS_E1x(bp)) attn.sig[4] = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_5_FUNC_0 + port*4); return bnx2x_parity_attn(bp, global, print, attn.sig); } static inline void bnx2x_attn_int_deasserted4(struct bnx2x *bp, u32 attn) { u32 val; if (attn & AEU_INPUTS_ATTN_BITS_PGLUE_HW_INTERRUPT) { val = REG_RD(bp, PGLUE_B_REG_PGLUE_B_INT_STS_CLR); BNX2X_ERR("PGLUE hw attention 0x%x\n", val); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_ADDRESS_ERROR) BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" "ADDRESS_ERROR\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_INCORRECT_RCV_BEHAVIOR) BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" "INCORRECT_RCV_BEHAVIOR\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN) BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" "WAS_ERROR_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_VF_LENGTH_VIOLATION_ATTN) BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" "VF_LENGTH_VIOLATION_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_VF_GRC_SPACE_VIOLATION_ATTN) BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" "VF_GRC_SPACE_VIOLATION_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_VF_MSIX_BAR_VIOLATION_ATTN) BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" "VF_MSIX_BAR_VIOLATION_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_ERROR_ATTN) BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" "TCPL_ERROR_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_IN_TWO_RCBS_ATTN) BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" "TCPL_IN_TWO_RCBS_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_CSSNOOP_FIFO_OVERFLOW) BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" "CSSNOOP_FIFO_OVERFLOW\n"); } if (attn & AEU_INPUTS_ATTN_BITS_ATC_HW_INTERRUPT) { val = REG_RD(bp, ATC_REG_ATC_INT_STS_CLR); BNX2X_ERR("ATC hw attention 0x%x\n", val); if (val & ATC_ATC_INT_STS_REG_ADDRESS_ERROR) BNX2X_ERR("ATC_ATC_INT_STS_REG_ADDRESS_ERROR\n"); if (val & ATC_ATC_INT_STS_REG_ATC_TCPL_TO_NOT_PEND) BNX2X_ERR("ATC_ATC_INT_STS_REG" "_ATC_TCPL_TO_NOT_PEND\n"); if (val & ATC_ATC_INT_STS_REG_ATC_GPA_MULTIPLE_HITS) BNX2X_ERR("ATC_ATC_INT_STS_REG_" "ATC_GPA_MULTIPLE_HITS\n"); if (val & ATC_ATC_INT_STS_REG_ATC_RCPL_TO_EMPTY_CNT) BNX2X_ERR("ATC_ATC_INT_STS_REG_" "ATC_RCPL_TO_EMPTY_CNT\n"); if (val & ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR) BNX2X_ERR("ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR\n"); if (val & ATC_ATC_INT_STS_REG_ATC_IREQ_LESS_THAN_STU) BNX2X_ERR("ATC_ATC_INT_STS_REG_" "ATC_IREQ_LESS_THAN_STU\n"); } if (attn & (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)) { BNX2X_ERR("FATAL parity attention set4 0x%x\n", (u32)(attn & (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR))); } } static void bnx2x_attn_int_deasserted(struct bnx2x *bp, u32 deasserted) { struct attn_route attn, *group_mask; int port = BP_PORT(bp); int index; u32 reg_addr; u32 val; u32 aeu_mask; bool global = false; /* need to take HW lock because MCP or other port might also try to handle this event */ bnx2x_acquire_alr(bp); if (bnx2x_chk_parity_attn(bp, &global, true)) { #ifndef BNX2X_STOP_ON_ERROR bp->recovery_state = BNX2X_RECOVERY_INIT; schedule_delayed_work(&bp->sp_rtnl_task, 0); /* Disable HW interrupts */ bnx2x_int_disable(bp); /* In case of parity errors don't handle attentions so that * other function would "see" parity errors. */ #else bnx2x_panic(); #endif bnx2x_release_alr(bp); return; } attn.sig[0] = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_1_FUNC_0 + port*4); attn.sig[1] = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_2_FUNC_0 + port*4); attn.sig[2] = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_3_FUNC_0 + port*4); attn.sig[3] = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_4_FUNC_0 + port*4); if (!CHIP_IS_E1x(bp)) attn.sig[4] = REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_5_FUNC_0 + port*4); else attn.sig[4] = 0; DP(NETIF_MSG_HW, "attn: %08x %08x %08x %08x %08x\n", attn.sig[0], attn.sig[1], attn.sig[2], attn.sig[3], attn.sig[4]); for (index = 0; index < MAX_DYNAMIC_ATTN_GRPS; index++) { if (deasserted & (1 << index)) { group_mask = &bp->attn_group[index]; DP(NETIF_MSG_HW, "group[%d]: %08x %08x " "%08x %08x %08x\n", index, group_mask->sig[0], group_mask->sig[1], group_mask->sig[2], group_mask->sig[3], group_mask->sig[4]); bnx2x_attn_int_deasserted4(bp, attn.sig[4] & group_mask->sig[4]); bnx2x_attn_int_deasserted3(bp, attn.sig[3] & group_mask->sig[3]); bnx2x_attn_int_deasserted1(bp, attn.sig[1] & group_mask->sig[1]); bnx2x_attn_int_deasserted2(bp, attn.sig[2] & group_mask->sig[2]); bnx2x_attn_int_deasserted0(bp, attn.sig[0] & group_mask->sig[0]); } } bnx2x_release_alr(bp); if (bp->common.int_block == INT_BLOCK_HC) reg_addr = (HC_REG_COMMAND_REG + port*32 + COMMAND_REG_ATTN_BITS_CLR); else reg_addr = (BAR_IGU_INTMEM + IGU_CMD_ATTN_BIT_CLR_UPPER*8); val = ~deasserted; DP(NETIF_MSG_HW, "about to mask 0x%08x at %s addr 0x%x\n", val, (bp->common.int_block == INT_BLOCK_HC) ? "HC" : "IGU", reg_addr); REG_WR(bp, reg_addr, val); if (~bp->attn_state & deasserted) BNX2X_ERR("IGU ERROR\n"); reg_addr = port ? MISC_REG_AEU_MASK_ATTN_FUNC_1 : MISC_REG_AEU_MASK_ATTN_FUNC_0; bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_PORT0_ATT_MASK + port); aeu_mask = REG_RD(bp, reg_addr); DP(NETIF_MSG_HW, "aeu_mask %x newly deasserted %x\n", aeu_mask, deasserted); aeu_mask |= (deasserted & 0x3ff); DP(NETIF_MSG_HW, "new mask %x\n", aeu_mask); REG_WR(bp, reg_addr, aeu_mask); bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_PORT0_ATT_MASK + port); DP(NETIF_MSG_HW, "attn_state %x\n", bp->attn_state); bp->attn_state &= ~deasserted; DP(NETIF_MSG_HW, "new state %x\n", bp->attn_state); } static void bnx2x_attn_int(struct bnx2x *bp) { /* read local copy of bits */ u32 attn_bits = le32_to_cpu(bp->def_status_blk->atten_status_block. attn_bits); u32 attn_ack = le32_to_cpu(bp->def_status_blk->atten_status_block. attn_bits_ack); u32 attn_state = bp->attn_state; /* look for changed bits */ u32 asserted = attn_bits & ~attn_ack & ~attn_state; u32 deasserted = ~attn_bits & attn_ack & attn_state; DP(NETIF_MSG_HW, "attn_bits %x attn_ack %x asserted %x deasserted %x\n", attn_bits, attn_ack, asserted, deasserted); if (~(attn_bits ^ attn_ack) & (attn_bits ^ attn_state)) BNX2X_ERR("BAD attention state\n"); /* handle bits that were raised */ if (asserted) bnx2x_attn_int_asserted(bp, asserted); if (deasserted) bnx2x_attn_int_deasserted(bp, deasserted); } void bnx2x_igu_ack_sb(struct bnx2x *bp, u8 igu_sb_id, u8 segment, u16 index, u8 op, u8 update) { u32 igu_addr = BAR_IGU_INTMEM + (IGU_CMD_INT_ACK_BASE + igu_sb_id)*8; bnx2x_igu_ack_sb_gen(bp, igu_sb_id, segment, index, op, update, igu_addr); } static inline void bnx2x_update_eq_prod(struct bnx2x *bp, u16 prod) { /* No memory barriers */ storm_memset_eq_prod(bp, prod, BP_FUNC(bp)); mmiowb(); /* keep prod updates ordered */ } #ifdef BCM_CNIC static int bnx2x_cnic_handle_cfc_del(struct bnx2x *bp, u32 cid, union event_ring_elem *elem) { u8 err = elem->message.error; if (!bp->cnic_eth_dev.starting_cid || (cid < bp->cnic_eth_dev.starting_cid && cid != bp->cnic_eth_dev.iscsi_l2_cid)) return 1; DP(BNX2X_MSG_SP, "got delete ramrod for CNIC CID %d\n", cid); if (unlikely(err)) { BNX2X_ERR("got delete ramrod for CNIC CID %d with error!\n", cid); bnx2x_panic_dump(bp); } bnx2x_cnic_cfc_comp(bp, cid, err); return 0; } #endif static inline void bnx2x_handle_mcast_eqe(struct bnx2x *bp) { struct bnx2x_mcast_ramrod_params rparam; int rc; memset(&rparam, 0, sizeof(rparam)); rparam.mcast_obj = &bp->mcast_obj; netif_addr_lock_bh(bp->dev); /* Clear pending state for the last command */ bp->mcast_obj.raw.clear_pending(&bp->mcast_obj.raw); /* If there are pending mcast commands - send them */ if (bp->mcast_obj.check_pending(&bp->mcast_obj)) { rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_CONT); if (rc < 0) BNX2X_ERR("Failed to send pending mcast commands: %d\n", rc); } netif_addr_unlock_bh(bp->dev); } static inline void bnx2x_handle_classification_eqe(struct bnx2x *bp, union event_ring_elem *elem) { unsigned long ramrod_flags = 0; int rc = 0; u32 cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK; struct bnx2x_vlan_mac_obj *vlan_mac_obj; /* Always push next commands out, don't wait here */ __set_bit(RAMROD_CONT, &ramrod_flags); switch (elem->message.data.eth_event.echo >> BNX2X_SWCID_SHIFT) { case BNX2X_FILTER_MAC_PENDING: #ifdef BCM_CNIC if (cid == BNX2X_ISCSI_ETH_CID) vlan_mac_obj = &bp->iscsi_l2_mac_obj; else #endif vlan_mac_obj = &bp->fp[cid].mac_obj; break; vlan_mac_obj = &bp->fp[cid].mac_obj; case BNX2X_FILTER_MCAST_PENDING: /* This is only relevant for 57710 where multicast MACs are * configured as unicast MACs using the same ramrod. */ bnx2x_handle_mcast_eqe(bp); return; default: BNX2X_ERR("Unsupported classification command: %d\n", elem->message.data.eth_event.echo); return; } rc = vlan_mac_obj->complete(bp, vlan_mac_obj, elem, &ramrod_flags); if (rc < 0) BNX2X_ERR("Failed to schedule new commands: %d\n", rc); else if (rc > 0) DP(BNX2X_MSG_SP, "Scheduled next pending commands...\n"); } #ifdef BCM_CNIC static void bnx2x_set_iscsi_eth_rx_mode(struct bnx2x *bp, bool start); #endif static inline void bnx2x_handle_rx_mode_eqe(struct bnx2x *bp) { netif_addr_lock_bh(bp->dev); clear_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state); /* Send rx_mode command again if was requested */ if (test_and_clear_bit(BNX2X_FILTER_RX_MODE_SCHED, &bp->sp_state)) bnx2x_set_storm_rx_mode(bp); #ifdef BCM_CNIC else if (test_and_clear_bit(BNX2X_FILTER_ISCSI_ETH_START_SCHED, &bp->sp_state)) bnx2x_set_iscsi_eth_rx_mode(bp, true); else if (test_and_clear_bit(BNX2X_FILTER_ISCSI_ETH_STOP_SCHED, &bp->sp_state)) bnx2x_set_iscsi_eth_rx_mode(bp, false); #endif netif_addr_unlock_bh(bp->dev); } static inline struct bnx2x_queue_sp_obj *bnx2x_cid_to_q_obj( struct bnx2x *bp, u32 cid) { DP(BNX2X_MSG_SP, "retrieving fp from cid %d", cid); #ifdef BCM_CNIC if (cid == BNX2X_FCOE_ETH_CID) return &bnx2x_fcoe(bp, q_obj); else #endif return &bnx2x_fp(bp, CID_TO_FP(cid), q_obj); } static void bnx2x_eq_int(struct bnx2x *bp) { u16 hw_cons, sw_cons, sw_prod; union event_ring_elem *elem; u32 cid; u8 opcode; int spqe_cnt = 0; struct bnx2x_queue_sp_obj *q_obj; struct bnx2x_func_sp_obj *f_obj = &bp->func_obj; struct bnx2x_raw_obj *rss_raw = &bp->rss_conf_obj.raw; hw_cons = le16_to_cpu(*bp->eq_cons_sb); /* The hw_cos range is 1-255, 257 - the sw_cons range is 0-254, 256. * when we get the the next-page we nned to adjust so the loop * condition below will be met. The next element is the size of a * regular element and hence incrementing by 1 */ if ((hw_cons & EQ_DESC_MAX_PAGE) == EQ_DESC_MAX_PAGE) hw_cons++; /* This function may never run in parallel with itself for a * specific bp, thus there is no need in "paired" read memory * barrier here. */ sw_cons = bp->eq_cons; sw_prod = bp->eq_prod; DP(BNX2X_MSG_SP, "EQ: hw_cons %u sw_cons %u bp->eq_spq_left %x\n", hw_cons, sw_cons, atomic_read(&bp->eq_spq_left)); for (; sw_cons != hw_cons; sw_prod = NEXT_EQ_IDX(sw_prod), sw_cons = NEXT_EQ_IDX(sw_cons)) { elem = &bp->eq_ring[EQ_DESC(sw_cons)]; cid = SW_CID(elem->message.data.cfc_del_event.cid); opcode = elem->message.opcode; /* handle eq element */ switch (opcode) { case EVENT_RING_OPCODE_STAT_QUERY: DP(NETIF_MSG_TIMER, "got statistics comp event %d\n", bp->stats_comp++); /* nothing to do with stats comp */ goto next_spqe; case EVENT_RING_OPCODE_CFC_DEL: /* handle according to cid range */ /* * we may want to verify here that the bp state is * HALTING */ DP(BNX2X_MSG_SP, "got delete ramrod for MULTI[%d]\n", cid); #ifdef BCM_CNIC if (!bnx2x_cnic_handle_cfc_del(bp, cid, elem)) goto next_spqe; #endif q_obj = bnx2x_cid_to_q_obj(bp, cid); if (q_obj->complete_cmd(bp, q_obj, BNX2X_Q_CMD_CFC_DEL)) break; goto next_spqe; case EVENT_RING_OPCODE_STOP_TRAFFIC: DP(BNX2X_MSG_SP, "got STOP TRAFFIC\n"); if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_TX_STOP)) break; bnx2x_dcbx_set_params(bp, BNX2X_DCBX_STATE_TX_PAUSED); goto next_spqe; case EVENT_RING_OPCODE_START_TRAFFIC: DP(BNX2X_MSG_SP, "got START TRAFFIC\n"); if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_TX_START)) break; bnx2x_dcbx_set_params(bp, BNX2X_DCBX_STATE_TX_RELEASED); goto next_spqe; case EVENT_RING_OPCODE_FUNCTION_START: DP(BNX2X_MSG_SP, "got FUNC_START ramrod\n"); if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_START)) break; goto next_spqe; case EVENT_RING_OPCODE_FUNCTION_STOP: DP(BNX2X_MSG_SP, "got FUNC_STOP ramrod\n"); if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_STOP)) break; goto next_spqe; } switch (opcode | bp->state) { case (EVENT_RING_OPCODE_RSS_UPDATE_RULES | BNX2X_STATE_OPEN): case (EVENT_RING_OPCODE_RSS_UPDATE_RULES | BNX2X_STATE_OPENING_WAIT4_PORT): cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK; DP(BNX2X_MSG_SP, "got RSS_UPDATE ramrod. CID %d\n", cid); rss_raw->clear_pending(rss_raw); break; case (EVENT_RING_OPCODE_SET_MAC | BNX2X_STATE_OPEN): case (EVENT_RING_OPCODE_SET_MAC | BNX2X_STATE_DIAG): case (EVENT_RING_OPCODE_SET_MAC | BNX2X_STATE_CLOSING_WAIT4_HALT): case (EVENT_RING_OPCODE_CLASSIFICATION_RULES | BNX2X_STATE_OPEN): case (EVENT_RING_OPCODE_CLASSIFICATION_RULES | BNX2X_STATE_DIAG): case (EVENT_RING_OPCODE_CLASSIFICATION_RULES | BNX2X_STATE_CLOSING_WAIT4_HALT): DP(BNX2X_MSG_SP, "got (un)set mac ramrod\n"); bnx2x_handle_classification_eqe(bp, elem); break; case (EVENT_RING_OPCODE_MULTICAST_RULES | BNX2X_STATE_OPEN): case (EVENT_RING_OPCODE_MULTICAST_RULES | BNX2X_STATE_DIAG): case (EVENT_RING_OPCODE_MULTICAST_RULES | BNX2X_STATE_CLOSING_WAIT4_HALT): DP(BNX2X_MSG_SP, "got mcast ramrod\n"); bnx2x_handle_mcast_eqe(bp); break; case (EVENT_RING_OPCODE_FILTERS_RULES | BNX2X_STATE_OPEN): case (EVENT_RING_OPCODE_FILTERS_RULES | BNX2X_STATE_DIAG): case (EVENT_RING_OPCODE_FILTERS_RULES | BNX2X_STATE_CLOSING_WAIT4_HALT): DP(BNX2X_MSG_SP, "got rx_mode ramrod\n"); bnx2x_handle_rx_mode_eqe(bp); break; default: /* unknown event log error and continue */ BNX2X_ERR("Unknown EQ event %d, bp->state 0x%x\n", elem->message.opcode, bp->state); } next_spqe: spqe_cnt++; } /* for */ smp_mb__before_atomic_inc(); atomic_add(spqe_cnt, &bp->eq_spq_left); bp->eq_cons = sw_cons; bp->eq_prod = sw_prod; /* Make sure that above mem writes were issued towards the memory */ smp_wmb(); /* update producer */ bnx2x_update_eq_prod(bp, bp->eq_prod); } static void bnx2x_sp_task(struct work_struct *work) { struct bnx2x *bp = container_of(work, struct bnx2x, sp_task.work); u16 status; status = bnx2x_update_dsb_idx(bp); /* if (status == 0) */ /* BNX2X_ERR("spurious slowpath interrupt!\n"); */ DP(NETIF_MSG_INTR, "got a slowpath interrupt (status 0x%x)\n", status); /* HW attentions */ if (status & BNX2X_DEF_SB_ATT_IDX) { bnx2x_attn_int(bp); status &= ~BNX2X_DEF_SB_ATT_IDX; } /* SP events: STAT_QUERY and others */ if (status & BNX2X_DEF_SB_IDX) { #ifdef BCM_CNIC struct bnx2x_fastpath *fp = bnx2x_fcoe_fp(bp); if ((!NO_FCOE(bp)) && (bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) { /* * Prevent local bottom-halves from running as * we are going to change the local NAPI list. */ local_bh_disable(); napi_schedule(&bnx2x_fcoe(bp, napi)); local_bh_enable(); } #endif /* Handle EQ completions */ bnx2x_eq_int(bp); bnx2x_ack_sb(bp, bp->igu_dsb_id, USTORM_ID, le16_to_cpu(bp->def_idx), IGU_INT_NOP, 1); status &= ~BNX2X_DEF_SB_IDX; } if (unlikely(status)) DP(NETIF_MSG_INTR, "got an unknown interrupt! (status 0x%x)\n", status); bnx2x_ack_sb(bp, bp->igu_dsb_id, ATTENTION_ID, le16_to_cpu(bp->def_att_idx), IGU_INT_ENABLE, 1); } irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance) { struct net_device *dev = dev_instance; struct bnx2x *bp = netdev_priv(dev); bnx2x_ack_sb(bp, bp->igu_dsb_id, USTORM_ID, 0, IGU_INT_DISABLE, 0); #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return IRQ_HANDLED; #endif #ifdef BCM_CNIC { struct cnic_ops *c_ops; rcu_read_lock(); c_ops = rcu_dereference(bp->cnic_ops); if (c_ops) c_ops->cnic_handler(bp->cnic_data, NULL); rcu_read_unlock(); } #endif queue_delayed_work(bnx2x_wq, &bp->sp_task, 0); return IRQ_HANDLED; } /* end of slow path */ void bnx2x_drv_pulse(struct bnx2x *bp) { SHMEM_WR(bp, func_mb[BP_FW_MB_IDX(bp)].drv_pulse_mb, bp->fw_drv_pulse_wr_seq); } static void bnx2x_timer(unsigned long data) { u8 cos; struct bnx2x *bp = (struct bnx2x *) data; if (!netif_running(bp->dev)) return; if (poll) { struct bnx2x_fastpath *fp = &bp->fp[0]; for_each_cos_in_tx_queue(fp, cos) bnx2x_tx_int(bp, &fp->txdata[cos]); bnx2x_rx_int(fp, 1000); } if (!BP_NOMCP(bp)) { int mb_idx = BP_FW_MB_IDX(bp); u32 drv_pulse; u32 mcp_pulse; ++bp->fw_drv_pulse_wr_seq; bp->fw_drv_pulse_wr_seq &= DRV_PULSE_SEQ_MASK; /* TBD - add SYSTEM_TIME */ drv_pulse = bp->fw_drv_pulse_wr_seq; bnx2x_drv_pulse(bp); mcp_pulse = (SHMEM_RD(bp, func_mb[mb_idx].mcp_pulse_mb) & MCP_PULSE_SEQ_MASK); /* The delta between driver pulse and mcp response * should be 1 (before mcp response) or 0 (after mcp response) */ if ((drv_pulse != mcp_pulse) && (drv_pulse != ((mcp_pulse + 1) & MCP_PULSE_SEQ_MASK))) { /* someone lost a heartbeat... */ BNX2X_ERR("drv_pulse (0x%x) != mcp_pulse (0x%x)\n", drv_pulse, mcp_pulse); } } if (bp->state == BNX2X_STATE_OPEN) bnx2x_stats_handle(bp, STATS_EVENT_UPDATE); mod_timer(&bp->timer, jiffies + bp->current_interval); } /* end of Statistics */ /* nic init */ /* * nic init service functions */ static inline void bnx2x_fill(struct bnx2x *bp, u32 addr, int fill, u32 len) { u32 i; if (!(len%4) && !(addr%4)) for (i = 0; i < len; i += 4) REG_WR(bp, addr + i, fill); else for (i = 0; i < len; i++) REG_WR8(bp, addr + i, fill); } /* helper: writes FP SP data to FW - data_size in dwords */ static inline void bnx2x_wr_fp_sb_data(struct bnx2x *bp, int fw_sb_id, u32 *sb_data_p, u32 data_size) { int index; for (index = 0; index < data_size; index++) REG_WR(bp, BAR_CSTRORM_INTMEM + CSTORM_STATUS_BLOCK_DATA_OFFSET(fw_sb_id) + sizeof(u32)*index, *(sb_data_p + index)); } static inline void bnx2x_zero_fp_sb(struct bnx2x *bp, int fw_sb_id) { u32 *sb_data_p; u32 data_size = 0; struct hc_status_block_data_e2 sb_data_e2; struct hc_status_block_data_e1x sb_data_e1x; /* disable the function first */ if (!CHIP_IS_E1x(bp)) { memset(&sb_data_e2, 0, sizeof(struct hc_status_block_data_e2)); sb_data_e2.common.state = SB_DISABLED; sb_data_e2.common.p_func.vf_valid = false; sb_data_p = (u32 *)&sb_data_e2; data_size = sizeof(struct hc_status_block_data_e2)/sizeof(u32); } else { memset(&sb_data_e1x, 0, sizeof(struct hc_status_block_data_e1x)); sb_data_e1x.common.state = SB_DISABLED; sb_data_e1x.common.p_func.vf_valid = false; sb_data_p = (u32 *)&sb_data_e1x; data_size = sizeof(struct hc_status_block_data_e1x)/sizeof(u32); } bnx2x_wr_fp_sb_data(bp, fw_sb_id, sb_data_p, data_size); bnx2x_fill(bp, BAR_CSTRORM_INTMEM + CSTORM_STATUS_BLOCK_OFFSET(fw_sb_id), 0, CSTORM_STATUS_BLOCK_SIZE); bnx2x_fill(bp, BAR_CSTRORM_INTMEM + CSTORM_SYNC_BLOCK_OFFSET(fw_sb_id), 0, CSTORM_SYNC_BLOCK_SIZE); } /* helper: writes SP SB data to FW */ static inline void bnx2x_wr_sp_sb_data(struct bnx2x *bp, struct hc_sp_status_block_data *sp_sb_data) { int func = BP_FUNC(bp); int i; for (i = 0; i < sizeof(struct hc_sp_status_block_data)/sizeof(u32); i++) REG_WR(bp, BAR_CSTRORM_INTMEM + CSTORM_SP_STATUS_BLOCK_DATA_OFFSET(func) + i*sizeof(u32), *((u32 *)sp_sb_data + i)); } static inline void bnx2x_zero_sp_sb(struct bnx2x *bp) { int func = BP_FUNC(bp); struct hc_sp_status_block_data sp_sb_data; memset(&sp_sb_data, 0, sizeof(struct hc_sp_status_block_data)); sp_sb_data.state = SB_DISABLED; sp_sb_data.p_func.vf_valid = false; bnx2x_wr_sp_sb_data(bp, &sp_sb_data); bnx2x_fill(bp, BAR_CSTRORM_INTMEM + CSTORM_SP_STATUS_BLOCK_OFFSET(func), 0, CSTORM_SP_STATUS_BLOCK_SIZE); bnx2x_fill(bp, BAR_CSTRORM_INTMEM + CSTORM_SP_SYNC_BLOCK_OFFSET(func), 0, CSTORM_SP_SYNC_BLOCK_SIZE); } static inline void bnx2x_setup_ndsb_state_machine(struct hc_status_block_sm *hc_sm, int igu_sb_id, int igu_seg_id) { hc_sm->igu_sb_id = igu_sb_id; hc_sm->igu_seg_id = igu_seg_id; hc_sm->timer_value = 0xFF; hc_sm->time_to_expire = 0xFFFFFFFF; } /* allocates state machine ids. */ static inline void bnx2x_map_sb_state_machines(struct hc_index_data *index_data) { /* zero out state machine indices */ /* rx indices */ index_data[HC_INDEX_ETH_RX_CQ_CONS].flags &= ~HC_INDEX_DATA_SM_ID; /* tx indices */ index_data[HC_INDEX_OOO_TX_CQ_CONS].flags &= ~HC_INDEX_DATA_SM_ID; index_data[HC_INDEX_ETH_TX_CQ_CONS_COS0].flags &= ~HC_INDEX_DATA_SM_ID; index_data[HC_INDEX_ETH_TX_CQ_CONS_COS1].flags &= ~HC_INDEX_DATA_SM_ID; index_data[HC_INDEX_ETH_TX_CQ_CONS_COS2].flags &= ~HC_INDEX_DATA_SM_ID; /* map indices */ /* rx indices */ index_data[HC_INDEX_ETH_RX_CQ_CONS].flags |= SM_RX_ID << HC_INDEX_DATA_SM_ID_SHIFT; /* tx indices */ index_data[HC_INDEX_OOO_TX_CQ_CONS].flags |= SM_TX_ID << HC_INDEX_DATA_SM_ID_SHIFT; index_data[HC_INDEX_ETH_TX_CQ_CONS_COS0].flags |= SM_TX_ID << HC_INDEX_DATA_SM_ID_SHIFT; index_data[HC_INDEX_ETH_TX_CQ_CONS_COS1].flags |= SM_TX_ID << HC_INDEX_DATA_SM_ID_SHIFT; index_data[HC_INDEX_ETH_TX_CQ_CONS_COS2].flags |= SM_TX_ID << HC_INDEX_DATA_SM_ID_SHIFT; } static void bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid, u8 vf_valid, int fw_sb_id, int igu_sb_id) { int igu_seg_id; struct hc_status_block_data_e2 sb_data_e2; struct hc_status_block_data_e1x sb_data_e1x; struct hc_status_block_sm *hc_sm_p; int data_size; u32 *sb_data_p; if (CHIP_INT_MODE_IS_BC(bp)) igu_seg_id = HC_SEG_ACCESS_NORM; else igu_seg_id = IGU_SEG_ACCESS_NORM; bnx2x_zero_fp_sb(bp, fw_sb_id); if (!CHIP_IS_E1x(bp)) { memset(&sb_data_e2, 0, sizeof(struct hc_status_block_data_e2)); sb_data_e2.common.state = SB_ENABLED; sb_data_e2.common.p_func.pf_id = BP_FUNC(bp); sb_data_e2.common.p_func.vf_id = vfid; sb_data_e2.common.p_func.vf_valid = vf_valid; sb_data_e2.common.p_func.vnic_id = BP_VN(bp); sb_data_e2.common.same_igu_sb_1b = true; sb_data_e2.common.host_sb_addr.hi = U64_HI(mapping); sb_data_e2.common.host_sb_addr.lo = U64_LO(mapping); hc_sm_p = sb_data_e2.common.state_machine; sb_data_p = (u32 *)&sb_data_e2; data_size = sizeof(struct hc_status_block_data_e2)/sizeof(u32); bnx2x_map_sb_state_machines(sb_data_e2.index_data); } else { memset(&sb_data_e1x, 0, sizeof(struct hc_status_block_data_e1x)); sb_data_e1x.common.state = SB_ENABLED; sb_data_e1x.common.p_func.pf_id = BP_FUNC(bp); sb_data_e1x.common.p_func.vf_id = 0xff; sb_data_e1x.common.p_func.vf_valid = false; sb_data_e1x.common.p_func.vnic_id = BP_VN(bp); sb_data_e1x.common.same_igu_sb_1b = true; sb_data_e1x.common.host_sb_addr.hi = U64_HI(mapping); sb_data_e1x.common.host_sb_addr.lo = U64_LO(mapping); hc_sm_p = sb_data_e1x.common.state_machine; sb_data_p = (u32 *)&sb_data_e1x; data_size = sizeof(struct hc_status_block_data_e1x)/sizeof(u32); bnx2x_map_sb_state_machines(sb_data_e1x.index_data); } bnx2x_setup_ndsb_state_machine(&hc_sm_p[SM_RX_ID], igu_sb_id, igu_seg_id); bnx2x_setup_ndsb_state_machine(&hc_sm_p[SM_TX_ID], igu_sb_id, igu_seg_id); DP(NETIF_MSG_HW, "Init FW SB %d\n", fw_sb_id); /* write indecies to HW */ bnx2x_wr_fp_sb_data(bp, fw_sb_id, sb_data_p, data_size); } static void bnx2x_update_coalesce_sb(struct bnx2x *bp, u8 fw_sb_id, u16 tx_usec, u16 rx_usec) { bnx2x_update_coalesce_sb_index(bp, fw_sb_id, HC_INDEX_ETH_RX_CQ_CONS, false, rx_usec); bnx2x_update_coalesce_sb_index(bp, fw_sb_id, HC_INDEX_ETH_TX_CQ_CONS_COS0, false, tx_usec); bnx2x_update_coalesce_sb_index(bp, fw_sb_id, HC_INDEX_ETH_TX_CQ_CONS_COS1, false, tx_usec); bnx2x_update_coalesce_sb_index(bp, fw_sb_id, HC_INDEX_ETH_TX_CQ_CONS_COS2, false, tx_usec); } static void bnx2x_init_def_sb(struct bnx2x *bp) { struct host_sp_status_block *def_sb = bp->def_status_blk; dma_addr_t mapping = bp->def_status_blk_mapping; int igu_sp_sb_index; int igu_seg_id; int port = BP_PORT(bp); int func = BP_FUNC(bp); int reg_offset, reg_offset_en5; u64 section; int index; struct hc_sp_status_block_data sp_sb_data; memset(&sp_sb_data, 0, sizeof(struct hc_sp_status_block_data)); if (CHIP_INT_MODE_IS_BC(bp)) { igu_sp_sb_index = DEF_SB_IGU_ID; igu_seg_id = HC_SEG_ACCESS_DEF; } else { igu_sp_sb_index = bp->igu_dsb_id; igu_seg_id = IGU_SEG_ACCESS_DEF; } /* ATTN */ section = ((u64)mapping) + offsetof(struct host_sp_status_block, atten_status_block); def_sb->atten_status_block.status_block_id = igu_sp_sb_index; bp->attn_state = 0; reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 : MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0); reg_offset_en5 = (port ? MISC_REG_AEU_ENABLE5_FUNC_1_OUT_0 : MISC_REG_AEU_ENABLE5_FUNC_0_OUT_0); for (index = 0; index < MAX_DYNAMIC_ATTN_GRPS; index++) { int sindex; /* take care of sig[0]..sig[4] */ for (sindex = 0; sindex < 4; sindex++) bp->attn_group[index].sig[sindex] = REG_RD(bp, reg_offset + sindex*0x4 + 0x10*index); if (!CHIP_IS_E1x(bp)) /* * enable5 is separate from the rest of the registers, * and therefore the address skip is 4 * and not 16 between the different groups */ bp->attn_group[index].sig[4] = REG_RD(bp, reg_offset_en5 + 0x4*index); else bp->attn_group[index].sig[4] = 0; } if (bp->common.int_block == INT_BLOCK_HC) { reg_offset = (port ? HC_REG_ATTN_MSG1_ADDR_L : HC_REG_ATTN_MSG0_ADDR_L); REG_WR(bp, reg_offset, U64_LO(section)); REG_WR(bp, reg_offset + 4, U64_HI(section)); } else if (!CHIP_IS_E1x(bp)) { REG_WR(bp, IGU_REG_ATTN_MSG_ADDR_L, U64_LO(section)); REG_WR(bp, IGU_REG_ATTN_MSG_ADDR_H, U64_HI(section)); } section = ((u64)mapping) + offsetof(struct host_sp_status_block, sp_sb); bnx2x_zero_sp_sb(bp); sp_sb_data.state = SB_ENABLED; sp_sb_data.host_sb_addr.lo = U64_LO(section); sp_sb_data.host_sb_addr.hi = U64_HI(section); sp_sb_data.igu_sb_id = igu_sp_sb_index; sp_sb_data.igu_seg_id = igu_seg_id; sp_sb_data.p_func.pf_id = func; sp_sb_data.p_func.vnic_id = BP_VN(bp); sp_sb_data.p_func.vf_id = 0xff; bnx2x_wr_sp_sb_data(bp, &sp_sb_data); bnx2x_ack_sb(bp, bp->igu_dsb_id, USTORM_ID, 0, IGU_INT_ENABLE, 0); } void bnx2x_update_coalesce(struct bnx2x *bp) { int i; for_each_eth_queue(bp, i) bnx2x_update_coalesce_sb(bp, bp->fp[i].fw_sb_id, bp->tx_ticks, bp->rx_ticks); } static void bnx2x_init_sp_ring(struct bnx2x *bp) { spin_lock_init(&bp->spq_lock); atomic_set(&bp->cq_spq_left, MAX_SPQ_PENDING); bp->spq_prod_idx = 0; bp->dsb_sp_prod = BNX2X_SP_DSB_INDEX; bp->spq_prod_bd = bp->spq; bp->spq_last_bd = bp->spq_prod_bd + MAX_SP_DESC_CNT; } static void bnx2x_init_eq_ring(struct bnx2x *bp) { int i; for (i = 1; i <= NUM_EQ_PAGES; i++) { union event_ring_elem *elem = &bp->eq_ring[EQ_DESC_CNT_PAGE * i - 1]; elem->next_page.addr.hi = cpu_to_le32(U64_HI(bp->eq_mapping + BCM_PAGE_SIZE * (i % NUM_EQ_PAGES))); elem->next_page.addr.lo = cpu_to_le32(U64_LO(bp->eq_mapping + BCM_PAGE_SIZE*(i % NUM_EQ_PAGES))); } bp->eq_cons = 0; bp->eq_prod = NUM_EQ_DESC; bp->eq_cons_sb = BNX2X_EQ_INDEX; /* we want a warning message before it gets rought... */ atomic_set(&bp->eq_spq_left, min_t(int, MAX_SP_DESC_CNT - MAX_SPQ_PENDING, NUM_EQ_DESC) - 1); } /* called with netif_addr_lock_bh() */ void bnx2x_set_q_rx_mode(struct bnx2x *bp, u8 cl_id, unsigned long rx_mode_flags, unsigned long rx_accept_flags, unsigned long tx_accept_flags, unsigned long ramrod_flags) { struct bnx2x_rx_mode_ramrod_params ramrod_param; int rc; memset(&ramrod_param, 0, sizeof(ramrod_param)); /* Prepare ramrod parameters */ ramrod_param.cid = 0; ramrod_param.cl_id = cl_id; ramrod_param.rx_mode_obj = &bp->rx_mode_obj; ramrod_param.func_id = BP_FUNC(bp); ramrod_param.pstate = &bp->sp_state; ramrod_param.state = BNX2X_FILTER_RX_MODE_PENDING; ramrod_param.rdata = bnx2x_sp(bp, rx_mode_rdata); ramrod_param.rdata_mapping = bnx2x_sp_mapping(bp, rx_mode_rdata); set_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state); ramrod_param.ramrod_flags = ramrod_flags; ramrod_param.rx_mode_flags = rx_mode_flags; ramrod_param.rx_accept_flags = rx_accept_flags; ramrod_param.tx_accept_flags = tx_accept_flags; rc = bnx2x_config_rx_mode(bp, &ramrod_param); if (rc < 0) { BNX2X_ERR("Set rx_mode %d failed\n", bp->rx_mode); return; } } /* called with netif_addr_lock_bh() */ void bnx2x_set_storm_rx_mode(struct bnx2x *bp) { unsigned long rx_mode_flags = 0, ramrod_flags = 0; unsigned long rx_accept_flags = 0, tx_accept_flags = 0; #ifdef BCM_CNIC if (!NO_FCOE(bp)) /* Configure rx_mode of FCoE Queue */ __set_bit(BNX2X_RX_MODE_FCOE_ETH, &rx_mode_flags); #endif switch (bp->rx_mode) { case BNX2X_RX_MODE_NONE: /* * 'drop all' supersedes any accept flags that may have been * passed to the function. */ break; case BNX2X_RX_MODE_NORMAL: __set_bit(BNX2X_ACCEPT_UNICAST, &rx_accept_flags); __set_bit(BNX2X_ACCEPT_MULTICAST, &rx_accept_flags); __set_bit(BNX2X_ACCEPT_BROADCAST, &rx_accept_flags); /* internal switching mode */ __set_bit(BNX2X_ACCEPT_UNICAST, &tx_accept_flags); __set_bit(BNX2X_ACCEPT_MULTICAST, &tx_accept_flags); __set_bit(BNX2X_ACCEPT_BROADCAST, &tx_accept_flags); break; case BNX2X_RX_MODE_ALLMULTI: __set_bit(BNX2X_ACCEPT_UNICAST, &rx_accept_flags); __set_bit(BNX2X_ACCEPT_ALL_MULTICAST, &rx_accept_flags); __set_bit(BNX2X_ACCEPT_BROADCAST, &rx_accept_flags); /* internal switching mode */ __set_bit(BNX2X_ACCEPT_UNICAST, &tx_accept_flags); __set_bit(BNX2X_ACCEPT_ALL_MULTICAST, &tx_accept_flags); __set_bit(BNX2X_ACCEPT_BROADCAST, &tx_accept_flags); break; case BNX2X_RX_MODE_PROMISC: /* According to deffinition of SI mode, iface in promisc mode * should receive matched and unmatched (in resolution of port) * unicast packets. */ __set_bit(BNX2X_ACCEPT_UNMATCHED, &rx_accept_flags); __set_bit(BNX2X_ACCEPT_UNICAST, &rx_accept_flags); __set_bit(BNX2X_ACCEPT_ALL_MULTICAST, &rx_accept_flags); __set_bit(BNX2X_ACCEPT_BROADCAST, &rx_accept_flags); /* internal switching mode */ __set_bit(BNX2X_ACCEPT_ALL_MULTICAST, &tx_accept_flags); __set_bit(BNX2X_ACCEPT_BROADCAST, &tx_accept_flags); if (IS_MF_SI(bp)) __set_bit(BNX2X_ACCEPT_ALL_UNICAST, &tx_accept_flags); else __set_bit(BNX2X_ACCEPT_UNICAST, &tx_accept_flags); break; default: BNX2X_ERR("Unknown rx_mode: %d\n", bp->rx_mode); return; } if (bp->rx_mode != BNX2X_RX_MODE_NONE) { __set_bit(BNX2X_ACCEPT_ANY_VLAN, &rx_accept_flags); __set_bit(BNX2X_ACCEPT_ANY_VLAN, &tx_accept_flags); } __set_bit(RAMROD_RX, &ramrod_flags); __set_bit(RAMROD_TX, &ramrod_flags); bnx2x_set_q_rx_mode(bp, bp->fp->cl_id, rx_mode_flags, rx_accept_flags, tx_accept_flags, ramrod_flags); } static void bnx2x_init_internal_common(struct bnx2x *bp) { int i; if (IS_MF_SI(bp)) /* * In switch independent mode, the TSTORM needs to accept * packets that failed classification, since approximate match * mac addresses aren't written to NIG LLH */ REG_WR8(bp, BAR_TSTRORM_INTMEM + TSTORM_ACCEPT_CLASSIFY_FAILED_OFFSET, 2); else if (!CHIP_IS_E1(bp)) /* 57710 doesn't support MF */ REG_WR8(bp, BAR_TSTRORM_INTMEM + TSTORM_ACCEPT_CLASSIFY_FAILED_OFFSET, 0); /* Zero this manually as its initialization is currently missing in the initTool */ for (i = 0; i < (USTORM_AGG_DATA_SIZE >> 2); i++) REG_WR(bp, BAR_USTRORM_INTMEM + USTORM_AGG_DATA_OFFSET + i * 4, 0); if (!CHIP_IS_E1x(bp)) { REG_WR8(bp, BAR_CSTRORM_INTMEM + CSTORM_IGU_MODE_OFFSET, CHIP_INT_MODE_IS_BC(bp) ? HC_IGU_BC_MODE : HC_IGU_NBC_MODE); } } static void bnx2x_init_internal(struct bnx2x *bp, u32 load_code) { switch (load_code) { case FW_MSG_CODE_DRV_LOAD_COMMON: case FW_MSG_CODE_DRV_LOAD_COMMON_CHIP: bnx2x_init_internal_common(bp); /* no break */ case FW_MSG_CODE_DRV_LOAD_PORT: /* nothing to do */ /* no break */ case FW_MSG_CODE_DRV_LOAD_FUNCTION: /* internal memory per function is initialized inside bnx2x_pf_init */ break; default: BNX2X_ERR("Unknown load_code (0x%x) from MCP\n", load_code); break; } } static inline u8 bnx2x_fp_igu_sb_id(struct bnx2x_fastpath *fp) { return fp->bp->igu_base_sb + fp->index + CNIC_PRESENT; } static inline u8 bnx2x_fp_fw_sb_id(struct bnx2x_fastpath *fp) { return fp->bp->base_fw_ndsb + fp->index + CNIC_PRESENT; } static inline u8 bnx2x_fp_cl_id(struct bnx2x_fastpath *fp) { if (CHIP_IS_E1x(fp->bp)) return BP_L_ID(fp->bp) + fp->index; else /* We want Client ID to be the same as IGU SB ID for 57712 */ return bnx2x_fp_igu_sb_id(fp); } static void bnx2x_init_eth_fp(struct bnx2x *bp, int fp_idx) { struct bnx2x_fastpath *fp = &bp->fp[fp_idx]; u8 cos; unsigned long q_type = 0; u32 cids[BNX2X_MULTI_TX_COS] = { 0 }; fp->cid = fp_idx; fp->cl_id = bnx2x_fp_cl_id(fp); fp->fw_sb_id = bnx2x_fp_fw_sb_id(fp); fp->igu_sb_id = bnx2x_fp_igu_sb_id(fp); /* qZone id equals to FW (per path) client id */ fp->cl_qzone_id = bnx2x_fp_qzone_id(fp); /* init shortcut */ fp->ustorm_rx_prods_offset = bnx2x_rx_ustorm_prods_offset(fp); /* Setup SB indicies */ fp->rx_cons_sb = BNX2X_RX_SB_INDEX; /* Configure Queue State object */ __set_bit(BNX2X_Q_TYPE_HAS_RX, &q_type); __set_bit(BNX2X_Q_TYPE_HAS_TX, &q_type); BUG_ON(fp->max_cos > BNX2X_MULTI_TX_COS); /* init tx data */ for_each_cos_in_tx_queue(fp, cos) { bnx2x_init_txdata(bp, &fp->txdata[cos], CID_COS_TO_TX_ONLY_CID(fp->cid, cos), FP_COS_TO_TXQ(fp, cos), BNX2X_TX_SB_INDEX_BASE + cos); cids[cos] = fp->txdata[cos].cid; } bnx2x_init_queue_obj(bp, &fp->q_obj, fp->cl_id, cids, fp->max_cos, BP_FUNC(bp), bnx2x_sp(bp, q_rdata), bnx2x_sp_mapping(bp, q_rdata), q_type); /** * Configure classification DBs: Always enable Tx switching */ bnx2x_init_vlan_mac_fp_objs(fp, BNX2X_OBJ_TYPE_RX_TX); DP(NETIF_MSG_IFUP, "queue[%d]: bnx2x_init_sb(%p,%p) " "cl_id %d fw_sb %d igu_sb %d\n", fp_idx, bp, fp->status_blk.e2_sb, fp->cl_id, fp->fw_sb_id, fp->igu_sb_id); bnx2x_init_sb(bp, fp->status_blk_mapping, BNX2X_VF_ID_INVALID, false, fp->fw_sb_id, fp->igu_sb_id); bnx2x_update_fpsb_idx(fp); } void bnx2x_nic_init(struct bnx2x *bp, u32 load_code) { int i; for_each_eth_queue(bp, i) bnx2x_init_eth_fp(bp, i); #ifdef BCM_CNIC if (!NO_FCOE(bp)) bnx2x_init_fcoe_fp(bp); bnx2x_init_sb(bp, bp->cnic_sb_mapping, BNX2X_VF_ID_INVALID, false, bnx2x_cnic_fw_sb_id(bp), bnx2x_cnic_igu_sb_id(bp)); #endif /* Initialize MOD_ABS interrupts */ bnx2x_init_mod_abs_int(bp, &bp->link_vars, bp->common.chip_id, bp->common.shmem_base, bp->common.shmem2_base, BP_PORT(bp)); /* ensure status block indices were read */ rmb(); bnx2x_init_def_sb(bp); bnx2x_update_dsb_idx(bp); bnx2x_init_rx_rings(bp); bnx2x_init_tx_rings(bp); bnx2x_init_sp_ring(bp); bnx2x_init_eq_ring(bp); bnx2x_init_internal(bp, load_code); bnx2x_pf_init(bp); bnx2x_stats_init(bp); /* flush all before enabling interrupts */ mb(); mmiowb(); bnx2x_int_enable(bp); /* Check for SPIO5 */ bnx2x_attn_int_deasserted0(bp, REG_RD(bp, MISC_REG_AEU_AFTER_INVERT_1_FUNC_0 + BP_PORT(bp)*4) & AEU_INPUTS_ATTN_BITS_SPIO5); } /* end of nic init */ /* * gzip service functions */ static int bnx2x_gunzip_init(struct bnx2x *bp) { bp->gunzip_buf = dma_alloc_coherent(&bp->pdev->dev, FW_BUF_SIZE, &bp->gunzip_mapping, GFP_KERNEL); if (bp->gunzip_buf == NULL) goto gunzip_nomem1; bp->strm = kmalloc(sizeof(*bp->strm), GFP_KERNEL); if (bp->strm == NULL) goto gunzip_nomem2; bp->strm->workspace = vmalloc(zlib_inflate_workspacesize()); if (bp->strm->workspace == NULL) goto gunzip_nomem3; return 0; gunzip_nomem3: kfree(bp->strm); bp->strm = NULL; gunzip_nomem2: dma_free_coherent(&bp->pdev->dev, FW_BUF_SIZE, bp->gunzip_buf, bp->gunzip_mapping); bp->gunzip_buf = NULL; gunzip_nomem1: netdev_err(bp->dev, "Cannot allocate firmware buffer for" " un-compression\n"); return -ENOMEM; } static void bnx2x_gunzip_end(struct bnx2x *bp) { if (bp->strm) { vfree(bp->strm->workspace); kfree(bp->strm); bp->strm = NULL; } if (bp->gunzip_buf) { dma_free_coherent(&bp->pdev->dev, FW_BUF_SIZE, bp->gunzip_buf, bp->gunzip_mapping); bp->gunzip_buf = NULL; } } static int bnx2x_gunzip(struct bnx2x *bp, const u8 *zbuf, int len) { int n, rc; /* check gzip header */ if ((zbuf[0] != 0x1f) || (zbuf[1] != 0x8b) || (zbuf[2] != Z_DEFLATED)) { BNX2X_ERR("Bad gzip header\n"); return -EINVAL; } n = 10; #define FNAME 0x8 if (zbuf[3] & FNAME) while ((zbuf[n++] != 0) && (n < len)); bp->strm->next_in = (typeof(bp->strm->next_in))zbuf + n; bp->strm->avail_in = len - n; bp->strm->next_out = bp->gunzip_buf; bp->strm->avail_out = FW_BUF_SIZE; rc = zlib_inflateInit2(bp->strm, -MAX_WBITS); if (rc != Z_OK) return rc; rc = zlib_inflate(bp->strm, Z_FINISH); if ((rc != Z_OK) && (rc != Z_STREAM_END)) netdev_err(bp->dev, "Firmware decompression error: %s\n", bp->strm->msg); bp->gunzip_outlen = (FW_BUF_SIZE - bp->strm->avail_out); if (bp->gunzip_outlen & 0x3) netdev_err(bp->dev, "Firmware decompression error:" " gunzip_outlen (%d) not aligned\n", bp->gunzip_outlen); bp->gunzip_outlen >>= 2; zlib_inflateEnd(bp->strm); if (rc == Z_STREAM_END) return 0; return rc; } /* nic load/unload */ /* * General service functions */ /* send a NIG loopback debug packet */ static void bnx2x_lb_pckt(struct bnx2x *bp) { u32 wb_write[3]; /* Ethernet source and destination addresses */ wb_write[0] = 0x55555555; wb_write[1] = 0x55555555; wb_write[2] = 0x20; /* SOP */ REG_WR_DMAE(bp, NIG_REG_DEBUG_PACKET_LB, wb_write, 3); /* NON-IP protocol */ wb_write[0] = 0x09000000; wb_write[1] = 0x55555555; wb_write[2] = 0x10; /* EOP, eop_bvalid = 0 */ REG_WR_DMAE(bp, NIG_REG_DEBUG_PACKET_LB, wb_write, 3); } /* some of the internal memories * are not directly readable from the driver * to test them we send debug packets */ static int bnx2x_int_mem_test(struct bnx2x *bp) { int factor; int count, i; u32 val = 0; if (CHIP_REV_IS_FPGA(bp)) factor = 120; else if (CHIP_REV_IS_EMUL(bp)) factor = 200; else factor = 1; /* Disable inputs of parser neighbor blocks */ REG_WR(bp, TSDM_REG_ENABLE_IN1, 0x0); REG_WR(bp, TCM_REG_PRS_IFEN, 0x0); REG_WR(bp, CFC_REG_DEBUG0, 0x1); REG_WR(bp, NIG_REG_PRS_REQ_IN_EN, 0x0); /* Write 0 to parser credits for CFC search request */ REG_WR(bp, PRS_REG_CFC_SEARCH_INITIAL_CREDIT, 0x0); /* send Ethernet packet */ bnx2x_lb_pckt(bp); /* TODO do i reset NIG statistic? */ /* Wait until NIG register shows 1 packet of size 0x10 */ count = 1000 * factor; while (count) { bnx2x_read_dmae(bp, NIG_REG_STAT2_BRB_OCTET, 2); val = *bnx2x_sp(bp, wb_data[0]); if (val == 0x10) break; msleep(10); count--; } if (val != 0x10) { BNX2X_ERR("NIG timeout val = 0x%x\n", val); return -1; } /* Wait until PRS register shows 1 packet */ count = 1000 * factor; while (count) { val = REG_RD(bp, PRS_REG_NUM_OF_PACKETS); if (val == 1) break; msleep(10); count--; } if (val != 0x1) { BNX2X_ERR("PRS timeout val = 0x%x\n", val); return -2; } /* Reset and init BRB, PRS */ REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR, 0x03); msleep(50); REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 0x03); msleep(50); bnx2x_init_block(bp, BLOCK_BRB1, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_PRS, PHASE_COMMON); DP(NETIF_MSG_HW, "part2\n"); /* Disable inputs of parser neighbor blocks */ REG_WR(bp, TSDM_REG_ENABLE_IN1, 0x0); REG_WR(bp, TCM_REG_PRS_IFEN, 0x0); REG_WR(bp, CFC_REG_DEBUG0, 0x1); REG_WR(bp, NIG_REG_PRS_REQ_IN_EN, 0x0); /* Write 0 to parser credits for CFC search request */ REG_WR(bp, PRS_REG_CFC_SEARCH_INITIAL_CREDIT, 0x0); /* send 10 Ethernet packets */ for (i = 0; i < 10; i++) bnx2x_lb_pckt(bp); /* Wait until NIG register shows 10 + 1 packets of size 11*0x10 = 0xb0 */ count = 1000 * factor; while (count) { bnx2x_read_dmae(bp, NIG_REG_STAT2_BRB_OCTET, 2); val = *bnx2x_sp(bp, wb_data[0]); if (val == 0xb0) break; msleep(10); count--; } if (val != 0xb0) { BNX2X_ERR("NIG timeout val = 0x%x\n", val); return -3; } /* Wait until PRS register shows 2 packets */ val = REG_RD(bp, PRS_REG_NUM_OF_PACKETS); if (val != 2) BNX2X_ERR("PRS timeout val = 0x%x\n", val); /* Write 1 to parser credits for CFC search request */ REG_WR(bp, PRS_REG_CFC_SEARCH_INITIAL_CREDIT, 0x1); /* Wait until PRS register shows 3 packets */ msleep(10 * factor); /* Wait until NIG register shows 1 packet of size 0x10 */ val = REG_RD(bp, PRS_REG_NUM_OF_PACKETS); if (val != 3) BNX2X_ERR("PRS timeout val = 0x%x\n", val); /* clear NIG EOP FIFO */ for (i = 0; i < 11; i++) REG_RD(bp, NIG_REG_INGRESS_EOP_LB_FIFO); val = REG_RD(bp, NIG_REG_INGRESS_EOP_LB_EMPTY); if (val != 1) { BNX2X_ERR("clear of NIG failed\n"); return -4; } /* Reset and init BRB, PRS, NIG */ REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR, 0x03); msleep(50); REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 0x03); msleep(50); bnx2x_init_block(bp, BLOCK_BRB1, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_PRS, PHASE_COMMON); #ifndef BCM_CNIC /* set NIC mode */ REG_WR(bp, PRS_REG_NIC_MODE, 1); #endif /* Enable inputs of parser neighbor blocks */ REG_WR(bp, TSDM_REG_ENABLE_IN1, 0x7fffffff); REG_WR(bp, TCM_REG_PRS_IFEN, 0x1); REG_WR(bp, CFC_REG_DEBUG0, 0x0); REG_WR(bp, NIG_REG_PRS_REQ_IN_EN, 0x1); DP(NETIF_MSG_HW, "done\n"); return 0; /* OK */ } static void bnx2x_enable_blocks_attention(struct bnx2x *bp) { REG_WR(bp, PXP_REG_PXP_INT_MASK_0, 0); if (!CHIP_IS_E1x(bp)) REG_WR(bp, PXP_REG_PXP_INT_MASK_1, 0x40); else REG_WR(bp, PXP_REG_PXP_INT_MASK_1, 0); REG_WR(bp, DORQ_REG_DORQ_INT_MASK, 0); REG_WR(bp, CFC_REG_CFC_INT_MASK, 0); /* * mask read length error interrupts in brb for parser * (parsing unit and 'checksum and crc' unit) * these errors are legal (PU reads fixed length and CAC can cause * read length error on truncated packets) */ REG_WR(bp, BRB1_REG_BRB1_INT_MASK, 0xFC00); REG_WR(bp, QM_REG_QM_INT_MASK, 0); REG_WR(bp, TM_REG_TM_INT_MASK, 0); REG_WR(bp, XSDM_REG_XSDM_INT_MASK_0, 0); REG_WR(bp, XSDM_REG_XSDM_INT_MASK_1, 0); REG_WR(bp, XCM_REG_XCM_INT_MASK, 0); /* REG_WR(bp, XSEM_REG_XSEM_INT_MASK_0, 0); */ /* REG_WR(bp, XSEM_REG_XSEM_INT_MASK_1, 0); */ REG_WR(bp, USDM_REG_USDM_INT_MASK_0, 0); REG_WR(bp, USDM_REG_USDM_INT_MASK_1, 0); REG_WR(bp, UCM_REG_UCM_INT_MASK, 0); /* REG_WR(bp, USEM_REG_USEM_INT_MASK_0, 0); */ /* REG_WR(bp, USEM_REG_USEM_INT_MASK_1, 0); */ REG_WR(bp, GRCBASE_UPB + PB_REG_PB_INT_MASK, 0); REG_WR(bp, CSDM_REG_CSDM_INT_MASK_0, 0); REG_WR(bp, CSDM_REG_CSDM_INT_MASK_1, 0); REG_WR(bp, CCM_REG_CCM_INT_MASK, 0); /* REG_WR(bp, CSEM_REG_CSEM_INT_MASK_0, 0); */ /* REG_WR(bp, CSEM_REG_CSEM_INT_MASK_1, 0); */ if (CHIP_REV_IS_FPGA(bp)) REG_WR(bp, PXP2_REG_PXP2_INT_MASK_0, 0x580000); else if (!CHIP_IS_E1x(bp)) REG_WR(bp, PXP2_REG_PXP2_INT_MASK_0, (PXP2_PXP2_INT_MASK_0_REG_PGL_CPL_OF | PXP2_PXP2_INT_MASK_0_REG_PGL_CPL_AFT | PXP2_PXP2_INT_MASK_0_REG_PGL_PCIE_ATTN | PXP2_PXP2_INT_MASK_0_REG_PGL_READ_BLOCKED | PXP2_PXP2_INT_MASK_0_REG_PGL_WRITE_BLOCKED)); else REG_WR(bp, PXP2_REG_PXP2_INT_MASK_0, 0x480000); REG_WR(bp, TSDM_REG_TSDM_INT_MASK_0, 0); REG_WR(bp, TSDM_REG_TSDM_INT_MASK_1, 0); REG_WR(bp, TCM_REG_TCM_INT_MASK, 0); /* REG_WR(bp, TSEM_REG_TSEM_INT_MASK_0, 0); */ if (!CHIP_IS_E1x(bp)) /* enable VFC attentions: bits 11 and 12, bits 31:13 reserved */ REG_WR(bp, TSEM_REG_TSEM_INT_MASK_1, 0x07ff); REG_WR(bp, CDU_REG_CDU_INT_MASK, 0); REG_WR(bp, DMAE_REG_DMAE_INT_MASK, 0); /* REG_WR(bp, MISC_REG_MISC_INT_MASK, 0); */ REG_WR(bp, PBF_REG_PBF_INT_MASK, 0x18); /* bit 3,4 masked */ } static void bnx2x_reset_common(struct bnx2x *bp) { u32 val = 0x1400; /* reset_common */ REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR, 0xd3ffff7f); if (CHIP_IS_E3(bp)) { val |= MISC_REGISTERS_RESET_REG_2_MSTAT0; val |= MISC_REGISTERS_RESET_REG_2_MSTAT1; } REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, val); } static void bnx2x_setup_dmae(struct bnx2x *bp) { bp->dmae_ready = 0; spin_lock_init(&bp->dmae_lock); } static void bnx2x_init_pxp(struct bnx2x *bp) { u16 devctl; int r_order, w_order; pci_read_config_word(bp->pdev, pci_pcie_cap(bp->pdev) + PCI_EXP_DEVCTL, &devctl); DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl); w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5); if (bp->mrrs == -1) r_order = ((devctl & PCI_EXP_DEVCTL_READRQ) >> 12); else { DP(NETIF_MSG_HW, "force read order to %d\n", bp->mrrs); r_order = bp->mrrs; } bnx2x_init_pxp_arb(bp, r_order, w_order); } static void bnx2x_setup_fan_failure_detection(struct bnx2x *bp) { int is_required; u32 val; int port; if (BP_NOMCP(bp)) return; is_required = 0; val = SHMEM_RD(bp, dev_info.shared_hw_config.config2) & SHARED_HW_CFG_FAN_FAILURE_MASK; if (val == SHARED_HW_CFG_FAN_FAILURE_ENABLED) is_required = 1; /* * The fan failure mechanism is usually related to the PHY type since * the power consumption of the board is affected by the PHY. Currently, * fan is required for most designs with SFX7101, BCM8727 and BCM8481. */ else if (val == SHARED_HW_CFG_FAN_FAILURE_PHY_TYPE) for (port = PORT_0; port < PORT_MAX; port++) { is_required |= bnx2x_fan_failure_det_req( bp, bp->common.shmem_base, bp->common.shmem2_base, port); } DP(NETIF_MSG_HW, "fan detection setting: %d\n", is_required); if (is_required == 0) return; /* Fan failure is indicated by SPIO 5 */ bnx2x_set_spio(bp, MISC_REGISTERS_SPIO_5, MISC_REGISTERS_SPIO_INPUT_HI_Z); /* set to active low mode */ val = REG_RD(bp, MISC_REG_SPIO_INT); val |= ((1 << MISC_REGISTERS_SPIO_5) << MISC_REGISTERS_SPIO_INT_OLD_SET_POS); REG_WR(bp, MISC_REG_SPIO_INT, val); /* enable interrupt to signal the IGU */ val = REG_RD(bp, MISC_REG_SPIO_EVENT_EN); val |= (1 << MISC_REGISTERS_SPIO_5); REG_WR(bp, MISC_REG_SPIO_EVENT_EN, val); } static void bnx2x_pretend_func(struct bnx2x *bp, u8 pretend_func_num) { u32 offset = 0; if (CHIP_IS_E1(bp)) return; if (CHIP_IS_E1H(bp) && (pretend_func_num >= E1H_FUNC_MAX)) return; switch (BP_ABS_FUNC(bp)) { case 0: offset = PXP2_REG_PGL_PRETEND_FUNC_F0; break; case 1: offset = PXP2_REG_PGL_PRETEND_FUNC_F1; break; case 2: offset = PXP2_REG_PGL_PRETEND_FUNC_F2; break; case 3: offset = PXP2_REG_PGL_PRETEND_FUNC_F3; break; case 4: offset = PXP2_REG_PGL_PRETEND_FUNC_F4; break; case 5: offset = PXP2_REG_PGL_PRETEND_FUNC_F5; break; case 6: offset = PXP2_REG_PGL_PRETEND_FUNC_F6; break; case 7: offset = PXP2_REG_PGL_PRETEND_FUNC_F7; break; default: return; } REG_WR(bp, offset, pretend_func_num); REG_RD(bp, offset); DP(NETIF_MSG_HW, "Pretending to func %d\n", pretend_func_num); } void bnx2x_pf_disable(struct bnx2x *bp) { u32 val = REG_RD(bp, IGU_REG_PF_CONFIGURATION); val &= ~IGU_PF_CONF_FUNC_EN; REG_WR(bp, IGU_REG_PF_CONFIGURATION, val); REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 0); REG_WR(bp, CFC_REG_WEAK_ENABLE_PF, 0); } static inline void bnx2x__common_init_phy(struct bnx2x *bp) { u32 shmem_base[2], shmem2_base[2]; shmem_base[0] = bp->common.shmem_base; shmem2_base[0] = bp->common.shmem2_base; if (!CHIP_IS_E1x(bp)) { shmem_base[1] = SHMEM2_RD(bp, other_shmem_base_addr); shmem2_base[1] = SHMEM2_RD(bp, other_shmem2_base_addr); } bnx2x_acquire_phy_lock(bp); bnx2x_common_init_phy(bp, shmem_base, shmem2_base, bp->common.chip_id); bnx2x_release_phy_lock(bp); } /** * bnx2x_init_hw_common - initialize the HW at the COMMON phase. * * @bp: driver handle */ static int bnx2x_init_hw_common(struct bnx2x *bp) { u32 val; DP(BNX2X_MSG_MCP, "starting common init func %d\n", BP_ABS_FUNC(bp)); /* * take the UNDI lock to protect undi_unload flow from accessing * registers while we're resetting the chip */ bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RESET); bnx2x_reset_common(bp); REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 0xffffffff); val = 0xfffc; if (CHIP_IS_E3(bp)) { val |= MISC_REGISTERS_RESET_REG_2_MSTAT0; val |= MISC_REGISTERS_RESET_REG_2_MSTAT1; } REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, val); bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RESET); bnx2x_init_block(bp, BLOCK_MISC, PHASE_COMMON); if (!CHIP_IS_E1x(bp)) { u8 abs_func_id; /** * 4-port mode or 2-port mode we need to turn of master-enable * for everyone, after that, turn it back on for self. * so, we disregard multi-function or not, and always disable * for all functions on the given path, this means 0,2,4,6 for * path 0 and 1,3,5,7 for path 1 */ for (abs_func_id = BP_PATH(bp); abs_func_id < E2_FUNC_MAX*2; abs_func_id += 2) { if (abs_func_id == BP_ABS_FUNC(bp)) { REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 1); continue; } bnx2x_pretend_func(bp, abs_func_id); /* clear pf enable */ bnx2x_pf_disable(bp); bnx2x_pretend_func(bp, BP_ABS_FUNC(bp)); } } bnx2x_init_block(bp, BLOCK_PXP, PHASE_COMMON); if (CHIP_IS_E1(bp)) { /* enable HW interrupt from PXP on USDM overflow bit 16 on INT_MASK_0 */ REG_WR(bp, PXP_REG_PXP_INT_MASK_0, 0); } bnx2x_init_block(bp, BLOCK_PXP2, PHASE_COMMON); bnx2x_init_pxp(bp); #ifdef __BIG_ENDIAN REG_WR(bp, PXP2_REG_RQ_QM_ENDIAN_M, 1); REG_WR(bp, PXP2_REG_RQ_TM_ENDIAN_M, 1); REG_WR(bp, PXP2_REG_RQ_SRC_ENDIAN_M, 1); REG_WR(bp, PXP2_REG_RQ_CDU_ENDIAN_M, 1); REG_WR(bp, PXP2_REG_RQ_DBG_ENDIAN_M, 1); /* make sure this value is 0 */ REG_WR(bp, PXP2_REG_RQ_HC_ENDIAN_M, 0); /* REG_WR(bp, PXP2_REG_RD_PBF_SWAP_MODE, 1); */ REG_WR(bp, PXP2_REG_RD_QM_SWAP_MODE, 1); REG_WR(bp, PXP2_REG_RD_TM_SWAP_MODE, 1); REG_WR(bp, PXP2_REG_RD_SRC_SWAP_MODE, 1); REG_WR(bp, PXP2_REG_RD_CDURD_SWAP_MODE, 1); #endif bnx2x_ilt_init_page_size(bp, INITOP_SET); if (CHIP_REV_IS_FPGA(bp) && CHIP_IS_E1H(bp)) REG_WR(bp, PXP2_REG_PGL_TAGS_LIMIT, 0x1); /* let the HW do it's magic ... */ msleep(100); /* finish PXP init */ val = REG_RD(bp, PXP2_REG_RQ_CFG_DONE); if (val != 1) { BNX2X_ERR("PXP2 CFG failed\n"); return -EBUSY; } val = REG_RD(bp, PXP2_REG_RD_INIT_DONE); if (val != 1) { BNX2X_ERR("PXP2 RD_INIT failed\n"); return -EBUSY; } /* Timers bug workaround E2 only. We need to set the entire ILT to * have entries with value "0" and valid bit on. * This needs to be done by the first PF that is loaded in a path * (i.e. common phase) */ if (!CHIP_IS_E1x(bp)) { /* In E2 there is a bug in the timers block that can cause function 6 / 7 * (i.e. vnic3) to start even if it is marked as "scan-off". * This occurs when a different function (func2,3) is being marked * as "scan-off". Real-life scenario for example: if a driver is being * load-unloaded while func6,7 are down. This will cause the timer to access * the ilt, translate to a logical address and send a request to read/write. * Since the ilt for the function that is down is not valid, this will cause * a translation error which is unrecoverable. * The Workaround is intended to make sure that when this happens nothing fatal * will occur. The workaround: * 1. First PF driver which loads on a path will: * a. After taking the chip out of reset, by using pretend, * it will write "0" to the following registers of * the other vnics. * REG_WR(pdev, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 0); * REG_WR(pdev, CFC_REG_WEAK_ENABLE_PF,0); * REG_WR(pdev, CFC_REG_STRONG_ENABLE_PF,0); * And for itself it will write '1' to * PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER to enable * dmae-operations (writing to pram for example.) * note: can be done for only function 6,7 but cleaner this * way. * b. Write zero+valid to the entire ILT. * c. Init the first_timers_ilt_entry, last_timers_ilt_entry of * VNIC3 (of that port). The range allocated will be the * entire ILT. This is needed to prevent ILT range error. * 2. Any PF driver load flow: * a. ILT update with the physical addresses of the allocated * logical pages. * b. Wait 20msec. - note that this timeout is needed to make * sure there are no requests in one of the PXP internal * queues with "old" ILT addresses. * c. PF enable in the PGLC. * d. Clear the was_error of the PF in the PGLC. (could have * occured while driver was down) * e. PF enable in the CFC (WEAK + STRONG) * f. Timers scan enable * 3. PF driver unload flow: * a. Clear the Timers scan_en. * b. Polling for scan_on=0 for that PF. * c. Clear the PF enable bit in the PXP. * d. Clear the PF enable in the CFC (WEAK + STRONG) * e. Write zero+valid to all ILT entries (The valid bit must * stay set) * f. If this is VNIC 3 of a port then also init * first_timers_ilt_entry to zero and last_timers_ilt_entry * to the last enrty in the ILT. * * Notes: * Currently the PF error in the PGLC is non recoverable. * In the future the there will be a recovery routine for this error. * Currently attention is masked. * Having an MCP lock on the load/unload process does not guarantee that * there is no Timer disable during Func6/7 enable. This is because the * Timers scan is currently being cleared by the MCP on FLR. * Step 2.d can be done only for PF6/7 and the driver can also check if * there is error before clearing it. But the flow above is simpler and * more general. * All ILT entries are written by zero+valid and not just PF6/7 * ILT entries since in the future the ILT entries allocation for * PF-s might be dynamic. */ struct ilt_client_info ilt_cli; struct bnx2x_ilt ilt; memset(&ilt_cli, 0, sizeof(struct ilt_client_info)); memset(&ilt, 0, sizeof(struct bnx2x_ilt)); /* initialize dummy TM client */ ilt_cli.start = 0; ilt_cli.end = ILT_NUM_PAGE_ENTRIES - 1; ilt_cli.client_num = ILT_CLIENT_TM; /* Step 1: set zeroes to all ilt page entries with valid bit on * Step 2: set the timers first/last ilt entry to point * to the entire range to prevent ILT range error for 3rd/4th * vnic (this code assumes existance of the vnic) * * both steps performed by call to bnx2x_ilt_client_init_op() * with dummy TM client * * we must use pretend since PXP2_REG_RQ_##blk##_FIRST_ILT * and his brother are split registers */ bnx2x_pretend_func(bp, (BP_PATH(bp) + 6)); bnx2x_ilt_client_init_op_ilt(bp, &ilt, &ilt_cli, INITOP_CLEAR); bnx2x_pretend_func(bp, BP_ABS_FUNC(bp)); REG_WR(bp, PXP2_REG_RQ_DRAM_ALIGN, BNX2X_PXP_DRAM_ALIGN); REG_WR(bp, PXP2_REG_RQ_DRAM_ALIGN_RD, BNX2X_PXP_DRAM_ALIGN); REG_WR(bp, PXP2_REG_RQ_DRAM_ALIGN_SEL, 1); } REG_WR(bp, PXP2_REG_RQ_DISABLE_INPUTS, 0); REG_WR(bp, PXP2_REG_RD_DISABLE_INPUTS, 0); if (!CHIP_IS_E1x(bp)) { int factor = CHIP_REV_IS_EMUL(bp) ? 1000 : (CHIP_REV_IS_FPGA(bp) ? 400 : 0); bnx2x_init_block(bp, BLOCK_PGLUE_B, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_ATC, PHASE_COMMON); /* let the HW do it's magic ... */ do { msleep(200); val = REG_RD(bp, ATC_REG_ATC_INIT_DONE); } while (factor-- && (val != 1)); if (val != 1) { BNX2X_ERR("ATC_INIT failed\n"); return -EBUSY; } } bnx2x_init_block(bp, BLOCK_DMAE, PHASE_COMMON); /* clean the DMAE memory */ bp->dmae_ready = 1; bnx2x_init_fill(bp, TSEM_REG_PRAM, 0, 8, 1); bnx2x_init_block(bp, BLOCK_TCM, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_UCM, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_CCM, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_XCM, PHASE_COMMON); bnx2x_read_dmae(bp, XSEM_REG_PASSIVE_BUFFER, 3); bnx2x_read_dmae(bp, CSEM_REG_PASSIVE_BUFFER, 3); bnx2x_read_dmae(bp, TSEM_REG_PASSIVE_BUFFER, 3); bnx2x_read_dmae(bp, USEM_REG_PASSIVE_BUFFER, 3); bnx2x_init_block(bp, BLOCK_QM, PHASE_COMMON); /* QM queues pointers table */ bnx2x_qm_init_ptr_table(bp, bp->qm_cid_count, INITOP_SET); /* soft reset pulse */ REG_WR(bp, QM_REG_SOFT_RESET, 1); REG_WR(bp, QM_REG_SOFT_RESET, 0); #ifdef BCM_CNIC bnx2x_init_block(bp, BLOCK_TM, PHASE_COMMON); #endif bnx2x_init_block(bp, BLOCK_DORQ, PHASE_COMMON); REG_WR(bp, DORQ_REG_DPM_CID_OFST, BNX2X_DB_SHIFT); if (!CHIP_REV_IS_SLOW(bp)) /* enable hw interrupt from doorbell Q */ REG_WR(bp, DORQ_REG_DORQ_INT_MASK, 0); bnx2x_init_block(bp, BLOCK_BRB1, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_PRS, PHASE_COMMON); REG_WR(bp, PRS_REG_A_PRSU_20, 0xf); if (!CHIP_IS_E1(bp)) REG_WR(bp, PRS_REG_E1HOV_MODE, bp->path_has_ovlan); if (!CHIP_IS_E1x(bp) && !CHIP_IS_E3B0(bp)) /* Bit-map indicating which L2 hdrs may appear * after the basic Ethernet header */ REG_WR(bp, PRS_REG_HDRS_AFTER_BASIC, bp->path_has_ovlan ? 7 : 6); bnx2x_init_block(bp, BLOCK_TSDM, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_CSDM, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_USDM, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_XSDM, PHASE_COMMON); if (!CHIP_IS_E1x(bp)) { /* reset VFC memories */ REG_WR(bp, TSEM_REG_FAST_MEMORY + VFC_REG_MEMORIES_RST, VFC_MEMORIES_RST_REG_CAM_RST | VFC_MEMORIES_RST_REG_RAM_RST); REG_WR(bp, XSEM_REG_FAST_MEMORY + VFC_REG_MEMORIES_RST, VFC_MEMORIES_RST_REG_CAM_RST | VFC_MEMORIES_RST_REG_RAM_RST); msleep(20); } bnx2x_init_block(bp, BLOCK_TSEM, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_USEM, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_CSEM, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_XSEM, PHASE_COMMON); /* sync semi rtc */ REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR, 0x80000000); REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, 0x80000000); bnx2x_init_block(bp, BLOCK_UPB, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_XPB, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_PBF, PHASE_COMMON); if (!CHIP_IS_E1x(bp)) REG_WR(bp, PBF_REG_HDRS_AFTER_BASIC, bp->path_has_ovlan ? 7 : 6); REG_WR(bp, SRC_REG_SOFT_RST, 1); bnx2x_init_block(bp, BLOCK_SRC, PHASE_COMMON); #ifdef BCM_CNIC REG_WR(bp, SRC_REG_KEYSEARCH_0, 0x63285672); REG_WR(bp, SRC_REG_KEYSEARCH_1, 0x24b8f2cc); REG_WR(bp, SRC_REG_KEYSEARCH_2, 0x223aef9b); REG_WR(bp, SRC_REG_KEYSEARCH_3, 0x26001e3a); REG_WR(bp, SRC_REG_KEYSEARCH_4, 0x7ae91116); REG_WR(bp, SRC_REG_KEYSEARCH_5, 0x5ce5230b); REG_WR(bp, SRC_REG_KEYSEARCH_6, 0x298d8adf); REG_WR(bp, SRC_REG_KEYSEARCH_7, 0x6eb0ff09); REG_WR(bp, SRC_REG_KEYSEARCH_8, 0x1830f82f); REG_WR(bp, SRC_REG_KEYSEARCH_9, 0x01e46be7); #endif REG_WR(bp, SRC_REG_SOFT_RST, 0); if (sizeof(union cdu_context) != 1024) /* we currently assume that a context is 1024 bytes */ dev_alert(&bp->pdev->dev, "please adjust the size " "of cdu_context(%ld)\n", (long)sizeof(union cdu_context)); bnx2x_init_block(bp, BLOCK_CDU, PHASE_COMMON); val = (4 << 24) + (0 << 12) + 1024; REG_WR(bp, CDU_REG_CDU_GLOBAL_PARAMS, val); bnx2x_init_block(bp, BLOCK_CFC, PHASE_COMMON); REG_WR(bp, CFC_REG_INIT_REG, 0x7FF); /* enable context validation interrupt from CFC */ REG_WR(bp, CFC_REG_CFC_INT_MASK, 0); /* set the thresholds to prevent CFC/CDU race */ REG_WR(bp, CFC_REG_DEBUG0, 0x20020000); bnx2x_init_block(bp, BLOCK_HC, PHASE_COMMON); if (!CHIP_IS_E1x(bp) && BP_NOMCP(bp)) REG_WR(bp, IGU_REG_RESET_MEMORIES, 0x36); bnx2x_init_block(bp, BLOCK_IGU, PHASE_COMMON); bnx2x_init_block(bp, BLOCK_MISC_AEU, PHASE_COMMON); /* Reset PCIE errors for debug */ REG_WR(bp, 0x2814, 0xffffffff); REG_WR(bp, 0x3820, 0xffffffff); if (!CHIP_IS_E1x(bp)) { REG_WR(bp, PCICFG_OFFSET + PXPCS_TL_CONTROL_5, (PXPCS_TL_CONTROL_5_ERR_UNSPPORT1 | PXPCS_TL_CONTROL_5_ERR_UNSPPORT)); REG_WR(bp, PCICFG_OFFSET + PXPCS_TL_FUNC345_STAT, (PXPCS_TL_FUNC345_STAT_ERR_UNSPPORT4 | PXPCS_TL_FUNC345_STAT_ERR_UNSPPORT3 | PXPCS_TL_FUNC345_STAT_ERR_UNSPPORT2)); REG_WR(bp, PCICFG_OFFSET + PXPCS_TL_FUNC678_STAT, (PXPCS_TL_FUNC678_STAT_ERR_UNSPPORT7 | PXPCS_TL_FUNC678_STAT_ERR_UNSPPORT6 | PXPCS_TL_FUNC678_STAT_ERR_UNSPPORT5)); } bnx2x_init_block(bp, BLOCK_NIG, PHASE_COMMON); if (!CHIP_IS_E1(bp)) { /* in E3 this done in per-port section */ if (!CHIP_IS_E3(bp)) REG_WR(bp, NIG_REG_LLH_MF_MODE, IS_MF(bp)); } if (CHIP_IS_E1H(bp)) /* not applicable for E2 (and above ...) */ REG_WR(bp, NIG_REG_LLH_E1HOV_MODE, IS_MF_SD(bp)); if (CHIP_REV_IS_SLOW(bp)) msleep(200); /* finish CFC init */ val = reg_poll(bp, CFC_REG_LL_INIT_DONE, 1, 100, 10); if (val != 1) { BNX2X_ERR("CFC LL_INIT failed\n"); return -EBUSY; } val = reg_poll(bp, CFC_REG_AC_INIT_DONE, 1, 100, 10); if (val != 1) { BNX2X_ERR("CFC AC_INIT failed\n"); return -EBUSY; } val = reg_poll(bp, CFC_REG_CAM_INIT_DONE, 1, 100, 10); if (val != 1) { BNX2X_ERR("CFC CAM_INIT failed\n"); return -EBUSY; } REG_WR(bp, CFC_REG_DEBUG0, 0); if (CHIP_IS_E1(bp)) { /* read NIG statistic to see if this is our first up since powerup */ bnx2x_read_dmae(bp, NIG_REG_STAT2_BRB_OCTET, 2); val = *bnx2x_sp(bp, wb_data[0]); /* do internal memory self test */ if ((val == 0) && bnx2x_int_mem_test(bp)) { BNX2X_ERR("internal mem self test failed\n"); return -EBUSY; } } bnx2x_setup_fan_failure_detection(bp); /* clear PXP2 attentions */ REG_RD(bp, PXP2_REG_PXP2_INT_STS_CLR_0); bnx2x_enable_blocks_attention(bp); bnx2x_enable_blocks_parity(bp); if (!BP_NOMCP(bp)) { if (CHIP_IS_E1x(bp)) bnx2x__common_init_phy(bp); } else BNX2X_ERR("Bootcode is missing - can not initialize link\n"); return 0; } /** * bnx2x_init_hw_common_chip - init HW at the COMMON_CHIP phase. * * @bp: driver handle */ static int bnx2x_init_hw_common_chip(struct bnx2x *bp) { int rc = bnx2x_init_hw_common(bp); if (rc) return rc; /* In E2 2-PORT mode, same ext phy is used for the two paths */ if (!BP_NOMCP(bp)) bnx2x__common_init_phy(bp); return 0; } static int bnx2x_init_hw_port(struct bnx2x *bp) { int port = BP_PORT(bp); int init_phase = port ? PHASE_PORT1 : PHASE_PORT0; u32 low, high; u32 val; bnx2x__link_reset(bp); DP(BNX2X_MSG_MCP, "starting port init port %d\n", port); REG_WR(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, 0); bnx2x_init_block(bp, BLOCK_MISC, init_phase); bnx2x_init_block(bp, BLOCK_PXP, init_phase); bnx2x_init_block(bp, BLOCK_PXP2, init_phase); /* Timers bug workaround: disables the pf_master bit in pglue at * common phase, we need to enable it here before any dmae access are * attempted. Therefore we manually added the enable-master to the * port phase (it also happens in the function phase) */ if (!CHIP_IS_E1x(bp)) REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 1); bnx2x_init_block(bp, BLOCK_ATC, init_phase); bnx2x_init_block(bp, BLOCK_DMAE, init_phase); bnx2x_init_block(bp, BLOCK_PGLUE_B, init_phase); bnx2x_init_block(bp, BLOCK_QM, init_phase); bnx2x_init_block(bp, BLOCK_TCM, init_phase); bnx2x_init_block(bp, BLOCK_UCM, init_phase); bnx2x_init_block(bp, BLOCK_CCM, init_phase); bnx2x_init_block(bp, BLOCK_XCM, init_phase); /* QM cid (connection) count */ bnx2x_qm_init_cid_count(bp, bp->qm_cid_count, INITOP_SET); #ifdef BCM_CNIC bnx2x_init_block(bp, BLOCK_TM, init_phase); REG_WR(bp, TM_REG_LIN0_SCAN_TIME + port*4, 20); REG_WR(bp, TM_REG_LIN0_MAX_ACTIVE_CID + port*4, 31); #endif bnx2x_init_block(bp, BLOCK_DORQ, init_phase); if (CHIP_IS_E1(bp) || CHIP_IS_E1H(bp)) { bnx2x_init_block(bp, BLOCK_BRB1, init_phase); if (IS_MF(bp)) low = ((bp->flags & ONE_PORT_FLAG) ? 160 : 246); else if (bp->dev->mtu > 4096) { if (bp->flags & ONE_PORT_FLAG) low = 160; else { val = bp->dev->mtu; /* (24*1024 + val*4)/256 */ low = 96 + (val/64) + ((val % 64) ? 1 : 0); } } else low = ((bp->flags & ONE_PORT_FLAG) ? 80 : 160); high = low + 56; /* 14*1024/256 */ REG_WR(bp, BRB1_REG_PAUSE_LOW_THRESHOLD_0 + port*4, low); REG_WR(bp, BRB1_REG_PAUSE_HIGH_THRESHOLD_0 + port*4, high); } if (CHIP_MODE_IS_4_PORT(bp)) REG_WR(bp, (BP_PORT(bp) ? BRB1_REG_MAC_GUARANTIED_1 : BRB1_REG_MAC_GUARANTIED_0), 40); bnx2x_init_block(bp, BLOCK_PRS, init_phase); if (CHIP_IS_E3B0(bp)) /* Ovlan exists only if we are in multi-function + * switch-dependent mode, in switch-independent there * is no ovlan headers */ REG_WR(bp, BP_PORT(bp) ? PRS_REG_HDRS_AFTER_BASIC_PORT_1 : PRS_REG_HDRS_AFTER_BASIC_PORT_0, (bp->path_has_ovlan ? 7 : 6)); bnx2x_init_block(bp, BLOCK_TSDM, init_phase); bnx2x_init_block(bp, BLOCK_CSDM, init_phase); bnx2x_init_block(bp, BLOCK_USDM, init_phase); bnx2x_init_block(bp, BLOCK_XSDM, init_phase); bnx2x_init_block(bp, BLOCK_TSEM, init_phase); bnx2x_init_block(bp, BLOCK_USEM, init_phase); bnx2x_init_block(bp, BLOCK_CSEM, init_phase); bnx2x_init_block(bp, BLOCK_XSEM, init_phase); bnx2x_init_block(bp, BLOCK_UPB, init_phase); bnx2x_init_block(bp, BLOCK_XPB, init_phase); bnx2x_init_block(bp, BLOCK_PBF, init_phase); if (CHIP_IS_E1x(bp)) { /* configure PBF to work without PAUSE mtu 9000 */ REG_WR(bp, PBF_REG_P0_PAUSE_ENABLE + port*4, 0); /* update threshold */ REG_WR(bp, PBF_REG_P0_ARB_THRSH + port*4, (9040/16)); /* update init credit */ REG_WR(bp, PBF_REG_P0_INIT_CRD + port*4, (9040/16) + 553 - 22); /* probe changes */ REG_WR(bp, PBF_REG_INIT_P0 + port*4, 1); udelay(50); REG_WR(bp, PBF_REG_INIT_P0 + port*4, 0); } #ifdef BCM_CNIC bnx2x_init_block(bp, BLOCK_SRC, init_phase); #endif bnx2x_init_block(bp, BLOCK_CDU, init_phase); bnx2x_init_block(bp, BLOCK_CFC, init_phase); if (CHIP_IS_E1(bp)) { REG_WR(bp, HC_REG_LEADING_EDGE_0 + port*8, 0); REG_WR(bp, HC_REG_TRAILING_EDGE_0 + port*8, 0); } bnx2x_init_block(bp, BLOCK_HC, init_phase); bnx2x_init_block(bp, BLOCK_IGU, init_phase); bnx2x_init_block(bp, BLOCK_MISC_AEU, init_phase); /* init aeu_mask_attn_func_0/1: * - SF mode: bits 3-7 are masked. only bits 0-2 are in use * - MF mode: bit 3 is masked. bits 0-2 are in use as in SF * bits 4-7 are used for "per vn group attention" */ val = IS_MF(bp) ? 0xF7 : 0x7; /* Enable DCBX attention for all but E1 */ val |= CHIP_IS_E1(bp) ? 0 : 0x10; REG_WR(bp, MISC_REG_AEU_MASK_ATTN_FUNC_0 + port*4, val); bnx2x_init_block(bp, BLOCK_NIG, init_phase); if (!CHIP_IS_E1x(bp)) { /* Bit-map indicating which L2 hdrs may appear after the * basic Ethernet header */ REG_WR(bp, BP_PORT(bp) ? NIG_REG_P1_HDRS_AFTER_BASIC : NIG_REG_P0_HDRS_AFTER_BASIC, IS_MF_SD(bp) ? 7 : 6); if (CHIP_IS_E3(bp)) REG_WR(bp, BP_PORT(bp) ? NIG_REG_LLH1_MF_MODE : NIG_REG_LLH_MF_MODE, IS_MF(bp)); } if (!CHIP_IS_E3(bp)) REG_WR(bp, NIG_REG_XGXS_SERDES0_MODE_SEL + port*4, 1); if (!CHIP_IS_E1(bp)) { /* 0x2 disable mf_ov, 0x1 enable */ REG_WR(bp, NIG_REG_LLH0_BRB1_DRV_MASK_MF + port*4, (IS_MF_SD(bp) ? 0x1 : 0x2)); if (!CHIP_IS_E1x(bp)) { val = 0; switch (bp->mf_mode) { case MULTI_FUNCTION_SD: val = 1; break; case MULTI_FUNCTION_SI: val = 2; break; } REG_WR(bp, (BP_PORT(bp) ? NIG_REG_LLH1_CLS_TYPE : NIG_REG_LLH0_CLS_TYPE), val); } { REG_WR(bp, NIG_REG_LLFC_ENABLE_0 + port*4, 0); REG_WR(bp, NIG_REG_LLFC_OUT_EN_0 + port*4, 0); REG_WR(bp, NIG_REG_PAUSE_ENABLE_0 + port*4, 1); } } /* If SPIO5 is set to generate interrupts, enable it for this port */ val = REG_RD(bp, MISC_REG_SPIO_EVENT_EN); if (val & (1 << MISC_REGISTERS_SPIO_5)) { u32 reg_addr = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 : MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0); val = REG_RD(bp, reg_addr); val |= AEU_INPUTS_ATTN_BITS_SPIO5; REG_WR(bp, reg_addr, val); } return 0; } static void bnx2x_ilt_wr(struct bnx2x *bp, u32 index, dma_addr_t addr) { int reg; if (CHIP_IS_E1(bp)) reg = PXP2_REG_RQ_ONCHIP_AT + index*8; else reg = PXP2_REG_RQ_ONCHIP_AT_B0 + index*8; bnx2x_wb_wr(bp, reg, ONCHIP_ADDR1(addr), ONCHIP_ADDR2(addr)); } static inline void bnx2x_igu_clear_sb(struct bnx2x *bp, u8 idu_sb_id) { bnx2x_igu_clear_sb_gen(bp, BP_FUNC(bp), idu_sb_id, true /*PF*/); } static inline void bnx2x_clear_func_ilt(struct bnx2x *bp, u32 func) { u32 i, base = FUNC_ILT_BASE(func); for (i = base; i < base + ILT_PER_FUNC; i++) bnx2x_ilt_wr(bp, i, 0); } static int bnx2x_init_hw_func(struct bnx2x *bp) { int port = BP_PORT(bp); int func = BP_FUNC(bp); int init_phase = PHASE_PF0 + func; struct bnx2x_ilt *ilt = BP_ILT(bp); u16 cdu_ilt_start; u32 addr, val; u32 main_mem_base, main_mem_size, main_mem_prty_clr; int i, main_mem_width; DP(BNX2X_MSG_MCP, "starting func init func %d\n", func); /* FLR cleanup - hmmm */ if (!CHIP_IS_E1x(bp)) bnx2x_pf_flr_clnup(bp); /* set MSI reconfigure capability */ if (bp->common.int_block == INT_BLOCK_HC) { addr = (port ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0); val = REG_RD(bp, addr); val |= HC_CONFIG_0_REG_MSI_ATTN_EN_0; REG_WR(bp, addr, val); } bnx2x_init_block(bp, BLOCK_PXP, init_phase); bnx2x_init_block(bp, BLOCK_PXP2, init_phase); ilt = BP_ILT(bp); cdu_ilt_start = ilt->clients[ILT_CLIENT_CDU].start; for (i = 0; i < L2_ILT_LINES(bp); i++) { ilt->lines[cdu_ilt_start + i].page = bp->context.vcxt + (ILT_PAGE_CIDS * i); ilt->lines[cdu_ilt_start + i].page_mapping = bp->context.cxt_mapping + (CDU_ILT_PAGE_SZ * i); /* cdu ilt pages are allocated manually so there's no need to set the size */ } bnx2x_ilt_init_op(bp, INITOP_SET); #ifdef BCM_CNIC bnx2x_src_init_t2(bp, bp->t2, bp->t2_mapping, SRC_CONN_NUM); /* T1 hash bits value determines the T1 number of entries */ REG_WR(bp, SRC_REG_NUMBER_HASH_BITS0 + port*4, SRC_HASH_BITS); #endif #ifndef BCM_CNIC /* set NIC mode */ REG_WR(bp, PRS_REG_NIC_MODE, 1); #endif /* BCM_CNIC */ if (!CHIP_IS_E1x(bp)) { u32 pf_conf = IGU_PF_CONF_FUNC_EN; /* Turn on a single ISR mode in IGU if driver is going to use * INT#x or MSI */ if (!(bp->flags & USING_MSIX_FLAG)) pf_conf |= IGU_PF_CONF_SINGLE_ISR_EN; /* * Timers workaround bug: function init part. * Need to wait 20msec after initializing ILT, * needed to make sure there are no requests in * one of the PXP internal queues with "old" ILT addresses */ msleep(20); /* * Master enable - Due to WB DMAE writes performed before this * register is re-initialized as part of the regular function * init */ REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_MASTER, 1); /* Enable the function in IGU */ REG_WR(bp, IGU_REG_PF_CONFIGURATION, pf_conf); } bp->dmae_ready = 1; bnx2x_init_block(bp, BLOCK_PGLUE_B, init_phase); if (!CHIP_IS_E1x(bp)) REG_WR(bp, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR, func); bnx2x_init_block(bp, BLOCK_ATC, init_phase); bnx2x_init_block(bp, BLOCK_DMAE, init_phase); bnx2x_init_block(bp, BLOCK_NIG, init_phase); bnx2x_init_block(bp, BLOCK_SRC, init_phase); bnx2x_init_block(bp, BLOCK_MISC, init_phase); bnx2x_init_block(bp, BLOCK_TCM, init_phase); bnx2x_init_block(bp, BLOCK_UCM, init_phase); bnx2x_init_block(bp, BLOCK_CCM, init_phase); bnx2x_init_block(bp, BLOCK_XCM, init_phase); bnx2x_init_block(bp, BLOCK_TSEM, init_phase); bnx2x_init_block(bp, BLOCK_USEM, init_phase); bnx2x_init_block(bp, BLOCK_CSEM, init_phase); bnx2x_init_block(bp, BLOCK_XSEM, init_phase); if (!CHIP_IS_E1x(bp)) REG_WR(bp, QM_REG_PF_EN, 1); if (!CHIP_IS_E1x(bp)) { REG_WR(bp, TSEM_REG_VFPF_ERR_NUM, BNX2X_MAX_NUM_OF_VFS + func); REG_WR(bp, USEM_REG_VFPF_ERR_NUM, BNX2X_MAX_NUM_OF_VFS + func); REG_WR(bp, CSEM_REG_VFPF_ERR_NUM, BNX2X_MAX_NUM_OF_VFS + func); REG_WR(bp, XSEM_REG_VFPF_ERR_NUM, BNX2X_MAX_NUM_OF_VFS + func); } bnx2x_init_block(bp, BLOCK_QM, init_phase); bnx2x_init_block(bp, BLOCK_TM, init_phase); bnx2x_init_block(bp, BLOCK_DORQ, init_phase); bnx2x_init_block(bp, BLOCK_BRB1, init_phase); bnx2x_init_block(bp, BLOCK_PRS, init_phase); bnx2x_init_block(bp, BLOCK_TSDM, init_phase); bnx2x_init_block(bp, BLOCK_CSDM, init_phase); bnx2x_init_block(bp, BLOCK_USDM, init_phase); bnx2x_init_block(bp, BLOCK_XSDM, init_phase); bnx2x_init_block(bp, BLOCK_UPB, init_phase); bnx2x_init_block(bp, BLOCK_XPB, init_phase); bnx2x_init_block(bp, BLOCK_PBF, init_phase); if (!CHIP_IS_E1x(bp)) REG_WR(bp, PBF_REG_DISABLE_PF, 0); bnx2x_init_block(bp, BLOCK_CDU, init_phase); bnx2x_init_block(bp, BLOCK_CFC, init_phase); if (!CHIP_IS_E1x(bp)) REG_WR(bp, CFC_REG_WEAK_ENABLE_PF, 1); if (IS_MF(bp)) { REG_WR(bp, NIG_REG_LLH0_FUNC_EN + port*8, 1); REG_WR(bp, NIG_REG_LLH0_FUNC_VLAN_ID + port*8, bp->mf_ov); } bnx2x_init_block(bp, BLOCK_MISC_AEU, init_phase); /* HC init per function */ if (bp->common.int_block == INT_BLOCK_HC) { if (CHIP_IS_E1H(bp)) { REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_12 + func*4, 0); REG_WR(bp, HC_REG_LEADING_EDGE_0 + port*8, 0); REG_WR(bp, HC_REG_TRAILING_EDGE_0 + port*8, 0); } bnx2x_init_block(bp, BLOCK_HC, init_phase); } else { int num_segs, sb_idx, prod_offset; REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_12 + func*4, 0); if (!CHIP_IS_E1x(bp)) { REG_WR(bp, IGU_REG_LEADING_EDGE_LATCH, 0); REG_WR(bp, IGU_REG_TRAILING_EDGE_LATCH, 0); } bnx2x_init_block(bp, BLOCK_IGU, init_phase); if (!CHIP_IS_E1x(bp)) { int dsb_idx = 0; /** * Producer memory: * E2 mode: address 0-135 match to the mapping memory; * 136 - PF0 default prod; 137 - PF1 default prod; * 138 - PF2 default prod; 139 - PF3 default prod; * 140 - PF0 attn prod; 141 - PF1 attn prod; * 142 - PF2 attn prod; 143 - PF3 attn prod; * 144-147 reserved. * * E1.5 mode - In backward compatible mode; * for non default SB; each even line in the memory * holds the U producer and each odd line hold * the C producer. The first 128 producers are for * NDSB (PF0 - 0-31; PF1 - 32-63 and so on). The last 20 * producers are for the DSB for each PF. * Each PF has five segments: (the order inside each * segment is PF0; PF1; PF2; PF3) - 128-131 U prods; * 132-135 C prods; 136-139 X prods; 140-143 T prods; * 144-147 attn prods; */ /* non-default-status-blocks */ num_segs = CHIP_INT_MODE_IS_BC(bp) ? IGU_BC_NDSB_NUM_SEGS : IGU_NORM_NDSB_NUM_SEGS; for (sb_idx = 0; sb_idx < bp->igu_sb_cnt; sb_idx++) { prod_offset = (bp->igu_base_sb + sb_idx) * num_segs; for (i = 0; i < num_segs; i++) { addr = IGU_REG_PROD_CONS_MEMORY + (prod_offset + i) * 4; REG_WR(bp, addr, 0); } /* send consumer update with value 0 */ bnx2x_ack_sb(bp, bp->igu_base_sb + sb_idx, USTORM_ID, 0, IGU_INT_NOP, 1); bnx2x_igu_clear_sb(bp, bp->igu_base_sb + sb_idx); } /* default-status-blocks */ num_segs = CHIP_INT_MODE_IS_BC(bp) ? IGU_BC_DSB_NUM_SEGS : IGU_NORM_DSB_NUM_SEGS; if (CHIP_MODE_IS_4_PORT(bp)) dsb_idx = BP_FUNC(bp); else dsb_idx = BP_VN(bp); prod_offset = (CHIP_INT_MODE_IS_BC(bp) ? IGU_BC_BASE_DSB_PROD + dsb_idx : IGU_NORM_BASE_DSB_PROD + dsb_idx); /* * igu prods come in chunks of E1HVN_MAX (4) - * does not matters what is the current chip mode */ for (i = 0; i < (num_segs * E1HVN_MAX); i += E1HVN_MAX) { addr = IGU_REG_PROD_CONS_MEMORY + (prod_offset + i)*4; REG_WR(bp, addr, 0); } /* send consumer update with 0 */ if (CHIP_INT_MODE_IS_BC(bp)) { bnx2x_ack_sb(bp, bp->igu_dsb_id, USTORM_ID, 0, IGU_INT_NOP, 1); bnx2x_ack_sb(bp, bp->igu_dsb_id, CSTORM_ID, 0, IGU_INT_NOP, 1); bnx2x_ack_sb(bp, bp->igu_dsb_id, XSTORM_ID, 0, IGU_INT_NOP, 1); bnx2x_ack_sb(bp, bp->igu_dsb_id, TSTORM_ID, 0, IGU_INT_NOP, 1); bnx2x_ack_sb(bp, bp->igu_dsb_id, ATTENTION_ID, 0, IGU_INT_NOP, 1); } else { bnx2x_ack_sb(bp, bp->igu_dsb_id, USTORM_ID, 0, IGU_INT_NOP, 1); bnx2x_ack_sb(bp, bp->igu_dsb_id, ATTENTION_ID, 0, IGU_INT_NOP, 1); } bnx2x_igu_clear_sb(bp, bp->igu_dsb_id); /* !!! these should become driver const once rf-tool supports split-68 const */ REG_WR(bp, IGU_REG_SB_INT_BEFORE_MASK_LSB, 0); REG_WR(bp, IGU_REG_SB_INT_BEFORE_MASK_MSB, 0); REG_WR(bp, IGU_REG_SB_MASK_LSB, 0); REG_WR(bp, IGU_REG_SB_MASK_MSB, 0); REG_WR(bp, IGU_REG_PBA_STATUS_LSB, 0); REG_WR(bp, IGU_REG_PBA_STATUS_MSB, 0); } } /* Reset PCIE errors for debug */ REG_WR(bp, 0x2114, 0xffffffff); REG_WR(bp, 0x2120, 0xffffffff); if (CHIP_IS_E1x(bp)) { main_mem_size = HC_REG_MAIN_MEMORY_SIZE / 2; /*dwords*/ main_mem_base = HC_REG_MAIN_MEMORY + BP_PORT(bp) * (main_mem_size * 4); main_mem_prty_clr = HC_REG_HC_PRTY_STS_CLR; main_mem_width = 8; val = REG_RD(bp, main_mem_prty_clr); if (val) DP(BNX2X_MSG_MCP, "Hmmm... Parity errors in HC " "block during " "function init (0x%x)!\n", val); /* Clear "false" parity errors in MSI-X table */ for (i = main_mem_base; i < main_mem_base + main_mem_size * 4; i += main_mem_width) { bnx2x_read_dmae(bp, i, main_mem_width / 4); bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), i, main_mem_width / 4); } /* Clear HC parity attention */ REG_RD(bp, main_mem_prty_clr); } #ifdef BNX2X_STOP_ON_ERROR /* Enable STORMs SP logging */ REG_WR8(bp, BAR_USTRORM_INTMEM + USTORM_RECORD_SLOW_PATH_OFFSET(BP_FUNC(bp)), 1); REG_WR8(bp, BAR_TSTRORM_INTMEM + TSTORM_RECORD_SLOW_PATH_OFFSET(BP_FUNC(bp)), 1); REG_WR8(bp, BAR_CSTRORM_INTMEM + CSTORM_RECORD_SLOW_PATH_OFFSET(BP_FUNC(bp)), 1); REG_WR8(bp, BAR_XSTRORM_INTMEM + XSTORM_RECORD_SLOW_PATH_OFFSET(BP_FUNC(bp)), 1); #endif bnx2x_phy_probe(&bp->link_params); return 0; } void bnx2x_free_mem(struct bnx2x *bp) { /* fastpath */ bnx2x_free_fp_mem(bp); /* end of fastpath */ BNX2X_PCI_FREE(bp->def_status_blk, bp->def_status_blk_mapping, sizeof(struct host_sp_status_block)); BNX2X_PCI_FREE(bp->fw_stats, bp->fw_stats_mapping, bp->fw_stats_data_sz + bp->fw_stats_req_sz); BNX2X_PCI_FREE(bp->slowpath, bp->slowpath_mapping, sizeof(struct bnx2x_slowpath)); BNX2X_PCI_FREE(bp->context.vcxt, bp->context.cxt_mapping, bp->context.size); bnx2x_ilt_mem_op(bp, ILT_MEMOP_FREE); BNX2X_FREE(bp->ilt->lines); #ifdef BCM_CNIC if (!CHIP_IS_E1x(bp)) BNX2X_PCI_FREE(bp->cnic_sb.e2_sb, bp->cnic_sb_mapping, sizeof(struct host_hc_status_block_e2)); else BNX2X_PCI_FREE(bp->cnic_sb.e1x_sb, bp->cnic_sb_mapping, sizeof(struct host_hc_status_block_e1x)); BNX2X_PCI_FREE(bp->t2, bp->t2_mapping, SRC_T2_SZ); #endif BNX2X_PCI_FREE(bp->spq, bp->spq_mapping, BCM_PAGE_SIZE); BNX2X_PCI_FREE(bp->eq_ring, bp->eq_mapping, BCM_PAGE_SIZE * NUM_EQ_PAGES); } static inline int bnx2x_alloc_fw_stats_mem(struct bnx2x *bp) { int num_groups; /* number of eth_queues */ u8 num_queue_stats = BNX2X_NUM_ETH_QUEUES(bp); /* Total number of FW statistics requests = * 1 for port stats + 1 for PF stats + num_eth_queues */ bp->fw_stats_num = 2 + num_queue_stats; /* Request is built from stats_query_header and an array of * stats_query_cmd_group each of which contains * STATS_QUERY_CMD_COUNT rules. The real number or requests is * configured in the stats_query_header. */ num_groups = (2 + num_queue_stats) / STATS_QUERY_CMD_COUNT + (((2 + num_queue_stats) % STATS_QUERY_CMD_COUNT) ? 1 : 0); bp->fw_stats_req_sz = sizeof(struct stats_query_header) + num_groups * sizeof(struct stats_query_cmd_group); /* Data for statistics requests + stats_conter * * stats_counter holds per-STORM counters that are incremented * when STORM has finished with the current request. */ bp->fw_stats_data_sz = sizeof(struct per_port_stats) + sizeof(struct per_pf_stats) + sizeof(struct per_queue_stats) * num_queue_stats + sizeof(struct stats_counter); BNX2X_PCI_ALLOC(bp->fw_stats, &bp->fw_stats_mapping, bp->fw_stats_data_sz + bp->fw_stats_req_sz); /* Set shortcuts */ bp->fw_stats_req = (struct bnx2x_fw_stats_req *)bp->fw_stats; bp->fw_stats_req_mapping = bp->fw_stats_mapping; bp->fw_stats_data = (struct bnx2x_fw_stats_data *) ((u8 *)bp->fw_stats + bp->fw_stats_req_sz); bp->fw_stats_data_mapping = bp->fw_stats_mapping + bp->fw_stats_req_sz; return 0; alloc_mem_err: BNX2X_PCI_FREE(bp->fw_stats, bp->fw_stats_mapping, bp->fw_stats_data_sz + bp->fw_stats_req_sz); return -ENOMEM; } int bnx2x_alloc_mem(struct bnx2x *bp) { #ifdef BCM_CNIC if (!CHIP_IS_E1x(bp)) /* size = the status block + ramrod buffers */ BNX2X_PCI_ALLOC(bp->cnic_sb.e2_sb, &bp->cnic_sb_mapping, sizeof(struct host_hc_status_block_e2)); else BNX2X_PCI_ALLOC(bp->cnic_sb.e1x_sb, &bp->cnic_sb_mapping, sizeof(struct host_hc_status_block_e1x)); /* allocate searcher T2 table */ BNX2X_PCI_ALLOC(bp->t2, &bp->t2_mapping, SRC_T2_SZ); #endif BNX2X_PCI_ALLOC(bp->def_status_blk, &bp->def_status_blk_mapping, sizeof(struct host_sp_status_block)); BNX2X_PCI_ALLOC(bp->slowpath, &bp->slowpath_mapping, sizeof(struct bnx2x_slowpath)); /* Allocated memory for FW statistics */ if (bnx2x_alloc_fw_stats_mem(bp)) goto alloc_mem_err; bp->context.size = sizeof(union cdu_context) * BNX2X_L2_CID_COUNT(bp); BNX2X_PCI_ALLOC(bp->context.vcxt, &bp->context.cxt_mapping, bp->context.size); BNX2X_ALLOC(bp->ilt->lines, sizeof(struct ilt_line) * ILT_MAX_LINES); if (bnx2x_ilt_mem_op(bp, ILT_MEMOP_ALLOC)) goto alloc_mem_err; /* Slow path ring */ BNX2X_PCI_ALLOC(bp->spq, &bp->spq_mapping, BCM_PAGE_SIZE); /* EQ */ BNX2X_PCI_ALLOC(bp->eq_ring, &bp->eq_mapping, BCM_PAGE_SIZE * NUM_EQ_PAGES); /* fastpath */ /* need to be done at the end, since it's self adjusting to amount * of memory available for RSS queues */ if (bnx2x_alloc_fp_mem(bp)) goto alloc_mem_err; return 0; alloc_mem_err: bnx2x_free_mem(bp); return -ENOMEM; } /* * Init service functions */ int bnx2x_set_mac_one(struct bnx2x *bp, u8 *mac, struct bnx2x_vlan_mac_obj *obj, bool set, int mac_type, unsigned long *ramrod_flags) { int rc; struct bnx2x_vlan_mac_ramrod_params ramrod_param; memset(&ramrod_param, 0, sizeof(ramrod_param)); /* Fill general parameters */ ramrod_param.vlan_mac_obj = obj; ramrod_param.ramrod_flags = *ramrod_flags; /* Fill a user request section if needed */ if (!test_bit(RAMROD_CONT, ramrod_flags)) { memcpy(ramrod_param.user_req.u.mac.mac, mac, ETH_ALEN); __set_bit(mac_type, &ramrod_param.user_req.vlan_mac_flags); /* Set the command: ADD or DEL */ if (set) ramrod_param.user_req.cmd = BNX2X_VLAN_MAC_ADD; else ramrod_param.user_req.cmd = BNX2X_VLAN_MAC_DEL; } rc = bnx2x_config_vlan_mac(bp, &ramrod_param); if (rc < 0) BNX2X_ERR("%s MAC failed\n", (set ? "Set" : "Del")); return rc; } int bnx2x_del_all_macs(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *mac_obj, int mac_type, bool wait_for_comp) { int rc; unsigned long ramrod_flags = 0, vlan_mac_flags = 0; /* Wait for completion of requested */ if (wait_for_comp) __set_bit(RAMROD_COMP_WAIT, &ramrod_flags); /* Set the mac type of addresses we want to clear */ __set_bit(mac_type, &vlan_mac_flags); rc = mac_obj->delete_all(bp, mac_obj, &vlan_mac_flags, &ramrod_flags); if (rc < 0) BNX2X_ERR("Failed to delete MACs: %d\n", rc); return rc; } int bnx2x_set_eth_mac(struct bnx2x *bp, bool set) { unsigned long ramrod_flags = 0; DP(NETIF_MSG_IFUP, "Adding Eth MAC\n"); __set_bit(RAMROD_COMP_WAIT, &ramrod_flags); /* Eth MAC is set on RSS leading client (fp[0]) */ return bnx2x_set_mac_one(bp, bp->dev->dev_addr, &bp->fp->mac_obj, set, BNX2X_ETH_MAC, &ramrod_flags); } int bnx2x_setup_leading(struct bnx2x *bp) { return bnx2x_setup_queue(bp, &bp->fp[0], 1); } /** * bnx2x_set_int_mode - configure interrupt mode * * @bp: driver handle * * In case of MSI-X it will also try to enable MSI-X. */ static void __devinit bnx2x_set_int_mode(struct bnx2x *bp) { switch (int_mode) { case INT_MODE_MSI: bnx2x_enable_msi(bp); /* falling through... */ case INT_MODE_INTx: bp->num_queues = 1 + NON_ETH_CONTEXT_USE; DP(NETIF_MSG_IFUP, "set number of queues to 1\n"); break; default: /* Set number of queues according to bp->multi_mode value */ bnx2x_set_num_queues(bp); DP(NETIF_MSG_IFUP, "set number of queues to %d\n", bp->num_queues); /* if we can't use MSI-X we only need one fp, * so try to enable MSI-X with the requested number of fp's * and fallback to MSI or legacy INTx with one fp */ if (bnx2x_enable_msix(bp)) { /* failed to enable MSI-X */ if (bp->multi_mode) DP(NETIF_MSG_IFUP, "Multi requested but failed to " "enable MSI-X (%d), " "set number of queues to %d\n", bp->num_queues, 1 + NON_ETH_CONTEXT_USE); bp->num_queues = 1 + NON_ETH_CONTEXT_USE; /* Try to enable MSI */ if (!(bp->flags & DISABLE_MSI_FLAG)) bnx2x_enable_msi(bp); } break; } } /* must be called prioir to any HW initializations */ static inline u16 bnx2x_cid_ilt_lines(struct bnx2x *bp) { return L2_ILT_LINES(bp); } void bnx2x_ilt_set_info(struct bnx2x *bp) { struct ilt_client_info *ilt_client; struct bnx2x_ilt *ilt = BP_ILT(bp); u16 line = 0; ilt->start_line = FUNC_ILT_BASE(BP_FUNC(bp)); DP(BNX2X_MSG_SP, "ilt starts at line %d\n", ilt->start_line); /* CDU */ ilt_client = &ilt->clients[ILT_CLIENT_CDU]; ilt_client->client_num = ILT_CLIENT_CDU; ilt_client->page_size = CDU_ILT_PAGE_SZ; ilt_client->flags = ILT_CLIENT_SKIP_MEM; ilt_client->start = line; line += bnx2x_cid_ilt_lines(bp); #ifdef BCM_CNIC line += CNIC_ILT_LINES; #endif ilt_client->end = line - 1; DP(BNX2X_MSG_SP, "ilt client[CDU]: start %d, end %d, psz 0x%x, " "flags 0x%x, hw psz %d\n", ilt_client->start, ilt_client->end, ilt_client->page_size, ilt_client->flags, ilog2(ilt_client->page_size >> 12)); /* QM */ if (QM_INIT(bp->qm_cid_count)) { ilt_client = &ilt->clients[ILT_CLIENT_QM]; ilt_client->client_num = ILT_CLIENT_QM; ilt_client->page_size = QM_ILT_PAGE_SZ; ilt_client->flags = 0; ilt_client->start = line; /* 4 bytes for each cid */ line += DIV_ROUND_UP(bp->qm_cid_count * QM_QUEUES_PER_FUNC * 4, QM_ILT_PAGE_SZ); ilt_client->end = line - 1; DP(BNX2X_MSG_SP, "ilt client[QM]: start %d, end %d, psz 0x%x, " "flags 0x%x, hw psz %d\n", ilt_client->start, ilt_client->end, ilt_client->page_size, ilt_client->flags, ilog2(ilt_client->page_size >> 12)); } /* SRC */ ilt_client = &ilt->clients[ILT_CLIENT_SRC]; #ifdef BCM_CNIC ilt_client->client_num = ILT_CLIENT_SRC; ilt_client->page_size = SRC_ILT_PAGE_SZ; ilt_client->flags = 0; ilt_client->start = line; line += SRC_ILT_LINES; ilt_client->end = line - 1; DP(BNX2X_MSG_SP, "ilt client[SRC]: start %d, end %d, psz 0x%x, " "flags 0x%x, hw psz %d\n", ilt_client->start, ilt_client->end, ilt_client->page_size, ilt_client->flags, ilog2(ilt_client->page_size >> 12)); #else ilt_client->flags = (ILT_CLIENT_SKIP_INIT | ILT_CLIENT_SKIP_MEM); #endif /* TM */ ilt_client = &ilt->clients[ILT_CLIENT_TM]; #ifdef BCM_CNIC ilt_client->client_num = ILT_CLIENT_TM; ilt_client->page_size = TM_ILT_PAGE_SZ; ilt_client->flags = 0; ilt_client->start = line; line += TM_ILT_LINES; ilt_client->end = line - 1; DP(BNX2X_MSG_SP, "ilt client[TM]: start %d, end %d, psz 0x%x, " "flags 0x%x, hw psz %d\n", ilt_client->start, ilt_client->end, ilt_client->page_size, ilt_client->flags, ilog2(ilt_client->page_size >> 12)); #else ilt_client->flags = (ILT_CLIENT_SKIP_INIT | ILT_CLIENT_SKIP_MEM); #endif BUG_ON(line > ILT_MAX_LINES); } /** * bnx2x_pf_q_prep_init - prepare INIT transition parameters * * @bp: driver handle * @fp: pointer to fastpath * @init_params: pointer to parameters structure * * parameters configured: * - HC configuration * - Queue's CDU context */ static inline void bnx2x_pf_q_prep_init(struct bnx2x *bp, struct bnx2x_fastpath *fp, struct bnx2x_queue_init_params *init_params) { u8 cos; /* FCoE Queue uses Default SB, thus has no HC capabilities */ if (!IS_FCOE_FP(fp)) { __set_bit(BNX2X_Q_FLG_HC, &init_params->rx.flags); __set_bit(BNX2X_Q_FLG_HC, &init_params->tx.flags); /* If HC is supporterd, enable host coalescing in the transition * to INIT state. */ __set_bit(BNX2X_Q_FLG_HC_EN, &init_params->rx.flags); __set_bit(BNX2X_Q_FLG_HC_EN, &init_params->tx.flags); /* HC rate */ init_params->rx.hc_rate = bp->rx_ticks ? (1000000 / bp->rx_ticks) : 0; init_params->tx.hc_rate = bp->tx_ticks ? (1000000 / bp->tx_ticks) : 0; /* FW SB ID */ init_params->rx.fw_sb_id = init_params->tx.fw_sb_id = fp->fw_sb_id; /* * CQ index among the SB indices: FCoE clients uses the default * SB, therefore it's different. */ init_params->rx.sb_cq_index = HC_INDEX_ETH_RX_CQ_CONS; init_params->tx.sb_cq_index = HC_INDEX_ETH_FIRST_TX_CQ_CONS; } /* set maximum number of COSs supported by this queue */ init_params->max_cos = fp->max_cos; DP(BNX2X_MSG_SP, "fp: %d setting queue params max cos to: %d", fp->index, init_params->max_cos); /* set the context pointers queue object */ for (cos = FIRST_TX_COS_INDEX; cos < init_params->max_cos; cos++) init_params->cxts[cos] = &bp->context.vcxt[fp->txdata[cos].cid].eth; } int bnx2x_setup_tx_only(struct bnx2x *bp, struct bnx2x_fastpath *fp, struct bnx2x_queue_state_params *q_params, struct bnx2x_queue_setup_tx_only_params *tx_only_params, int tx_index, bool leading) { memset(tx_only_params, 0, sizeof(*tx_only_params)); /* Set the command */ q_params->cmd = BNX2X_Q_CMD_SETUP_TX_ONLY; /* Set tx-only QUEUE flags: don't zero statistics */ tx_only_params->flags = bnx2x_get_common_flags(bp, fp, false); /* choose the index of the cid to send the slow path on */ tx_only_params->cid_index = tx_index; /* Set general TX_ONLY_SETUP parameters */ bnx2x_pf_q_prep_general(bp, fp, &tx_only_params->gen_params, tx_index); /* Set Tx TX_ONLY_SETUP parameters */ bnx2x_pf_tx_q_prep(bp, fp, &tx_only_params->txq_params, tx_index); DP(BNX2X_MSG_SP, "preparing to send tx-only ramrod for connection:" "cos %d, primary cid %d, cid %d, " "client id %d, sp-client id %d, flags %lx", tx_index, q_params->q_obj->cids[FIRST_TX_COS_INDEX], q_params->q_obj->cids[tx_index], q_params->q_obj->cl_id, tx_only_params->gen_params.spcl_id, tx_only_params->flags); /* send the ramrod */ return bnx2x_queue_state_change(bp, q_params); } /** * bnx2x_setup_queue - setup queue * * @bp: driver handle * @fp: pointer to fastpath * @leading: is leading * * This function performs 2 steps in a Queue state machine * actually: 1) RESET->INIT 2) INIT->SETUP */ int bnx2x_setup_queue(struct bnx2x *bp, struct bnx2x_fastpath *fp, bool leading) { struct bnx2x_queue_state_params q_params = {0}; struct bnx2x_queue_setup_params *setup_params = &q_params.params.setup; struct bnx2x_queue_setup_tx_only_params *tx_only_params = &q_params.params.tx_only; int rc; u8 tx_index; DP(BNX2X_MSG_SP, "setting up queue %d", fp->index); /* reset IGU state skip FCoE L2 queue */ if (!IS_FCOE_FP(fp)) bnx2x_ack_sb(bp, fp->igu_sb_id, USTORM_ID, 0, IGU_INT_ENABLE, 0); q_params.q_obj = &fp->q_obj; /* We want to wait for completion in this context */ __set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags); /* Prepare the INIT parameters */ bnx2x_pf_q_prep_init(bp, fp, &q_params.params.init); /* Set the command */ q_params.cmd = BNX2X_Q_CMD_INIT; /* Change the state to INIT */ rc = bnx2x_queue_state_change(bp, &q_params); if (rc) { BNX2X_ERR("Queue(%d) INIT failed\n", fp->index); return rc; } DP(BNX2X_MSG_SP, "init complete"); /* Now move the Queue to the SETUP state... */ memset(setup_params, 0, sizeof(*setup_params)); /* Set QUEUE flags */ setup_params->flags = bnx2x_get_q_flags(bp, fp, leading); /* Set general SETUP parameters */ bnx2x_pf_q_prep_general(bp, fp, &setup_params->gen_params, FIRST_TX_COS_INDEX); bnx2x_pf_rx_q_prep(bp, fp, &setup_params->pause_params, &setup_params->rxq_params); bnx2x_pf_tx_q_prep(bp, fp, &setup_params->txq_params, FIRST_TX_COS_INDEX); /* Set the command */ q_params.cmd = BNX2X_Q_CMD_SETUP; /* Change the state to SETUP */ rc = bnx2x_queue_state_change(bp, &q_params); if (rc) { BNX2X_ERR("Queue(%d) SETUP failed\n", fp->index); return rc; } /* loop through the relevant tx-only indices */ for (tx_index = FIRST_TX_ONLY_COS_INDEX; tx_index < fp->max_cos; tx_index++) { /* prepare and send tx-only ramrod*/ rc = bnx2x_setup_tx_only(bp, fp, &q_params, tx_only_params, tx_index, leading); if (rc) { BNX2X_ERR("Queue(%d.%d) TX_ONLY_SETUP failed\n", fp->index, tx_index); return rc; } } return rc; } static int bnx2x_stop_queue(struct bnx2x *bp, int index) { struct bnx2x_fastpath *fp = &bp->fp[index]; struct bnx2x_fp_txdata *txdata; struct bnx2x_queue_state_params q_params = {0}; int rc, tx_index; DP(BNX2X_MSG_SP, "stopping queue %d cid %d", index, fp->cid); q_params.q_obj = &fp->q_obj; /* We want to wait for completion in this context */ __set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags); /* close tx-only connections */ for (tx_index = FIRST_TX_ONLY_COS_INDEX; tx_index < fp->max_cos; tx_index++){ /* ascertain this is a normal queue*/ txdata = &fp->txdata[tx_index]; DP(BNX2X_MSG_SP, "stopping tx-only queue %d", txdata->txq_index); /* send halt terminate on tx-only connection */ q_params.cmd = BNX2X_Q_CMD_TERMINATE; memset(&q_params.params.terminate, 0, sizeof(q_params.params.terminate)); q_params.params.terminate.cid_index = tx_index; rc = bnx2x_queue_state_change(bp, &q_params); if (rc) return rc; /* send halt terminate on tx-only connection */ q_params.cmd = BNX2X_Q_CMD_CFC_DEL; memset(&q_params.params.cfc_del, 0, sizeof(q_params.params.cfc_del)); q_params.params.cfc_del.cid_index = tx_index; rc = bnx2x_queue_state_change(bp, &q_params); if (rc) return rc; } /* Stop the primary connection: */ /* ...halt the connection */ q_params.cmd = BNX2X_Q_CMD_HALT; rc = bnx2x_queue_state_change(bp, &q_params); if (rc) return rc; /* ...terminate the connection */ q_params.cmd = BNX2X_Q_CMD_TERMINATE; memset(&q_params.params.terminate, 0, sizeof(q_params.params.terminate)); q_params.params.terminate.cid_index = FIRST_TX_COS_INDEX; rc = bnx2x_queue_state_change(bp, &q_params); if (rc) return rc; /* ...delete cfc entry */ q_params.cmd = BNX2X_Q_CMD_CFC_DEL; memset(&q_params.params.cfc_del, 0, sizeof(q_params.params.cfc_del)); q_params.params.cfc_del.cid_index = FIRST_TX_COS_INDEX; return bnx2x_queue_state_change(bp, &q_params); } static void bnx2x_reset_func(struct bnx2x *bp) { int port = BP_PORT(bp); int func = BP_FUNC(bp); int i; /* Disable the function in the FW */ REG_WR8(bp, BAR_XSTRORM_INTMEM + XSTORM_FUNC_EN_OFFSET(func), 0); REG_WR8(bp, BAR_CSTRORM_INTMEM + CSTORM_FUNC_EN_OFFSET(func), 0); REG_WR8(bp, BAR_TSTRORM_INTMEM + TSTORM_FUNC_EN_OFFSET(func), 0); REG_WR8(bp, BAR_USTRORM_INTMEM + USTORM_FUNC_EN_OFFSET(func), 0); /* FP SBs */ for_each_eth_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; REG_WR8(bp, BAR_CSTRORM_INTMEM + CSTORM_STATUS_BLOCK_DATA_STATE_OFFSET(fp->fw_sb_id), SB_DISABLED); } #ifdef BCM_CNIC /* CNIC SB */ REG_WR8(bp, BAR_CSTRORM_INTMEM + CSTORM_STATUS_BLOCK_DATA_STATE_OFFSET(bnx2x_cnic_fw_sb_id(bp)), SB_DISABLED); #endif /* SP SB */ REG_WR8(bp, BAR_CSTRORM_INTMEM + CSTORM_SP_STATUS_BLOCK_DATA_STATE_OFFSET(func), SB_DISABLED); for (i = 0; i < XSTORM_SPQ_DATA_SIZE / 4; i++) REG_WR(bp, BAR_XSTRORM_INTMEM + XSTORM_SPQ_DATA_OFFSET(func), 0); /* Configure IGU */ if (bp->common.int_block == INT_BLOCK_HC) { REG_WR(bp, HC_REG_LEADING_EDGE_0 + port*8, 0); REG_WR(bp, HC_REG_TRAILING_EDGE_0 + port*8, 0); } else { REG_WR(bp, IGU_REG_LEADING_EDGE_LATCH, 0); REG_WR(bp, IGU_REG_TRAILING_EDGE_LATCH, 0); } #ifdef BCM_CNIC /* Disable Timer scan */ REG_WR(bp, TM_REG_EN_LINEAR0_TIMER + port*4, 0); /* * Wait for at least 10ms and up to 2 second for the timers scan to * complete */ for (i = 0; i < 200; i++) { msleep(10); if (!REG_RD(bp, TM_REG_LIN0_SCAN_ON + port*4)) break; } #endif /* Clear ILT */ bnx2x_clear_func_ilt(bp, func); /* Timers workaround bug for E2: if this is vnic-3, * we need to set the entire ilt range for this timers. */ if (!CHIP_IS_E1x(bp) && BP_VN(bp) == 3) { struct ilt_client_info ilt_cli; /* use dummy TM client */ memset(&ilt_cli, 0, sizeof(struct ilt_client_info)); ilt_cli.start = 0; ilt_cli.end = ILT_NUM_PAGE_ENTRIES - 1; ilt_cli.client_num = ILT_CLIENT_TM; bnx2x_ilt_boundry_init_op(bp, &ilt_cli, 0, INITOP_CLEAR); } /* this assumes that reset_port() called before reset_func()*/ if (!CHIP_IS_E1x(bp)) bnx2x_pf_disable(bp); bp->dmae_ready = 0; } static void bnx2x_reset_port(struct bnx2x *bp) { int port = BP_PORT(bp); u32 val; /* Reset physical Link */ bnx2x__link_reset(bp); REG_WR(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, 0); /* Do not rcv packets to BRB */ REG_WR(bp, NIG_REG_LLH0_BRB1_DRV_MASK + port*4, 0x0); /* Do not direct rcv packets that are not for MCP to the BRB */ REG_WR(bp, (port ? NIG_REG_LLH1_BRB1_NOT_MCP : NIG_REG_LLH0_BRB1_NOT_MCP), 0x0); /* Configure AEU */ REG_WR(bp, MISC_REG_AEU_MASK_ATTN_FUNC_0 + port*4, 0); msleep(100); /* Check for BRB port occupancy */ val = REG_RD(bp, BRB1_REG_PORT_NUM_OCC_BLOCKS_0 + port*4); if (val) DP(NETIF_MSG_IFDOWN, "BRB1 is not empty %d blocks are occupied\n", val); /* TODO: Close Doorbell port? */ } static inline int bnx2x_reset_hw(struct bnx2x *bp, u32 load_code) { struct bnx2x_func_state_params func_params = {0}; /* Prepare parameters for function state transitions */ __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags); func_params.f_obj = &bp->func_obj; func_params.cmd = BNX2X_F_CMD_HW_RESET; func_params.params.hw_init.load_phase = load_code; return bnx2x_func_state_change(bp, &func_params); } static inline int bnx2x_func_stop(struct bnx2x *bp) { struct bnx2x_func_state_params func_params = {0}; int rc; /* Prepare parameters for function state transitions */ __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags); func_params.f_obj = &bp->func_obj; func_params.cmd = BNX2X_F_CMD_STOP; /* * Try to stop the function the 'good way'. If fails (in case * of a parity error during bnx2x_chip_cleanup()) and we are * not in a debug mode, perform a state transaction in order to * enable further HW_RESET transaction. */ rc = bnx2x_func_state_change(bp, &func_params); if (rc) { #ifdef BNX2X_STOP_ON_ERROR return rc; #else BNX2X_ERR("FUNC_STOP ramrod failed. Running a dry " "transaction\n"); __set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags); return bnx2x_func_state_change(bp, &func_params); #endif } return 0; } /** * bnx2x_send_unload_req - request unload mode from the MCP. * * @bp: driver handle * @unload_mode: requested function's unload mode * * Return unload mode returned by the MCP: COMMON, PORT or FUNC. */ u32 bnx2x_send_unload_req(struct bnx2x *bp, int unload_mode) { u32 reset_code = 0; int port = BP_PORT(bp); /* Select the UNLOAD request mode */ if (unload_mode == UNLOAD_NORMAL) reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS; else if (bp->flags & NO_WOL_FLAG) reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_MCP; else if (bp->wol) { u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; u8 *mac_addr = bp->dev->dev_addr; u32 val; u16 pmc; /* The mac address is written to entries 1-4 to * preserve entry 0 which is used by the PMF */ u8 entry = (BP_VN(bp) + 1)*8; val = (mac_addr[0] << 8) | mac_addr[1]; EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH + entry, val); val = (mac_addr[2] << 24) | (mac_addr[3] << 16) | (mac_addr[4] << 8) | mac_addr[5]; EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH + entry + 4, val); /* Enable the PME and clear the status */ pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, &pmc); pmc |= PCI_PM_CTRL_PME_ENABLE | PCI_PM_CTRL_PME_STATUS; pci_write_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, pmc); reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_EN; } else reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS; /* Send the request to the MCP */ if (!BP_NOMCP(bp)) reset_code = bnx2x_fw_command(bp, reset_code, 0); else { int path = BP_PATH(bp); DP(NETIF_MSG_IFDOWN, "NO MCP - load counts[%d] " "%d, %d, %d\n", path, load_count[path][0], load_count[path][1], load_count[path][2]); load_count[path][0]--; load_count[path][1 + port]--; DP(NETIF_MSG_IFDOWN, "NO MCP - new load counts[%d] " "%d, %d, %d\n", path, load_count[path][0], load_count[path][1], load_count[path][2]); if (load_count[path][0] == 0) reset_code = FW_MSG_CODE_DRV_UNLOAD_COMMON; else if (load_count[path][1 + port] == 0) reset_code = FW_MSG_CODE_DRV_UNLOAD_PORT; else reset_code = FW_MSG_CODE_DRV_UNLOAD_FUNCTION; } return reset_code; } /** * bnx2x_send_unload_done - send UNLOAD_DONE command to the MCP. * * @bp: driver handle */ void bnx2x_send_unload_done(struct bnx2x *bp) { /* Report UNLOAD_DONE to MCP */ if (!BP_NOMCP(bp)) bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_DONE, 0); } static inline int bnx2x_func_wait_started(struct bnx2x *bp) { int tout = 50; int msix = (bp->flags & USING_MSIX_FLAG) ? 1 : 0; if (!bp->port.pmf) return 0; /* * (assumption: No Attention from MCP at this stage) * PMF probably in the middle of TXdisable/enable transaction * 1. Sync IRS for default SB * 2. Sync SP queue - this guarantes us that attention handling started * 3. Wait, that TXdisable/enable transaction completes * * 1+2 guranty that if DCBx attention was scheduled it already changed * pending bit of transaction from STARTED-->TX_STOPPED, if we alredy * received complettion for the transaction the state is TX_STOPPED. * State will return to STARTED after completion of TX_STOPPED-->STARTED * transaction. */ /* make sure default SB ISR is done */ if (msix) synchronize_irq(bp->msix_table[0].vector); else synchronize_irq(bp->pdev->irq); flush_workqueue(bnx2x_wq); while (bnx2x_func_get_state(bp, &bp->func_obj) != BNX2X_F_STATE_STARTED && tout--) msleep(20); if (bnx2x_func_get_state(bp, &bp->func_obj) != BNX2X_F_STATE_STARTED) { #ifdef BNX2X_STOP_ON_ERROR return -EBUSY; #else /* * Failed to complete the transaction in a "good way" * Force both transactions with CLR bit */ struct bnx2x_func_state_params func_params = {0}; DP(BNX2X_MSG_SP, "Hmmm... unexpected function state! " "Forcing STARTED-->TX_ST0PPED-->STARTED\n"); func_params.f_obj = &bp->func_obj; __set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags); /* STARTED-->TX_ST0PPED */ func_params.cmd = BNX2X_F_CMD_TX_STOP; bnx2x_func_state_change(bp, &func_params); /* TX_ST0PPED-->STARTED */ func_params.cmd = BNX2X_F_CMD_TX_START; return bnx2x_func_state_change(bp, &func_params); #endif } return 0; } void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode) { int port = BP_PORT(bp); int i, rc = 0; u8 cos; struct bnx2x_mcast_ramrod_params rparam = {0}; u32 reset_code; /* Wait until tx fastpath tasks complete */ for_each_tx_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; for_each_cos_in_tx_queue(fp, cos) rc = bnx2x_clean_tx_queue(bp, &fp->txdata[cos]); #ifdef BNX2X_STOP_ON_ERROR if (rc) return; #endif } /* Give HW time to discard old tx messages */ usleep_range(1000, 1000); /* Clean all ETH MACs */ rc = bnx2x_del_all_macs(bp, &bp->fp[0].mac_obj, BNX2X_ETH_MAC, false); if (rc < 0) BNX2X_ERR("Failed to delete all ETH macs: %d\n", rc); /* Clean up UC list */ rc = bnx2x_del_all_macs(bp, &bp->fp[0].mac_obj, BNX2X_UC_LIST_MAC, true); if (rc < 0) BNX2X_ERR("Failed to schedule DEL commands for UC MACs list: " "%d\n", rc); /* Disable LLH */ if (!CHIP_IS_E1(bp)) REG_WR(bp, NIG_REG_LLH0_FUNC_EN + port*8, 0); /* Set "drop all" (stop Rx). * We need to take a netif_addr_lock() here in order to prevent * a race between the completion code and this code. */ netif_addr_lock_bh(bp->dev); /* Schedule the rx_mode command */ if (test_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state)) set_bit(BNX2X_FILTER_RX_MODE_SCHED, &bp->sp_state); else bnx2x_set_storm_rx_mode(bp); /* Cleanup multicast configuration */ rparam.mcast_obj = &bp->mcast_obj; rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_DEL); if (rc < 0) BNX2X_ERR("Failed to send DEL multicast command: %d\n", rc); netif_addr_unlock_bh(bp->dev); /* * Send the UNLOAD_REQUEST to the MCP. This will return if * this function should perform FUNC, PORT or COMMON HW * reset. */ reset_code = bnx2x_send_unload_req(bp, unload_mode); /* * (assumption: No Attention from MCP at this stage) * PMF probably in the middle of TXdisable/enable transaction */ rc = bnx2x_func_wait_started(bp); if (rc) { BNX2X_ERR("bnx2x_func_wait_started failed\n"); #ifdef BNX2X_STOP_ON_ERROR return; #endif } /* Close multi and leading connections * Completions for ramrods are collected in a synchronous way */ for_each_queue(bp, i) if (bnx2x_stop_queue(bp, i)) #ifdef BNX2X_STOP_ON_ERROR return; #else goto unload_error; #endif /* If SP settings didn't get completed so far - something * very wrong has happen. */ if (!bnx2x_wait_sp_comp(bp, ~0x0UL)) BNX2X_ERR("Hmmm... Common slow path ramrods got stuck!\n"); #ifndef BNX2X_STOP_ON_ERROR unload_error: #endif rc = bnx2x_func_stop(bp); if (rc) { BNX2X_ERR("Function stop failed!\n"); #ifdef BNX2X_STOP_ON_ERROR return; #endif } /* Disable HW interrupts, NAPI */ bnx2x_netif_stop(bp, 1); /* Release IRQs */ bnx2x_free_irq(bp); /* Reset the chip */ rc = bnx2x_reset_hw(bp, reset_code); if (rc) BNX2X_ERR("HW_RESET failed\n"); /* Report UNLOAD_DONE to MCP */ bnx2x_send_unload_done(bp); } void bnx2x_disable_close_the_gate(struct bnx2x *bp) { u32 val; DP(NETIF_MSG_HW, "Disabling \"close the gates\"\n"); if (CHIP_IS_E1(bp)) { int port = BP_PORT(bp); u32 addr = port ? MISC_REG_AEU_MASK_ATTN_FUNC_1 : MISC_REG_AEU_MASK_ATTN_FUNC_0; val = REG_RD(bp, addr); val &= ~(0x300); REG_WR(bp, addr, val); } else { val = REG_RD(bp, MISC_REG_AEU_GENERAL_MASK); val &= ~(MISC_AEU_GENERAL_MASK_REG_AEU_PXP_CLOSE_MASK | MISC_AEU_GENERAL_MASK_REG_AEU_NIG_CLOSE_MASK); REG_WR(bp, MISC_REG_AEU_GENERAL_MASK, val); } } /* Close gates #2, #3 and #4: */ static void bnx2x_set_234_gates(struct bnx2x *bp, bool close) { u32 val; /* Gates #2 and #4a are closed/opened for "not E1" only */ if (!CHIP_IS_E1(bp)) { /* #4 */ REG_WR(bp, PXP_REG_HST_DISCARD_DOORBELLS, !!close); /* #2 */ REG_WR(bp, PXP_REG_HST_DISCARD_INTERNAL_WRITES, !!close); } /* #3 */ if (CHIP_IS_E1x(bp)) { /* Prevent interrupts from HC on both ports */ val = REG_RD(bp, HC_REG_CONFIG_1); REG_WR(bp, HC_REG_CONFIG_1, (!close) ? (val | HC_CONFIG_1_REG_BLOCK_DISABLE_1) : (val & ~(u32)HC_CONFIG_1_REG_BLOCK_DISABLE_1)); val = REG_RD(bp, HC_REG_CONFIG_0); REG_WR(bp, HC_REG_CONFIG_0, (!close) ? (val | HC_CONFIG_0_REG_BLOCK_DISABLE_0) : (val & ~(u32)HC_CONFIG_0_REG_BLOCK_DISABLE_0)); } else { /* Prevent incomming interrupts in IGU */ val = REG_RD(bp, IGU_REG_BLOCK_CONFIGURATION); REG_WR(bp, IGU_REG_BLOCK_CONFIGURATION, (!close) ? (val | IGU_BLOCK_CONFIGURATION_REG_BLOCK_ENABLE) : (val & ~(u32)IGU_BLOCK_CONFIGURATION_REG_BLOCK_ENABLE)); } DP(NETIF_MSG_HW, "%s gates #2, #3 and #4\n", close ? "closing" : "opening"); mmiowb(); } #define SHARED_MF_CLP_MAGIC 0x80000000 /* `magic' bit */ static void bnx2x_clp_reset_prep(struct bnx2x *bp, u32 *magic_val) { /* Do some magic... */ u32 val = MF_CFG_RD(bp, shared_mf_config.clp_mb); *magic_val = val & SHARED_MF_CLP_MAGIC; MF_CFG_WR(bp, shared_mf_config.clp_mb, val | SHARED_MF_CLP_MAGIC); } /** * bnx2x_clp_reset_done - restore the value of the `magic' bit. * * @bp: driver handle * @magic_val: old value of the `magic' bit. */ static void bnx2x_clp_reset_done(struct bnx2x *bp, u32 magic_val) { /* Restore the `magic' bit value... */ u32 val = MF_CFG_RD(bp, shared_mf_config.clp_mb); MF_CFG_WR(bp, shared_mf_config.clp_mb, (val & (~SHARED_MF_CLP_MAGIC)) | magic_val); } /** * bnx2x_reset_mcp_prep - prepare for MCP reset. * * @bp: driver handle * @magic_val: old value of 'magic' bit. * * Takes care of CLP configurations. */ static void bnx2x_reset_mcp_prep(struct bnx2x *bp, u32 *magic_val) { u32 shmem; u32 validity_offset; DP(NETIF_MSG_HW, "Starting\n"); /* Set `magic' bit in order to save MF config */ if (!CHIP_IS_E1(bp)) bnx2x_clp_reset_prep(bp, magic_val); /* Get shmem offset */ shmem = REG_RD(bp, MISC_REG_SHARED_MEM_ADDR); validity_offset = offsetof(struct shmem_region, validity_map[0]); /* Clear validity map flags */ if (shmem > 0) REG_WR(bp, shmem + validity_offset, 0); } #define MCP_TIMEOUT 5000 /* 5 seconds (in ms) */ #define MCP_ONE_TIMEOUT 100 /* 100 ms */ /** * bnx2x_mcp_wait_one - wait for MCP_ONE_TIMEOUT * * @bp: driver handle */ static inline void bnx2x_mcp_wait_one(struct bnx2x *bp) { /* special handling for emulation and FPGA, wait 10 times longer */ if (CHIP_REV_IS_SLOW(bp)) msleep(MCP_ONE_TIMEOUT*10); else msleep(MCP_ONE_TIMEOUT); } /* * initializes bp->common.shmem_base and waits for validity signature to appear */ static int bnx2x_init_shmem(struct bnx2x *bp) { int cnt = 0; u32 val = 0; do { bp->common.shmem_base = REG_RD(bp, MISC_REG_SHARED_MEM_ADDR); if (bp->common.shmem_base) { val = SHMEM_RD(bp, validity_map[BP_PORT(bp)]); if (val & SHR_MEM_VALIDITY_MB) return 0; } bnx2x_mcp_wait_one(bp); } while (cnt++ < (MCP_TIMEOUT / MCP_ONE_TIMEOUT)); BNX2X_ERR("BAD MCP validity signature\n"); return -ENODEV; } static int bnx2x_reset_mcp_comp(struct bnx2x *bp, u32 magic_val) { int rc = bnx2x_init_shmem(bp); /* Restore the `magic' bit value */ if (!CHIP_IS_E1(bp)) bnx2x_clp_reset_done(bp, magic_val); return rc; } static void bnx2x_pxp_prep(struct bnx2x *bp) { if (!CHIP_IS_E1(bp)) { REG_WR(bp, PXP2_REG_RD_START_INIT, 0); REG_WR(bp, PXP2_REG_RQ_RBC_DONE, 0); mmiowb(); } } /* * Reset the whole chip except for: * - PCIE core * - PCI Glue, PSWHST, PXP/PXP2 RF (all controlled by * one reset bit) * - IGU * - MISC (including AEU) * - GRC * - RBCN, RBCP */ static void bnx2x_process_kill_chip_reset(struct bnx2x *bp, bool global) { u32 not_reset_mask1, reset_mask1, not_reset_mask2, reset_mask2; u32 global_bits2, stay_reset2; /* * Bits that have to be set in reset_mask2 if we want to reset 'global' * (per chip) blocks. */ global_bits2 = MISC_REGISTERS_RESET_REG_2_RST_MCP_N_RESET_CMN_CPU | MISC_REGISTERS_RESET_REG_2_RST_MCP_N_RESET_CMN_CORE; /* Don't reset the following blocks */ not_reset_mask1 = MISC_REGISTERS_RESET_REG_1_RST_HC | MISC_REGISTERS_RESET_REG_1_RST_PXPV | MISC_REGISTERS_RESET_REG_1_RST_PXP; not_reset_mask2 = MISC_REGISTERS_RESET_REG_2_RST_PCI_MDIO | MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE | MISC_REGISTERS_RESET_REG_2_RST_EMAC1_HARD_CORE | MISC_REGISTERS_RESET_REG_2_RST_MISC_CORE | MISC_REGISTERS_RESET_REG_2_RST_RBCN | MISC_REGISTERS_RESET_REG_2_RST_GRC | MISC_REGISTERS_RESET_REG_2_RST_MCP_N_RESET_REG_HARD_CORE | MISC_REGISTERS_RESET_REG_2_RST_MCP_N_HARD_CORE_RST_B | MISC_REGISTERS_RESET_REG_2_RST_ATC | MISC_REGISTERS_RESET_REG_2_PGLC; /* * Keep the following blocks in reset: * - all xxMACs are handled by the bnx2x_link code. */ stay_reset2 = MISC_REGISTERS_RESET_REG_2_RST_BMAC0 | MISC_REGISTERS_RESET_REG_2_RST_BMAC1 | MISC_REGISTERS_RESET_REG_2_RST_EMAC0 | MISC_REGISTERS_RESET_REG_2_RST_EMAC1 | MISC_REGISTERS_RESET_REG_2_UMAC0 | MISC_REGISTERS_RESET_REG_2_UMAC1 | MISC_REGISTERS_RESET_REG_2_XMAC | MISC_REGISTERS_RESET_REG_2_XMAC_SOFT; /* Full reset masks according to the chip */ reset_mask1 = 0xffffffff; if (CHIP_IS_E1(bp)) reset_mask2 = 0xffff; else if (CHIP_IS_E1H(bp)) reset_mask2 = 0x1ffff; else if (CHIP_IS_E2(bp)) reset_mask2 = 0xfffff; else /* CHIP_IS_E3 */ reset_mask2 = 0x3ffffff; /* Don't reset global blocks unless we need to */ if (!global) reset_mask2 &= ~global_bits2; /* * In case of attention in the QM, we need to reset PXP * (MISC_REGISTERS_RESET_REG_2_RST_PXP_RQ_RD_WR) before QM * because otherwise QM reset would release 'close the gates' shortly * before resetting the PXP, then the PSWRQ would send a write * request to PGLUE. Then when PXP is reset, PGLUE would try to * read the payload data from PSWWR, but PSWWR would not * respond. The write queue in PGLUE would stuck, dmae commands * would not return. Therefore it's important to reset the second * reset register (containing the * MISC_REGISTERS_RESET_REG_2_RST_PXP_RQ_RD_WR bit) before the * first one (containing the MISC_REGISTERS_RESET_REG_1_RST_QM * bit). */ REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, reset_mask2 & (~not_reset_mask2)); REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR, reset_mask1 & (~not_reset_mask1)); barrier(); mmiowb(); REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET, reset_mask2 & (~stay_reset2)); barrier(); mmiowb(); REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, reset_mask1); mmiowb(); } /** * bnx2x_er_poll_igu_vq - poll for pending writes bit. * It should get cleared in no more than 1s. * * @bp: driver handle * * It should get cleared in no more than 1s. Returns 0 if * pending writes bit gets cleared. */ static int bnx2x_er_poll_igu_vq(struct bnx2x *bp) { u32 cnt = 1000; u32 pend_bits = 0; do { pend_bits = REG_RD(bp, IGU_REG_PENDING_BITS_STATUS); if (pend_bits == 0) break; usleep_range(1000, 1000); } while (cnt-- > 0); if (cnt <= 0) { BNX2X_ERR("Still pending IGU requests pend_bits=%x!\n", pend_bits); return -EBUSY; } return 0; } static int bnx2x_process_kill(struct bnx2x *bp, bool global) { int cnt = 1000; u32 val = 0; u32 sr_cnt, blk_cnt, port_is_idle_0, port_is_idle_1, pgl_exp_rom2; /* Empty the Tetris buffer, wait for 1s */ do { sr_cnt = REG_RD(bp, PXP2_REG_RD_SR_CNT); blk_cnt = REG_RD(bp, PXP2_REG_RD_BLK_CNT); port_is_idle_0 = REG_RD(bp, PXP2_REG_RD_PORT_IS_IDLE_0); port_is_idle_1 = REG_RD(bp, PXP2_REG_RD_PORT_IS_IDLE_1); pgl_exp_rom2 = REG_RD(bp, PXP2_REG_PGL_EXP_ROM2); if ((sr_cnt == 0x7e) && (blk_cnt == 0xa0) && ((port_is_idle_0 & 0x1) == 0x1) && ((port_is_idle_1 & 0x1) == 0x1) && (pgl_exp_rom2 == 0xffffffff)) break; usleep_range(1000, 1000); } while (cnt-- > 0); if (cnt <= 0) { DP(NETIF_MSG_HW, "Tetris buffer didn't get empty or there" " are still" " outstanding read requests after 1s!\n"); DP(NETIF_MSG_HW, "sr_cnt=0x%08x, blk_cnt=0x%08x," " port_is_idle_0=0x%08x," " port_is_idle_1=0x%08x, pgl_exp_rom2=0x%08x\n", sr_cnt, blk_cnt, port_is_idle_0, port_is_idle_1, pgl_exp_rom2); return -EAGAIN; } barrier(); /* Close gates #2, #3 and #4 */ bnx2x_set_234_gates(bp, true); /* Poll for IGU VQs for 57712 and newer chips */ if (!CHIP_IS_E1x(bp) && bnx2x_er_poll_igu_vq(bp)) return -EAGAIN; /* TBD: Indicate that "process kill" is in progress to MCP */ /* Clear "unprepared" bit */ REG_WR(bp, MISC_REG_UNPREPARED, 0); barrier(); /* Make sure all is written to the chip before the reset */ mmiowb(); /* Wait for 1ms to empty GLUE and PCI-E core queues, * PSWHST, GRC and PSWRD Tetris buffer. */ usleep_range(1000, 1000); /* Prepare to chip reset: */ /* MCP */ if (global) bnx2x_reset_mcp_prep(bp, &val); /* PXP */ bnx2x_pxp_prep(bp); barrier(); /* reset the chip */ bnx2x_process_kill_chip_reset(bp, global); barrier(); /* Recover after reset: */ /* MCP */ if (global && bnx2x_reset_mcp_comp(bp, val)) return -EAGAIN; /* TBD: Add resetting the NO_MCP mode DB here */ /* PXP */ bnx2x_pxp_prep(bp); /* Open the gates #2, #3 and #4 */ bnx2x_set_234_gates(bp, false); /* TBD: IGU/AEU preparation bring back the AEU/IGU to a * reset state, re-enable attentions. */ return 0; } int bnx2x_leader_reset(struct bnx2x *bp) { int rc = 0; bool global = bnx2x_reset_is_global(bp); /* Try to recover after the failure */ if (bnx2x_process_kill(bp, global)) { netdev_err(bp->dev, "Something bad had happen on engine %d! " "Aii!\n", BP_PATH(bp)); rc = -EAGAIN; goto exit_leader_reset; } /* * Clear RESET_IN_PROGRES and RESET_GLOBAL bits and update the driver * state. */ bnx2x_set_reset_done(bp); if (global) bnx2x_clear_reset_global(bp); exit_leader_reset: bp->is_leader = 0; bnx2x_release_leader_lock(bp); smp_mb(); return rc; } static inline void bnx2x_recovery_failed(struct bnx2x *bp) { netdev_err(bp->dev, "Recovery has failed. Power cycle is needed.\n"); /* Disconnect this device */ netif_device_detach(bp->dev); /* * Block ifup for all function on this engine until "process kill" * or power cycle. */ bnx2x_set_reset_in_progress(bp); /* Shut down the power */ bnx2x_set_power_state(bp, PCI_D3hot); bp->recovery_state = BNX2X_RECOVERY_FAILED; smp_mb(); } /* * Assumption: runs under rtnl lock. This together with the fact * that it's called only from bnx2x_sp_rtnl() ensure that it * will never be called when netif_running(bp->dev) is false. */ static void bnx2x_parity_recover(struct bnx2x *bp) { bool global = false; DP(NETIF_MSG_HW, "Handling parity\n"); while (1) { switch (bp->recovery_state) { case BNX2X_RECOVERY_INIT: DP(NETIF_MSG_HW, "State is BNX2X_RECOVERY_INIT\n"); bnx2x_chk_parity_attn(bp, &global, false); /* Try to get a LEADER_LOCK HW lock */ if (bnx2x_trylock_leader_lock(bp)) { bnx2x_set_reset_in_progress(bp); /* * Check if there is a global attention and if * there was a global attention, set the global * reset bit. */ if (global) bnx2x_set_reset_global(bp); bp->is_leader = 1; } /* Stop the driver */ /* If interface has been removed - break */ if (bnx2x_nic_unload(bp, UNLOAD_RECOVERY)) return; bp->recovery_state = BNX2X_RECOVERY_WAIT; /* * Reset MCP command sequence number and MCP mail box * sequence as we are going to reset the MCP. */ if (global) { bp->fw_seq = 0; bp->fw_drv_pulse_wr_seq = 0; } /* Ensure "is_leader", MCP command sequence and * "recovery_state" update values are seen on other * CPUs. */ smp_mb(); break; case BNX2X_RECOVERY_WAIT: DP(NETIF_MSG_HW, "State is BNX2X_RECOVERY_WAIT\n"); if (bp->is_leader) { int other_engine = BP_PATH(bp) ? 0 : 1; u32 other_load_counter = bnx2x_get_load_cnt(bp, other_engine); u32 load_counter = bnx2x_get_load_cnt(bp, BP_PATH(bp)); global = bnx2x_reset_is_global(bp); /* * In case of a parity in a global block, let * the first leader that performs a * leader_reset() reset the global blocks in * order to clear global attentions. Otherwise * the the gates will remain closed for that * engine. */ if (load_counter || (global && other_load_counter)) { /* Wait until all other functions get * down. */ schedule_delayed_work(&bp->sp_rtnl_task, HZ/10); return; } else { /* If all other functions got down - * try to bring the chip back to * normal. In any case it's an exit * point for a leader. */ if (bnx2x_leader_reset(bp)) { bnx2x_recovery_failed(bp); return; } /* If we are here, means that the * leader has succeeded and doesn't * want to be a leader any more. Try * to continue as a none-leader. */ break; } } else { /* non-leader */ if (!bnx2x_reset_is_done(bp, BP_PATH(bp))) { /* Try to get a LEADER_LOCK HW lock as * long as a former leader may have * been unloaded by the user or * released a leadership by another * reason. */ if (bnx2x_trylock_leader_lock(bp)) { /* I'm a leader now! Restart a * switch case. */ bp->is_leader = 1; break; } schedule_delayed_work(&bp->sp_rtnl_task, HZ/10); return; } else { /* * If there was a global attention, wait * for it to be cleared. */ if (bnx2x_reset_is_global(bp)) { schedule_delayed_work( &bp->sp_rtnl_task, HZ/10); return; } if (bnx2x_nic_load(bp, LOAD_NORMAL)) bnx2x_recovery_failed(bp); else { bp->recovery_state = BNX2X_RECOVERY_DONE; smp_mb(); } return; } } default: return; } } } /* bnx2x_nic_unload() flushes the bnx2x_wq, thus reset task is * scheduled on a general queue in order to prevent a dead lock. */ static void bnx2x_sp_rtnl_task(struct work_struct *work) { struct bnx2x *bp = container_of(work, struct bnx2x, sp_rtnl_task.work); rtnl_lock(); if (!netif_running(bp->dev)) goto sp_rtnl_exit; /* if stop on error is defined no recovery flows should be executed */ #ifdef BNX2X_STOP_ON_ERROR BNX2X_ERR("recovery flow called but STOP_ON_ERROR defined " "so reset not done to allow debug dump,\n" "you will need to reboot when done\n"); goto sp_rtnl_not_reset; #endif if (unlikely(bp->recovery_state != BNX2X_RECOVERY_DONE)) { /* * Clear all pending SP commands as we are going to reset the * function anyway. */ bp->sp_rtnl_state = 0; smp_mb(); bnx2x_parity_recover(bp); goto sp_rtnl_exit; } if (test_and_clear_bit(BNX2X_SP_RTNL_TX_TIMEOUT, &bp->sp_rtnl_state)) { /* * Clear all pending SP commands as we are going to reset the * function anyway. */ bp->sp_rtnl_state = 0; smp_mb(); bnx2x_nic_unload(bp, UNLOAD_NORMAL); bnx2x_nic_load(bp, LOAD_NORMAL); goto sp_rtnl_exit; } #ifdef BNX2X_STOP_ON_ERROR sp_rtnl_not_reset: #endif if (test_and_clear_bit(BNX2X_SP_RTNL_SETUP_TC, &bp->sp_rtnl_state)) bnx2x_setup_tc(bp->dev, bp->dcbx_port_params.ets.num_of_cos); sp_rtnl_exit: rtnl_unlock(); } /* end of nic load/unload */ static void bnx2x_period_task(struct work_struct *work) { struct bnx2x *bp = container_of(work, struct bnx2x, period_task.work); if (!netif_running(bp->dev)) goto period_task_exit; if (CHIP_REV_IS_SLOW(bp)) { BNX2X_ERR("period task called on emulation, ignoring\n"); goto period_task_exit; } bnx2x_acquire_phy_lock(bp); /* * The barrier is needed to ensure the ordering between the writing to * the bp->port.pmf in the bnx2x_nic_load() or bnx2x_pmf_update() and * the reading here. */ smp_mb(); if (bp->port.pmf) { bnx2x_period_func(&bp->link_params, &bp->link_vars); /* Re-queue task in 1 sec */ queue_delayed_work(bnx2x_wq, &bp->period_task, 1*HZ); } bnx2x_release_phy_lock(bp); period_task_exit: return; } /* * Init service functions */ static u32 bnx2x_get_pretend_reg(struct bnx2x *bp) { u32 base = PXP2_REG_PGL_PRETEND_FUNC_F0; u32 stride = PXP2_REG_PGL_PRETEND_FUNC_F1 - base; return base + (BP_ABS_FUNC(bp)) * stride; } static void bnx2x_undi_int_disable_e1h(struct bnx2x *bp) { u32 reg = bnx2x_get_pretend_reg(bp); /* Flush all outstanding writes */ mmiowb(); /* Pretend to be function 0 */ REG_WR(bp, reg, 0); REG_RD(bp, reg); /* Flush the GRC transaction (in the chip) */ /* From now we are in the "like-E1" mode */ bnx2x_int_disable(bp); /* Flush all outstanding writes */ mmiowb(); /* Restore the original function */ REG_WR(bp, reg, BP_ABS_FUNC(bp)); REG_RD(bp, reg); } static inline void bnx2x_undi_int_disable(struct bnx2x *bp) { if (CHIP_IS_E1(bp)) bnx2x_int_disable(bp); else bnx2x_undi_int_disable_e1h(bp); } static void __devinit bnx2x_undi_unload(struct bnx2x *bp) { u32 val; /* Check if there is any driver already loaded */ val = REG_RD(bp, MISC_REG_UNPREPARED); if (val == 0x1) { bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RESET); /* * Check if it is the UNDI driver * UNDI driver initializes CID offset for normal bell to 0x7 */ val = REG_RD(bp, DORQ_REG_NORM_CID_OFST); if (val == 0x7) { u32 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS; /* save our pf_num */ int orig_pf_num = bp->pf_num; int port; u32 swap_en, swap_val, value; /* clear the UNDI indication */ REG_WR(bp, DORQ_REG_NORM_CID_OFST, 0); BNX2X_DEV_INFO("UNDI is active! reset device\n"); /* try unload UNDI on port 0 */ bp->pf_num = 0; bp->fw_seq = (SHMEM_RD(bp, func_mb[bp->pf_num].drv_mb_header) & DRV_MSG_SEQ_NUMBER_MASK); reset_code = bnx2x_fw_command(bp, reset_code, 0); /* if UNDI is loaded on the other port */ if (reset_code != FW_MSG_CODE_DRV_UNLOAD_COMMON) { /* send "DONE" for previous unload */ bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_DONE, 0); /* unload UNDI on port 1 */ bp->pf_num = 1; bp->fw_seq = (SHMEM_RD(bp, func_mb[bp->pf_num].drv_mb_header) & DRV_MSG_SEQ_NUMBER_MASK); reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS; bnx2x_fw_command(bp, reset_code, 0); } bnx2x_undi_int_disable(bp); port = BP_PORT(bp); /* close input traffic and wait for it */ /* Do not rcv packets to BRB */ REG_WR(bp, (port ? NIG_REG_LLH1_BRB1_DRV_MASK : NIG_REG_LLH0_BRB1_DRV_MASK), 0x0); /* Do not direct rcv packets that are not for MCP to * the BRB */ REG_WR(bp, (port ? NIG_REG_LLH1_BRB1_NOT_MCP : NIG_REG_LLH0_BRB1_NOT_MCP), 0x0); /* clear AEU */ REG_WR(bp, (port ? MISC_REG_AEU_MASK_ATTN_FUNC_1 : MISC_REG_AEU_MASK_ATTN_FUNC_0), 0); msleep(10); /* save NIG port swap info */ swap_val = REG_RD(bp, NIG_REG_PORT_SWAP); swap_en = REG_RD(bp, NIG_REG_STRAP_OVERRIDE); /* reset device */ REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_CLEAR, 0xd3ffffff); value = 0x1400; if (CHIP_IS_E3(bp)) { value |= MISC_REGISTERS_RESET_REG_2_MSTAT0; value |= MISC_REGISTERS_RESET_REG_2_MSTAT1; } REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, value); /* take the NIG out of reset and restore swap values */ REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET, MISC_REGISTERS_RESET_REG_1_RST_NIG); REG_WR(bp, NIG_REG_PORT_SWAP, swap_val); REG_WR(bp, NIG_REG_STRAP_OVERRIDE, swap_en); /* send unload done to the MCP */ bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_DONE, 0); /* restore our func and fw_seq */ bp->pf_num = orig_pf_num; bp->fw_seq = (SHMEM_RD(bp, func_mb[bp->pf_num].drv_mb_header) & DRV_MSG_SEQ_NUMBER_MASK); } /* now it's safe to release the lock */ bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RESET); } } static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp) { u32 val, val2, val3, val4, id; u16 pmc; /* Get the chip revision id and number. */ /* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */ val = REG_RD(bp, MISC_REG_CHIP_NUM); id = ((val & 0xffff) << 16); val = REG_RD(bp, MISC_REG_CHIP_REV); id |= ((val & 0xf) << 12); val = REG_RD(bp, MISC_REG_CHIP_METAL); id |= ((val & 0xff) << 4); val = REG_RD(bp, MISC_REG_BOND_ID); id |= (val & 0xf); bp->common.chip_id = id; /* Set doorbell size */ bp->db_size = (1 << BNX2X_DB_SHIFT); if (!CHIP_IS_E1x(bp)) { val = REG_RD(bp, MISC_REG_PORT4MODE_EN_OVWR); if ((val & 1) == 0) val = REG_RD(bp, MISC_REG_PORT4MODE_EN); else val = (val >> 1) & 1; BNX2X_DEV_INFO("chip is in %s\n", val ? "4_PORT_MODE" : "2_PORT_MODE"); bp->common.chip_port_mode = val ? CHIP_4_PORT_MODE : CHIP_2_PORT_MODE; if (CHIP_MODE_IS_4_PORT(bp)) bp->pfid = (bp->pf_num >> 1); /* 0..3 */ else bp->pfid = (bp->pf_num & 0x6); /* 0, 2, 4, 6 */ } else { bp->common.chip_port_mode = CHIP_PORT_MODE_NONE; /* N/A */ bp->pfid = bp->pf_num; /* 0..7 */ } bp->link_params.chip_id = bp->common.chip_id; BNX2X_DEV_INFO("chip ID is 0x%x\n", id); val = (REG_RD(bp, 0x2874) & 0x55); if ((bp->common.chip_id & 0x1) || (CHIP_IS_E1(bp) && val) || (CHIP_IS_E1H(bp) && (val == 0x55))) { bp->flags |= ONE_PORT_FLAG; BNX2X_DEV_INFO("single port device\n"); } val = REG_RD(bp, MCP_REG_MCPR_NVM_CFG4); bp->common.flash_size = (BNX2X_NVRAM_1MB_SIZE << (val & MCPR_NVM_CFG4_FLASH_SIZE)); BNX2X_DEV_INFO("flash_size 0x%x (%d)\n", bp->common.flash_size, bp->common.flash_size); bnx2x_init_shmem(bp); bp->common.shmem2_base = REG_RD(bp, (BP_PATH(bp) ? MISC_REG_GENERIC_CR_1 : MISC_REG_GENERIC_CR_0)); bp->link_params.shmem_base = bp->common.shmem_base; bp->link_params.shmem2_base = bp->common.shmem2_base; BNX2X_DEV_INFO("shmem offset 0x%x shmem2 offset 0x%x\n", bp->common.shmem_base, bp->common.shmem2_base); if (!bp->common.shmem_base) { BNX2X_DEV_INFO("MCP not active\n"); bp->flags |= NO_MCP_FLAG; return; } bp->common.hw_config = SHMEM_RD(bp, dev_info.shared_hw_config.config); BNX2X_DEV_INFO("hw_config 0x%08x\n", bp->common.hw_config); bp->link_params.hw_led_mode = ((bp->common.hw_config & SHARED_HW_CFG_LED_MODE_MASK) >> SHARED_HW_CFG_LED_MODE_SHIFT); bp->link_params.feature_config_flags = 0; val = SHMEM_RD(bp, dev_info.shared_feature_config.config); if (val & SHARED_FEAT_CFG_OVERRIDE_PREEMPHASIS_CFG_ENABLED) bp->link_params.feature_config_flags |= FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED; else bp->link_params.feature_config_flags &= ~FEATURE_CONFIG_OVERRIDE_PREEMPHASIS_ENABLED; val = SHMEM_RD(bp, dev_info.bc_rev) >> 8; bp->common.bc_ver = val; BNX2X_DEV_INFO("bc_ver %X\n", val); if (val < BNX2X_BC_VER) { /* for now only warn * later we might need to enforce this */ BNX2X_ERR("This driver needs bc_ver %X but found %X, " "please upgrade BC\n", BNX2X_BC_VER, val); } bp->link_params.feature_config_flags |= (val >= REQ_BC_VER_4_VRFY_FIRST_PHY_OPT_MDL) ? FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY : 0; bp->link_params.feature_config_flags |= (val >= REQ_BC_VER_4_VRFY_SPECIFIC_PHY_OPT_MDL) ? FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY : 0; bp->link_params.feature_config_flags |= (val >= REQ_BC_VER_4_SFP_TX_DISABLE_SUPPORTED) ? FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED : 0; pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_PMC, &pmc); bp->flags |= (pmc & PCI_PM_CAP_PME_D3cold) ? 0 : NO_WOL_FLAG; BNX2X_DEV_INFO("%sWoL capable\n", (bp->flags & NO_WOL_FLAG) ? "not " : ""); val = SHMEM_RD(bp, dev_info.shared_hw_config.part_num); val2 = SHMEM_RD(bp, dev_info.shared_hw_config.part_num[4]); val3 = SHMEM_RD(bp, dev_info.shared_hw_config.part_num[8]); val4 = SHMEM_RD(bp, dev_info.shared_hw_config.part_num[12]); dev_info(&bp->pdev->dev, "part number %X-%X-%X-%X\n", val, val2, val3, val4); } #define IGU_FID(val) GET_FIELD((val), IGU_REG_MAPPING_MEMORY_FID) #define IGU_VEC(val) GET_FIELD((val), IGU_REG_MAPPING_MEMORY_VECTOR) static void __devinit bnx2x_get_igu_cam_info(struct bnx2x *bp) { int pfid = BP_FUNC(bp); int igu_sb_id; u32 val; u8 fid, igu_sb_cnt = 0; bp->igu_base_sb = 0xff; if (CHIP_INT_MODE_IS_BC(bp)) { int vn = BP_VN(bp); igu_sb_cnt = bp->igu_sb_cnt; bp->igu_base_sb = (CHIP_MODE_IS_4_PORT(bp) ? pfid : vn) * FP_SB_MAX_E1x; bp->igu_dsb_id = E1HVN_MAX * FP_SB_MAX_E1x + (CHIP_MODE_IS_4_PORT(bp) ? pfid : vn); return; } /* IGU in normal mode - read CAM */ for (igu_sb_id = 0; igu_sb_id < IGU_REG_MAPPING_MEMORY_SIZE; igu_sb_id++) { val = REG_RD(bp, IGU_REG_MAPPING_MEMORY + igu_sb_id * 4); if (!(val & IGU_REG_MAPPING_MEMORY_VALID)) continue; fid = IGU_FID(val); if ((fid & IGU_FID_ENCODE_IS_PF)) { if ((fid & IGU_FID_PF_NUM_MASK) != pfid) continue; if (IGU_VEC(val) == 0) /* default status block */ bp->igu_dsb_id = igu_sb_id; else { if (bp->igu_base_sb == 0xff) bp->igu_base_sb = igu_sb_id; igu_sb_cnt++; } } } #ifdef CONFIG_PCI_MSI /* * It's expected that number of CAM entries for this functions is equal * to the number evaluated based on the MSI-X table size. We want a * harsh warning if these values are different! */ WARN_ON(bp->igu_sb_cnt != igu_sb_cnt); #endif if (igu_sb_cnt == 0) BNX2X_ERR("CAM configuration error\n"); } static void __devinit bnx2x_link_settings_supported(struct bnx2x *bp, u32 switch_cfg) { int cfg_size = 0, idx, port = BP_PORT(bp); /* Aggregation of supported attributes of all external phys */ bp->port.supported[0] = 0; bp->port.supported[1] = 0; switch (bp->link_params.num_phys) { case 1: bp->port.supported[0] = bp->link_params.phy[INT_PHY].supported; cfg_size = 1; break; case 2: bp->port.supported[0] = bp->link_params.phy[EXT_PHY1].supported; cfg_size = 1; break; case 3: if (bp->link_params.multi_phy_config & PORT_HW_CFG_PHY_SWAPPED_ENABLED) { bp->port.supported[1] = bp->link_params.phy[EXT_PHY1].supported; bp->port.supported[0] = bp->link_params.phy[EXT_PHY2].supported; } else { bp->port.supported[0] = bp->link_params.phy[EXT_PHY1].supported; bp->port.supported[1] = bp->link_params.phy[EXT_PHY2].supported; } cfg_size = 2; break; } if (!(bp->port.supported[0] || bp->port.supported[1])) { BNX2X_ERR("NVRAM config error. BAD phy config." "PHY1 config 0x%x, PHY2 config 0x%x\n", SHMEM_RD(bp, dev_info.port_hw_config[port].external_phy_config), SHMEM_RD(bp, dev_info.port_hw_config[port].external_phy_config2)); return; } if (CHIP_IS_E3(bp)) bp->port.phy_addr = REG_RD(bp, MISC_REG_WC0_CTRL_PHY_ADDR); else { switch (switch_cfg) { case SWITCH_CFG_1G: bp->port.phy_addr = REG_RD( bp, NIG_REG_SERDES0_CTRL_PHY_ADDR + port*0x10); break; case SWITCH_CFG_10G: bp->port.phy_addr = REG_RD( bp, NIG_REG_XGXS0_CTRL_PHY_ADDR + port*0x18); break; default: BNX2X_ERR("BAD switch_cfg link_config 0x%x\n", bp->port.link_config[0]); return; } } BNX2X_DEV_INFO("phy_addr 0x%x\n", bp->port.phy_addr); /* mask what we support according to speed_cap_mask per configuration */ for (idx = 0; idx < cfg_size; idx++) { if (!(bp->link_params.speed_cap_mask[idx] & PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)) bp->port.supported[idx] &= ~SUPPORTED_10baseT_Half; if (!(bp->link_params.speed_cap_mask[idx] & PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL)) bp->port.supported[idx] &= ~SUPPORTED_10baseT_Full; if (!(bp->link_params.speed_cap_mask[idx] & PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)) bp->port.supported[idx] &= ~SUPPORTED_100baseT_Half; if (!(bp->link_params.speed_cap_mask[idx] & PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL)) bp->port.supported[idx] &= ~SUPPORTED_100baseT_Full; if (!(bp->link_params.speed_cap_mask[idx] & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) bp->port.supported[idx] &= ~(SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full); if (!(bp->link_params.speed_cap_mask[idx] & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G)) bp->port.supported[idx] &= ~SUPPORTED_2500baseX_Full; if (!(bp->link_params.speed_cap_mask[idx] & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) bp->port.supported[idx] &= ~SUPPORTED_10000baseT_Full; } BNX2X_DEV_INFO("supported 0x%x 0x%x\n", bp->port.supported[0], bp->port.supported[1]); } static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) { u32 link_config, idx, cfg_size = 0; bp->port.advertising[0] = 0; bp->port.advertising[1] = 0; switch (bp->link_params.num_phys) { case 1: case 2: cfg_size = 1; break; case 3: cfg_size = 2; break; } for (idx = 0; idx < cfg_size; idx++) { bp->link_params.req_duplex[idx] = DUPLEX_FULL; link_config = bp->port.link_config[idx]; switch (link_config & PORT_FEATURE_LINK_SPEED_MASK) { case PORT_FEATURE_LINK_SPEED_AUTO: if (bp->port.supported[idx] & SUPPORTED_Autoneg) { bp->link_params.req_line_speed[idx] = SPEED_AUTO_NEG; bp->port.advertising[idx] |= bp->port.supported[idx]; } else { /* force 10G, no AN */ bp->link_params.req_line_speed[idx] = SPEED_10000; bp->port.advertising[idx] |= (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE); continue; } break; case PORT_FEATURE_LINK_SPEED_10M_FULL: if (bp->port.supported[idx] & SUPPORTED_10baseT_Full) { bp->link_params.req_line_speed[idx] = SPEED_10; bp->port.advertising[idx] |= (ADVERTISED_10baseT_Full | ADVERTISED_TP); } else { BNX2X_ERR("NVRAM config error. " "Invalid link_config 0x%x" " speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; } break; case PORT_FEATURE_LINK_SPEED_10M_HALF: if (bp->port.supported[idx] & SUPPORTED_10baseT_Half) { bp->link_params.req_line_speed[idx] = SPEED_10; bp->link_params.req_duplex[idx] = DUPLEX_HALF; bp->port.advertising[idx] |= (ADVERTISED_10baseT_Half | ADVERTISED_TP); } else { BNX2X_ERR("NVRAM config error. " "Invalid link_config 0x%x" " speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; } break; case PORT_FEATURE_LINK_SPEED_100M_FULL: if (bp->port.supported[idx] & SUPPORTED_100baseT_Full) { bp->link_params.req_line_speed[idx] = SPEED_100; bp->port.advertising[idx] |= (ADVERTISED_100baseT_Full | ADVERTISED_TP); } else { BNX2X_ERR("NVRAM config error. " "Invalid link_config 0x%x" " speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; } break; case PORT_FEATURE_LINK_SPEED_100M_HALF: if (bp->port.supported[idx] & SUPPORTED_100baseT_Half) { bp->link_params.req_line_speed[idx] = SPEED_100; bp->link_params.req_duplex[idx] = DUPLEX_HALF; bp->port.advertising[idx] |= (ADVERTISED_100baseT_Half | ADVERTISED_TP); } else { BNX2X_ERR("NVRAM config error. " "Invalid link_config 0x%x" " speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; } break; case PORT_FEATURE_LINK_SPEED_1G: if (bp->port.supported[idx] & SUPPORTED_1000baseT_Full) { bp->link_params.req_line_speed[idx] = SPEED_1000; bp->port.advertising[idx] |= (ADVERTISED_1000baseT_Full | ADVERTISED_TP); } else { BNX2X_ERR("NVRAM config error. " "Invalid link_config 0x%x" " speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; } break; case PORT_FEATURE_LINK_SPEED_2_5G: if (bp->port.supported[idx] & SUPPORTED_2500baseX_Full) { bp->link_params.req_line_speed[idx] = SPEED_2500; bp->port.advertising[idx] |= (ADVERTISED_2500baseX_Full | ADVERTISED_TP); } else { BNX2X_ERR("NVRAM config error. " "Invalid link_config 0x%x" " speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; } break; case PORT_FEATURE_LINK_SPEED_10G_CX4: if (bp->port.supported[idx] & SUPPORTED_10000baseT_Full) { bp->link_params.req_line_speed[idx] = SPEED_10000; bp->port.advertising[idx] |= (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE); } else { BNX2X_ERR("NVRAM config error. " "Invalid link_config 0x%x" " speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; } break; case PORT_FEATURE_LINK_SPEED_20G: bp->link_params.req_line_speed[idx] = SPEED_20000; break; default: BNX2X_ERR("NVRAM config error. " "BAD link speed link_config 0x%x\n", link_config); bp->link_params.req_line_speed[idx] = SPEED_AUTO_NEG; bp->port.advertising[idx] = bp->port.supported[idx]; break; } bp->link_params.req_flow_ctrl[idx] = (link_config & PORT_FEATURE_FLOW_CONTROL_MASK); if ((bp->link_params.req_flow_ctrl[idx] == BNX2X_FLOW_CTRL_AUTO) && !(bp->port.supported[idx] & SUPPORTED_Autoneg)) { bp->link_params.req_flow_ctrl[idx] = BNX2X_FLOW_CTRL_NONE; } BNX2X_DEV_INFO("req_line_speed %d req_duplex %d req_flow_ctrl" " 0x%x advertising 0x%x\n", bp->link_params.req_line_speed[idx], bp->link_params.req_duplex[idx], bp->link_params.req_flow_ctrl[idx], bp->port.advertising[idx]); } } static void __devinit bnx2x_set_mac_buf(u8 *mac_buf, u32 mac_lo, u16 mac_hi) { mac_hi = cpu_to_be16(mac_hi); mac_lo = cpu_to_be32(mac_lo); memcpy(mac_buf, &mac_hi, sizeof(mac_hi)); memcpy(mac_buf + sizeof(mac_hi), &mac_lo, sizeof(mac_lo)); } static void __devinit bnx2x_get_port_hwinfo(struct bnx2x *bp) { int port = BP_PORT(bp); u32 config; u32 ext_phy_type, ext_phy_config; bp->link_params.bp = bp; bp->link_params.port = port; bp->link_params.lane_config = SHMEM_RD(bp, dev_info.port_hw_config[port].lane_config); bp->link_params.speed_cap_mask[0] = SHMEM_RD(bp, dev_info.port_hw_config[port].speed_capability_mask); bp->link_params.speed_cap_mask[1] = SHMEM_RD(bp, dev_info.port_hw_config[port].speed_capability_mask2); bp->port.link_config[0] = SHMEM_RD(bp, dev_info.port_feature_config[port].link_config); bp->port.link_config[1] = SHMEM_RD(bp, dev_info.port_feature_config[port].link_config2); bp->link_params.multi_phy_config = SHMEM_RD(bp, dev_info.port_hw_config[port].multi_phy_config); /* If the device is capable of WoL, set the default state according * to the HW */ config = SHMEM_RD(bp, dev_info.port_feature_config[port].config); bp->wol = (!(bp->flags & NO_WOL_FLAG) && (config & PORT_FEATURE_WOL_ENABLED)); BNX2X_DEV_INFO("lane_config 0x%08x " "speed_cap_mask0 0x%08x link_config0 0x%08x\n", bp->link_params.lane_config, bp->link_params.speed_cap_mask[0], bp->port.link_config[0]); bp->link_params.switch_cfg = (bp->port.link_config[0] & PORT_FEATURE_CONNECTED_SWITCH_MASK); bnx2x_phy_probe(&bp->link_params); bnx2x_link_settings_supported(bp, bp->link_params.switch_cfg); bnx2x_link_settings_requested(bp); /* * If connected directly, work with the internal PHY, otherwise, work * with the external PHY */ ext_phy_config = SHMEM_RD(bp, dev_info.port_hw_config[port].external_phy_config); ext_phy_type = XGXS_EXT_PHY_TYPE(ext_phy_config); if (ext_phy_type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) bp->mdio.prtad = bp->port.phy_addr; else if ((ext_phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE) && (ext_phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN)) bp->mdio.prtad = XGXS_EXT_PHY_ADDR(ext_phy_config); /* * Check if hw lock is required to access MDC/MDIO bus to the PHY(s) * In MF mode, it is set to cover self test cases */ if (IS_MF(bp)) bp->port.need_hw_lock = 1; else bp->port.need_hw_lock = bnx2x_hw_lock_required(bp, bp->common.shmem_base, bp->common.shmem2_base); } #ifdef BCM_CNIC static void __devinit bnx2x_get_cnic_info(struct bnx2x *bp) { int port = BP_PORT(bp); int func = BP_ABS_FUNC(bp); u32 max_iscsi_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, drv_lic_key[port].max_iscsi_conn); u32 max_fcoe_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, drv_lic_key[port].max_fcoe_conn); /* Get the number of maximum allowed iSCSI and FCoE connections */ bp->cnic_eth_dev.max_iscsi_conn = (max_iscsi_conn & BNX2X_MAX_ISCSI_INIT_CONN_MASK) >> BNX2X_MAX_ISCSI_INIT_CONN_SHIFT; bp->cnic_eth_dev.max_fcoe_conn = (max_fcoe_conn & BNX2X_MAX_FCOE_INIT_CONN_MASK) >> BNX2X_MAX_FCOE_INIT_CONN_SHIFT; /* Read the WWN: */ if (!IS_MF(bp)) { /* Port info */ bp->cnic_eth_dev.fcoe_wwn_port_name_hi = SHMEM_RD(bp, dev_info.port_hw_config[port]. fcoe_wwn_port_name_upper); bp->cnic_eth_dev.fcoe_wwn_port_name_lo = SHMEM_RD(bp, dev_info.port_hw_config[port]. fcoe_wwn_port_name_lower); /* Node info */ bp->cnic_eth_dev.fcoe_wwn_node_name_hi = SHMEM_RD(bp, dev_info.port_hw_config[port]. fcoe_wwn_node_name_upper); bp->cnic_eth_dev.fcoe_wwn_node_name_lo = SHMEM_RD(bp, dev_info.port_hw_config[port]. fcoe_wwn_node_name_lower); } else if (!IS_MF_SD(bp)) { u32 cfg = MF_CFG_RD(bp, func_ext_config[func].func_cfg); /* * Read the WWN info only if the FCoE feature is enabled for * this function. */ if (cfg & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD) { /* Port info */ bp->cnic_eth_dev.fcoe_wwn_port_name_hi = MF_CFG_RD(bp, func_ext_config[func]. fcoe_wwn_port_name_upper); bp->cnic_eth_dev.fcoe_wwn_port_name_lo = MF_CFG_RD(bp, func_ext_config[func]. fcoe_wwn_port_name_lower); /* Node info */ bp->cnic_eth_dev.fcoe_wwn_node_name_hi = MF_CFG_RD(bp, func_ext_config[func]. fcoe_wwn_node_name_upper); bp->cnic_eth_dev.fcoe_wwn_node_name_lo = MF_CFG_RD(bp, func_ext_config[func]. fcoe_wwn_node_name_lower); } } BNX2X_DEV_INFO("max_iscsi_conn 0x%x max_fcoe_conn 0x%x\n", bp->cnic_eth_dev.max_iscsi_conn, bp->cnic_eth_dev.max_fcoe_conn); /* * If maximum allowed number of connections is zero - * disable the feature. */ if (!bp->cnic_eth_dev.max_iscsi_conn) bp->flags |= NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG; if (!bp->cnic_eth_dev.max_fcoe_conn) bp->flags |= NO_FCOE_FLAG; } #endif static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) { u32 val, val2; int func = BP_ABS_FUNC(bp); int port = BP_PORT(bp); #ifdef BCM_CNIC u8 *iscsi_mac = bp->cnic_eth_dev.iscsi_mac; u8 *fip_mac = bp->fip_mac; #endif /* Zero primary MAC configuration */ memset(bp->dev->dev_addr, 0, ETH_ALEN); if (BP_NOMCP(bp)) { BNX2X_ERROR("warning: random MAC workaround active\n"); random_ether_addr(bp->dev->dev_addr); } else if (IS_MF(bp)) { val2 = MF_CFG_RD(bp, func_mf_config[func].mac_upper); val = MF_CFG_RD(bp, func_mf_config[func].mac_lower); if ((val2 != FUNC_MF_CFG_UPPERMAC_DEFAULT) && (val != FUNC_MF_CFG_LOWERMAC_DEFAULT)) bnx2x_set_mac_buf(bp->dev->dev_addr, val, val2); #ifdef BCM_CNIC /* iSCSI and FCoE NPAR MACs: if there is no either iSCSI or * FCoE MAC then the appropriate feature should be disabled. */ if (IS_MF_SI(bp)) { u32 cfg = MF_CFG_RD(bp, func_ext_config[func].func_cfg); if (cfg & MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD) { val2 = MF_CFG_RD(bp, func_ext_config[func]. iscsi_mac_addr_upper); val = MF_CFG_RD(bp, func_ext_config[func]. iscsi_mac_addr_lower); bnx2x_set_mac_buf(iscsi_mac, val, val2); BNX2X_DEV_INFO("Read iSCSI MAC: " BNX2X_MAC_FMT"\n", BNX2X_MAC_PRN_LIST(iscsi_mac)); } else bp->flags |= NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG; if (cfg & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD) { val2 = MF_CFG_RD(bp, func_ext_config[func]. fcoe_mac_addr_upper); val = MF_CFG_RD(bp, func_ext_config[func]. fcoe_mac_addr_lower); bnx2x_set_mac_buf(fip_mac, val, val2); BNX2X_DEV_INFO("Read FCoE L2 MAC to " BNX2X_MAC_FMT"\n", BNX2X_MAC_PRN_LIST(fip_mac)); } else bp->flags |= NO_FCOE_FLAG; } #endif } else { /* in SF read MACs from port configuration */ val2 = SHMEM_RD(bp, dev_info.port_hw_config[port].mac_upper); val = SHMEM_RD(bp, dev_info.port_hw_config[port].mac_lower); bnx2x_set_mac_buf(bp->dev->dev_addr, val, val2); #ifdef BCM_CNIC val2 = SHMEM_RD(bp, dev_info.port_hw_config[port]. iscsi_mac_upper); val = SHMEM_RD(bp, dev_info.port_hw_config[port]. iscsi_mac_lower); bnx2x_set_mac_buf(iscsi_mac, val, val2); val2 = SHMEM_RD(bp, dev_info.port_hw_config[port]. fcoe_fip_mac_upper); val = SHMEM_RD(bp, dev_info.port_hw_config[port]. fcoe_fip_mac_lower); bnx2x_set_mac_buf(fip_mac, val, val2); #endif } memcpy(bp->link_params.mac_addr, bp->dev->dev_addr, ETH_ALEN); memcpy(bp->dev->perm_addr, bp->dev->dev_addr, ETH_ALEN); #ifdef BCM_CNIC /* Set the FCoE MAC in MF_SD mode */ if (!CHIP_IS_E1x(bp) && IS_MF_SD(bp)) memcpy(fip_mac, bp->dev->dev_addr, ETH_ALEN); /* Disable iSCSI if MAC configuration is * invalid. */ if (!is_valid_ether_addr(iscsi_mac)) { bp->flags |= NO_ISCSI_FLAG; memset(iscsi_mac, 0, ETH_ALEN); } /* Disable FCoE if MAC configuration is * invalid. */ if (!is_valid_ether_addr(fip_mac)) { bp->flags |= NO_FCOE_FLAG; memset(bp->fip_mac, 0, ETH_ALEN); } #endif if (!is_valid_ether_addr(bp->dev->dev_addr)) dev_err(&bp->pdev->dev, "bad Ethernet MAC address configuration: " BNX2X_MAC_FMT", change it manually before bringing up " "the appropriate network interface\n", BNX2X_MAC_PRN_LIST(bp->dev->dev_addr)); } static int __devinit bnx2x_get_hwinfo(struct bnx2x *bp) { int /*abs*/func = BP_ABS_FUNC(bp); int vn; u32 val = 0; int rc = 0; bnx2x_get_common_hwinfo(bp); /* * initialize IGU parameters */ if (CHIP_IS_E1x(bp)) { bp->common.int_block = INT_BLOCK_HC; bp->igu_dsb_id = DEF_SB_IGU_ID; bp->igu_base_sb = 0; } else { bp->common.int_block = INT_BLOCK_IGU; /* do not allow device reset during IGU info preocessing */ bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RESET); val = REG_RD(bp, IGU_REG_BLOCK_CONFIGURATION); if (val & IGU_BLOCK_CONFIGURATION_REG_BACKWARD_COMP_EN) { int tout = 5000; BNX2X_DEV_INFO("FORCING Normal Mode\n"); val &= ~(IGU_BLOCK_CONFIGURATION_REG_BACKWARD_COMP_EN); REG_WR(bp, IGU_REG_BLOCK_CONFIGURATION, val); REG_WR(bp, IGU_REG_RESET_MEMORIES, 0x7f); while (tout && REG_RD(bp, IGU_REG_RESET_MEMORIES)) { tout--; usleep_range(1000, 1000); } if (REG_RD(bp, IGU_REG_RESET_MEMORIES)) { dev_err(&bp->pdev->dev, "FORCING Normal Mode failed!!!\n"); return -EPERM; } } if (val & IGU_BLOCK_CONFIGURATION_REG_BACKWARD_COMP_EN) { BNX2X_DEV_INFO("IGU Backward Compatible Mode\n"); bp->common.int_block |= INT_BLOCK_MODE_BW_COMP; } else BNX2X_DEV_INFO("IGU Normal Mode\n"); bnx2x_get_igu_cam_info(bp); bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RESET); } /* * set base FW non-default (fast path) status block id, this value is * used to initialize the fw_sb_id saved on the fp/queue structure to * determine the id used by the FW. */ if (CHIP_IS_E1x(bp)) bp->base_fw_ndsb = BP_PORT(bp) * FP_SB_MAX_E1x + BP_L_ID(bp); else /* * 57712 - we currently use one FW SB per IGU SB (Rx and Tx of * the same queue are indicated on the same IGU SB). So we prefer * FW and IGU SBs to be the same value. */ bp->base_fw_ndsb = bp->igu_base_sb; BNX2X_DEV_INFO("igu_dsb_id %d igu_base_sb %d igu_sb_cnt %d\n" "base_fw_ndsb %d\n", bp->igu_dsb_id, bp->igu_base_sb, bp->igu_sb_cnt, bp->base_fw_ndsb); /* * Initialize MF configuration */ bp->mf_ov = 0; bp->mf_mode = 0; vn = BP_VN(bp); if (!CHIP_IS_E1(bp) && !BP_NOMCP(bp)) { BNX2X_DEV_INFO("shmem2base 0x%x, size %d, mfcfg offset %d\n", bp->common.shmem2_base, SHMEM2_RD(bp, size), (u32)offsetof(struct shmem2_region, mf_cfg_addr)); if (SHMEM2_HAS(bp, mf_cfg_addr)) bp->common.mf_cfg_base = SHMEM2_RD(bp, mf_cfg_addr); else bp->common.mf_cfg_base = bp->common.shmem_base + offsetof(struct shmem_region, func_mb) + E1H_FUNC_MAX * sizeof(struct drv_func_mb); /* * get mf configuration: * 1. existence of MF configuration * 2. MAC address must be legal (check only upper bytes) * for Switch-Independent mode; * OVLAN must be legal for Switch-Dependent mode * 3. SF_MODE configures specific MF mode */ if (bp->common.mf_cfg_base != SHMEM_MF_CFG_ADDR_NONE) { /* get mf configuration */ val = SHMEM_RD(bp, dev_info.shared_feature_config.config); val &= SHARED_FEAT_CFG_FORCE_SF_MODE_MASK; switch (val) { case SHARED_FEAT_CFG_FORCE_SF_MODE_SWITCH_INDEPT: val = MF_CFG_RD(bp, func_mf_config[func]. mac_upper); /* check for legal mac (upper bytes)*/ if (val != 0xffff) { bp->mf_mode = MULTI_FUNCTION_SI; bp->mf_config[vn] = MF_CFG_RD(bp, func_mf_config[func].config); } else BNX2X_DEV_INFO("illegal MAC address " "for SI\n"); break; case SHARED_FEAT_CFG_FORCE_SF_MODE_MF_ALLOWED: /* get OV configuration */ val = MF_CFG_RD(bp, func_mf_config[FUNC_0].e1hov_tag); val &= FUNC_MF_CFG_E1HOV_TAG_MASK; if (val != FUNC_MF_CFG_E1HOV_TAG_DEFAULT) { bp->mf_mode = MULTI_FUNCTION_SD; bp->mf_config[vn] = MF_CFG_RD(bp, func_mf_config[func].config); } else BNX2X_DEV_INFO("illegal OV for SD\n"); break; default: /* Unknown configuration: reset mf_config */ bp->mf_config[vn] = 0; BNX2X_DEV_INFO("unkown MF mode 0x%x\n", val); } } BNX2X_DEV_INFO("%s function mode\n", IS_MF(bp) ? "multi" : "single"); switch (bp->mf_mode) { case MULTI_FUNCTION_SD: val = MF_CFG_RD(bp, func_mf_config[func].e1hov_tag) & FUNC_MF_CFG_E1HOV_TAG_MASK; if (val != FUNC_MF_CFG_E1HOV_TAG_DEFAULT) { bp->mf_ov = val; bp->path_has_ovlan = true; BNX2X_DEV_INFO("MF OV for func %d is %d " "(0x%04x)\n", func, bp->mf_ov, bp->mf_ov); } else { dev_err(&bp->pdev->dev, "No valid MF OV for func %d, " "aborting\n", func); return -EPERM; } break; case MULTI_FUNCTION_SI: BNX2X_DEV_INFO("func %d is in MF " "switch-independent mode\n", func); break; default: if (vn) { dev_err(&bp->pdev->dev, "VN %d is in a single function mode, " "aborting\n", vn); return -EPERM; } break; } /* check if other port on the path needs ovlan: * Since MF configuration is shared between ports * Possible mixed modes are only * {SF, SI} {SF, SD} {SD, SF} {SI, SF} */ if (CHIP_MODE_IS_4_PORT(bp) && !bp->path_has_ovlan && !IS_MF(bp) && bp->common.mf_cfg_base != SHMEM_MF_CFG_ADDR_NONE) { u8 other_port = !BP_PORT(bp); u8 other_func = BP_PATH(bp) + 2*other_port; val = MF_CFG_RD(bp, func_mf_config[other_func].e1hov_tag); if (val != FUNC_MF_CFG_E1HOV_TAG_DEFAULT) bp->path_has_ovlan = true; } } /* adjust igu_sb_cnt to MF for E1x */ if (CHIP_IS_E1x(bp) && IS_MF(bp)) bp->igu_sb_cnt /= E1HVN_MAX; /* port info */ bnx2x_get_port_hwinfo(bp); /* Get MAC addresses */ bnx2x_get_mac_hwinfo(bp); #ifdef BCM_CNIC bnx2x_get_cnic_info(bp); #endif /* Get current FW pulse sequence */ if (!BP_NOMCP(bp)) { int mb_idx = BP_FW_MB_IDX(bp); bp->fw_drv_pulse_wr_seq = (SHMEM_RD(bp, func_mb[mb_idx].drv_pulse_mb) & DRV_PULSE_SEQ_MASK); BNX2X_DEV_INFO("drv_pulse 0x%x\n", bp->fw_drv_pulse_wr_seq); } return rc; } static void __devinit bnx2x_read_fwinfo(struct bnx2x *bp) { int cnt, i, block_end, rodi; char vpd_data[BNX2X_VPD_LEN+1]; char str_id_reg[VENDOR_ID_LEN+1]; char str_id_cap[VENDOR_ID_LEN+1]; u8 len; cnt = pci_read_vpd(bp->pdev, 0, BNX2X_VPD_LEN, vpd_data); memset(bp->fw_ver, 0, sizeof(bp->fw_ver)); if (cnt < BNX2X_VPD_LEN) goto out_not_found; i = pci_vpd_find_tag(vpd_data, 0, BNX2X_VPD_LEN, PCI_VPD_LRDT_RO_DATA); if (i < 0) goto out_not_found; block_end = i + PCI_VPD_LRDT_TAG_SIZE + pci_vpd_lrdt_size(&vpd_data[i]); i += PCI_VPD_LRDT_TAG_SIZE; if (block_end > BNX2X_VPD_LEN) goto out_not_found; rodi = pci_vpd_find_info_keyword(vpd_data, i, block_end, PCI_VPD_RO_KEYWORD_MFR_ID); if (rodi < 0) goto out_not_found; len = pci_vpd_info_field_size(&vpd_data[rodi]); if (len != VENDOR_ID_LEN) goto out_not_found; rodi += PCI_VPD_INFO_FLD_HDR_SIZE; /* vendor specific info */ snprintf(str_id_reg, VENDOR_ID_LEN + 1, "%04x", PCI_VENDOR_ID_DELL); snprintf(str_id_cap, VENDOR_ID_LEN + 1, "%04X", PCI_VENDOR_ID_DELL); if (!strncmp(str_id_reg, &vpd_data[rodi], VENDOR_ID_LEN) || !strncmp(str_id_cap, &vpd_data[rodi], VENDOR_ID_LEN)) { rodi = pci_vpd_find_info_keyword(vpd_data, i, block_end, PCI_VPD_RO_KEYWORD_VENDOR0); if (rodi >= 0) { len = pci_vpd_info_field_size(&vpd_data[rodi]); rodi += PCI_VPD_INFO_FLD_HDR_SIZE; if (len < 32 && (len + rodi) <= BNX2X_VPD_LEN) { memcpy(bp->fw_ver, &vpd_data[rodi], len); bp->fw_ver[len] = ' '; } } return; } out_not_found: return; } static void __devinit bnx2x_set_modes_bitmap(struct bnx2x *bp) { u32 flags = 0; if (CHIP_REV_IS_FPGA(bp)) SET_FLAGS(flags, MODE_FPGA); else if (CHIP_REV_IS_EMUL(bp)) SET_FLAGS(flags, MODE_EMUL); else SET_FLAGS(flags, MODE_ASIC); if (CHIP_MODE_IS_4_PORT(bp)) SET_FLAGS(flags, MODE_PORT4); else SET_FLAGS(flags, MODE_PORT2); if (CHIP_IS_E2(bp)) SET_FLAGS(flags, MODE_E2); else if (CHIP_IS_E3(bp)) { SET_FLAGS(flags, MODE_E3); if (CHIP_REV(bp) == CHIP_REV_Ax) SET_FLAGS(flags, MODE_E3_A0); else /*if (CHIP_REV(bp) == CHIP_REV_Bx)*/ SET_FLAGS(flags, MODE_E3_B0 | MODE_COS3); } if (IS_MF(bp)) { SET_FLAGS(flags, MODE_MF); switch (bp->mf_mode) { case MULTI_FUNCTION_SD: SET_FLAGS(flags, MODE_MF_SD); break; case MULTI_FUNCTION_SI: SET_FLAGS(flags, MODE_MF_SI); break; } } else SET_FLAGS(flags, MODE_SF); #if defined(__LITTLE_ENDIAN) SET_FLAGS(flags, MODE_LITTLE_ENDIAN); #else /*(__BIG_ENDIAN)*/ SET_FLAGS(flags, MODE_BIG_ENDIAN); #endif INIT_MODE_FLAGS(bp) = flags; } static int __devinit bnx2x_init_bp(struct bnx2x *bp) { int func; int timer_interval; int rc; mutex_init(&bp->port.phy_mutex); mutex_init(&bp->fw_mb_mutex); spin_lock_init(&bp->stats_lock); #ifdef BCM_CNIC mutex_init(&bp->cnic_mutex); #endif INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task); INIT_DELAYED_WORK(&bp->sp_rtnl_task, bnx2x_sp_rtnl_task); INIT_DELAYED_WORK(&bp->period_task, bnx2x_period_task); rc = bnx2x_get_hwinfo(bp); if (rc) return rc; bnx2x_set_modes_bitmap(bp); rc = bnx2x_alloc_mem_bp(bp); if (rc) return rc; bnx2x_read_fwinfo(bp); func = BP_FUNC(bp); /* need to reset chip if undi was active */ if (!BP_NOMCP(bp)) bnx2x_undi_unload(bp); /* init fw_seq after undi_unload! */ if (!BP_NOMCP(bp)) { bp->fw_seq = (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) & DRV_MSG_SEQ_NUMBER_MASK); BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq); } if (CHIP_REV_IS_FPGA(bp)) dev_err(&bp->pdev->dev, "FPGA detected\n"); if (BP_NOMCP(bp) && (func == 0)) dev_err(&bp->pdev->dev, "MCP disabled, " "must load devices in order!\n"); bp->multi_mode = multi_mode; /* Set TPA flags */ if (disable_tpa) { bp->flags &= ~TPA_ENABLE_FLAG; bp->dev->features &= ~NETIF_F_LRO; } else { bp->flags |= TPA_ENABLE_FLAG; bp->dev->features |= NETIF_F_LRO; } bp->disable_tpa = disable_tpa; if (CHIP_IS_E1(bp)) bp->dropless_fc = 0; else bp->dropless_fc = dropless_fc; bp->mrrs = mrrs; bp->tx_ring_size = MAX_TX_AVAIL; /* make sure that the numbers are in the right granularity */ bp->tx_ticks = (50 / BNX2X_BTR) * BNX2X_BTR; bp->rx_ticks = (25 / BNX2X_BTR) * BNX2X_BTR; timer_interval = (CHIP_REV_IS_SLOW(bp) ? 5*HZ : HZ); bp->current_interval = (poll ? poll : timer_interval); init_timer(&bp->timer); bp->timer.expires = jiffies + bp->current_interval; bp->timer.data = (unsigned long) bp; bp->timer.function = bnx2x_timer; bnx2x_dcbx_set_state(bp, true, BNX2X_DCBX_ENABLED_ON_NEG_ON); bnx2x_dcbx_init_params(bp); #ifdef BCM_CNIC if (CHIP_IS_E1x(bp)) bp->cnic_base_cl_id = FP_SB_MAX_E1x; else bp->cnic_base_cl_id = FP_SB_MAX_E2; #endif /* multiple tx priority */ if (CHIP_IS_E1x(bp)) bp->max_cos = BNX2X_MULTI_TX_COS_E1X; if (CHIP_IS_E2(bp) || CHIP_IS_E3A0(bp)) bp->max_cos = BNX2X_MULTI_TX_COS_E2_E3A0; if (CHIP_IS_E3B0(bp)) bp->max_cos = BNX2X_MULTI_TX_COS_E3B0; return rc; } /**************************************************************************** * General service functions ****************************************************************************/ /* * net_device service functions */ /* called with rtnl_lock */ static int bnx2x_open(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); bool global = false; int other_engine = BP_PATH(bp) ? 0 : 1; u32 other_load_counter, load_counter; netif_carrier_off(dev); bnx2x_set_power_state(bp, PCI_D0); other_load_counter = bnx2x_get_load_cnt(bp, other_engine); load_counter = bnx2x_get_load_cnt(bp, BP_PATH(bp)); /* * If parity had happen during the unload, then attentions * and/or RECOVERY_IN_PROGRES may still be set. In this case we * want the first function loaded on the current engine to * complete the recovery. */ if (!bnx2x_reset_is_done(bp, BP_PATH(bp)) || bnx2x_chk_parity_attn(bp, &global, true)) do { /* * If there are attentions and they are in a global * blocks, set the GLOBAL_RESET bit regardless whether * it will be this function that will complete the * recovery or not. */ if (global) bnx2x_set_reset_global(bp); /* * Only the first function on the current engine should * try to recover in open. In case of attentions in * global blocks only the first in the chip should try * to recover. */ if ((!load_counter && (!global || !other_load_counter)) && bnx2x_trylock_leader_lock(bp) && !bnx2x_leader_reset(bp)) { netdev_info(bp->dev, "Recovered in open\n"); break; } /* recovery has failed... */ bnx2x_set_power_state(bp, PCI_D3hot); bp->recovery_state = BNX2X_RECOVERY_FAILED; netdev_err(bp->dev, "Recovery flow hasn't been properly" " completed yet. Try again later. If u still see this" " message after a few retries then power cycle is" " required.\n"); return -EAGAIN; } while (0); bp->recovery_state = BNX2X_RECOVERY_DONE; return bnx2x_nic_load(bp, LOAD_OPEN); } /* called with rtnl_lock */ static int bnx2x_close(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); /* Unload the driver, release IRQs */ bnx2x_nic_unload(bp, UNLOAD_CLOSE); /* Power off */ bnx2x_set_power_state(bp, PCI_D3hot); return 0; } static inline int bnx2x_init_mcast_macs_list(struct bnx2x *bp, struct bnx2x_mcast_ramrod_params *p) { int mc_count = netdev_mc_count(bp->dev); struct bnx2x_mcast_list_elem *mc_mac = kzalloc(sizeof(*mc_mac) * mc_count, GFP_ATOMIC); struct netdev_hw_addr *ha; if (!mc_mac) return -ENOMEM; INIT_LIST_HEAD(&p->mcast_list); netdev_for_each_mc_addr(ha, bp->dev) { mc_mac->mac = bnx2x_mc_addr(ha); list_add_tail(&mc_mac->link, &p->mcast_list); mc_mac++; } p->mcast_list_len = mc_count; return 0; } static inline void bnx2x_free_mcast_macs_list( struct bnx2x_mcast_ramrod_params *p) { struct bnx2x_mcast_list_elem *mc_mac = list_first_entry(&p->mcast_list, struct bnx2x_mcast_list_elem, link); WARN_ON(!mc_mac); kfree(mc_mac); } /** * bnx2x_set_uc_list - configure a new unicast MACs list. * * @bp: driver handle * * We will use zero (0) as a MAC type for these MACs. */ static inline int bnx2x_set_uc_list(struct bnx2x *bp) { int rc; struct net_device *dev = bp->dev; struct netdev_hw_addr *ha; struct bnx2x_vlan_mac_obj *mac_obj = &bp->fp->mac_obj; unsigned long ramrod_flags = 0; /* First schedule a cleanup up of old configuration */ rc = bnx2x_del_all_macs(bp, mac_obj, BNX2X_UC_LIST_MAC, false); if (rc < 0) { BNX2X_ERR("Failed to schedule DELETE operations: %d\n", rc); return rc; } netdev_for_each_uc_addr(ha, dev) { rc = bnx2x_set_mac_one(bp, bnx2x_uc_addr(ha), mac_obj, true, BNX2X_UC_LIST_MAC, &ramrod_flags); if (rc < 0) { BNX2X_ERR("Failed to schedule ADD operations: %d\n", rc); return rc; } } /* Execute the pending commands */ __set_bit(RAMROD_CONT, &ramrod_flags); return bnx2x_set_mac_one(bp, NULL, mac_obj, false /* don't care */, BNX2X_UC_LIST_MAC, &ramrod_flags); } static inline int bnx2x_set_mc_list(struct bnx2x *bp) { struct net_device *dev = bp->dev; struct bnx2x_mcast_ramrod_params rparam = {0}; int rc = 0; rparam.mcast_obj = &bp->mcast_obj; /* first, clear all configured multicast MACs */ rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_DEL); if (rc < 0) { BNX2X_ERR("Failed to clear multicast " "configuration: %d\n", rc); return rc; } /* then, configure a new MACs list */ if (netdev_mc_count(dev)) { rc = bnx2x_init_mcast_macs_list(bp, &rparam); if (rc) { BNX2X_ERR("Failed to create multicast MACs " "list: %d\n", rc); return rc; } /* Now add the new MACs */ rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_ADD); if (rc < 0) BNX2X_ERR("Failed to set a new multicast " "configuration: %d\n", rc); bnx2x_free_mcast_macs_list(&rparam); } return rc; } /* If bp->state is OPEN, should be called with netif_addr_lock_bh() */ void bnx2x_set_rx_mode(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); u32 rx_mode = BNX2X_RX_MODE_NORMAL; if (bp->state != BNX2X_STATE_OPEN) { DP(NETIF_MSG_IFUP, "state is %x, returning\n", bp->state); return; } DP(NETIF_MSG_IFUP, "dev->flags = %x\n", bp->dev->flags); if (dev->flags & IFF_PROMISC) rx_mode = BNX2X_RX_MODE_PROMISC; else if ((dev->flags & IFF_ALLMULTI) || ((netdev_mc_count(dev) > BNX2X_MAX_MULTICAST) && CHIP_IS_E1(bp))) rx_mode = BNX2X_RX_MODE_ALLMULTI; else { /* some multicasts */ if (bnx2x_set_mc_list(bp) < 0) rx_mode = BNX2X_RX_MODE_ALLMULTI; if (bnx2x_set_uc_list(bp) < 0) rx_mode = BNX2X_RX_MODE_PROMISC; } bp->rx_mode = rx_mode; /* Schedule the rx_mode command */ if (test_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state)) { set_bit(BNX2X_FILTER_RX_MODE_SCHED, &bp->sp_state); return; } bnx2x_set_storm_rx_mode(bp); } /* called with rtnl_lock */ static int bnx2x_mdio_read(struct net_device *netdev, int prtad, int devad, u16 addr) { struct bnx2x *bp = netdev_priv(netdev); u16 value; int rc; DP(NETIF_MSG_LINK, "mdio_read: prtad 0x%x, devad 0x%x, addr 0x%x\n", prtad, devad, addr); /* The HW expects different devad if CL22 is used */ devad = (devad == MDIO_DEVAD_NONE) ? DEFAULT_PHY_DEV_ADDR : devad; bnx2x_acquire_phy_lock(bp); rc = bnx2x_phy_read(&bp->link_params, prtad, devad, addr, &value); bnx2x_release_phy_lock(bp); DP(NETIF_MSG_LINK, "mdio_read_val 0x%x rc = 0x%x\n", value, rc); if (!rc) rc = value; return rc; } /* called with rtnl_lock */ static int bnx2x_mdio_write(struct net_device *netdev, int prtad, int devad, u16 addr, u16 value) { struct bnx2x *bp = netdev_priv(netdev); int rc; DP(NETIF_MSG_LINK, "mdio_write: prtad 0x%x, devad 0x%x, addr 0x%x," " value 0x%x\n", prtad, devad, addr, value); /* The HW expects different devad if CL22 is used */ devad = (devad == MDIO_DEVAD_NONE) ? DEFAULT_PHY_DEV_ADDR : devad; bnx2x_acquire_phy_lock(bp); rc = bnx2x_phy_write(&bp->link_params, prtad, devad, addr, value); bnx2x_release_phy_lock(bp); return rc; } /* called with rtnl_lock */ static int bnx2x_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { struct bnx2x *bp = netdev_priv(dev); struct mii_ioctl_data *mdio = if_mii(ifr); DP(NETIF_MSG_LINK, "ioctl: phy id 0x%x, reg 0x%x, val_in 0x%x\n", mdio->phy_id, mdio->reg_num, mdio->val_in); if (!netif_running(dev)) return -EAGAIN; return mdio_mii_ioctl(&bp->mdio, mdio, cmd); } #ifdef CONFIG_NET_POLL_CONTROLLER static void poll_bnx2x(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); disable_irq(bp->pdev->irq); bnx2x_interrupt(bp->pdev->irq, dev); enable_irq(bp->pdev->irq); } #endif static const struct net_device_ops bnx2x_netdev_ops = { .ndo_open = bnx2x_open, .ndo_stop = bnx2x_close, .ndo_start_xmit = bnx2x_start_xmit, .ndo_select_queue = bnx2x_select_queue, .ndo_set_rx_mode = bnx2x_set_rx_mode, .ndo_set_mac_address = bnx2x_change_mac_addr, .ndo_validate_addr = eth_validate_addr, .ndo_do_ioctl = bnx2x_ioctl, .ndo_change_mtu = bnx2x_change_mtu, .ndo_fix_features = bnx2x_fix_features, .ndo_set_features = bnx2x_set_features, .ndo_tx_timeout = bnx2x_tx_timeout, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = poll_bnx2x, #endif .ndo_setup_tc = bnx2x_setup_tc, #if defined(NETDEV_FCOE_WWNN) && defined(BCM_CNIC) .ndo_fcoe_get_wwn = bnx2x_fcoe_get_wwn, #endif }; static inline int bnx2x_set_coherency_mask(struct bnx2x *bp) { struct device *dev = &bp->pdev->dev; if (dma_set_mask(dev, DMA_BIT_MASK(64)) == 0) { bp->flags |= USING_DAC_FLAG; if (dma_set_coherent_mask(dev, DMA_BIT_MASK(64)) != 0) { dev_err(dev, "dma_set_coherent_mask failed, " "aborting\n"); return -EIO; } } else if (dma_set_mask(dev, DMA_BIT_MASK(32)) != 0) { dev_err(dev, "System does not support DMA, aborting\n"); return -EIO; } return 0; } static int __devinit bnx2x_init_dev(struct pci_dev *pdev, struct net_device *dev, unsigned long board_type) { struct bnx2x *bp; int rc; SET_NETDEV_DEV(dev, &pdev->dev); bp = netdev_priv(dev); bp->dev = dev; bp->pdev = pdev; bp->flags = 0; bp->pf_num = PCI_FUNC(pdev->devfn); rc = pci_enable_device(pdev); if (rc) { dev_err(&bp->pdev->dev, "Cannot enable PCI device, aborting\n"); goto err_out; } if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { dev_err(&bp->pdev->dev, "Cannot find PCI device base address, aborting\n"); rc = -ENODEV; goto err_out_disable; } if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) { dev_err(&bp->pdev->dev, "Cannot find second PCI device" " base address, aborting\n"); rc = -ENODEV; goto err_out_disable; } if (atomic_read(&pdev->enable_cnt) == 1) { rc = pci_request_regions(pdev, DRV_MODULE_NAME); if (rc) { dev_err(&bp->pdev->dev, "Cannot obtain PCI resources, aborting\n"); goto err_out_disable; } pci_set_master(pdev); pci_save_state(pdev); } bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); if (bp->pm_cap == 0) { dev_err(&bp->pdev->dev, "Cannot find power management capability, aborting\n"); rc = -EIO; goto err_out_release; } if (!pci_is_pcie(pdev)) { dev_err(&bp->pdev->dev, "Not PCI Express, aborting\n"); rc = -EIO; goto err_out_release; } rc = bnx2x_set_coherency_mask(bp); if (rc) goto err_out_release; dev->mem_start = pci_resource_start(pdev, 0); dev->base_addr = dev->mem_start; dev->mem_end = pci_resource_end(pdev, 0); dev->irq = pdev->irq; bp->regview = pci_ioremap_bar(pdev, 0); if (!bp->regview) { dev_err(&bp->pdev->dev, "Cannot map register space, aborting\n"); rc = -ENOMEM; goto err_out_release; } bnx2x_set_power_state(bp, PCI_D0); /* clean indirect addresses */ pci_write_config_dword(bp->pdev, PCICFG_GRC_ADDRESS, PCICFG_VENDOR_ID_OFFSET); /* * Clean the following indirect addresses for all functions since it * is not used by the driver. */ REG_WR(bp, PXP2_REG_PGL_ADDR_88_F0, 0); REG_WR(bp, PXP2_REG_PGL_ADDR_8C_F0, 0); REG_WR(bp, PXP2_REG_PGL_ADDR_90_F0, 0); REG_WR(bp, PXP2_REG_PGL_ADDR_94_F0, 0); if (CHIP_IS_E1x(bp)) { REG_WR(bp, PXP2_REG_PGL_ADDR_88_F1, 0); REG_WR(bp, PXP2_REG_PGL_ADDR_8C_F1, 0); REG_WR(bp, PXP2_REG_PGL_ADDR_90_F1, 0); REG_WR(bp, PXP2_REG_PGL_ADDR_94_F1, 0); } /* * Enable internal target-read (in case we are probed after PF FLR). * Must be done prior to any BAR read access. Only for 57712 and up */ if (board_type != BCM57710 && board_type != BCM57711 && board_type != BCM57711E) REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1); /* Reset the load counter */ bnx2x_clear_load_cnt(bp); dev->watchdog_timeo = TX_TIMEOUT; dev->netdev_ops = &bnx2x_netdev_ops; bnx2x_set_ethtool_ops(dev); dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_RXCSUM | NETIF_F_LRO | NETIF_F_HW_VLAN_TX; dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_HIGHDMA; dev->features |= dev->hw_features | NETIF_F_HW_VLAN_RX; if (bp->flags & USING_DAC_FLAG) dev->features |= NETIF_F_HIGHDMA; /* Add Loopback capability to the device */ dev->hw_features |= NETIF_F_LOOPBACK; #ifdef BCM_DCBNL dev->dcbnl_ops = &bnx2x_dcbnl_ops; #endif /* get_port_hwinfo() will set prtad and mmds properly */ bp->mdio.prtad = MDIO_PRTAD_NONE; bp->mdio.mmds = 0; bp->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; bp->mdio.dev = dev; bp->mdio.mdio_read = bnx2x_mdio_read; bp->mdio.mdio_write = bnx2x_mdio_write; return 0; err_out_release: if (atomic_read(&pdev->enable_cnt) == 1) pci_release_regions(pdev); err_out_disable: pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); err_out: return rc; } static void __devinit bnx2x_get_pcie_width_speed(struct bnx2x *bp, int *width, int *speed) { u32 val = REG_RD(bp, PCICFG_OFFSET + PCICFG_LINK_CONTROL); *width = (val & PCICFG_LINK_WIDTH) >> PCICFG_LINK_WIDTH_SHIFT; /* return value of 1=2.5GHz 2=5GHz */ *speed = (val & PCICFG_LINK_SPEED) >> PCICFG_LINK_SPEED_SHIFT; } static int bnx2x_check_firmware(struct bnx2x *bp) { const struct firmware *firmware = bp->firmware; struct bnx2x_fw_file_hdr *fw_hdr; struct bnx2x_fw_file_section *sections; u32 offset, len, num_ops; u16 *ops_offsets; int i; const u8 *fw_ver; if (firmware->size < sizeof(struct bnx2x_fw_file_hdr)) return -EINVAL; fw_hdr = (struct bnx2x_fw_file_hdr *)firmware->data; sections = (struct bnx2x_fw_file_section *)fw_hdr; /* Make sure none of the offsets and sizes make us read beyond * the end of the firmware data */ for (i = 0; i < sizeof(*fw_hdr) / sizeof(*sections); i++) { offset = be32_to_cpu(sections[i].offset); len = be32_to_cpu(sections[i].len); if (offset + len > firmware->size) { dev_err(&bp->pdev->dev, "Section %d length is out of bounds\n", i); return -EINVAL; } } /* Likewise for the init_ops offsets */ offset = be32_to_cpu(fw_hdr->init_ops_offsets.offset); ops_offsets = (u16 *)(firmware->data + offset); num_ops = be32_to_cpu(fw_hdr->init_ops.len) / sizeof(struct raw_op); for (i = 0; i < be32_to_cpu(fw_hdr->init_ops_offsets.len) / 2; i++) { if (be16_to_cpu(ops_offsets[i]) > num_ops) { dev_err(&bp->pdev->dev, "Section offset %d is out of bounds\n", i); return -EINVAL; } } /* Check FW version */ offset = be32_to_cpu(fw_hdr->fw_version.offset); fw_ver = firmware->data + offset; if ((fw_ver[0] != BCM_5710_FW_MAJOR_VERSION) || (fw_ver[1] != BCM_5710_FW_MINOR_VERSION) || (fw_ver[2] != BCM_5710_FW_REVISION_VERSION) || (fw_ver[3] != BCM_5710_FW_ENGINEERING_VERSION)) { dev_err(&bp->pdev->dev, "Bad FW version:%d.%d.%d.%d. Should be %d.%d.%d.%d\n", fw_ver[0], fw_ver[1], fw_ver[2], fw_ver[3], BCM_5710_FW_MAJOR_VERSION, BCM_5710_FW_MINOR_VERSION, BCM_5710_FW_REVISION_VERSION, BCM_5710_FW_ENGINEERING_VERSION); return -EINVAL; } return 0; } static inline void be32_to_cpu_n(const u8 *_source, u8 *_target, u32 n) { const __be32 *source = (const __be32 *)_source; u32 *target = (u32 *)_target; u32 i; for (i = 0; i < n/4; i++) target[i] = be32_to_cpu(source[i]); } /* Ops array is stored in the following format: {op(8bit), offset(24bit, big endian), data(32bit, big endian)} */ static inline void bnx2x_prep_ops(const u8 *_source, u8 *_target, u32 n) { const __be32 *source = (const __be32 *)_source; struct raw_op *target = (struct raw_op *)_target; u32 i, j, tmp; for (i = 0, j = 0; i < n/8; i++, j += 2) { tmp = be32_to_cpu(source[j]); target[i].op = (tmp >> 24) & 0xff; target[i].offset = tmp & 0xffffff; target[i].raw_data = be32_to_cpu(source[j + 1]); } } /** * IRO array is stored in the following format: * {base(24bit), m1(16bit), m2(16bit), m3(16bit), size(16bit) } */ static inline void bnx2x_prep_iro(const u8 *_source, u8 *_target, u32 n) { const __be32 *source = (const __be32 *)_source; struct iro *target = (struct iro *)_target; u32 i, j, tmp; for (i = 0, j = 0; i < n/sizeof(struct iro); i++) { target[i].base = be32_to_cpu(source[j]); j++; tmp = be32_to_cpu(source[j]); target[i].m1 = (tmp >> 16) & 0xffff; target[i].m2 = tmp & 0xffff; j++; tmp = be32_to_cpu(source[j]); target[i].m3 = (tmp >> 16) & 0xffff; target[i].size = tmp & 0xffff; j++; } } static inline void be16_to_cpu_n(const u8 *_source, u8 *_target, u32 n) { const __be16 *source = (const __be16 *)_source; u16 *target = (u16 *)_target; u32 i; for (i = 0; i < n/2; i++) target[i] = be16_to_cpu(source[i]); } #define BNX2X_ALLOC_AND_SET(arr, lbl, func) \ do { \ u32 len = be32_to_cpu(fw_hdr->arr.len); \ bp->arr = kmalloc(len, GFP_KERNEL); \ if (!bp->arr) { \ pr_err("Failed to allocate %d bytes for "#arr"\n", len); \ goto lbl; \ } \ func(bp->firmware->data + be32_to_cpu(fw_hdr->arr.offset), \ (u8 *)bp->arr, len); \ } while (0) int bnx2x_init_firmware(struct bnx2x *bp) { const char *fw_file_name; struct bnx2x_fw_file_hdr *fw_hdr; int rc; if (CHIP_IS_E1(bp)) fw_file_name = FW_FILE_NAME_E1; else if (CHIP_IS_E1H(bp)) fw_file_name = FW_FILE_NAME_E1H; else if (!CHIP_IS_E1x(bp)) fw_file_name = FW_FILE_NAME_E2; else { BNX2X_ERR("Unsupported chip revision\n"); return -EINVAL; } BNX2X_DEV_INFO("Loading %s\n", fw_file_name); rc = request_firmware(&bp->firmware, fw_file_name, &bp->pdev->dev); if (rc) { BNX2X_ERR("Can't load firmware file %s\n", fw_file_name); goto request_firmware_exit; } rc = bnx2x_check_firmware(bp); if (rc) { BNX2X_ERR("Corrupt firmware file %s\n", fw_file_name); goto request_firmware_exit; } fw_hdr = (struct bnx2x_fw_file_hdr *)bp->firmware->data; /* Initialize the pointers to the init arrays */ /* Blob */ BNX2X_ALLOC_AND_SET(init_data, request_firmware_exit, be32_to_cpu_n); /* Opcodes */ BNX2X_ALLOC_AND_SET(init_ops, init_ops_alloc_err, bnx2x_prep_ops); /* Offsets */ BNX2X_ALLOC_AND_SET(init_ops_offsets, init_offsets_alloc_err, be16_to_cpu_n); /* STORMs firmware */ INIT_TSEM_INT_TABLE_DATA(bp) = bp->firmware->data + be32_to_cpu(fw_hdr->tsem_int_table_data.offset); INIT_TSEM_PRAM_DATA(bp) = bp->firmware->data + be32_to_cpu(fw_hdr->tsem_pram_data.offset); INIT_USEM_INT_TABLE_DATA(bp) = bp->firmware->data + be32_to_cpu(fw_hdr->usem_int_table_data.offset); INIT_USEM_PRAM_DATA(bp) = bp->firmware->data + be32_to_cpu(fw_hdr->usem_pram_data.offset); INIT_XSEM_INT_TABLE_DATA(bp) = bp->firmware->data + be32_to_cpu(fw_hdr->xsem_int_table_data.offset); INIT_XSEM_PRAM_DATA(bp) = bp->firmware->data + be32_to_cpu(fw_hdr->xsem_pram_data.offset); INIT_CSEM_INT_TABLE_DATA(bp) = bp->firmware->data + be32_to_cpu(fw_hdr->csem_int_table_data.offset); INIT_CSEM_PRAM_DATA(bp) = bp->firmware->data + be32_to_cpu(fw_hdr->csem_pram_data.offset); /* IRO */ BNX2X_ALLOC_AND_SET(iro_arr, iro_alloc_err, bnx2x_prep_iro); return 0; iro_alloc_err: kfree(bp->init_ops_offsets); init_offsets_alloc_err: kfree(bp->init_ops); init_ops_alloc_err: kfree(bp->init_data); request_firmware_exit: release_firmware(bp->firmware); return rc; } static void bnx2x_release_firmware(struct bnx2x *bp) { kfree(bp->init_ops_offsets); kfree(bp->init_ops); kfree(bp->init_data); release_firmware(bp->firmware); } static struct bnx2x_func_sp_drv_ops bnx2x_func_sp_drv = { .init_hw_cmn_chip = bnx2x_init_hw_common_chip, .init_hw_cmn = bnx2x_init_hw_common, .init_hw_port = bnx2x_init_hw_port, .init_hw_func = bnx2x_init_hw_func, .reset_hw_cmn = bnx2x_reset_common, .reset_hw_port = bnx2x_reset_port, .reset_hw_func = bnx2x_reset_func, .gunzip_init = bnx2x_gunzip_init, .gunzip_end = bnx2x_gunzip_end, .init_fw = bnx2x_init_firmware, .release_fw = bnx2x_release_firmware, }; void bnx2x__init_func_obj(struct bnx2x *bp) { /* Prepare DMAE related driver resources */ bnx2x_setup_dmae(bp); bnx2x_init_func_obj(bp, &bp->func_obj, bnx2x_sp(bp, func_rdata), bnx2x_sp_mapping(bp, func_rdata), &bnx2x_func_sp_drv); } /* must be called after sriov-enable */ static inline int bnx2x_set_qm_cid_count(struct bnx2x *bp) { int cid_count = BNX2X_L2_CID_COUNT(bp); #ifdef BCM_CNIC cid_count += CNIC_CID_MAX; #endif return roundup(cid_count, QM_CID_ROUND); } /** * bnx2x_get_num_none_def_sbs - return the number of none default SBs * * @dev: pci device * */ static inline int bnx2x_get_num_non_def_sbs(struct pci_dev *pdev) { int pos; u16 control; pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX); /* * If MSI-X is not supported - return number of SBs needed to support * one fast path queue: one FP queue + SB for CNIC */ if (!pos) return 1 + CNIC_PRESENT; /* * The value in the PCI configuration space is the index of the last * entry, namely one less than the actual size of the table, which is * exactly what we want to return from this function: number of all SBs * without the default SB. */ pci_read_config_word(pdev, pos + PCI_MSI_FLAGS, &control); return control & PCI_MSIX_FLAGS_QSIZE; } static int __devinit bnx2x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { struct net_device *dev = NULL; struct bnx2x *bp; int pcie_width, pcie_speed; int rc, max_non_def_sbs; int rx_count, tx_count, rss_count; /* * An estimated maximum supported CoS number according to the chip * version. * We will try to roughly estimate the maximum number of CoSes this chip * may support in order to minimize the memory allocated for Tx * netdev_queue's. This number will be accurately calculated during the * initialization of bp->max_cos based on the chip versions AND chip * revision in the bnx2x_init_bp(). */ u8 max_cos_est = 0; switch (ent->driver_data) { case BCM57710: case BCM57711: case BCM57711E: max_cos_est = BNX2X_MULTI_TX_COS_E1X; break; case BCM57712: case BCM57712_MF: max_cos_est = BNX2X_MULTI_TX_COS_E2_E3A0; break; case BCM57800: case BCM57800_MF: case BCM57810: case BCM57810_MF: case BCM57840: case BCM57840_MF: max_cos_est = BNX2X_MULTI_TX_COS_E3B0; break; default: pr_err("Unknown board_type (%ld), aborting\n", ent->driver_data); return -ENODEV; } max_non_def_sbs = bnx2x_get_num_non_def_sbs(pdev); /* !!! FIXME !!! * Do not allow the maximum SB count to grow above 16 * since Special CIDs starts from 16*BNX2X_MULTI_TX_COS=48. * We will use the FP_SB_MAX_E1x macro for this matter. */ max_non_def_sbs = min_t(int, FP_SB_MAX_E1x, max_non_def_sbs); WARN_ON(!max_non_def_sbs); /* Maximum number of RSS queues: one IGU SB goes to CNIC */ rss_count = max_non_def_sbs - CNIC_PRESENT; /* Maximum number of netdev Rx queues: RSS + FCoE L2 */ rx_count = rss_count + FCOE_PRESENT; /* * Maximum number of netdev Tx queues: * Maximum TSS queues * Maximum supported number of CoS + FCoE L2 */ tx_count = MAX_TXQS_PER_COS * max_cos_est + FCOE_PRESENT; /* dev zeroed in init_etherdev */ dev = alloc_etherdev_mqs(sizeof(*bp), tx_count, rx_count); if (!dev) { dev_err(&pdev->dev, "Cannot allocate net device\n"); return -ENOMEM; } bp = netdev_priv(dev); DP(NETIF_MSG_DRV, "Allocated netdev with %d tx and %d rx queues\n", tx_count, rx_count); bp->igu_sb_cnt = max_non_def_sbs; bp->msg_enable = debug; pci_set_drvdata(pdev, dev); rc = bnx2x_init_dev(pdev, dev, ent->driver_data); if (rc < 0) { free_netdev(dev); return rc; } DP(NETIF_MSG_DRV, "max_non_def_sbs %d", max_non_def_sbs); rc = bnx2x_init_bp(bp); if (rc) goto init_one_exit; /* * Map doorbels here as we need the real value of bp->max_cos which * is initialized in bnx2x_init_bp(). */ bp->doorbells = ioremap_nocache(pci_resource_start(pdev, 2), min_t(u64, BNX2X_DB_SIZE(bp), pci_resource_len(pdev, 2))); if (!bp->doorbells) { dev_err(&bp->pdev->dev, "Cannot map doorbell space, aborting\n"); rc = -ENOMEM; goto init_one_exit; } /* calc qm_cid_count */ bp->qm_cid_count = bnx2x_set_qm_cid_count(bp); #ifdef BCM_CNIC /* disable FCOE L2 queue for E1x and E3*/ if (CHIP_IS_E1x(bp) || CHIP_IS_E3(bp)) bp->flags |= NO_FCOE_FLAG; #endif /* Configure interrupt mode: try to enable MSI-X/MSI if * needed, set bp->num_queues appropriately. */ bnx2x_set_int_mode(bp); /* Add all NAPI objects */ bnx2x_add_all_napi(bp); rc = register_netdev(dev); if (rc) { dev_err(&pdev->dev, "Cannot register net device\n"); goto init_one_exit; } #ifdef BCM_CNIC if (!NO_FCOE(bp)) { /* Add storage MAC address */ rtnl_lock(); dev_addr_add(bp->dev, bp->fip_mac, NETDEV_HW_ADDR_T_SAN); rtnl_unlock(); } #endif bnx2x_get_pcie_width_speed(bp, &pcie_width, &pcie_speed); netdev_info(dev, "%s (%c%d) PCI-E x%d %s found at mem %lx," " IRQ %d, ", board_info[ent->driver_data].name, (CHIP_REV(bp) >> 12) + 'A', (CHIP_METAL(bp) >> 4), pcie_width, ((!CHIP_IS_E2(bp) && pcie_speed == 2) || (CHIP_IS_E2(bp) && pcie_speed == 1)) ? "5GHz (Gen2)" : "2.5GHz", dev->base_addr, bp->pdev->irq); pr_cont("node addr %pM\n", dev->dev_addr); return 0; init_one_exit: if (bp->regview) iounmap(bp->regview); if (bp->doorbells) iounmap(bp->doorbells); free_netdev(dev); if (atomic_read(&pdev->enable_cnt) == 1) pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); return rc; } static void __devexit bnx2x_remove_one(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); struct bnx2x *bp; if (!dev) { dev_err(&pdev->dev, "BAD net device from bnx2x_init_one\n"); return; } bp = netdev_priv(dev); #ifdef BCM_CNIC /* Delete storage MAC address */ if (!NO_FCOE(bp)) { rtnl_lock(); dev_addr_del(bp->dev, bp->fip_mac, NETDEV_HW_ADDR_T_SAN); rtnl_unlock(); } #endif #ifdef BCM_DCBNL /* Delete app tlvs from dcbnl */ bnx2x_dcbnl_update_applist(bp, true); #endif unregister_netdev(dev); /* Delete all NAPI objects */ bnx2x_del_all_napi(bp); /* Power on: we can't let PCI layer write to us while we are in D3 */ bnx2x_set_power_state(bp, PCI_D0); /* Disable MSI/MSI-X */ bnx2x_disable_msi(bp); /* Power off */ bnx2x_set_power_state(bp, PCI_D3hot); /* Make sure RESET task is not scheduled before continuing */ cancel_delayed_work_sync(&bp->sp_rtnl_task); if (bp->regview) iounmap(bp->regview); if (bp->doorbells) iounmap(bp->doorbells); bnx2x_free_mem_bp(bp); free_netdev(dev); if (atomic_read(&pdev->enable_cnt) == 1) pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); } static int bnx2x_eeh_nic_unload(struct bnx2x *bp) { int i; bp->state = BNX2X_STATE_ERROR; bp->rx_mode = BNX2X_RX_MODE_NONE; #ifdef BCM_CNIC bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD); #endif /* Stop Tx */ bnx2x_tx_disable(bp); bnx2x_netif_stop(bp, 0); del_timer_sync(&bp->timer); bnx2x_stats_handle(bp, STATS_EVENT_STOP); /* Release IRQs */ bnx2x_free_irq(bp); /* Free SKBs, SGEs, TPA pool and driver internals */ bnx2x_free_skbs(bp); for_each_rx_queue(bp, i) bnx2x_free_rx_sge_range(bp, bp->fp + i, NUM_RX_SGE); bnx2x_free_mem(bp); bp->state = BNX2X_STATE_CLOSED; netif_carrier_off(bp->dev); return 0; } static void bnx2x_eeh_recover(struct bnx2x *bp) { u32 val; mutex_init(&bp->port.phy_mutex); bp->common.shmem_base = REG_RD(bp, MISC_REG_SHARED_MEM_ADDR); bp->link_params.shmem_base = bp->common.shmem_base; BNX2X_DEV_INFO("shmem offset is 0x%x\n", bp->common.shmem_base); if (!bp->common.shmem_base || (bp->common.shmem_base < 0xA0000) || (bp->common.shmem_base >= 0xC0000)) { BNX2X_DEV_INFO("MCP not active\n"); bp->flags |= NO_MCP_FLAG; return; } val = SHMEM_RD(bp, validity_map[BP_PORT(bp)]); if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) != (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) BNX2X_ERR("BAD MCP validity signature\n"); if (!BP_NOMCP(bp)) { bp->fw_seq = (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) & DRV_MSG_SEQ_NUMBER_MASK); BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq); } } /** * bnx2x_io_error_detected - called when PCI error is detected * @pdev: Pointer to PCI device * @state: The current pci connection state * * This function is called after a PCI bus error affecting * this device has been detected. */ static pci_ers_result_t bnx2x_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { struct net_device *dev = pci_get_drvdata(pdev); struct bnx2x *bp = netdev_priv(dev); rtnl_lock(); netif_device_detach(dev); if (state == pci_channel_io_perm_failure) { rtnl_unlock(); return PCI_ERS_RESULT_DISCONNECT; } if (netif_running(dev)) bnx2x_eeh_nic_unload(bp); pci_disable_device(pdev); rtnl_unlock(); /* Request a slot reset */ return PCI_ERS_RESULT_NEED_RESET; } /** * bnx2x_io_slot_reset - called after the PCI bus has been reset * @pdev: Pointer to PCI device * * Restart the card from scratch, as if from a cold-boot. */ static pci_ers_result_t bnx2x_io_slot_reset(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); struct bnx2x *bp = netdev_priv(dev); rtnl_lock(); if (pci_enable_device(pdev)) { dev_err(&pdev->dev, "Cannot re-enable PCI device after reset\n"); rtnl_unlock(); return PCI_ERS_RESULT_DISCONNECT; } pci_set_master(pdev); pci_restore_state(pdev); if (netif_running(dev)) bnx2x_set_power_state(bp, PCI_D0); rtnl_unlock(); return PCI_ERS_RESULT_RECOVERED; } /** * bnx2x_io_resume - called when traffic can start flowing again * @pdev: Pointer to PCI device * * This callback is called when the error recovery driver tells us that * its OK to resume normal operation. */ static void bnx2x_io_resume(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); struct bnx2x *bp = netdev_priv(dev); if (bp->recovery_state != BNX2X_RECOVERY_DONE) { netdev_err(bp->dev, "Handling parity error recovery. " "Try again later\n"); return; } rtnl_lock(); bnx2x_eeh_recover(bp); if (netif_running(dev)) bnx2x_nic_load(bp, LOAD_NORMAL); netif_device_attach(dev); rtnl_unlock(); } static struct pci_error_handlers bnx2x_err_handler = { .error_detected = bnx2x_io_error_detected, .slot_reset = bnx2x_io_slot_reset, .resume = bnx2x_io_resume, }; static struct pci_driver bnx2x_pci_driver = { .name = DRV_MODULE_NAME, .id_table = bnx2x_pci_tbl, .probe = bnx2x_init_one, .remove = __devexit_p(bnx2x_remove_one), .suspend = bnx2x_suspend, .resume = bnx2x_resume, .err_handler = &bnx2x_err_handler, }; static int __init bnx2x_init(void) { int ret; pr_info("%s", version); bnx2x_wq = create_singlethread_workqueue("bnx2x"); if (bnx2x_wq == NULL) { pr_err("Cannot create workqueue\n"); return -ENOMEM; } ret = pci_register_driver(&bnx2x_pci_driver); if (ret) { pr_err("Cannot register driver\n"); destroy_workqueue(bnx2x_wq); } return ret; } static void __exit bnx2x_cleanup(void) { pci_unregister_driver(&bnx2x_pci_driver); destroy_workqueue(bnx2x_wq); } void bnx2x_notify_link_changed(struct bnx2x *bp) { REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_12 + BP_FUNC(bp)*sizeof(u32), 1); } module_init(bnx2x_init); module_exit(bnx2x_cleanup); #ifdef BCM_CNIC /** * bnx2x_set_iscsi_eth_mac_addr - set iSCSI MAC(s). * * @bp: driver handle * @set: set or clear the CAM entry * * This function will wait until the ramdord completion returns. * Return 0 if success, -ENODEV if ramrod doesn't return. */ static inline int bnx2x_set_iscsi_eth_mac_addr(struct bnx2x *bp) { unsigned long ramrod_flags = 0; __set_bit(RAMROD_COMP_WAIT, &ramrod_flags); return bnx2x_set_mac_one(bp, bp->cnic_eth_dev.iscsi_mac, &bp->iscsi_l2_mac_obj, true, BNX2X_ISCSI_ETH_MAC, &ramrod_flags); } /* count denotes the number of new completions we have seen */ static void bnx2x_cnic_sp_post(struct bnx2x *bp, int count) { struct eth_spe *spe; #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return; #endif spin_lock_bh(&bp->spq_lock); BUG_ON(bp->cnic_spq_pending < count); bp->cnic_spq_pending -= count; for (; bp->cnic_kwq_pending; bp->cnic_kwq_pending--) { u16 type = (le16_to_cpu(bp->cnic_kwq_cons->hdr.type) & SPE_HDR_CONN_TYPE) >> SPE_HDR_CONN_TYPE_SHIFT; u8 cmd = (le32_to_cpu(bp->cnic_kwq_cons->hdr.conn_and_cmd_data) >> SPE_HDR_CMD_ID_SHIFT) & 0xff; /* Set validation for iSCSI L2 client before sending SETUP * ramrod */ if (type == ETH_CONNECTION_TYPE) { if (cmd == RAMROD_CMD_ID_ETH_CLIENT_SETUP) bnx2x_set_ctx_validation(bp, &bp->context. vcxt[BNX2X_ISCSI_ETH_CID].eth, BNX2X_ISCSI_ETH_CID); } /* * There may be not more than 8 L2, not more than 8 L5 SPEs * and in the air. We also check that number of outstanding * COMMON ramrods is not more than the EQ and SPQ can * accommodate. */ if (type == ETH_CONNECTION_TYPE) { if (!atomic_read(&bp->cq_spq_left)) break; else atomic_dec(&bp->cq_spq_left); } else if (type == NONE_CONNECTION_TYPE) { if (!atomic_read(&bp->eq_spq_left)) break; else atomic_dec(&bp->eq_spq_left); } else if ((type == ISCSI_CONNECTION_TYPE) || (type == FCOE_CONNECTION_TYPE)) { if (bp->cnic_spq_pending >= bp->cnic_eth_dev.max_kwqe_pending) break; else bp->cnic_spq_pending++; } else { BNX2X_ERR("Unknown SPE type: %d\n", type); bnx2x_panic(); break; } spe = bnx2x_sp_get_next(bp); *spe = *bp->cnic_kwq_cons; DP(NETIF_MSG_TIMER, "pending on SPQ %d, on KWQ %d count %d\n", bp->cnic_spq_pending, bp->cnic_kwq_pending, count); if (bp->cnic_kwq_cons == bp->cnic_kwq_last) bp->cnic_kwq_cons = bp->cnic_kwq; else bp->cnic_kwq_cons++; } bnx2x_sp_prod_update(bp); spin_unlock_bh(&bp->spq_lock); } static int bnx2x_cnic_sp_queue(struct net_device *dev, struct kwqe_16 *kwqes[], u32 count) { struct bnx2x *bp = netdev_priv(dev); int i; #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) return -EIO; #endif spin_lock_bh(&bp->spq_lock); for (i = 0; i < count; i++) { struct eth_spe *spe = (struct eth_spe *)kwqes[i]; if (bp->cnic_kwq_pending == MAX_SP_DESC_CNT) break; *bp->cnic_kwq_prod = *spe; bp->cnic_kwq_pending++; DP(NETIF_MSG_TIMER, "L5 SPQE %x %x %x:%x pos %d\n", spe->hdr.conn_and_cmd_data, spe->hdr.type, spe->data.update_data_addr.hi, spe->data.update_data_addr.lo, bp->cnic_kwq_pending); if (bp->cnic_kwq_prod == bp->cnic_kwq_last) bp->cnic_kwq_prod = bp->cnic_kwq; else bp->cnic_kwq_prod++; } spin_unlock_bh(&bp->spq_lock); if (bp->cnic_spq_pending < bp->cnic_eth_dev.max_kwqe_pending) bnx2x_cnic_sp_post(bp, 0); return i; } static int bnx2x_cnic_ctl_send(struct bnx2x *bp, struct cnic_ctl_info *ctl) { struct cnic_ops *c_ops; int rc = 0; mutex_lock(&bp->cnic_mutex); c_ops = rcu_dereference_protected(bp->cnic_ops, lockdep_is_held(&bp->cnic_mutex)); if (c_ops) rc = c_ops->cnic_ctl(bp->cnic_data, ctl); mutex_unlock(&bp->cnic_mutex); return rc; } static int bnx2x_cnic_ctl_send_bh(struct bnx2x *bp, struct cnic_ctl_info *ctl) { struct cnic_ops *c_ops; int rc = 0; rcu_read_lock(); c_ops = rcu_dereference(bp->cnic_ops); if (c_ops) rc = c_ops->cnic_ctl(bp->cnic_data, ctl); rcu_read_unlock(); return rc; } /* * for commands that have no data */ int bnx2x_cnic_notify(struct bnx2x *bp, int cmd) { struct cnic_ctl_info ctl = {0}; ctl.cmd = cmd; return bnx2x_cnic_ctl_send(bp, &ctl); } static void bnx2x_cnic_cfc_comp(struct bnx2x *bp, int cid, u8 err) { struct cnic_ctl_info ctl = {0}; /* first we tell CNIC and only then we count this as a completion */ ctl.cmd = CNIC_CTL_COMPLETION_CMD; ctl.data.comp.cid = cid; ctl.data.comp.error = err; bnx2x_cnic_ctl_send_bh(bp, &ctl); bnx2x_cnic_sp_post(bp, 0); } /* Called with netif_addr_lock_bh() taken. * Sets an rx_mode config for an iSCSI ETH client. * Doesn't block. * Completion should be checked outside. */ static void bnx2x_set_iscsi_eth_rx_mode(struct bnx2x *bp, bool start) { unsigned long accept_flags = 0, ramrod_flags = 0; u8 cl_id = bnx2x_cnic_eth_cl_id(bp, BNX2X_ISCSI_ETH_CL_ID_IDX); int sched_state = BNX2X_FILTER_ISCSI_ETH_STOP_SCHED; if (start) { /* Start accepting on iSCSI L2 ring. Accept all multicasts * because it's the only way for UIO Queue to accept * multicasts (in non-promiscuous mode only one Queue per * function will receive multicast packets (leading in our * case). */ __set_bit(BNX2X_ACCEPT_UNICAST, &accept_flags); __set_bit(BNX2X_ACCEPT_ALL_MULTICAST, &accept_flags); __set_bit(BNX2X_ACCEPT_BROADCAST, &accept_flags); __set_bit(BNX2X_ACCEPT_ANY_VLAN, &accept_flags); /* Clear STOP_PENDING bit if START is requested */ clear_bit(BNX2X_FILTER_ISCSI_ETH_STOP_SCHED, &bp->sp_state); sched_state = BNX2X_FILTER_ISCSI_ETH_START_SCHED; } else /* Clear START_PENDING bit if STOP is requested */ clear_bit(BNX2X_FILTER_ISCSI_ETH_START_SCHED, &bp->sp_state); if (test_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state)) set_bit(sched_state, &bp->sp_state); else { __set_bit(RAMROD_RX, &ramrod_flags); bnx2x_set_q_rx_mode(bp, cl_id, 0, accept_flags, 0, ramrod_flags); } } static int bnx2x_drv_ctl(struct net_device *dev, struct drv_ctl_info *ctl) { struct bnx2x *bp = netdev_priv(dev); int rc = 0; switch (ctl->cmd) { case DRV_CTL_CTXTBL_WR_CMD: { u32 index = ctl->data.io.offset; dma_addr_t addr = ctl->data.io.dma_addr; bnx2x_ilt_wr(bp, index, addr); break; } case DRV_CTL_RET_L5_SPQ_CREDIT_CMD: { int count = ctl->data.credit.credit_count; bnx2x_cnic_sp_post(bp, count); break; } /* rtnl_lock is held. */ case DRV_CTL_START_L2_CMD: { struct cnic_eth_dev *cp = &bp->cnic_eth_dev; unsigned long sp_bits = 0; /* Configure the iSCSI classification object */ bnx2x_init_mac_obj(bp, &bp->iscsi_l2_mac_obj, cp->iscsi_l2_client_id, cp->iscsi_l2_cid, BP_FUNC(bp), bnx2x_sp(bp, mac_rdata), bnx2x_sp_mapping(bp, mac_rdata), BNX2X_FILTER_MAC_PENDING, &bp->sp_state, BNX2X_OBJ_TYPE_RX, &bp->macs_pool); /* Set iSCSI MAC address */ rc = bnx2x_set_iscsi_eth_mac_addr(bp); if (rc) break; mmiowb(); barrier(); /* Start accepting on iSCSI L2 ring */ netif_addr_lock_bh(dev); bnx2x_set_iscsi_eth_rx_mode(bp, true); netif_addr_unlock_bh(dev); /* bits to wait on */ __set_bit(BNX2X_FILTER_RX_MODE_PENDING, &sp_bits); __set_bit(BNX2X_FILTER_ISCSI_ETH_START_SCHED, &sp_bits); if (!bnx2x_wait_sp_comp(bp, sp_bits)) BNX2X_ERR("rx_mode completion timed out!\n"); break; } /* rtnl_lock is held. */ case DRV_CTL_STOP_L2_CMD: { unsigned long sp_bits = 0; /* Stop accepting on iSCSI L2 ring */ netif_addr_lock_bh(dev); bnx2x_set_iscsi_eth_rx_mode(bp, false); netif_addr_unlock_bh(dev); /* bits to wait on */ __set_bit(BNX2X_FILTER_RX_MODE_PENDING, &sp_bits); __set_bit(BNX2X_FILTER_ISCSI_ETH_STOP_SCHED, &sp_bits); if (!bnx2x_wait_sp_comp(bp, sp_bits)) BNX2X_ERR("rx_mode completion timed out!\n"); mmiowb(); barrier(); /* Unset iSCSI L2 MAC */ rc = bnx2x_del_all_macs(bp, &bp->iscsi_l2_mac_obj, BNX2X_ISCSI_ETH_MAC, true); break; } case DRV_CTL_RET_L2_SPQ_CREDIT_CMD: { int count = ctl->data.credit.credit_count; smp_mb__before_atomic_inc(); atomic_add(count, &bp->cq_spq_left); smp_mb__after_atomic_inc(); break; } default: BNX2X_ERR("unknown command %x\n", ctl->cmd); rc = -EINVAL; } return rc; } void bnx2x_setup_cnic_irq_info(struct bnx2x *bp) { struct cnic_eth_dev *cp = &bp->cnic_eth_dev; if (bp->flags & USING_MSIX_FLAG) { cp->drv_state |= CNIC_DRV_STATE_USING_MSIX; cp->irq_arr[0].irq_flags |= CNIC_IRQ_FL_MSIX; cp->irq_arr[0].vector = bp->msix_table[1].vector; } else { cp->drv_state &= ~CNIC_DRV_STATE_USING_MSIX; cp->irq_arr[0].irq_flags &= ~CNIC_IRQ_FL_MSIX; } if (!CHIP_IS_E1x(bp)) cp->irq_arr[0].status_blk = (void *)bp->cnic_sb.e2_sb; else cp->irq_arr[0].status_blk = (void *)bp->cnic_sb.e1x_sb; cp->irq_arr[0].status_blk_num = bnx2x_cnic_fw_sb_id(bp); cp->irq_arr[0].status_blk_num2 = bnx2x_cnic_igu_sb_id(bp); cp->irq_arr[1].status_blk = bp->def_status_blk; cp->irq_arr[1].status_blk_num = DEF_SB_ID; cp->irq_arr[1].status_blk_num2 = DEF_SB_IGU_ID; cp->num_irq = 2; } static int bnx2x_register_cnic(struct net_device *dev, struct cnic_ops *ops, void *data) { struct bnx2x *bp = netdev_priv(dev); struct cnic_eth_dev *cp = &bp->cnic_eth_dev; if (ops == NULL) return -EINVAL; bp->cnic_kwq = kzalloc(PAGE_SIZE, GFP_KERNEL); if (!bp->cnic_kwq) return -ENOMEM; bp->cnic_kwq_cons = bp->cnic_kwq; bp->cnic_kwq_prod = bp->cnic_kwq; bp->cnic_kwq_last = bp->cnic_kwq + MAX_SP_DESC_CNT; bp->cnic_spq_pending = 0; bp->cnic_kwq_pending = 0; bp->cnic_data = data; cp->num_irq = 0; cp->drv_state |= CNIC_DRV_STATE_REGD; cp->iro_arr = bp->iro_arr; bnx2x_setup_cnic_irq_info(bp); rcu_assign_pointer(bp->cnic_ops, ops); return 0; } static int bnx2x_unregister_cnic(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); struct cnic_eth_dev *cp = &bp->cnic_eth_dev; mutex_lock(&bp->cnic_mutex); cp->drv_state = 0; rcu_assign_pointer(bp->cnic_ops, NULL); mutex_unlock(&bp->cnic_mutex); synchronize_rcu(); kfree(bp->cnic_kwq); bp->cnic_kwq = NULL; return 0; } struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); struct cnic_eth_dev *cp = &bp->cnic_eth_dev; /* If both iSCSI and FCoE are disabled - return NULL in * order to indicate CNIC that it should not try to work * with this device. */ if (NO_ISCSI(bp) && NO_FCOE(bp)) return NULL; cp->drv_owner = THIS_MODULE; cp->chip_id = CHIP_ID(bp); cp->pdev = bp->pdev; cp->io_base = bp->regview; cp->io_base2 = bp->doorbells; cp->max_kwqe_pending = 8; cp->ctx_blk_size = CDU_ILT_PAGE_SZ; cp->ctx_tbl_offset = FUNC_ILT_BASE(BP_FUNC(bp)) + bnx2x_cid_ilt_lines(bp); cp->ctx_tbl_len = CNIC_ILT_LINES; cp->starting_cid = bnx2x_cid_ilt_lines(bp) * ILT_PAGE_CIDS; cp->drv_submit_kwqes_16 = bnx2x_cnic_sp_queue; cp->drv_ctl = bnx2x_drv_ctl; cp->drv_register_cnic = bnx2x_register_cnic; cp->drv_unregister_cnic = bnx2x_unregister_cnic; cp->fcoe_init_cid = BNX2X_FCOE_ETH_CID; cp->iscsi_l2_client_id = bnx2x_cnic_eth_cl_id(bp, BNX2X_ISCSI_ETH_CL_ID_IDX); cp->iscsi_l2_cid = BNX2X_ISCSI_ETH_CID; if (NO_ISCSI_OOO(bp)) cp->drv_state |= CNIC_DRV_STATE_NO_ISCSI_OOO; if (NO_ISCSI(bp)) cp->drv_state |= CNIC_DRV_STATE_NO_ISCSI; if (NO_FCOE(bp)) cp->drv_state |= CNIC_DRV_STATE_NO_FCOE; DP(BNX2X_MSG_SP, "page_size %d, tbl_offset %d, tbl_lines %d, " "starting cid %d\n", cp->ctx_blk_size, cp->ctx_tbl_offset, cp->ctx_tbl_len, cp->starting_cid); return cp; } EXPORT_SYMBOL(bnx2x_cnic_probe); #endif /* BCM_CNIC */
gpl-2.0
MoKee/android_kernel_samsung_sc03e
fs/cifs/cifsfs.c
630
32323
/* * fs/cifs/cifsfs.c * * Copyright (C) International Business Machines Corp., 2002,2008 * Author(s): Steve French (sfrench@us.ibm.com) * * Common Internet FileSystem (CIFS) client * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Note that BB means BUGBUG (ie something to fix eventually) */ #include <linux/module.h> #include <linux/fs.h> #include <linux/mount.h> #include <linux/slab.h> #include <linux/init.h> #include <linux/list.h> #include <linux/seq_file.h> #include <linux/vfs.h> #include <linux/mempool.h> #include <linux/delay.h> #include <linux/kthread.h> #include <linux/freezer.h> #include <linux/namei.h> #include <net/ipv6.h> #include "cifsfs.h" #include "cifspdu.h" #define DECLARE_GLOBALS_HERE #include "cifsglob.h" #include "cifsproto.h" #include "cifs_debug.h" #include "cifs_fs_sb.h" #include <linux/mm.h> #include <linux/key-type.h> #include "cifs_spnego.h" #include "fscache.h" #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ int cifsFYI = 0; int cifsERROR = 1; int traceSMB = 0; unsigned int oplockEnabled = 1; unsigned int linuxExtEnabled = 1; unsigned int lookupCacheEnabled = 1; unsigned int multiuser_mount = 0; unsigned int global_secflags = CIFSSEC_DEF; /* unsigned int ntlmv2_support = 0; */ unsigned int sign_CIFS_PDUs = 1; static const struct super_operations cifs_super_ops; unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE; module_param(CIFSMaxBufSize, int, 0); MODULE_PARM_DESC(CIFSMaxBufSize, "Network buffer size (not including header). " "Default: 16384 Range: 8192 to 130048"); unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL; module_param(cifs_min_rcv, int, 0); MODULE_PARM_DESC(cifs_min_rcv, "Network buffers in pool. Default: 4 Range: " "1 to 64"); unsigned int cifs_min_small = 30; module_param(cifs_min_small, int, 0); MODULE_PARM_DESC(cifs_min_small, "Small network buffers in pool. Default: 30 " "Range: 2 to 256"); unsigned int cifs_max_pending = CIFS_MAX_REQ; module_param(cifs_max_pending, int, 0); MODULE_PARM_DESC(cifs_max_pending, "Simultaneous requests to server. " "Default: 50 Range: 2 to 256"); unsigned short echo_retries = 5; module_param(echo_retries, ushort, 0644); MODULE_PARM_DESC(echo_retries, "Number of echo attempts before giving up and " "reconnecting server. Default: 5. 0 means " "never reconnect."); extern mempool_t *cifs_sm_req_poolp; extern mempool_t *cifs_req_poolp; extern mempool_t *cifs_mid_poolp; void cifs_sb_active(struct super_block *sb) { struct cifs_sb_info *server = CIFS_SB(sb); if (atomic_inc_return(&server->active) == 1) atomic_inc(&sb->s_active); } void cifs_sb_deactive(struct super_block *sb) { struct cifs_sb_info *server = CIFS_SB(sb); if (atomic_dec_and_test(&server->active)) deactivate_super(sb); } static int cifs_read_super(struct super_block *sb) { struct inode *inode; struct cifs_sb_info *cifs_sb; int rc = 0; cifs_sb = CIFS_SB(sb); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) sb->s_flags |= MS_POSIXACL; if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES) sb->s_maxbytes = MAX_LFS_FILESIZE; else sb->s_maxbytes = MAX_NON_LFS; /* BB FIXME fix time_gran to be larger for LANMAN sessions */ sb->s_time_gran = 100; sb->s_magic = CIFS_MAGIC_NUMBER; sb->s_op = &cifs_super_ops; sb->s_bdi = &cifs_sb->bdi; sb->s_blocksize = CIFS_MAX_MSGSIZE; sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */ inode = cifs_root_iget(sb); if (IS_ERR(inode)) { rc = PTR_ERR(inode); inode = NULL; goto out_no_root; } sb->s_root = d_alloc_root(inode); if (!sb->s_root) { rc = -ENOMEM; goto out_no_root; } /* do that *after* d_alloc_root() - we want NULL ->d_op for root here */ if (cifs_sb_master_tcon(cifs_sb)->nocase) sb->s_d_op = &cifs_ci_dentry_ops; else sb->s_d_op = &cifs_dentry_ops; #ifdef CIFS_NFSD_EXPORT if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { cFYI(1, "export ops supported"); sb->s_export_op = &cifs_export_ops; } #endif /* CIFS_NFSD_EXPORT */ return 0; out_no_root: cERROR(1, "cifs_read_super: get root inode failed"); if (inode) iput(inode); return rc; } static void cifs_kill_sb(struct super_block *sb) { struct cifs_sb_info *cifs_sb = CIFS_SB(sb); kill_anon_super(sb); cifs_umount(cifs_sb); } static int cifs_statfs(struct dentry *dentry, struct kstatfs *buf) { struct super_block *sb = dentry->d_sb; struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); int rc = -EOPNOTSUPP; int xid; xid = GetXid(); buf->f_type = CIFS_MAGIC_NUMBER; /* * PATH_MAX may be too long - it would presumably be total path, * but note that some servers (includinng Samba 3) have a shorter * maximum path. * * Instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO. */ buf->f_namelen = PATH_MAX; buf->f_files = 0; /* undefined */ buf->f_ffree = 0; /* unlimited */ /* * We could add a second check for a QFS Unix capability bit */ if ((tcon->ses->capabilities & CAP_UNIX) && (CIFS_POSIX_EXTENSIONS & le64_to_cpu(tcon->fsUnixInfo.Capability))) rc = CIFSSMBQFSPosixInfo(xid, tcon, buf); /* * Only need to call the old QFSInfo if failed on newer one, * e.g. by OS/2. **/ if (rc && (tcon->ses->capabilities & CAP_NT_SMBS)) rc = CIFSSMBQFSInfo(xid, tcon, buf); /* * Some old Windows servers also do not support level 103, retry with * older level one if old server failed the previous call or we * bypassed it because we detected that this was an older LANMAN sess */ if (rc) rc = SMBOldQFSInfo(xid, tcon, buf); FreeXid(xid); return 0; } static int cifs_permission(struct inode *inode, int mask, unsigned int flags) { struct cifs_sb_info *cifs_sb; cifs_sb = CIFS_SB(inode->i_sb); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) { if ((mask & MAY_EXEC) && !execute_ok(inode)) return -EACCES; else return 0; } else /* file mode might have been restricted at mount time on the client (above and beyond ACL on servers) for servers which do not support setting and viewing mode bits, so allowing client to check permissions is useful */ return generic_permission(inode, mask, flags, NULL); } static struct kmem_cache *cifs_inode_cachep; static struct kmem_cache *cifs_req_cachep; static struct kmem_cache *cifs_mid_cachep; static struct kmem_cache *cifs_sm_req_cachep; mempool_t *cifs_sm_req_poolp; mempool_t *cifs_req_poolp; mempool_t *cifs_mid_poolp; static struct inode * cifs_alloc_inode(struct super_block *sb) { struct cifsInodeInfo *cifs_inode; cifs_inode = kmem_cache_alloc(cifs_inode_cachep, GFP_KERNEL); if (!cifs_inode) return NULL; cifs_inode->cifsAttrs = 0x20; /* default */ cifs_inode->time = 0; /* Until the file is open and we have gotten oplock info back from the server, can not assume caching of file data or metadata */ cifs_set_oplock_level(cifs_inode, 0); cifs_inode->delete_pending = false; cifs_inode->invalid_mapping = false; cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ cifs_inode->server_eof = 0; cifs_inode->uniqueid = 0; cifs_inode->createtime = 0; /* Can not set i_flags here - they get immediately overwritten to zero by the VFS */ /* cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME;*/ INIT_LIST_HEAD(&cifs_inode->openFileList); return &cifs_inode->vfs_inode; } static void cifs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(cifs_inode_cachep, CIFS_I(inode)); } static void cifs_destroy_inode(struct inode *inode) { call_rcu(&inode->i_rcu, cifs_i_callback); } static void cifs_evict_inode(struct inode *inode) { truncate_inode_pages(&inode->i_data, 0); end_writeback(inode); cifs_fscache_release_inode_cookie(inode); } static void cifs_show_address(struct seq_file *s, struct TCP_Server_Info *server) { struct sockaddr_in *sa = (struct sockaddr_in *) &server->dstaddr; struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *) &server->dstaddr; seq_printf(s, ",addr="); switch (server->dstaddr.ss_family) { case AF_INET: seq_printf(s, "%pI4", &sa->sin_addr.s_addr); break; case AF_INET6: seq_printf(s, "%pI6", &sa6->sin6_addr.s6_addr); if (sa6->sin6_scope_id) seq_printf(s, "%%%u", sa6->sin6_scope_id); break; default: seq_printf(s, "(unknown)"); } } static void cifs_show_security(struct seq_file *s, struct TCP_Server_Info *server) { seq_printf(s, ",sec="); switch (server->secType) { case LANMAN: seq_printf(s, "lanman"); break; case NTLMv2: seq_printf(s, "ntlmv2"); break; case NTLM: seq_printf(s, "ntlm"); break; case Kerberos: seq_printf(s, "krb5"); break; case RawNTLMSSP: seq_printf(s, "ntlmssp"); break; default: /* shouldn't ever happen */ seq_printf(s, "unknown"); break; } if (server->sec_mode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) seq_printf(s, "i"); } /* * cifs_show_options() is for displaying mount options in /proc/mounts. * Not all settable options are displayed but most of the important * ones are. */ static int cifs_show_options(struct seq_file *s, struct vfsmount *m) { struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb); struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); struct sockaddr *srcaddr; srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; cifs_show_security(s, tcon->ses->server); seq_printf(s, ",unc=%s", tcon->treeName); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER) seq_printf(s, ",multiuser"); else if (tcon->ses->user_name) seq_printf(s, ",username=%s", tcon->ses->user_name); if (tcon->ses->domainName) seq_printf(s, ",domain=%s", tcon->ses->domainName); if (srcaddr->sa_family != AF_UNSPEC) { struct sockaddr_in *saddr4; struct sockaddr_in6 *saddr6; saddr4 = (struct sockaddr_in *)srcaddr; saddr6 = (struct sockaddr_in6 *)srcaddr; if (srcaddr->sa_family == AF_INET6) seq_printf(s, ",srcaddr=%pI6c", &saddr6->sin6_addr); else if (srcaddr->sa_family == AF_INET) seq_printf(s, ",srcaddr=%pI4", &saddr4->sin_addr.s_addr); else seq_printf(s, ",srcaddr=BAD-AF:%i", (int)(srcaddr->sa_family)); } seq_printf(s, ",uid=%d", cifs_sb->mnt_uid); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) seq_printf(s, ",forceuid"); else seq_printf(s, ",noforceuid"); seq_printf(s, ",gid=%d", cifs_sb->mnt_gid); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) seq_printf(s, ",forcegid"); else seq_printf(s, ",noforcegid"); cifs_show_address(s, tcon->ses->server); if (!tcon->unix_ext) seq_printf(s, ",file_mode=0%o,dir_mode=0%o", cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode); if (tcon->seal) seq_printf(s, ",seal"); if (tcon->nocase) seq_printf(s, ",nocase"); if (tcon->retry) seq_printf(s, ",hard"); if (tcon->unix_ext) seq_printf(s, ",unix"); else seq_printf(s, ",nounix"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) seq_printf(s, ",posixpaths"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) seq_printf(s, ",setuids"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) seq_printf(s, ",serverino"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) seq_printf(s, ",rwpidforward"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) seq_printf(s, ",forcemand"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) seq_printf(s, ",directio"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) seq_printf(s, ",nouser_xattr"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) seq_printf(s, ",mapchars"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) seq_printf(s, ",sfu"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) seq_printf(s, ",nobrl"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) seq_printf(s, ",cifsacl"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) seq_printf(s, ",dynperm"); if (m->mnt_sb->s_flags & MS_POSIXACL) seq_printf(s, ",acl"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) seq_printf(s, ",mfsymlinks"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE) seq_printf(s, ",fsc"); seq_printf(s, ",rsize=%d", cifs_sb->rsize); seq_printf(s, ",wsize=%d", cifs_sb->wsize); /* convert actimeo and display it in seconds */ seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ); return 0; } static void cifs_umount_begin(struct super_block *sb) { struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_tcon *tcon; if (cifs_sb == NULL) return; tcon = cifs_sb_master_tcon(cifs_sb); spin_lock(&cifs_tcp_ses_lock); if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) { /* we have other mounts to same share or we have already tried to force umount this and woken up all waiting network requests, nothing to do */ spin_unlock(&cifs_tcp_ses_lock); return; } else if (tcon->tc_count == 1) tcon->tidStatus = CifsExiting; spin_unlock(&cifs_tcp_ses_lock); /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */ /* cancel_notify_requests(tcon); */ if (tcon->ses && tcon->ses->server) { cFYI(1, "wake up tasks now - umount begin not complete"); wake_up_all(&tcon->ses->server->request_q); wake_up_all(&tcon->ses->server->response_q); msleep(1); /* yield */ /* we have to kick the requests once more */ wake_up_all(&tcon->ses->server->response_q); msleep(1); } return; } #ifdef CONFIG_CIFS_STATS2 static int cifs_show_stats(struct seq_file *s, struct vfsmount *mnt) { /* BB FIXME */ return 0; } #endif static int cifs_remount(struct super_block *sb, int *flags, char *data) { *flags |= MS_NODIRATIME; return 0; } static int cifs_drop_inode(struct inode *inode) { struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); /* no serverino => unconditional eviction */ return !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) || generic_drop_inode(inode); } static const struct super_operations cifs_super_ops = { .statfs = cifs_statfs, .alloc_inode = cifs_alloc_inode, .destroy_inode = cifs_destroy_inode, .drop_inode = cifs_drop_inode, .evict_inode = cifs_evict_inode, /* .delete_inode = cifs_delete_inode, */ /* Do not need above function unless later we add lazy close of inodes or unless the kernel forgets to call us with the same number of releases (closes) as opens */ .show_options = cifs_show_options, .umount_begin = cifs_umount_begin, .remount_fs = cifs_remount, #ifdef CONFIG_CIFS_STATS2 .show_stats = cifs_show_stats, #endif }; /* * Get root dentry from superblock according to prefix path mount option. * Return dentry with refcount + 1 on success and NULL otherwise. */ static struct dentry * cifs_get_root(struct smb_vol *vol, struct super_block *sb) { struct dentry *dentry; struct cifs_sb_info *cifs_sb = CIFS_SB(sb); char *full_path = NULL; char *s, *p; char sep; int xid; full_path = cifs_build_path_to_root(vol, cifs_sb, cifs_sb_master_tcon(cifs_sb)); if (full_path == NULL) return ERR_PTR(-ENOMEM); cFYI(1, "Get root dentry for %s", full_path); xid = GetXid(); sep = CIFS_DIR_SEP(cifs_sb); dentry = dget(sb->s_root); p = s = full_path; do { struct inode *dir = dentry->d_inode; struct dentry *child; if (!dir) { dput(dentry); dentry = ERR_PTR(-ENOENT); break; } if (!S_ISDIR(dir->i_mode)) { dput(dentry); dentry = ERR_PTR(-ENOTDIR); break; } /* skip separators */ while (*s == sep) s++; if (!*s) break; p = s++; /* next separator */ while (*s && *s != sep) s++; mutex_lock(&dir->i_mutex); child = lookup_one_len(p, dentry, s - p); mutex_unlock(&dir->i_mutex); dput(dentry); dentry = child; } while (!IS_ERR(dentry)); _FreeXid(xid); kfree(full_path); return dentry; } static int cifs_set_super(struct super_block *sb, void *data) { struct cifs_mnt_data *mnt_data = data; sb->s_fs_info = mnt_data->cifs_sb; return set_anon_super(sb, NULL); } static struct dentry * cifs_do_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { int rc; struct super_block *sb; struct cifs_sb_info *cifs_sb; struct smb_vol *volume_info; struct cifs_mnt_data mnt_data; struct dentry *root; cFYI(1, "Devname: %s flags: %d ", dev_name, flags); volume_info = cifs_get_volume_info((char *)data, dev_name); if (IS_ERR(volume_info)) return ERR_CAST(volume_info); cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL); if (cifs_sb == NULL) { root = ERR_PTR(-ENOMEM); goto out_nls; } cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); if (cifs_sb->mountdata == NULL) { root = ERR_PTR(-ENOMEM); goto out_cifs_sb; } cifs_setup_cifs_sb(volume_info, cifs_sb); rc = cifs_mount(cifs_sb, volume_info); if (rc) { if (!(flags & MS_SILENT)) cERROR(1, "cifs_mount failed w/return code = %d", rc); root = ERR_PTR(rc); goto out_mountdata; } mnt_data.vol = volume_info; mnt_data.cifs_sb = cifs_sb; mnt_data.flags = flags; sb = sget(fs_type, cifs_match_super, cifs_set_super, &mnt_data); if (IS_ERR(sb)) { root = ERR_CAST(sb); cifs_umount(cifs_sb); goto out; } if (sb->s_root) { cFYI(1, "Use existing superblock"); cifs_umount(cifs_sb); } else { sb->s_flags = flags; /* BB should we make this contingent on mount parm? */ sb->s_flags |= MS_NODIRATIME | MS_NOATIME; rc = cifs_read_super(sb); if (rc) { root = ERR_PTR(rc); goto out_super; } sb->s_flags |= MS_ACTIVE; } root = cifs_get_root(volume_info, sb); if (IS_ERR(root)) goto out_super; cFYI(1, "dentry root is: %p", root); goto out; out_super: deactivate_locked_super(sb); out: cifs_cleanup_volume_info(volume_info); return root; out_mountdata: kfree(cifs_sb->mountdata); out_cifs_sb: kfree(cifs_sb); out_nls: unload_nls(volume_info->local_nls); goto out; } static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos) { struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; ssize_t written; int rc; written = generic_file_aio_write(iocb, iov, nr_segs, pos); if (CIFS_I(inode)->clientCanCacheAll) return written; rc = filemap_fdatawrite(inode->i_mapping); if (rc) cFYI(1, "cifs_file_aio_write: %d rc on %p inode", rc, inode); return written; } static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) { /* origin == SEEK_END => we must revalidate the cached file length */ if (origin == SEEK_END) { int rc; struct inode *inode = file->f_path.dentry->d_inode; /* * We need to be sure that all dirty pages are written and the * server has the newest file length. */ if (!CIFS_I(inode)->clientCanCacheRead && inode->i_mapping && inode->i_mapping->nrpages != 0) { rc = filemap_fdatawait(inode->i_mapping); if (rc) { mapping_set_error(inode->i_mapping, rc); return rc; } } /* * Some applications poll for the file length in this strange * way so we must seek to end on non-oplocked files by * setting the revalidate time to zero. */ CIFS_I(inode)->time = 0; rc = cifs_revalidate_file_attr(file); if (rc < 0) return (loff_t)rc; } return generic_file_llseek_unlocked(file, offset, origin); } static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) { /* note that this is called by vfs setlease with lock_flocks held to protect *lease from going away */ struct inode *inode = file->f_path.dentry->d_inode; struct cifsFileInfo *cfile = file->private_data; if (!(S_ISREG(inode->i_mode))) return -EINVAL; /* check if file is oplocked */ if (((arg == F_RDLCK) && (CIFS_I(inode)->clientCanCacheRead)) || ((arg == F_WRLCK) && (CIFS_I(inode)->clientCanCacheAll))) return generic_setlease(file, arg, lease); else if (tlink_tcon(cfile->tlink)->local_lease && !CIFS_I(inode)->clientCanCacheRead) /* If the server claims to support oplock on this file, then we still need to check oplock even if the local_lease mount option is set, but there are servers which do not support oplock for which this mount option may be useful if the user knows that the file won't be changed on the server by anyone else */ return generic_setlease(file, arg, lease); else return -EAGAIN; } struct file_system_type cifs_fs_type = { .owner = THIS_MODULE, .name = "cifs", .mount = cifs_do_mount, .kill_sb = cifs_kill_sb, /* .fs_flags */ }; const struct inode_operations cifs_dir_inode_ops = { .create = cifs_create, .lookup = cifs_lookup, .getattr = cifs_getattr, .unlink = cifs_unlink, .link = cifs_hardlink, .mkdir = cifs_mkdir, .rmdir = cifs_rmdir, .rename = cifs_rename, .permission = cifs_permission, /* revalidate:cifs_revalidate, */ .setattr = cifs_setattr, .symlink = cifs_symlink, .mknod = cifs_mknod, #ifdef CONFIG_CIFS_XATTR .setxattr = cifs_setxattr, .getxattr = cifs_getxattr, .listxattr = cifs_listxattr, .removexattr = cifs_removexattr, #endif }; const struct inode_operations cifs_file_inode_ops = { /* revalidate:cifs_revalidate, */ .setattr = cifs_setattr, .getattr = cifs_getattr, /* do we need this anymore? */ .rename = cifs_rename, .permission = cifs_permission, #ifdef CONFIG_CIFS_XATTR .setxattr = cifs_setxattr, .getxattr = cifs_getxattr, .listxattr = cifs_listxattr, .removexattr = cifs_removexattr, #endif }; const struct inode_operations cifs_symlink_inode_ops = { .readlink = generic_readlink, .follow_link = cifs_follow_link, .put_link = cifs_put_link, .permission = cifs_permission, /* BB add the following two eventually */ /* revalidate: cifs_revalidate, setattr: cifs_notify_change, *//* BB do we need notify change */ #ifdef CONFIG_CIFS_XATTR .setxattr = cifs_setxattr, .getxattr = cifs_getxattr, .listxattr = cifs_listxattr, .removexattr = cifs_removexattr, #endif }; const struct file_operations cifs_file_ops = { .read = do_sync_read, .write = do_sync_write, .aio_read = generic_file_aio_read, .aio_write = cifs_file_aio_write, .open = cifs_open, .release = cifs_close, .lock = cifs_lock, .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, .splice_read = generic_file_splice_read, .llseek = cifs_llseek, #ifdef CONFIG_CIFS_POSIX .unlocked_ioctl = cifs_ioctl, #endif /* CONFIG_CIFS_POSIX */ .setlease = cifs_setlease, }; const struct file_operations cifs_file_strict_ops = { .read = do_sync_read, .write = do_sync_write, .aio_read = cifs_strict_readv, .aio_write = cifs_strict_writev, .open = cifs_open, .release = cifs_close, .lock = cifs_lock, .fsync = cifs_strict_fsync, .flush = cifs_flush, .mmap = cifs_file_strict_mmap, .splice_read = generic_file_splice_read, .llseek = cifs_llseek, #ifdef CONFIG_CIFS_POSIX .unlocked_ioctl = cifs_ioctl, #endif /* CONFIG_CIFS_POSIX */ .setlease = cifs_setlease, }; const struct file_operations cifs_file_direct_ops = { /* BB reevaluate whether they can be done with directio, no cache */ .read = do_sync_read, .write = do_sync_write, .aio_read = cifs_user_readv, .aio_write = cifs_user_writev, .open = cifs_open, .release = cifs_close, .lock = cifs_lock, .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, .splice_read = generic_file_splice_read, #ifdef CONFIG_CIFS_POSIX .unlocked_ioctl = cifs_ioctl, #endif /* CONFIG_CIFS_POSIX */ .llseek = cifs_llseek, .setlease = cifs_setlease, }; const struct file_operations cifs_file_nobrl_ops = { .read = do_sync_read, .write = do_sync_write, .aio_read = generic_file_aio_read, .aio_write = cifs_file_aio_write, .open = cifs_open, .release = cifs_close, .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, .splice_read = generic_file_splice_read, .llseek = cifs_llseek, #ifdef CONFIG_CIFS_POSIX .unlocked_ioctl = cifs_ioctl, #endif /* CONFIG_CIFS_POSIX */ .setlease = cifs_setlease, }; const struct file_operations cifs_file_strict_nobrl_ops = { .read = do_sync_read, .write = do_sync_write, .aio_read = cifs_strict_readv, .aio_write = cifs_strict_writev, .open = cifs_open, .release = cifs_close, .fsync = cifs_strict_fsync, .flush = cifs_flush, .mmap = cifs_file_strict_mmap, .splice_read = generic_file_splice_read, .llseek = cifs_llseek, #ifdef CONFIG_CIFS_POSIX .unlocked_ioctl = cifs_ioctl, #endif /* CONFIG_CIFS_POSIX */ .setlease = cifs_setlease, }; const struct file_operations cifs_file_direct_nobrl_ops = { /* BB reevaluate whether they can be done with directio, no cache */ .read = do_sync_read, .write = do_sync_write, .aio_read = cifs_user_readv, .aio_write = cifs_user_writev, .open = cifs_open, .release = cifs_close, .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, .splice_read = generic_file_splice_read, #ifdef CONFIG_CIFS_POSIX .unlocked_ioctl = cifs_ioctl, #endif /* CONFIG_CIFS_POSIX */ .llseek = cifs_llseek, .setlease = cifs_setlease, }; const struct file_operations cifs_dir_ops = { .readdir = cifs_readdir, .release = cifs_closedir, .read = generic_read_dir, .unlocked_ioctl = cifs_ioctl, .llseek = generic_file_llseek, }; static void cifs_init_once(void *inode) { struct cifsInodeInfo *cifsi = inode; inode_init_once(&cifsi->vfs_inode); INIT_LIST_HEAD(&cifsi->lockList); } static int cifs_init_inodecache(void) { cifs_inode_cachep = kmem_cache_create("cifs_inode_cache", sizeof(struct cifsInodeInfo), 0, (SLAB_RECLAIM_ACCOUNT| SLAB_MEM_SPREAD), cifs_init_once); if (cifs_inode_cachep == NULL) return -ENOMEM; return 0; } static void cifs_destroy_inodecache(void) { kmem_cache_destroy(cifs_inode_cachep); } static int cifs_init_request_bufs(void) { if (CIFSMaxBufSize < 8192) { /* Buffer size can not be smaller than 2 * PATH_MAX since maximum Unicode path name has to fit in any SMB/CIFS path based frames */ CIFSMaxBufSize = 8192; } else if (CIFSMaxBufSize > 1024*127) { CIFSMaxBufSize = 1024 * 127; } else { CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/ } /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */ cifs_req_cachep = kmem_cache_create("cifs_request", CIFSMaxBufSize + MAX_CIFS_HDR_SIZE, 0, SLAB_HWCACHE_ALIGN, NULL); if (cifs_req_cachep == NULL) return -ENOMEM; if (cifs_min_rcv < 1) cifs_min_rcv = 1; else if (cifs_min_rcv > 64) { cifs_min_rcv = 64; cERROR(1, "cifs_min_rcv set to maximum (64)"); } cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv, cifs_req_cachep); if (cifs_req_poolp == NULL) { kmem_cache_destroy(cifs_req_cachep); return -ENOMEM; } /* MAX_CIFS_SMALL_BUFFER_SIZE bytes is enough for most SMB responses and almost all handle based requests (but not write response, nor is it sufficient for path based requests). A smaller size would have been more efficient (compacting multiple slab items on one 4k page) for the case in which debug was on, but this larger size allows more SMBs to use small buffer alloc and is still much more efficient to alloc 1 per page off the slab compared to 17K (5page) alloc of large cifs buffers even when page debugging is on */ cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq", MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN, NULL); if (cifs_sm_req_cachep == NULL) { mempool_destroy(cifs_req_poolp); kmem_cache_destroy(cifs_req_cachep); return -ENOMEM; } if (cifs_min_small < 2) cifs_min_small = 2; else if (cifs_min_small > 256) { cifs_min_small = 256; cFYI(1, "cifs_min_small set to maximum (256)"); } cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small, cifs_sm_req_cachep); if (cifs_sm_req_poolp == NULL) { mempool_destroy(cifs_req_poolp); kmem_cache_destroy(cifs_req_cachep); kmem_cache_destroy(cifs_sm_req_cachep); return -ENOMEM; } return 0; } static void cifs_destroy_request_bufs(void) { mempool_destroy(cifs_req_poolp); kmem_cache_destroy(cifs_req_cachep); mempool_destroy(cifs_sm_req_poolp); kmem_cache_destroy(cifs_sm_req_cachep); } static int cifs_init_mids(void) { cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids", sizeof(struct mid_q_entry), 0, SLAB_HWCACHE_ALIGN, NULL); if (cifs_mid_cachep == NULL) return -ENOMEM; /* 3 is a reasonable minimum number of simultaneous operations */ cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep); if (cifs_mid_poolp == NULL) { kmem_cache_destroy(cifs_mid_cachep); return -ENOMEM; } return 0; } static void cifs_destroy_mids(void) { mempool_destroy(cifs_mid_poolp); kmem_cache_destroy(cifs_mid_cachep); } static int __init init_cifs(void) { int rc = 0; cifs_proc_init(); INIT_LIST_HEAD(&cifs_tcp_ses_list); #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */ INIT_LIST_HEAD(&GlobalDnotifyReqList); INIT_LIST_HEAD(&GlobalDnotifyRsp_Q); #endif /* was needed for dnotify, and will be needed for inotify when VFS fix */ /* * Initialize Global counters */ atomic_set(&sesInfoAllocCount, 0); atomic_set(&tconInfoAllocCount, 0); atomic_set(&tcpSesAllocCount, 0); atomic_set(&tcpSesReconnectCount, 0); atomic_set(&tconInfoReconnectCount, 0); atomic_set(&bufAllocCount, 0); atomic_set(&smBufAllocCount, 0); #ifdef CONFIG_CIFS_STATS2 atomic_set(&totBufAllocCount, 0); atomic_set(&totSmBufAllocCount, 0); #endif /* CONFIG_CIFS_STATS2 */ atomic_set(&midCount, 0); GlobalCurrentXid = 0; GlobalTotalActiveXid = 0; GlobalMaxActiveXid = 0; spin_lock_init(&cifs_tcp_ses_lock); spin_lock_init(&cifs_file_list_lock); spin_lock_init(&GlobalMid_Lock); if (cifs_max_pending < 2) { cifs_max_pending = 2; cFYI(1, "cifs_max_pending set to min of 2"); } else if (cifs_max_pending > 256) { cifs_max_pending = 256; cFYI(1, "cifs_max_pending set to max of 256"); } rc = cifs_fscache_register(); if (rc) goto out_clean_proc; rc = cifs_init_inodecache(); if (rc) goto out_unreg_fscache; rc = cifs_init_mids(); if (rc) goto out_destroy_inodecache; rc = cifs_init_request_bufs(); if (rc) goto out_destroy_mids; #ifdef CONFIG_CIFS_UPCALL rc = register_key_type(&cifs_spnego_key_type); if (rc) goto out_destroy_request_bufs; #endif /* CONFIG_CIFS_UPCALL */ #ifdef CONFIG_CIFS_ACL rc = init_cifs_idmap(); if (rc) goto out_register_key_type; #endif /* CONFIG_CIFS_ACL */ rc = register_filesystem(&cifs_fs_type); if (rc) goto out_init_cifs_idmap; return 0; out_init_cifs_idmap: #ifdef CONFIG_CIFS_ACL exit_cifs_idmap(); out_register_key_type: #endif #ifdef CONFIG_CIFS_UPCALL unregister_key_type(&cifs_spnego_key_type); out_destroy_request_bufs: #endif cifs_destroy_request_bufs(); out_destroy_mids: cifs_destroy_mids(); out_destroy_inodecache: cifs_destroy_inodecache(); out_unreg_fscache: cifs_fscache_unregister(); out_clean_proc: cifs_proc_clean(); return rc; } static void __exit exit_cifs(void) { cFYI(DBG2, "exit_cifs"); cifs_proc_clean(); cifs_fscache_unregister(); #ifdef CONFIG_CIFS_DFS_UPCALL cifs_dfs_release_automount_timer(); #endif #ifdef CONFIG_CIFS_ACL cifs_destroy_idmaptrees(); exit_cifs_idmap(); #endif #ifdef CONFIG_CIFS_UPCALL unregister_key_type(&cifs_spnego_key_type); #endif unregister_filesystem(&cifs_fs_type); cifs_destroy_inodecache(); cifs_destroy_mids(); cifs_destroy_request_bufs(); } MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>"); MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */ MODULE_DESCRIPTION ("VFS to access servers complying with the SNIA CIFS Specification " "e.g. Samba and Windows"); MODULE_VERSION(CIFS_VERSION); module_init(init_cifs) module_exit(exit_cifs)
gpl-2.0
priyatransbit/linux
drivers/media/media-entity.c
630
18390
/* * Media entity * * Copyright (C) 2010 Nokia Corporation * * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> * Sakari Ailus <sakari.ailus@iki.fi> * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/bitmap.h> #include <linux/module.h> #include <linux/slab.h> #include <media/media-entity.h> #include <media/media-device.h> /** * media_entity_init - Initialize a media entity * * @num_pads: Total number of sink and source pads. * @extra_links: Initial estimate of the number of extra links. * @pads: Array of 'num_pads' pads. * * The total number of pads is an intrinsic property of entities known by the * entity driver, while the total number of links depends on hardware design * and is an extrinsic property unknown to the entity driver. However, in most * use cases the entity driver can guess the number of links which can safely * be assumed to be equal to or larger than the number of pads. * * For those reasons the links array can be preallocated based on the entity * driver guess and will be reallocated later if extra links need to be * created. * * This function allocates a links array with enough space to hold at least * 'num_pads' + 'extra_links' elements. The media_entity::max_links field will * be set to the number of allocated elements. * * The pads array is managed by the entity driver and passed to * media_entity_init() where its pointer will be stored in the entity structure. */ int media_entity_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads, u16 extra_links) { struct media_link *links; unsigned int max_links = num_pads + extra_links; unsigned int i; links = kzalloc(max_links * sizeof(links[0]), GFP_KERNEL); if (links == NULL) return -ENOMEM; entity->group_id = 0; entity->max_links = max_links; entity->num_links = 0; entity->num_backlinks = 0; entity->num_pads = num_pads; entity->pads = pads; entity->links = links; for (i = 0; i < num_pads; i++) { pads[i].entity = entity; pads[i].index = i; } return 0; } EXPORT_SYMBOL_GPL(media_entity_init); void media_entity_cleanup(struct media_entity *entity) { kfree(entity->links); } EXPORT_SYMBOL_GPL(media_entity_cleanup); /* ----------------------------------------------------------------------------- * Graph traversal */ static struct media_entity * media_entity_other(struct media_entity *entity, struct media_link *link) { if (link->source->entity == entity) return link->sink->entity; else return link->source->entity; } /* push an entity to traversal stack */ static void stack_push(struct media_entity_graph *graph, struct media_entity *entity) { if (graph->top == MEDIA_ENTITY_ENUM_MAX_DEPTH - 1) { WARN_ON(1); return; } graph->top++; graph->stack[graph->top].link = 0; graph->stack[graph->top].entity = entity; } static struct media_entity *stack_pop(struct media_entity_graph *graph) { struct media_entity *entity; entity = graph->stack[graph->top].entity; graph->top--; return entity; } #define link_top(en) ((en)->stack[(en)->top].link) #define stack_top(en) ((en)->stack[(en)->top].entity) /** * media_entity_graph_walk_start - Start walking the media graph at a given entity * @graph: Media graph structure that will be used to walk the graph * @entity: Starting entity * * This function initializes the graph traversal structure to walk the entities * graph starting at the given entity. The traversal structure must not be * modified by the caller during graph traversal. When done the structure can * safely be freed. */ void media_entity_graph_walk_start(struct media_entity_graph *graph, struct media_entity *entity) { graph->top = 0; graph->stack[graph->top].entity = NULL; bitmap_zero(graph->entities, MEDIA_ENTITY_ENUM_MAX_ID); if (WARN_ON(entity->id >= MEDIA_ENTITY_ENUM_MAX_ID)) return; __set_bit(entity->id, graph->entities); stack_push(graph, entity); } EXPORT_SYMBOL_GPL(media_entity_graph_walk_start); /** * media_entity_graph_walk_next - Get the next entity in the graph * @graph: Media graph structure * * Perform a depth-first traversal of the given media entities graph. * * The graph structure must have been previously initialized with a call to * media_entity_graph_walk_start(). * * Return the next entity in the graph or NULL if the whole graph have been * traversed. */ struct media_entity * media_entity_graph_walk_next(struct media_entity_graph *graph) { if (stack_top(graph) == NULL) return NULL; /* * Depth first search. Push entity to stack and continue from * top of the stack until no more entities on the level can be * found. */ while (link_top(graph) < stack_top(graph)->num_links) { struct media_entity *entity = stack_top(graph); struct media_link *link = &entity->links[link_top(graph)]; struct media_entity *next; /* The link is not enabled so we do not follow. */ if (!(link->flags & MEDIA_LNK_FL_ENABLED)) { link_top(graph)++; continue; } /* Get the entity in the other end of the link . */ next = media_entity_other(entity, link); if (WARN_ON(next->id >= MEDIA_ENTITY_ENUM_MAX_ID)) return NULL; /* Has the entity already been visited? */ if (__test_and_set_bit(next->id, graph->entities)) { link_top(graph)++; continue; } /* Push the new entity to stack and start over. */ link_top(graph)++; stack_push(graph, next); } return stack_pop(graph); } EXPORT_SYMBOL_GPL(media_entity_graph_walk_next); /* ----------------------------------------------------------------------------- * Pipeline management */ /** * media_entity_pipeline_start - Mark a pipeline as streaming * @entity: Starting entity * @pipe: Media pipeline to be assigned to all entities in the pipeline. * * Mark all entities connected to a given entity through enabled links, either * directly or indirectly, as streaming. The given pipeline object is assigned to * every entity in the pipeline and stored in the media_entity pipe field. * * Calls to this function can be nested, in which case the same number of * media_entity_pipeline_stop() calls will be required to stop streaming. The * pipeline pointer must be identical for all nested calls to * media_entity_pipeline_start(). */ __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe) { struct media_device *mdev = entity->parent; struct media_entity_graph graph; struct media_entity *entity_err = entity; int ret; mutex_lock(&mdev->graph_mutex); media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { DECLARE_BITMAP(active, entity->num_pads); DECLARE_BITMAP(has_no_links, entity->num_pads); unsigned int i; entity->stream_count++; WARN_ON(entity->pipe && entity->pipe != pipe); entity->pipe = pipe; /* Already streaming --- no need to check. */ if (entity->stream_count > 1) continue; if (!entity->ops || !entity->ops->link_validate) continue; bitmap_zero(active, entity->num_pads); bitmap_fill(has_no_links, entity->num_pads); for (i = 0; i < entity->num_links; i++) { struct media_link *link = &entity->links[i]; struct media_pad *pad = link->sink->entity == entity ? link->sink : link->source; /* Mark that a pad is connected by a link. */ bitmap_clear(has_no_links, pad->index, 1); /* * Pads that either do not need to connect or * are connected through an enabled link are * fine. */ if (!(pad->flags & MEDIA_PAD_FL_MUST_CONNECT) || link->flags & MEDIA_LNK_FL_ENABLED) bitmap_set(active, pad->index, 1); /* * Link validation will only take place for * sink ends of the link that are enabled. */ if (link->sink != pad || !(link->flags & MEDIA_LNK_FL_ENABLED)) continue; ret = entity->ops->link_validate(link); if (ret < 0 && ret != -ENOIOCTLCMD) { dev_dbg(entity->parent->dev, "link validation failed for \"%s\":%u -> \"%s\":%u, error %d\n", entity->name, link->source->index, link->sink->entity->name, link->sink->index, ret); goto error; } } /* Either no links or validated links are fine. */ bitmap_or(active, active, has_no_links, entity->num_pads); if (!bitmap_full(active, entity->num_pads)) { ret = -EPIPE; dev_dbg(entity->parent->dev, "\"%s\":%u must be connected by an enabled link\n", entity->name, (unsigned)find_first_zero_bit( active, entity->num_pads)); goto error; } } mutex_unlock(&mdev->graph_mutex); return 0; error: /* * Link validation on graph failed. We revert what we did and * return the error. */ media_entity_graph_walk_start(&graph, entity_err); while ((entity_err = media_entity_graph_walk_next(&graph))) { entity_err->stream_count--; if (entity_err->stream_count == 0) entity_err->pipe = NULL; /* * We haven't increased stream_count further than this * so we quit here. */ if (entity_err == entity) break; } mutex_unlock(&mdev->graph_mutex); return ret; } EXPORT_SYMBOL_GPL(media_entity_pipeline_start); /** * media_entity_pipeline_stop - Mark a pipeline as not streaming * @entity: Starting entity * * Mark all entities connected to a given entity through enabled links, either * directly or indirectly, as not streaming. The media_entity pipe field is * reset to NULL. * * If multiple calls to media_entity_pipeline_start() have been made, the same * number of calls to this function are required to mark the pipeline as not * streaming. */ void media_entity_pipeline_stop(struct media_entity *entity) { struct media_device *mdev = entity->parent; struct media_entity_graph graph; mutex_lock(&mdev->graph_mutex); media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { entity->stream_count--; if (entity->stream_count == 0) entity->pipe = NULL; } mutex_unlock(&mdev->graph_mutex); } EXPORT_SYMBOL_GPL(media_entity_pipeline_stop); /* ----------------------------------------------------------------------------- * Module use count */ /* * media_entity_get - Get a reference to the parent module * @entity: The entity * * Get a reference to the parent media device module. * * The function will return immediately if @entity is NULL. * * Return a pointer to the entity on success or NULL on failure. */ struct media_entity *media_entity_get(struct media_entity *entity) { if (entity == NULL) return NULL; if (entity->parent->dev && !try_module_get(entity->parent->dev->driver->owner)) return NULL; return entity; } EXPORT_SYMBOL_GPL(media_entity_get); /* * media_entity_put - Release the reference to the parent module * @entity: The entity * * Release the reference count acquired by media_entity_get(). * * The function will return immediately if @entity is NULL. */ void media_entity_put(struct media_entity *entity) { if (entity == NULL) return; if (entity->parent->dev) module_put(entity->parent->dev->driver->owner); } EXPORT_SYMBOL_GPL(media_entity_put); /* ----------------------------------------------------------------------------- * Links management */ static struct media_link *media_entity_add_link(struct media_entity *entity) { if (entity->num_links >= entity->max_links) { struct media_link *links = entity->links; unsigned int max_links = entity->max_links + 2; unsigned int i; links = krealloc(links, max_links * sizeof(*links), GFP_KERNEL); if (links == NULL) return NULL; for (i = 0; i < entity->num_links; i++) links[i].reverse->reverse = &links[i]; entity->max_links = max_links; entity->links = links; } return &entity->links[entity->num_links++]; } int media_entity_create_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, u16 sink_pad, u32 flags) { struct media_link *link; struct media_link *backlink; BUG_ON(source == NULL || sink == NULL); BUG_ON(source_pad >= source->num_pads); BUG_ON(sink_pad >= sink->num_pads); link = media_entity_add_link(source); if (link == NULL) return -ENOMEM; link->source = &source->pads[source_pad]; link->sink = &sink->pads[sink_pad]; link->flags = flags; /* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ backlink = media_entity_add_link(sink); if (backlink == NULL) { source->num_links--; return -ENOMEM; } backlink->source = &source->pads[source_pad]; backlink->sink = &sink->pads[sink_pad]; backlink->flags = flags; link->reverse = backlink; backlink->reverse = link; sink->num_backlinks++; return 0; } EXPORT_SYMBOL_GPL(media_entity_create_link); void __media_entity_remove_links(struct media_entity *entity) { unsigned int i; for (i = 0; i < entity->num_links; i++) { struct media_link *link = &entity->links[i]; struct media_entity *remote; unsigned int r = 0; if (link->source->entity == entity) remote = link->sink->entity; else remote = link->source->entity; while (r < remote->num_links) { struct media_link *rlink = &remote->links[r]; if (rlink != link->reverse) { r++; continue; } if (link->source->entity == entity) remote->num_backlinks--; if (--remote->num_links == 0) break; /* Insert last entry in place of the dropped link. */ *rlink = remote->links[remote->num_links]; } } entity->num_links = 0; entity->num_backlinks = 0; } EXPORT_SYMBOL_GPL(__media_entity_remove_links); void media_entity_remove_links(struct media_entity *entity) { /* Do nothing if the entity is not registered. */ if (entity->parent == NULL) return; mutex_lock(&entity->parent->graph_mutex); __media_entity_remove_links(entity); mutex_unlock(&entity->parent->graph_mutex); } EXPORT_SYMBOL_GPL(media_entity_remove_links); static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) { int ret; /* Notify both entities. */ ret = media_entity_call(link->source->entity, link_setup, link->source, link->sink, flags); if (ret < 0 && ret != -ENOIOCTLCMD) return ret; ret = media_entity_call(link->sink->entity, link_setup, link->sink, link->source, flags); if (ret < 0 && ret != -ENOIOCTLCMD) { media_entity_call(link->source->entity, link_setup, link->source, link->sink, link->flags); return ret; } link->flags = flags; link->reverse->flags = link->flags; return 0; } /** * __media_entity_setup_link - Configure a media link * @link: The link being configured * @flags: Link configuration flags * * The bulk of link setup is handled by the two entities connected through the * link. This function notifies both entities of the link configuration change. * * If the link is immutable or if the current and new configuration are * identical, return immediately. * * The user is expected to hold link->source->parent->mutex. If not, * media_entity_setup_link() should be used instead. */ int __media_entity_setup_link(struct media_link *link, u32 flags) { const u32 mask = MEDIA_LNK_FL_ENABLED; struct media_device *mdev; struct media_entity *source, *sink; int ret = -EBUSY; if (link == NULL) return -EINVAL; /* The non-modifiable link flags must not be modified. */ if ((link->flags & ~mask) != (flags & ~mask)) return -EINVAL; if (link->flags & MEDIA_LNK_FL_IMMUTABLE) return link->flags == flags ? 0 : -EINVAL; if (link->flags == flags) return 0; source = link->source->entity; sink = link->sink->entity; if (!(link->flags & MEDIA_LNK_FL_DYNAMIC) && (source->stream_count || sink->stream_count)) return -EBUSY; mdev = source->parent; if (mdev->link_notify) { ret = mdev->link_notify(link, flags, MEDIA_DEV_NOTIFY_PRE_LINK_CH); if (ret < 0) return ret; } ret = __media_entity_setup_link_notify(link, flags); if (mdev->link_notify) mdev->link_notify(link, flags, MEDIA_DEV_NOTIFY_POST_LINK_CH); return ret; } int media_entity_setup_link(struct media_link *link, u32 flags) { int ret; mutex_lock(&link->source->entity->parent->graph_mutex); ret = __media_entity_setup_link(link, flags); mutex_unlock(&link->source->entity->parent->graph_mutex); return ret; } EXPORT_SYMBOL_GPL(media_entity_setup_link); /** * media_entity_find_link - Find a link between two pads * @source: Source pad * @sink: Sink pad * * Return a pointer to the link between the two entities. If no such link * exists, return NULL. */ struct media_link * media_entity_find_link(struct media_pad *source, struct media_pad *sink) { struct media_link *link; unsigned int i; for (i = 0; i < source->entity->num_links; ++i) { link = &source->entity->links[i]; if (link->source->entity == source->entity && link->source->index == source->index && link->sink->entity == sink->entity && link->sink->index == sink->index) return link; } return NULL; } EXPORT_SYMBOL_GPL(media_entity_find_link); /** * media_entity_remote_pad - Find the pad at the remote end of a link * @pad: Pad at the local end of the link * * Search for a remote pad connected to the given pad by iterating over all * links originating or terminating at that pad until an enabled link is found. * * Return a pointer to the pad at the remote end of the first found enabled * link, or NULL if no enabled link has been found. */ struct media_pad *media_entity_remote_pad(struct media_pad *pad) { unsigned int i; for (i = 0; i < pad->entity->num_links; i++) { struct media_link *link = &pad->entity->links[i]; if (!(link->flags & MEDIA_LNK_FL_ENABLED)) continue; if (link->source == pad) return link->sink; if (link->sink == pad) return link->source; } return NULL; } EXPORT_SYMBOL_GPL(media_entity_remote_pad);
gpl-2.0
bensonhsu2013/diff_variant_i8160
drivers/infiniband/hw/qib/qib_pcie.c
886
20562
/* * Copyright (c) 2008, 2009 QLogic Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <linux/pci.h> #include <linux/io.h> #include <linux/delay.h> #include <linux/vmalloc.h> #include <linux/aer.h> #include "qib.h" /* * This file contains PCIe utility routines that are common to the * various QLogic InfiniPath adapters */ /* * Code to adjust PCIe capabilities. * To minimize the change footprint, we call it * from qib_pcie_params, which every chip-specific * file calls, even though this violates some * expectations of harmlessness. */ static int qib_tune_pcie_caps(struct qib_devdata *); static int qib_tune_pcie_coalesce(struct qib_devdata *); /* * Do all the common PCIe setup and initialization. * devdata is not yet allocated, and is not allocated until after this * routine returns success. Therefore qib_dev_err() can't be used for error * printing. */ int qib_pcie_init(struct pci_dev *pdev, const struct pci_device_id *ent) { int ret; ret = pci_enable_device(pdev); if (ret) { /* * This can happen (in theory) iff: * We did a chip reset, and then failed to reprogram the * BAR, or the chip reset due to an internal error. We then * unloaded the driver and reloaded it. * * Both reset cases set the BAR back to initial state. For * the latter case, the AER sticky error bit at offset 0x718 * should be set, but the Linux kernel doesn't yet know * about that, it appears. If the original BAR was retained * in the kernel data structures, this may be OK. */ qib_early_err(&pdev->dev, "pci enable failed: error %d\n", -ret); goto done; } ret = pci_request_regions(pdev, QIB_DRV_NAME); if (ret) { qib_devinfo(pdev, "pci_request_regions fails: err %d\n", -ret); goto bail; } ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); if (ret) { /* * If the 64 bit setup fails, try 32 bit. Some systems * do not setup 64 bit maps on systems with 2GB or less * memory installed. */ ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); if (ret) { qib_devinfo(pdev, "Unable to set DMA mask: %d\n", ret); goto bail; } ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); } else ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); if (ret) qib_early_err(&pdev->dev, "Unable to set DMA consistent mask: %d\n", ret); pci_set_master(pdev); ret = pci_enable_pcie_error_reporting(pdev); if (ret) qib_early_err(&pdev->dev, "Unable to enable pcie error reporting: %d\n", ret); goto done; bail: pci_disable_device(pdev); pci_release_regions(pdev); done: return ret; } /* * Do remaining PCIe setup, once dd is allocated, and save away * fields required to re-initialize after a chip reset, or for * various other purposes */ int qib_pcie_ddinit(struct qib_devdata *dd, struct pci_dev *pdev, const struct pci_device_id *ent) { unsigned long len; resource_size_t addr; dd->pcidev = pdev; pci_set_drvdata(pdev, dd); addr = pci_resource_start(pdev, 0); len = pci_resource_len(pdev, 0); #if defined(__powerpc__) /* There isn't a generic way to specify writethrough mappings */ dd->kregbase = __ioremap(addr, len, _PAGE_NO_CACHE | _PAGE_WRITETHRU); #else dd->kregbase = ioremap_nocache(addr, len); #endif if (!dd->kregbase) return -ENOMEM; dd->kregend = (u64 __iomem *)((void __iomem *) dd->kregbase + len); dd->physaddr = addr; /* used for io_remap, etc. */ /* * Save BARs to rewrite after device reset. Save all 64 bits of * BAR, just in case. */ dd->pcibar0 = addr; dd->pcibar1 = addr >> 32; dd->deviceid = ent->device; /* save for later use */ dd->vendorid = ent->vendor; return 0; } /* * Do PCIe cleanup, after chip-specific cleanup, etc. Just prior * to releasing the dd memory. * void because none of the core pcie cleanup returns are void */ void qib_pcie_ddcleanup(struct qib_devdata *dd) { u64 __iomem *base = (void __iomem *) dd->kregbase; dd->kregbase = NULL; iounmap(base); if (dd->piobase) iounmap(dd->piobase); if (dd->userbase) iounmap(dd->userbase); if (dd->piovl15base) iounmap(dd->piovl15base); pci_disable_device(dd->pcidev); pci_release_regions(dd->pcidev); pci_set_drvdata(dd->pcidev, NULL); } static void qib_msix_setup(struct qib_devdata *dd, int pos, u32 *msixcnt, struct msix_entry *msix_entry) { int ret; u32 tabsize = 0; u16 msix_flags; pci_read_config_word(dd->pcidev, pos + PCI_MSIX_FLAGS, &msix_flags); tabsize = 1 + (msix_flags & PCI_MSIX_FLAGS_QSIZE); if (tabsize > *msixcnt) tabsize = *msixcnt; ret = pci_enable_msix(dd->pcidev, msix_entry, tabsize); if (ret > 0) { tabsize = ret; ret = pci_enable_msix(dd->pcidev, msix_entry, tabsize); } if (ret) { qib_dev_err(dd, "pci_enable_msix %d vectors failed: %d, " "falling back to INTx\n", tabsize, ret); tabsize = 0; } *msixcnt = tabsize; if (ret) qib_enable_intx(dd->pcidev); } /** * We save the msi lo and hi values, so we can restore them after * chip reset (the kernel PCI infrastructure doesn't yet handle that * correctly. */ static int qib_msi_setup(struct qib_devdata *dd, int pos) { struct pci_dev *pdev = dd->pcidev; u16 control; int ret; ret = pci_enable_msi(pdev); if (ret) qib_dev_err(dd, "pci_enable_msi failed: %d, " "interrupts may not work\n", ret); /* continue even if it fails, we may still be OK... */ pci_read_config_dword(pdev, pos + PCI_MSI_ADDRESS_LO, &dd->msi_lo); pci_read_config_dword(pdev, pos + PCI_MSI_ADDRESS_HI, &dd->msi_hi); pci_read_config_word(pdev, pos + PCI_MSI_FLAGS, &control); /* now save the data (vector) info */ pci_read_config_word(pdev, pos + ((control & PCI_MSI_FLAGS_64BIT) ? 12 : 8), &dd->msi_data); return ret; } int qib_pcie_params(struct qib_devdata *dd, u32 minw, u32 *nent, struct msix_entry *entry) { u16 linkstat, speed; int pos = 0, pose, ret = 1; pose = pci_find_capability(dd->pcidev, PCI_CAP_ID_EXP); if (!pose) { qib_dev_err(dd, "Can't find PCI Express capability!\n"); /* set up something... */ dd->lbus_width = 1; dd->lbus_speed = 2500; /* Gen1, 2.5GHz */ goto bail; } pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_MSIX); if (nent && *nent && pos) { qib_msix_setup(dd, pos, nent, entry); ret = 0; /* did it, either MSIx or INTx */ } else { pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_MSI); if (pos) ret = qib_msi_setup(dd, pos); else qib_dev_err(dd, "No PCI MSI or MSIx capability!\n"); } if (!pos) qib_enable_intx(dd->pcidev); pci_read_config_word(dd->pcidev, pose + PCI_EXP_LNKSTA, &linkstat); /* * speed is bits 0-3, linkwidth is bits 4-8 * no defines for them in headers */ speed = linkstat & 0xf; linkstat >>= 4; linkstat &= 0x1f; dd->lbus_width = linkstat; switch (speed) { case 1: dd->lbus_speed = 2500; /* Gen1, 2.5GHz */ break; case 2: dd->lbus_speed = 5000; /* Gen1, 5GHz */ break; default: /* not defined, assume gen1 */ dd->lbus_speed = 2500; break; } /* * Check against expected pcie width and complain if "wrong" * on first initialization, not afterwards (i.e., reset). */ if (minw && linkstat < minw) qib_dev_err(dd, "PCIe width %u (x%u HCA), performance reduced\n", linkstat, minw); qib_tune_pcie_caps(dd); qib_tune_pcie_coalesce(dd); bail: /* fill in string, even on errors */ snprintf(dd->lbus_info, sizeof(dd->lbus_info), "PCIe,%uMHz,x%u\n", dd->lbus_speed, dd->lbus_width); return ret; } /* * Setup pcie interrupt stuff again after a reset. I'd like to just call * pci_enable_msi() again for msi, but when I do that, * the MSI enable bit doesn't get set in the command word, and * we switch to to a different interrupt vector, which is confusing, * so I instead just do it all inline. Perhaps somehow can tie this * into the PCIe hotplug support at some point */ int qib_reinit_intr(struct qib_devdata *dd) { int pos; u16 control; int ret = 0; /* If we aren't using MSI, don't restore it */ if (!dd->msi_lo) goto bail; pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_MSI); if (!pos) { qib_dev_err(dd, "Can't find MSI capability, " "can't restore MSI settings\n"); ret = 0; /* nothing special for MSIx, just MSI */ goto bail; } pci_write_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_LO, dd->msi_lo); pci_write_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_HI, dd->msi_hi); pci_read_config_word(dd->pcidev, pos + PCI_MSI_FLAGS, &control); if (!(control & PCI_MSI_FLAGS_ENABLE)) { control |= PCI_MSI_FLAGS_ENABLE; pci_write_config_word(dd->pcidev, pos + PCI_MSI_FLAGS, control); } /* now rewrite the data (vector) info */ pci_write_config_word(dd->pcidev, pos + ((control & PCI_MSI_FLAGS_64BIT) ? 12 : 8), dd->msi_data); ret = 1; bail: if (!ret && (dd->flags & QIB_HAS_INTX)) { qib_enable_intx(dd->pcidev); ret = 1; } /* and now set the pci master bit again */ pci_set_master(dd->pcidev); return ret; } /* * Disable msi interrupt if enabled, and clear msi_lo. * This is used primarily for the fallback to INTx, but * is also used in reinit after reset, and during cleanup. */ void qib_nomsi(struct qib_devdata *dd) { dd->msi_lo = 0; pci_disable_msi(dd->pcidev); } /* * Same as qib_nosmi, but for MSIx. */ void qib_nomsix(struct qib_devdata *dd) { pci_disable_msix(dd->pcidev); } /* * Similar to pci_intx(pdev, 1), except that we make sure * msi(x) is off. */ void qib_enable_intx(struct pci_dev *pdev) { u16 cw, new; int pos; /* first, turn on INTx */ pci_read_config_word(pdev, PCI_COMMAND, &cw); new = cw & ~PCI_COMMAND_INTX_DISABLE; if (new != cw) pci_write_config_word(pdev, PCI_COMMAND, new); pos = pci_find_capability(pdev, PCI_CAP_ID_MSI); if (pos) { /* then turn off MSI */ pci_read_config_word(pdev, pos + PCI_MSI_FLAGS, &cw); new = cw & ~PCI_MSI_FLAGS_ENABLE; if (new != cw) pci_write_config_word(pdev, pos + PCI_MSI_FLAGS, new); } pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX); if (pos) { /* then turn off MSIx */ pci_read_config_word(pdev, pos + PCI_MSIX_FLAGS, &cw); new = cw & ~PCI_MSIX_FLAGS_ENABLE; if (new != cw) pci_write_config_word(pdev, pos + PCI_MSIX_FLAGS, new); } } /* * These two routines are helper routines for the device reset code * to move all the pcie code out of the chip-specific driver code. */ void qib_pcie_getcmd(struct qib_devdata *dd, u16 *cmd, u8 *iline, u8 *cline) { pci_read_config_word(dd->pcidev, PCI_COMMAND, cmd); pci_read_config_byte(dd->pcidev, PCI_INTERRUPT_LINE, iline); pci_read_config_byte(dd->pcidev, PCI_CACHE_LINE_SIZE, cline); } void qib_pcie_reenable(struct qib_devdata *dd, u16 cmd, u8 iline, u8 cline) { int r; r = pci_write_config_dword(dd->pcidev, PCI_BASE_ADDRESS_0, dd->pcibar0); if (r) qib_dev_err(dd, "rewrite of BAR0 failed: %d\n", r); r = pci_write_config_dword(dd->pcidev, PCI_BASE_ADDRESS_1, dd->pcibar1); if (r) qib_dev_err(dd, "rewrite of BAR1 failed: %d\n", r); /* now re-enable memory access, and restore cosmetic settings */ pci_write_config_word(dd->pcidev, PCI_COMMAND, cmd); pci_write_config_byte(dd->pcidev, PCI_INTERRUPT_LINE, iline); pci_write_config_byte(dd->pcidev, PCI_CACHE_LINE_SIZE, cline); r = pci_enable_device(dd->pcidev); if (r) qib_dev_err(dd, "pci_enable_device failed after " "reset: %d\n", r); } /* code to adjust PCIe capabilities. */ static int fld2val(int wd, int mask) { int lsbmask; if (!mask) return 0; wd &= mask; lsbmask = mask ^ (mask & (mask - 1)); wd /= lsbmask; return wd; } static int val2fld(int wd, int mask) { int lsbmask; if (!mask) return 0; lsbmask = mask ^ (mask & (mask - 1)); wd *= lsbmask; return wd; } static int qib_pcie_coalesce; module_param_named(pcie_coalesce, qib_pcie_coalesce, int, S_IRUGO); MODULE_PARM_DESC(pcie_coalesce, "tune PCIe colescing on some Intel chipsets"); /* * Enable PCIe completion and data coalescing, on Intel 5x00 and 7300 * chipsets. This is known to be unsafe for some revisions of some * of these chipsets, with some BIOS settings, and enabling it on those * systems may result in the system crashing, and/or data corruption. */ static int qib_tune_pcie_coalesce(struct qib_devdata *dd) { int r; struct pci_dev *parent; int ppos; u16 devid; u32 mask, bits, val; if (!qib_pcie_coalesce) return 0; /* Find out supported and configured values for parent (root) */ parent = dd->pcidev->bus->self; if (parent->bus->parent) { qib_devinfo(dd->pcidev, "Parent not root\n"); return 1; } ppos = pci_find_capability(parent, PCI_CAP_ID_EXP); if (!ppos) return 1; if (parent->vendor != 0x8086) return 1; /* * - bit 12: Max_rdcmp_Imt_EN: need to set to 1 * - bit 11: COALESCE_FORCE: need to set to 0 * - bit 10: COALESCE_EN: need to set to 1 * (but limitations on some on some chipsets) * * On the Intel 5000, 5100, and 7300 chipsets, there is * also: - bit 25:24: COALESCE_MODE, need to set to 0 */ devid = parent->device; if (devid >= 0x25e2 && devid <= 0x25fa) { u8 rev; /* 5000 P/V/X/Z */ pci_read_config_byte(parent, PCI_REVISION_ID, &rev); if (rev <= 0xb2) bits = 1U << 10; else bits = 7U << 10; mask = (3U << 24) | (7U << 10); } else if (devid >= 0x65e2 && devid <= 0x65fa) { /* 5100 */ bits = 1U << 10; mask = (3U << 24) | (7U << 10); } else if (devid >= 0x4021 && devid <= 0x402e) { /* 5400 */ bits = 7U << 10; mask = 7U << 10; } else if (devid >= 0x3604 && devid <= 0x360a) { /* 7300 */ bits = 7U << 10; mask = (3U << 24) | (7U << 10); } else { /* not one of the chipsets that we know about */ return 1; } pci_read_config_dword(parent, 0x48, &val); val &= ~mask; val |= bits; r = pci_write_config_dword(parent, 0x48, val); return 0; } /* * BIOS may not set PCIe bus-utilization parameters for best performance. * Check and optionally adjust them to maximize our throughput. */ static int qib_pcie_caps; module_param_named(pcie_caps, qib_pcie_caps, int, S_IRUGO); MODULE_PARM_DESC(pcie_caps, "Max PCIe tuning: Payload (4lsb), ReadReq (D4..7)"); static int qib_tune_pcie_caps(struct qib_devdata *dd) { int ret = 1; /* Assume the worst */ struct pci_dev *parent; int ppos, epos; u16 pcaps, pctl, ecaps, ectl; int rc_sup, ep_sup; int rc_cur, ep_cur; /* Find out supported and configured values for parent (root) */ parent = dd->pcidev->bus->self; if (parent->bus->parent) { qib_devinfo(dd->pcidev, "Parent not root\n"); goto bail; } ppos = pci_find_capability(parent, PCI_CAP_ID_EXP); if (ppos) { pci_read_config_word(parent, ppos + PCI_EXP_DEVCAP, &pcaps); pci_read_config_word(parent, ppos + PCI_EXP_DEVCTL, &pctl); } else goto bail; /* Find out supported and configured values for endpoint (us) */ epos = pci_find_capability(dd->pcidev, PCI_CAP_ID_EXP); if (epos) { pci_read_config_word(dd->pcidev, epos + PCI_EXP_DEVCAP, &ecaps); pci_read_config_word(dd->pcidev, epos + PCI_EXP_DEVCTL, &ectl); } else goto bail; ret = 0; /* Find max payload supported by root, endpoint */ rc_sup = fld2val(pcaps, PCI_EXP_DEVCAP_PAYLOAD); ep_sup = fld2val(ecaps, PCI_EXP_DEVCAP_PAYLOAD); if (rc_sup > ep_sup) rc_sup = ep_sup; rc_cur = fld2val(pctl, PCI_EXP_DEVCTL_PAYLOAD); ep_cur = fld2val(ectl, PCI_EXP_DEVCTL_PAYLOAD); /* If Supported greater than limit in module param, limit it */ if (rc_sup > (qib_pcie_caps & 7)) rc_sup = qib_pcie_caps & 7; /* If less than (allowed, supported), bump root payload */ if (rc_sup > rc_cur) { rc_cur = rc_sup; pctl = (pctl & ~PCI_EXP_DEVCTL_PAYLOAD) | val2fld(rc_cur, PCI_EXP_DEVCTL_PAYLOAD); pci_write_config_word(parent, ppos + PCI_EXP_DEVCTL, pctl); } /* If less than (allowed, supported), bump endpoint payload */ if (rc_sup > ep_cur) { ep_cur = rc_sup; ectl = (ectl & ~PCI_EXP_DEVCTL_PAYLOAD) | val2fld(ep_cur, PCI_EXP_DEVCTL_PAYLOAD); pci_write_config_word(dd->pcidev, epos + PCI_EXP_DEVCTL, ectl); } /* * Now the Read Request size. * No field for max supported, but PCIe spec limits it to 4096, * which is code '5' (log2(4096) - 7) */ rc_sup = 5; if (rc_sup > ((qib_pcie_caps >> 4) & 7)) rc_sup = (qib_pcie_caps >> 4) & 7; rc_cur = fld2val(pctl, PCI_EXP_DEVCTL_READRQ); ep_cur = fld2val(ectl, PCI_EXP_DEVCTL_READRQ); if (rc_sup > rc_cur) { rc_cur = rc_sup; pctl = (pctl & ~PCI_EXP_DEVCTL_READRQ) | val2fld(rc_cur, PCI_EXP_DEVCTL_READRQ); pci_write_config_word(parent, ppos + PCI_EXP_DEVCTL, pctl); } if (rc_sup > ep_cur) { ep_cur = rc_sup; ectl = (ectl & ~PCI_EXP_DEVCTL_READRQ) | val2fld(ep_cur, PCI_EXP_DEVCTL_READRQ); pci_write_config_word(dd->pcidev, epos + PCI_EXP_DEVCTL, ectl); } bail: return ret; } /* End of PCIe capability tuning */ /* * From here through qib_pci_err_handler definition is invoked via * PCI error infrastructure, registered via pci */ static pci_ers_result_t qib_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { struct qib_devdata *dd = pci_get_drvdata(pdev); pci_ers_result_t ret = PCI_ERS_RESULT_RECOVERED; switch (state) { case pci_channel_io_normal: qib_devinfo(pdev, "State Normal, ignoring\n"); break; case pci_channel_io_frozen: qib_devinfo(pdev, "State Frozen, requesting reset\n"); pci_disable_device(pdev); ret = PCI_ERS_RESULT_NEED_RESET; break; case pci_channel_io_perm_failure: qib_devinfo(pdev, "State Permanent Failure, disabling\n"); if (dd) { /* no more register accesses! */ dd->flags &= ~QIB_PRESENT; qib_disable_after_error(dd); } /* else early, or other problem */ ret = PCI_ERS_RESULT_DISCONNECT; break; default: /* shouldn't happen */ qib_devinfo(pdev, "QIB PCI errors detected (state %d)\n", state); break; } return ret; } static pci_ers_result_t qib_pci_mmio_enabled(struct pci_dev *pdev) { u64 words = 0U; struct qib_devdata *dd = pci_get_drvdata(pdev); pci_ers_result_t ret = PCI_ERS_RESULT_RECOVERED; if (dd && dd->pport) { words = dd->f_portcntr(dd->pport, QIBPORTCNTR_WORDRCV); if (words == ~0ULL) ret = PCI_ERS_RESULT_NEED_RESET; } qib_devinfo(pdev, "QIB mmio_enabled function called, " "read wordscntr %Lx, returning %d\n", words, ret); return ret; } static pci_ers_result_t qib_pci_slot_reset(struct pci_dev *pdev) { qib_devinfo(pdev, "QIB link_reset function called, ignored\n"); return PCI_ERS_RESULT_CAN_RECOVER; } static pci_ers_result_t qib_pci_link_reset(struct pci_dev *pdev) { qib_devinfo(pdev, "QIB link_reset function called, ignored\n"); return PCI_ERS_RESULT_CAN_RECOVER; } static void qib_pci_resume(struct pci_dev *pdev) { struct qib_devdata *dd = pci_get_drvdata(pdev); qib_devinfo(pdev, "QIB resume function called\n"); pci_cleanup_aer_uncorrect_error_status(pdev); /* * Running jobs will fail, since it's asynchronous * unlike sysfs-requested reset. Better than * doing nothing. */ qib_init(dd, 1); /* same as re-init after reset */ } struct pci_error_handlers qib_pci_err_handler = { .error_detected = qib_pci_error_detected, .mmio_enabled = qib_pci_mmio_enabled, .link_reset = qib_pci_link_reset, .slot_reset = qib_pci_slot_reset, .resume = qib_pci_resume, };
gpl-2.0
HSAFoundation/HSA-Drivers-Linux-AMD
src/kernel/fs/nls/nls_cp936.c
2934
698296
/* * linux/fs/nls/nls_cp936.c * * Charset cp936 translation tables. * This translation table was generated automatically, the * original table can be download from the Microsoft website. * (http://www.microsoft.com/typography/unicode/unicodecp.htm) */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/nls.h> #include <linux/errno.h> static const wchar_t c2u_81[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x4E02,0x4E04,0x4E05,0x4E06,0x4E0F,0x4E12,0x4E17,0x4E1F,/* 0x40-0x47 */ 0x4E20,0x4E21,0x4E23,0x4E26,0x4E29,0x4E2E,0x4E2F,0x4E31,/* 0x48-0x4F */ 0x4E33,0x4E35,0x4E37,0x4E3C,0x4E40,0x4E41,0x4E42,0x4E44,/* 0x50-0x57 */ 0x4E46,0x4E4A,0x4E51,0x4E55,0x4E57,0x4E5A,0x4E5B,0x4E62,/* 0x58-0x5F */ 0x4E63,0x4E64,0x4E65,0x4E67,0x4E68,0x4E6A,0x4E6B,0x4E6C,/* 0x60-0x67 */ 0x4E6D,0x4E6E,0x4E6F,0x4E72,0x4E74,0x4E75,0x4E76,0x4E77,/* 0x68-0x6F */ 0x4E78,0x4E79,0x4E7A,0x4E7B,0x4E7C,0x4E7D,0x4E7F,0x4E80,/* 0x70-0x77 */ 0x4E81,0x4E82,0x4E83,0x4E84,0x4E85,0x4E87,0x4E8A,0x0000,/* 0x78-0x7F */ 0x4E90,0x4E96,0x4E97,0x4E99,0x4E9C,0x4E9D,0x4E9E,0x4EA3,/* 0x80-0x87 */ 0x4EAA,0x4EAF,0x4EB0,0x4EB1,0x4EB4,0x4EB6,0x4EB7,0x4EB8,/* 0x88-0x8F */ 0x4EB9,0x4EBC,0x4EBD,0x4EBE,0x4EC8,0x4ECC,0x4ECF,0x4ED0,/* 0x90-0x97 */ 0x4ED2,0x4EDA,0x4EDB,0x4EDC,0x4EE0,0x4EE2,0x4EE6,0x4EE7,/* 0x98-0x9F */ 0x4EE9,0x4EED,0x4EEE,0x4EEF,0x4EF1,0x4EF4,0x4EF8,0x4EF9,/* 0xA0-0xA7 */ 0x4EFA,0x4EFC,0x4EFE,0x4F00,0x4F02,0x4F03,0x4F04,0x4F05,/* 0xA8-0xAF */ 0x4F06,0x4F07,0x4F08,0x4F0B,0x4F0C,0x4F12,0x4F13,0x4F14,/* 0xB0-0xB7 */ 0x4F15,0x4F16,0x4F1C,0x4F1D,0x4F21,0x4F23,0x4F28,0x4F29,/* 0xB8-0xBF */ 0x4F2C,0x4F2D,0x4F2E,0x4F31,0x4F33,0x4F35,0x4F37,0x4F39,/* 0xC0-0xC7 */ 0x4F3B,0x4F3E,0x4F3F,0x4F40,0x4F41,0x4F42,0x4F44,0x4F45,/* 0xC8-0xCF */ 0x4F47,0x4F48,0x4F49,0x4F4A,0x4F4B,0x4F4C,0x4F52,0x4F54,/* 0xD0-0xD7 */ 0x4F56,0x4F61,0x4F62,0x4F66,0x4F68,0x4F6A,0x4F6B,0x4F6D,/* 0xD8-0xDF */ 0x4F6E,0x4F71,0x4F72,0x4F75,0x4F77,0x4F78,0x4F79,0x4F7A,/* 0xE0-0xE7 */ 0x4F7D,0x4F80,0x4F81,0x4F82,0x4F85,0x4F86,0x4F87,0x4F8A,/* 0xE8-0xEF */ 0x4F8C,0x4F8E,0x4F90,0x4F92,0x4F93,0x4F95,0x4F96,0x4F98,/* 0xF0-0xF7 */ 0x4F99,0x4F9A,0x4F9C,0x4F9E,0x4F9F,0x4FA1,0x4FA2,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_82[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x4FA4,0x4FAB,0x4FAD,0x4FB0,0x4FB1,0x4FB2,0x4FB3,0x4FB4,/* 0x40-0x47 */ 0x4FB6,0x4FB7,0x4FB8,0x4FB9,0x4FBA,0x4FBB,0x4FBC,0x4FBD,/* 0x48-0x4F */ 0x4FBE,0x4FC0,0x4FC1,0x4FC2,0x4FC6,0x4FC7,0x4FC8,0x4FC9,/* 0x50-0x57 */ 0x4FCB,0x4FCC,0x4FCD,0x4FD2,0x4FD3,0x4FD4,0x4FD5,0x4FD6,/* 0x58-0x5F */ 0x4FD9,0x4FDB,0x4FE0,0x4FE2,0x4FE4,0x4FE5,0x4FE7,0x4FEB,/* 0x60-0x67 */ 0x4FEC,0x4FF0,0x4FF2,0x4FF4,0x4FF5,0x4FF6,0x4FF7,0x4FF9,/* 0x68-0x6F */ 0x4FFB,0x4FFC,0x4FFD,0x4FFF,0x5000,0x5001,0x5002,0x5003,/* 0x70-0x77 */ 0x5004,0x5005,0x5006,0x5007,0x5008,0x5009,0x500A,0x0000,/* 0x78-0x7F */ 0x500B,0x500E,0x5010,0x5011,0x5013,0x5015,0x5016,0x5017,/* 0x80-0x87 */ 0x501B,0x501D,0x501E,0x5020,0x5022,0x5023,0x5024,0x5027,/* 0x88-0x8F */ 0x502B,0x502F,0x5030,0x5031,0x5032,0x5033,0x5034,0x5035,/* 0x90-0x97 */ 0x5036,0x5037,0x5038,0x5039,0x503B,0x503D,0x503F,0x5040,/* 0x98-0x9F */ 0x5041,0x5042,0x5044,0x5045,0x5046,0x5049,0x504A,0x504B,/* 0xA0-0xA7 */ 0x504D,0x5050,0x5051,0x5052,0x5053,0x5054,0x5056,0x5057,/* 0xA8-0xAF */ 0x5058,0x5059,0x505B,0x505D,0x505E,0x505F,0x5060,0x5061,/* 0xB0-0xB7 */ 0x5062,0x5063,0x5064,0x5066,0x5067,0x5068,0x5069,0x506A,/* 0xB8-0xBF */ 0x506B,0x506D,0x506E,0x506F,0x5070,0x5071,0x5072,0x5073,/* 0xC0-0xC7 */ 0x5074,0x5075,0x5078,0x5079,0x507A,0x507C,0x507D,0x5081,/* 0xC8-0xCF */ 0x5082,0x5083,0x5084,0x5086,0x5087,0x5089,0x508A,0x508B,/* 0xD0-0xD7 */ 0x508C,0x508E,0x508F,0x5090,0x5091,0x5092,0x5093,0x5094,/* 0xD8-0xDF */ 0x5095,0x5096,0x5097,0x5098,0x5099,0x509A,0x509B,0x509C,/* 0xE0-0xE7 */ 0x509D,0x509E,0x509F,0x50A0,0x50A1,0x50A2,0x50A4,0x50A6,/* 0xE8-0xEF */ 0x50AA,0x50AB,0x50AD,0x50AE,0x50AF,0x50B0,0x50B1,0x50B3,/* 0xF0-0xF7 */ 0x50B4,0x50B5,0x50B6,0x50B7,0x50B8,0x50B9,0x50BC,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_83[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x50BD,0x50BE,0x50BF,0x50C0,0x50C1,0x50C2,0x50C3,0x50C4,/* 0x40-0x47 */ 0x50C5,0x50C6,0x50C7,0x50C8,0x50C9,0x50CA,0x50CB,0x50CC,/* 0x48-0x4F */ 0x50CD,0x50CE,0x50D0,0x50D1,0x50D2,0x50D3,0x50D4,0x50D5,/* 0x50-0x57 */ 0x50D7,0x50D8,0x50D9,0x50DB,0x50DC,0x50DD,0x50DE,0x50DF,/* 0x58-0x5F */ 0x50E0,0x50E1,0x50E2,0x50E3,0x50E4,0x50E5,0x50E8,0x50E9,/* 0x60-0x67 */ 0x50EA,0x50EB,0x50EF,0x50F0,0x50F1,0x50F2,0x50F4,0x50F6,/* 0x68-0x6F */ 0x50F7,0x50F8,0x50F9,0x50FA,0x50FC,0x50FD,0x50FE,0x50FF,/* 0x70-0x77 */ 0x5100,0x5101,0x5102,0x5103,0x5104,0x5105,0x5108,0x0000,/* 0x78-0x7F */ 0x5109,0x510A,0x510C,0x510D,0x510E,0x510F,0x5110,0x5111,/* 0x80-0x87 */ 0x5113,0x5114,0x5115,0x5116,0x5117,0x5118,0x5119,0x511A,/* 0x88-0x8F */ 0x511B,0x511C,0x511D,0x511E,0x511F,0x5120,0x5122,0x5123,/* 0x90-0x97 */ 0x5124,0x5125,0x5126,0x5127,0x5128,0x5129,0x512A,0x512B,/* 0x98-0x9F */ 0x512C,0x512D,0x512E,0x512F,0x5130,0x5131,0x5132,0x5133,/* 0xA0-0xA7 */ 0x5134,0x5135,0x5136,0x5137,0x5138,0x5139,0x513A,0x513B,/* 0xA8-0xAF */ 0x513C,0x513D,0x513E,0x5142,0x5147,0x514A,0x514C,0x514E,/* 0xB0-0xB7 */ 0x514F,0x5150,0x5152,0x5153,0x5157,0x5158,0x5159,0x515B,/* 0xB8-0xBF */ 0x515D,0x515E,0x515F,0x5160,0x5161,0x5163,0x5164,0x5166,/* 0xC0-0xC7 */ 0x5167,0x5169,0x516A,0x516F,0x5172,0x517A,0x517E,0x517F,/* 0xC8-0xCF */ 0x5183,0x5184,0x5186,0x5187,0x518A,0x518B,0x518E,0x518F,/* 0xD0-0xD7 */ 0x5190,0x5191,0x5193,0x5194,0x5198,0x519A,0x519D,0x519E,/* 0xD8-0xDF */ 0x519F,0x51A1,0x51A3,0x51A6,0x51A7,0x51A8,0x51A9,0x51AA,/* 0xE0-0xE7 */ 0x51AD,0x51AE,0x51B4,0x51B8,0x51B9,0x51BA,0x51BE,0x51BF,/* 0xE8-0xEF */ 0x51C1,0x51C2,0x51C3,0x51C5,0x51C8,0x51CA,0x51CD,0x51CE,/* 0xF0-0xF7 */ 0x51D0,0x51D2,0x51D3,0x51D4,0x51D5,0x51D6,0x51D7,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_84[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x51D8,0x51D9,0x51DA,0x51DC,0x51DE,0x51DF,0x51E2,0x51E3,/* 0x40-0x47 */ 0x51E5,0x51E6,0x51E7,0x51E8,0x51E9,0x51EA,0x51EC,0x51EE,/* 0x48-0x4F */ 0x51F1,0x51F2,0x51F4,0x51F7,0x51FE,0x5204,0x5205,0x5209,/* 0x50-0x57 */ 0x520B,0x520C,0x520F,0x5210,0x5213,0x5214,0x5215,0x521C,/* 0x58-0x5F */ 0x521E,0x521F,0x5221,0x5222,0x5223,0x5225,0x5226,0x5227,/* 0x60-0x67 */ 0x522A,0x522C,0x522F,0x5231,0x5232,0x5234,0x5235,0x523C,/* 0x68-0x6F */ 0x523E,0x5244,0x5245,0x5246,0x5247,0x5248,0x5249,0x524B,/* 0x70-0x77 */ 0x524E,0x524F,0x5252,0x5253,0x5255,0x5257,0x5258,0x0000,/* 0x78-0x7F */ 0x5259,0x525A,0x525B,0x525D,0x525F,0x5260,0x5262,0x5263,/* 0x80-0x87 */ 0x5264,0x5266,0x5268,0x526B,0x526C,0x526D,0x526E,0x5270,/* 0x88-0x8F */ 0x5271,0x5273,0x5274,0x5275,0x5276,0x5277,0x5278,0x5279,/* 0x90-0x97 */ 0x527A,0x527B,0x527C,0x527E,0x5280,0x5283,0x5284,0x5285,/* 0x98-0x9F */ 0x5286,0x5287,0x5289,0x528A,0x528B,0x528C,0x528D,0x528E,/* 0xA0-0xA7 */ 0x528F,0x5291,0x5292,0x5294,0x5295,0x5296,0x5297,0x5298,/* 0xA8-0xAF */ 0x5299,0x529A,0x529C,0x52A4,0x52A5,0x52A6,0x52A7,0x52AE,/* 0xB0-0xB7 */ 0x52AF,0x52B0,0x52B4,0x52B5,0x52B6,0x52B7,0x52B8,0x52B9,/* 0xB8-0xBF */ 0x52BA,0x52BB,0x52BC,0x52BD,0x52C0,0x52C1,0x52C2,0x52C4,/* 0xC0-0xC7 */ 0x52C5,0x52C6,0x52C8,0x52CA,0x52CC,0x52CD,0x52CE,0x52CF,/* 0xC8-0xCF */ 0x52D1,0x52D3,0x52D4,0x52D5,0x52D7,0x52D9,0x52DA,0x52DB,/* 0xD0-0xD7 */ 0x52DC,0x52DD,0x52DE,0x52E0,0x52E1,0x52E2,0x52E3,0x52E5,/* 0xD8-0xDF */ 0x52E6,0x52E7,0x52E8,0x52E9,0x52EA,0x52EB,0x52EC,0x52ED,/* 0xE0-0xE7 */ 0x52EE,0x52EF,0x52F1,0x52F2,0x52F3,0x52F4,0x52F5,0x52F6,/* 0xE8-0xEF */ 0x52F7,0x52F8,0x52FB,0x52FC,0x52FD,0x5301,0x5302,0x5303,/* 0xF0-0xF7 */ 0x5304,0x5307,0x5309,0x530A,0x530B,0x530C,0x530E,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_85[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x5311,0x5312,0x5313,0x5314,0x5318,0x531B,0x531C,0x531E,/* 0x40-0x47 */ 0x531F,0x5322,0x5324,0x5325,0x5327,0x5328,0x5329,0x532B,/* 0x48-0x4F */ 0x532C,0x532D,0x532F,0x5330,0x5331,0x5332,0x5333,0x5334,/* 0x50-0x57 */ 0x5335,0x5336,0x5337,0x5338,0x533C,0x533D,0x5340,0x5342,/* 0x58-0x5F */ 0x5344,0x5346,0x534B,0x534C,0x534D,0x5350,0x5354,0x5358,/* 0x60-0x67 */ 0x5359,0x535B,0x535D,0x5365,0x5368,0x536A,0x536C,0x536D,/* 0x68-0x6F */ 0x5372,0x5376,0x5379,0x537B,0x537C,0x537D,0x537E,0x5380,/* 0x70-0x77 */ 0x5381,0x5383,0x5387,0x5388,0x538A,0x538E,0x538F,0x0000,/* 0x78-0x7F */ 0x5390,0x5391,0x5392,0x5393,0x5394,0x5396,0x5397,0x5399,/* 0x80-0x87 */ 0x539B,0x539C,0x539E,0x53A0,0x53A1,0x53A4,0x53A7,0x53AA,/* 0x88-0x8F */ 0x53AB,0x53AC,0x53AD,0x53AF,0x53B0,0x53B1,0x53B2,0x53B3,/* 0x90-0x97 */ 0x53B4,0x53B5,0x53B7,0x53B8,0x53B9,0x53BA,0x53BC,0x53BD,/* 0x98-0x9F */ 0x53BE,0x53C0,0x53C3,0x53C4,0x53C5,0x53C6,0x53C7,0x53CE,/* 0xA0-0xA7 */ 0x53CF,0x53D0,0x53D2,0x53D3,0x53D5,0x53DA,0x53DC,0x53DD,/* 0xA8-0xAF */ 0x53DE,0x53E1,0x53E2,0x53E7,0x53F4,0x53FA,0x53FE,0x53FF,/* 0xB0-0xB7 */ 0x5400,0x5402,0x5405,0x5407,0x540B,0x5414,0x5418,0x5419,/* 0xB8-0xBF */ 0x541A,0x541C,0x5422,0x5424,0x5425,0x542A,0x5430,0x5433,/* 0xC0-0xC7 */ 0x5436,0x5437,0x543A,0x543D,0x543F,0x5441,0x5442,0x5444,/* 0xC8-0xCF */ 0x5445,0x5447,0x5449,0x544C,0x544D,0x544E,0x544F,0x5451,/* 0xD0-0xD7 */ 0x545A,0x545D,0x545E,0x545F,0x5460,0x5461,0x5463,0x5465,/* 0xD8-0xDF */ 0x5467,0x5469,0x546A,0x546B,0x546C,0x546D,0x546E,0x546F,/* 0xE0-0xE7 */ 0x5470,0x5474,0x5479,0x547A,0x547E,0x547F,0x5481,0x5483,/* 0xE8-0xEF */ 0x5485,0x5487,0x5488,0x5489,0x548A,0x548D,0x5491,0x5493,/* 0xF0-0xF7 */ 0x5497,0x5498,0x549C,0x549E,0x549F,0x54A0,0x54A1,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_86[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x54A2,0x54A5,0x54AE,0x54B0,0x54B2,0x54B5,0x54B6,0x54B7,/* 0x40-0x47 */ 0x54B9,0x54BA,0x54BC,0x54BE,0x54C3,0x54C5,0x54CA,0x54CB,/* 0x48-0x4F */ 0x54D6,0x54D8,0x54DB,0x54E0,0x54E1,0x54E2,0x54E3,0x54E4,/* 0x50-0x57 */ 0x54EB,0x54EC,0x54EF,0x54F0,0x54F1,0x54F4,0x54F5,0x54F6,/* 0x58-0x5F */ 0x54F7,0x54F8,0x54F9,0x54FB,0x54FE,0x5500,0x5502,0x5503,/* 0x60-0x67 */ 0x5504,0x5505,0x5508,0x550A,0x550B,0x550C,0x550D,0x550E,/* 0x68-0x6F */ 0x5512,0x5513,0x5515,0x5516,0x5517,0x5518,0x5519,0x551A,/* 0x70-0x77 */ 0x551C,0x551D,0x551E,0x551F,0x5521,0x5525,0x5526,0x0000,/* 0x78-0x7F */ 0x5528,0x5529,0x552B,0x552D,0x5532,0x5534,0x5535,0x5536,/* 0x80-0x87 */ 0x5538,0x5539,0x553A,0x553B,0x553D,0x5540,0x5542,0x5545,/* 0x88-0x8F */ 0x5547,0x5548,0x554B,0x554C,0x554D,0x554E,0x554F,0x5551,/* 0x90-0x97 */ 0x5552,0x5553,0x5554,0x5557,0x5558,0x5559,0x555A,0x555B,/* 0x98-0x9F */ 0x555D,0x555E,0x555F,0x5560,0x5562,0x5563,0x5568,0x5569,/* 0xA0-0xA7 */ 0x556B,0x556F,0x5570,0x5571,0x5572,0x5573,0x5574,0x5579,/* 0xA8-0xAF */ 0x557A,0x557D,0x557F,0x5585,0x5586,0x558C,0x558D,0x558E,/* 0xB0-0xB7 */ 0x5590,0x5592,0x5593,0x5595,0x5596,0x5597,0x559A,0x559B,/* 0xB8-0xBF */ 0x559E,0x55A0,0x55A1,0x55A2,0x55A3,0x55A4,0x55A5,0x55A6,/* 0xC0-0xC7 */ 0x55A8,0x55A9,0x55AA,0x55AB,0x55AC,0x55AD,0x55AE,0x55AF,/* 0xC8-0xCF */ 0x55B0,0x55B2,0x55B4,0x55B6,0x55B8,0x55BA,0x55BC,0x55BF,/* 0xD0-0xD7 */ 0x55C0,0x55C1,0x55C2,0x55C3,0x55C6,0x55C7,0x55C8,0x55CA,/* 0xD8-0xDF */ 0x55CB,0x55CE,0x55CF,0x55D0,0x55D5,0x55D7,0x55D8,0x55D9,/* 0xE0-0xE7 */ 0x55DA,0x55DB,0x55DE,0x55E0,0x55E2,0x55E7,0x55E9,0x55ED,/* 0xE8-0xEF */ 0x55EE,0x55F0,0x55F1,0x55F4,0x55F6,0x55F8,0x55F9,0x55FA,/* 0xF0-0xF7 */ 0x55FB,0x55FC,0x55FF,0x5602,0x5603,0x5604,0x5605,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_87[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x5606,0x5607,0x560A,0x560B,0x560D,0x5610,0x5611,0x5612,/* 0x40-0x47 */ 0x5613,0x5614,0x5615,0x5616,0x5617,0x5619,0x561A,0x561C,/* 0x48-0x4F */ 0x561D,0x5620,0x5621,0x5622,0x5625,0x5626,0x5628,0x5629,/* 0x50-0x57 */ 0x562A,0x562B,0x562E,0x562F,0x5630,0x5633,0x5635,0x5637,/* 0x58-0x5F */ 0x5638,0x563A,0x563C,0x563D,0x563E,0x5640,0x5641,0x5642,/* 0x60-0x67 */ 0x5643,0x5644,0x5645,0x5646,0x5647,0x5648,0x5649,0x564A,/* 0x68-0x6F */ 0x564B,0x564F,0x5650,0x5651,0x5652,0x5653,0x5655,0x5656,/* 0x70-0x77 */ 0x565A,0x565B,0x565D,0x565E,0x565F,0x5660,0x5661,0x0000,/* 0x78-0x7F */ 0x5663,0x5665,0x5666,0x5667,0x566D,0x566E,0x566F,0x5670,/* 0x80-0x87 */ 0x5672,0x5673,0x5674,0x5675,0x5677,0x5678,0x5679,0x567A,/* 0x88-0x8F */ 0x567D,0x567E,0x567F,0x5680,0x5681,0x5682,0x5683,0x5684,/* 0x90-0x97 */ 0x5687,0x5688,0x5689,0x568A,0x568B,0x568C,0x568D,0x5690,/* 0x98-0x9F */ 0x5691,0x5692,0x5694,0x5695,0x5696,0x5697,0x5698,0x5699,/* 0xA0-0xA7 */ 0x569A,0x569B,0x569C,0x569D,0x569E,0x569F,0x56A0,0x56A1,/* 0xA8-0xAF */ 0x56A2,0x56A4,0x56A5,0x56A6,0x56A7,0x56A8,0x56A9,0x56AA,/* 0xB0-0xB7 */ 0x56AB,0x56AC,0x56AD,0x56AE,0x56B0,0x56B1,0x56B2,0x56B3,/* 0xB8-0xBF */ 0x56B4,0x56B5,0x56B6,0x56B8,0x56B9,0x56BA,0x56BB,0x56BD,/* 0xC0-0xC7 */ 0x56BE,0x56BF,0x56C0,0x56C1,0x56C2,0x56C3,0x56C4,0x56C5,/* 0xC8-0xCF */ 0x56C6,0x56C7,0x56C8,0x56C9,0x56CB,0x56CC,0x56CD,0x56CE,/* 0xD0-0xD7 */ 0x56CF,0x56D0,0x56D1,0x56D2,0x56D3,0x56D5,0x56D6,0x56D8,/* 0xD8-0xDF */ 0x56D9,0x56DC,0x56E3,0x56E5,0x56E6,0x56E7,0x56E8,0x56E9,/* 0xE0-0xE7 */ 0x56EA,0x56EC,0x56EE,0x56EF,0x56F2,0x56F3,0x56F6,0x56F7,/* 0xE8-0xEF */ 0x56F8,0x56FB,0x56FC,0x5700,0x5701,0x5702,0x5705,0x5707,/* 0xF0-0xF7 */ 0x570B,0x570C,0x570D,0x570E,0x570F,0x5710,0x5711,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_88[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x5712,0x5713,0x5714,0x5715,0x5716,0x5717,0x5718,0x5719,/* 0x40-0x47 */ 0x571A,0x571B,0x571D,0x571E,0x5720,0x5721,0x5722,0x5724,/* 0x48-0x4F */ 0x5725,0x5726,0x5727,0x572B,0x5731,0x5732,0x5734,0x5735,/* 0x50-0x57 */ 0x5736,0x5737,0x5738,0x573C,0x573D,0x573F,0x5741,0x5743,/* 0x58-0x5F */ 0x5744,0x5745,0x5746,0x5748,0x5749,0x574B,0x5752,0x5753,/* 0x60-0x67 */ 0x5754,0x5755,0x5756,0x5758,0x5759,0x5762,0x5763,0x5765,/* 0x68-0x6F */ 0x5767,0x576C,0x576E,0x5770,0x5771,0x5772,0x5774,0x5775,/* 0x70-0x77 */ 0x5778,0x5779,0x577A,0x577D,0x577E,0x577F,0x5780,0x0000,/* 0x78-0x7F */ 0x5781,0x5787,0x5788,0x5789,0x578A,0x578D,0x578E,0x578F,/* 0x80-0x87 */ 0x5790,0x5791,0x5794,0x5795,0x5796,0x5797,0x5798,0x5799,/* 0x88-0x8F */ 0x579A,0x579C,0x579D,0x579E,0x579F,0x57A5,0x57A8,0x57AA,/* 0x90-0x97 */ 0x57AC,0x57AF,0x57B0,0x57B1,0x57B3,0x57B5,0x57B6,0x57B7,/* 0x98-0x9F */ 0x57B9,0x57BA,0x57BB,0x57BC,0x57BD,0x57BE,0x57BF,0x57C0,/* 0xA0-0xA7 */ 0x57C1,0x57C4,0x57C5,0x57C6,0x57C7,0x57C8,0x57C9,0x57CA,/* 0xA8-0xAF */ 0x57CC,0x57CD,0x57D0,0x57D1,0x57D3,0x57D6,0x57D7,0x57DB,/* 0xB0-0xB7 */ 0x57DC,0x57DE,0x57E1,0x57E2,0x57E3,0x57E5,0x57E6,0x57E7,/* 0xB8-0xBF */ 0x57E8,0x57E9,0x57EA,0x57EB,0x57EC,0x57EE,0x57F0,0x57F1,/* 0xC0-0xC7 */ 0x57F2,0x57F3,0x57F5,0x57F6,0x57F7,0x57FB,0x57FC,0x57FE,/* 0xC8-0xCF */ 0x57FF,0x5801,0x5803,0x5804,0x5805,0x5808,0x5809,0x580A,/* 0xD0-0xD7 */ 0x580C,0x580E,0x580F,0x5810,0x5812,0x5813,0x5814,0x5816,/* 0xD8-0xDF */ 0x5817,0x5818,0x581A,0x581B,0x581C,0x581D,0x581F,0x5822,/* 0xE0-0xE7 */ 0x5823,0x5825,0x5826,0x5827,0x5828,0x5829,0x582B,0x582C,/* 0xE8-0xEF */ 0x582D,0x582E,0x582F,0x5831,0x5832,0x5833,0x5834,0x5836,/* 0xF0-0xF7 */ 0x5837,0x5838,0x5839,0x583A,0x583B,0x583C,0x583D,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_89[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x583E,0x583F,0x5840,0x5841,0x5842,0x5843,0x5845,0x5846,/* 0x40-0x47 */ 0x5847,0x5848,0x5849,0x584A,0x584B,0x584E,0x584F,0x5850,/* 0x48-0x4F */ 0x5852,0x5853,0x5855,0x5856,0x5857,0x5859,0x585A,0x585B,/* 0x50-0x57 */ 0x585C,0x585D,0x585F,0x5860,0x5861,0x5862,0x5863,0x5864,/* 0x58-0x5F */ 0x5866,0x5867,0x5868,0x5869,0x586A,0x586D,0x586E,0x586F,/* 0x60-0x67 */ 0x5870,0x5871,0x5872,0x5873,0x5874,0x5875,0x5876,0x5877,/* 0x68-0x6F */ 0x5878,0x5879,0x587A,0x587B,0x587C,0x587D,0x587F,0x5882,/* 0x70-0x77 */ 0x5884,0x5886,0x5887,0x5888,0x588A,0x588B,0x588C,0x0000,/* 0x78-0x7F */ 0x588D,0x588E,0x588F,0x5890,0x5891,0x5894,0x5895,0x5896,/* 0x80-0x87 */ 0x5897,0x5898,0x589B,0x589C,0x589D,0x58A0,0x58A1,0x58A2,/* 0x88-0x8F */ 0x58A3,0x58A4,0x58A5,0x58A6,0x58A7,0x58AA,0x58AB,0x58AC,/* 0x90-0x97 */ 0x58AD,0x58AE,0x58AF,0x58B0,0x58B1,0x58B2,0x58B3,0x58B4,/* 0x98-0x9F */ 0x58B5,0x58B6,0x58B7,0x58B8,0x58B9,0x58BA,0x58BB,0x58BD,/* 0xA0-0xA7 */ 0x58BE,0x58BF,0x58C0,0x58C2,0x58C3,0x58C4,0x58C6,0x58C7,/* 0xA8-0xAF */ 0x58C8,0x58C9,0x58CA,0x58CB,0x58CC,0x58CD,0x58CE,0x58CF,/* 0xB0-0xB7 */ 0x58D0,0x58D2,0x58D3,0x58D4,0x58D6,0x58D7,0x58D8,0x58D9,/* 0xB8-0xBF */ 0x58DA,0x58DB,0x58DC,0x58DD,0x58DE,0x58DF,0x58E0,0x58E1,/* 0xC0-0xC7 */ 0x58E2,0x58E3,0x58E5,0x58E6,0x58E7,0x58E8,0x58E9,0x58EA,/* 0xC8-0xCF */ 0x58ED,0x58EF,0x58F1,0x58F2,0x58F4,0x58F5,0x58F7,0x58F8,/* 0xD0-0xD7 */ 0x58FA,0x58FB,0x58FC,0x58FD,0x58FE,0x58FF,0x5900,0x5901,/* 0xD8-0xDF */ 0x5903,0x5905,0x5906,0x5908,0x5909,0x590A,0x590B,0x590C,/* 0xE0-0xE7 */ 0x590E,0x5910,0x5911,0x5912,0x5913,0x5917,0x5918,0x591B,/* 0xE8-0xEF */ 0x591D,0x591E,0x5920,0x5921,0x5922,0x5923,0x5926,0x5928,/* 0xF0-0xF7 */ 0x592C,0x5930,0x5932,0x5933,0x5935,0x5936,0x593B,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_8A[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x593D,0x593E,0x593F,0x5940,0x5943,0x5945,0x5946,0x594A,/* 0x40-0x47 */ 0x594C,0x594D,0x5950,0x5952,0x5953,0x5959,0x595B,0x595C,/* 0x48-0x4F */ 0x595D,0x595E,0x595F,0x5961,0x5963,0x5964,0x5966,0x5967,/* 0x50-0x57 */ 0x5968,0x5969,0x596A,0x596B,0x596C,0x596D,0x596E,0x596F,/* 0x58-0x5F */ 0x5970,0x5971,0x5972,0x5975,0x5977,0x597A,0x597B,0x597C,/* 0x60-0x67 */ 0x597E,0x597F,0x5980,0x5985,0x5989,0x598B,0x598C,0x598E,/* 0x68-0x6F */ 0x598F,0x5990,0x5991,0x5994,0x5995,0x5998,0x599A,0x599B,/* 0x70-0x77 */ 0x599C,0x599D,0x599F,0x59A0,0x59A1,0x59A2,0x59A6,0x0000,/* 0x78-0x7F */ 0x59A7,0x59AC,0x59AD,0x59B0,0x59B1,0x59B3,0x59B4,0x59B5,/* 0x80-0x87 */ 0x59B6,0x59B7,0x59B8,0x59BA,0x59BC,0x59BD,0x59BF,0x59C0,/* 0x88-0x8F */ 0x59C1,0x59C2,0x59C3,0x59C4,0x59C5,0x59C7,0x59C8,0x59C9,/* 0x90-0x97 */ 0x59CC,0x59CD,0x59CE,0x59CF,0x59D5,0x59D6,0x59D9,0x59DB,/* 0x98-0x9F */ 0x59DE,0x59DF,0x59E0,0x59E1,0x59E2,0x59E4,0x59E6,0x59E7,/* 0xA0-0xA7 */ 0x59E9,0x59EA,0x59EB,0x59ED,0x59EE,0x59EF,0x59F0,0x59F1,/* 0xA8-0xAF */ 0x59F2,0x59F3,0x59F4,0x59F5,0x59F6,0x59F7,0x59F8,0x59FA,/* 0xB0-0xB7 */ 0x59FC,0x59FD,0x59FE,0x5A00,0x5A02,0x5A0A,0x5A0B,0x5A0D,/* 0xB8-0xBF */ 0x5A0E,0x5A0F,0x5A10,0x5A12,0x5A14,0x5A15,0x5A16,0x5A17,/* 0xC0-0xC7 */ 0x5A19,0x5A1A,0x5A1B,0x5A1D,0x5A1E,0x5A21,0x5A22,0x5A24,/* 0xC8-0xCF */ 0x5A26,0x5A27,0x5A28,0x5A2A,0x5A2B,0x5A2C,0x5A2D,0x5A2E,/* 0xD0-0xD7 */ 0x5A2F,0x5A30,0x5A33,0x5A35,0x5A37,0x5A38,0x5A39,0x5A3A,/* 0xD8-0xDF */ 0x5A3B,0x5A3D,0x5A3E,0x5A3F,0x5A41,0x5A42,0x5A43,0x5A44,/* 0xE0-0xE7 */ 0x5A45,0x5A47,0x5A48,0x5A4B,0x5A4C,0x5A4D,0x5A4E,0x5A4F,/* 0xE8-0xEF */ 0x5A50,0x5A51,0x5A52,0x5A53,0x5A54,0x5A56,0x5A57,0x5A58,/* 0xF0-0xF7 */ 0x5A59,0x5A5B,0x5A5C,0x5A5D,0x5A5E,0x5A5F,0x5A60,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_8B[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x5A61,0x5A63,0x5A64,0x5A65,0x5A66,0x5A68,0x5A69,0x5A6B,/* 0x40-0x47 */ 0x5A6C,0x5A6D,0x5A6E,0x5A6F,0x5A70,0x5A71,0x5A72,0x5A73,/* 0x48-0x4F */ 0x5A78,0x5A79,0x5A7B,0x5A7C,0x5A7D,0x5A7E,0x5A80,0x5A81,/* 0x50-0x57 */ 0x5A82,0x5A83,0x5A84,0x5A85,0x5A86,0x5A87,0x5A88,0x5A89,/* 0x58-0x5F */ 0x5A8A,0x5A8B,0x5A8C,0x5A8D,0x5A8E,0x5A8F,0x5A90,0x5A91,/* 0x60-0x67 */ 0x5A93,0x5A94,0x5A95,0x5A96,0x5A97,0x5A98,0x5A99,0x5A9C,/* 0x68-0x6F */ 0x5A9D,0x5A9E,0x5A9F,0x5AA0,0x5AA1,0x5AA2,0x5AA3,0x5AA4,/* 0x70-0x77 */ 0x5AA5,0x5AA6,0x5AA7,0x5AA8,0x5AA9,0x5AAB,0x5AAC,0x0000,/* 0x78-0x7F */ 0x5AAD,0x5AAE,0x5AAF,0x5AB0,0x5AB1,0x5AB4,0x5AB6,0x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x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_8C[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x5B48,0x5B49,0x5B4A,0x5B4B,0x5B4C,0x5B4D,0x5B4E,0x5B4F,/* 0x40-0x47 */ 0x5B52,0x5B56,0x5B5E,0x5B60,0x5B61,0x5B67,0x5B68,0x5B6B,/* 0x48-0x4F */ 0x5B6D,0x5B6E,0x5B6F,0x5B72,0x5B74,0x5B76,0x5B77,0x5B78,/* 0x50-0x57 */ 0x5B79,0x5B7B,0x5B7C,0x5B7E,0x5B7F,0x5B82,0x5B86,0x5B8A,/* 0x58-0x5F */ 0x5B8D,0x5B8E,0x5B90,0x5B91,0x5B92,0x5B94,0x5B96,0x5B9F,/* 0x60-0x67 */ 0x5BA7,0x5BA8,0x5BA9,0x5BAC,0x5BAD,0x5BAE,0x5BAF,0x5BB1,/* 0x68-0x6F */ 0x5BB2,0x5BB7,0x5BBA,0x5BBB,0x5BBC,0x5BC0,0x5BC1,0x5BC3,/* 0x70-0x77 */ 0x5BC8,0x5BC9,0x5BCA,0x5BCB,0x5BCD,0x5BCE,0x5BCF,0x0000,/* 0x78-0x7F */ 0x5BD1,0x5BD4,0x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5CA6,0x5CA7,0x5CA8,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_8D[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x5CAA,0x5CAE,0x5CAF,0x5CB0,0x5CB2,0x5CB4,0x5CB6,0x5CB9,/* 0x40-0x47 */ 0x5CBA,0x5CBB,0x5CBC,0x5CBE,0x5CC0,0x5CC2,0x5CC3,0x5CC5,/* 0x48-0x4F */ 0x5CC6,0x5CC7,0x5CC8,0x5CC9,0x5CCA,0x5CCC,0x5CCD,0x5CCE,/* 0x50-0x57 */ 0x5CCF,0x5CD0,0x5CD1,0x5CD3,0x5CD4,0x5CD5,0x5CD6,0x5CD7,/* 0x58-0x5F */ 0x5CD8,0x5CDA,0x5CDB,0x5CDC,0x5CDD,0x5CDE,0x5CDF,0x5CE0,/* 0x60-0x67 */ 0x5CE2,0x5CE3,0x5CE7,0x5CE9,0x5CEB,0x5CEC,0x5CEE,0x5CEF,/* 0x68-0x6F */ 0x5CF1,0x5CF2,0x5CF3,0x5CF4,0x5CF5,0x5CF6,0x5CF7,0x5CF8,/* 0x70-0x77 */ 0x5CF9,0x5CFA,0x5CFC,0x5CFD,0x5CFE,0x5CFF,0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x5D9B,0x5D9C,0x5D9E,0x5D9F,0x5DA0,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_8E[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x5DA1,0x5DA2,0x5DA3,0x5DA4,0x5DA5,0x5DA6,0x5DA7,0x5DA8,/* 0x40-0x47 */ 0x5DA9,0x5DAA,0x5DAB,0x5DAC,0x5DAD,0x5DAE,0x5DAF,0x5DB0,/* 0x48-0x4F */ 0x5DB1,0x5DB2,0x5DB3,0x5DB4,0x5DB5,0x5DB6,0x5DB8,0x5DB9,/* 0x50-0x57 */ 0x5DBA,0x5DBB,0x5DBC,0x5DBD,0x5DBE,0x5DBF,0x5DC0,0x5DC1,/* 0x58-0x5F */ 0x5DC2,0x5DC3,0x5DC4,0x5DC6,0x5DC7,0x5DC8,0x5DC9,0x5DCA,/* 0x60-0x67 */ 0x5DCB,0x5DCC,0x5DCE,0x5DCF,0x5DD0,0x5DD1,0x5DD2,0x5DD3,/* 0x68-0x6F */ 0x5DD4,0x5DD5,0x5DD6,0x5DD7,0x5DD8,0x5DD9,0x5DDA,0x5DDC,/* 0x70-0x77 */ 0x5DDF,0x5DE0,0x5DE3,0x5DE4,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,0x5EBD,/* 0xF0-0xF7 */ 0x5EBF,0x5EC0,0x5EC1,0x5EC2,0x5EC3,0x5EC4,0x5EC5,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_8F[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x5EC6,0x5EC7,0x5EC8,0x5ECB,0x5ECC,0x5ECD,0x5ECE,0x5ECF,/* 0x40-0x47 */ 0x5ED0,0x5ED4,0x5ED5,0x5ED7,0x5ED8,0x5ED9,0x5EDA,0x5EDC,/* 0x48-0x4F */ 0x5EDD,0x5EDE,0x5EDF,0x5EE0,0x5EE1,0x5EE2,0x5EE3,0x5EE4,/* 0x50-0x57 */ 0x5EE5,0x5EE6,0x5EE7,0x5EE9,0x5EEB,0x5EEC,0x5EED,0x5EEE,/* 0x58-0x5F */ 0x5EEF,0x5EF0,0x5EF1,0x5EF2,0x5EF3,0x5EF5,0x5EF8,0x5EF9,/* 0x60-0x67 */ 0x5EFB,0x5EFC,0x5EFD,0x5F05,0x5F06,0x5F07,0x5F09,0x5F0C,/* 0x68-0x6F */ 0x5F0D,0x5F0E,0x5F10,0x5F12,0x5F14,0x5F16,0x5F19,0x5F1A,/* 0x70-0x77 */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x5FE6,0x5FE8,0x5FE9,0x5FEC,0x5FEF,0x5FF0,0x5FF2,0x5FF3,/* 0xF0-0xF7 */ 0x5FF4,0x5FF6,0x5FF7,0x5FF9,0x5FFA,0x5FFC,0x6007,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_90[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x6008,0x6009,0x600B,0x600C,0x6010,0x6011,0x6013,0x6017,/* 0x40-0x47 */ 0x6018,0x601A,0x601E,0x601F,0x6022,0x6023,0x6024,0x602C,/* 0x48-0x4F */ 0x602D,0x602E,0x6030,0x6031,0x6032,0x6033,0x6034,0x6036,/* 0x50-0x57 */ 0x6037,0x6038,0x6039,0x603A,0x603D,0x603E,0x6040,0x6044,/* 0x58-0x5F */ 0x6045,0x6046,0x6047,0x6048,0x6049,0x604A,0x604C,0x604E,/* 0x60-0x67 */ 0x604F,0x6051,0x6053,0x6054,0x6056,0x6057,0x6058,0x605B,/* 0x68-0x6F */ 0x605C,0x605E,0x605F,0x6060,0x6061,0x6065,0x6066,0x606E,/* 0x70-0x77 */ 0x6071,0x6072,0x6074,0x6075,0x6077,0x607E,0x6080,0x0000,/* 0x78-0x7F */ 0x6081,0x6082,0x6085,0x6086,0x6087,0x6088,0x608A,0x608B,/* 0x80-0x87 */ 0x608E,0x608F,0x6090,0x6091,0x6093,0x6095,0x6097,0x6098,/* 0x88-0x8F */ 0x6099,0x609C,0x609E,0x60A1,0x60A2,0x60A4,0x60A5,0x60A7,/* 0x90-0x97 */ 0x60A9,0x60AA,0x60AE,0x60B0,0x60B3,0x60B5,0x60B6,0x60B7,/* 0x98-0x9F */ 0x60B9,0x60BA,0x60BD,0x60BE,0x60BF,0x60C0,0x60C1,0x60C2,/* 0xA0-0xA7 */ 0x60C3,0x60C4,0x60C7,0x60C8,0x60C9,0x60CC,0x60CD,0x60CE,/* 0xA8-0xAF */ 0x60CF,0x60D0,0x60D2,0x60D3,0x60D4,0x60D6,0x60D7,0x60D9,/* 0xB0-0xB7 */ 0x60DB,0x60DE,0x60E1,0x60E2,0x60E3,0x60E4,0x60E5,0x60EA,/* 0xB8-0xBF */ 0x60F1,0x60F2,0x60F5,0x60F7,0x60F8,0x60FB,0x60FC,0x60FD,/* 0xC0-0xC7 */ 0x60FE,0x60FF,0x6102,0x6103,0x6104,0x6105,0x6107,0x610A,/* 0xC8-0xCF */ 0x610B,0x610C,0x6110,0x6111,0x6112,0x6113,0x6114,0x6116,/* 0xD0-0xD7 */ 0x6117,0x6118,0x6119,0x611B,0x611C,0x611D,0x611E,0x6121,/* 0xD8-0xDF */ 0x6122,0x6125,0x6128,0x6129,0x612A,0x612C,0x612D,0x612E,/* 0xE0-0xE7 */ 0x612F,0x6130,0x6131,0x6132,0x6133,0x6134,0x6135,0x6136,/* 0xE8-0xEF */ 0x6137,0x6138,0x6139,0x613A,0x613B,0x613C,0x613D,0x613E,/* 0xF0-0xF7 */ 0x6140,0x6141,0x6142,0x6143,0x6144,0x6145,0x6146,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_91[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x6147,0x6149,0x614B,0x614D,0x614F,0x6150,0x6152,0x6153,/* 0x40-0x47 */ 0x6154,0x6156,0x6157,0x6158,0x6159,0x615A,0x615B,0x615C,/* 0x48-0x4F */ 0x615E,0x615F,0x6160,0x6161,0x6163,0x6164,0x6165,0x6166,/* 0x50-0x57 */ 0x6169,0x616A,0x616B,0x616C,0x616D,0x616E,0x616F,0x6171,/* 0x58-0x5F */ 0x6172,0x6173,0x6174,0x6176,0x6178,0x6179,0x617A,0x617B,/* 0x60-0x67 */ 0x617C,0x617D,0x617E,0x617F,0x6180,0x6181,0x6182,0x6183,/* 0x68-0x6F */ 0x6184,0x6185,0x6186,0x6187,0x6188,0x6189,0x618A,0x618C,/* 0x70-0x77 */ 0x618D,0x618F,0x6190,0x6191,0x6192,0x6193,0x6195,0x0000,/* 0x78-0x7F */ 0x6196,0x6197,0x6198,0x6199,0x619A,0x619B,0x619C,0x619E,/* 0x80-0x87 */ 0x619F,0x61A0,0x61A1,0x61A2,0x61A3,0x61A4,0x61A5,0x61A6,/* 0x88-0x8F */ 0x61AA,0x61AB,0x61AD,0x61AE,0x61AF,0x61B0,0x61B1,0x61B2,/* 0x90-0x97 */ 0x61B3,0x61B4,0x61B5,0x61B6,0x61B8,0x61B9,0x61BA,0x61BB,/* 0x98-0x9F */ 0x61BC,0x61BD,0x61BF,0x61C0,0x61C1,0x61C3,0x61C4,0x61C5,/* 0xA0-0xA7 */ 0x61C6,0x61C7,0x61C9,0x61CC,0x61CD,0x61CE,0x61CF,0x61D0,/* 0xA8-0xAF */ 0x61D3,0x61D5,0x61D6,0x61D7,0x61D8,0x61D9,0x61DA,0x61DB,/* 0xB0-0xB7 */ 0x61DC,0x61DD,0x61DE,0x61DF,0x61E0,0x61E1,0x61E2,0x61E3,/* 0xB8-0xBF */ 0x61E4,0x61E5,0x61E7,0x61E8,0x61E9,0x61EA,0x61EB,0x61EC,/* 0xC0-0xC7 */ 0x61ED,0x61EE,0x61EF,0x61F0,0x61F1,0x61F2,0x61F3,0x61F4,/* 0xC8-0xCF */ 0x61F6,0x61F7,0x61F8,0x61F9,0x61FA,0x61FB,0x61FC,0x61FD,/* 0xD0-0xD7 */ 0x61FE,0x6200,0x6201,0x6202,0x6203,0x6204,0x6205,0x6207,/* 0xD8-0xDF */ 0x6209,0x6213,0x6214,0x6219,0x621C,0x621D,0x621E,0x6220,/* 0xE0-0xE7 */ 0x6223,0x6226,0x6227,0x6228,0x6229,0x622B,0x622D,0x622F,/* 0xE8-0xEF */ 0x6230,0x6231,0x6232,0x6235,0x6236,0x6238,0x6239,0x623A,/* 0xF0-0xF7 */ 0x623B,0x623C,0x6242,0x6244,0x6245,0x6246,0x624A,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_92[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x624F,0x6250,0x6255,0x6256,0x6257,0x6259,0x625A,0x625C,/* 0x40-0x47 */ 0x625D,0x625E,0x625F,0x6260,0x6261,0x6262,0x6264,0x6265,/* 0x48-0x4F */ 0x6268,0x6271,0x6272,0x6274,0x6275,0x6277,0x6278,0x627A,/* 0x50-0x57 */ 0x627B,0x627D,0x6281,0x6282,0x6283,0x6285,0x6286,0x6287,/* 0x58-0x5F */ 0x6288,0x628B,0x628C,0x628D,0x628E,0x628F,0x6290,0x6294,/* 0x60-0x67 */ 0x6299,0x629C,0x629D,0x629E,0x62A3,0x62A6,0x62A7,0x62A9,/* 0x68-0x6F */ 0x62AA,0x62AD,0x62AE,0x62AF,0x62B0,0x62B2,0x62B3,0x62B4,/* 0x70-0x77 */ 0x62B6,0x62B7,0x62B8,0x62BA,0x62BE,0x62C0,0x62C1,0x0000,/* 0x78-0x7F */ 0x62C3,0x62CB,0x62CF,0x62D1,0x62D5,0x62DD,0x62DE,0x62E0,/* 0x80-0x87 */ 0x62E1,0x62E4,0x62EA,0x62EB,0x62F0,0x62F2,0x62F5,0x62F8,/* 0x88-0x8F */ 0x62F9,0x62FA,0x62FB,0x6300,0x6303,0x6304,0x6305,0x6306,/* 0x90-0x97 */ 0x630A,0x630B,0x630C,0x630D,0x630F,0x6310,0x6312,0x6313,/* 0x98-0x9F */ 0x6314,0x6315,0x6317,0x6318,0x6319,0x631C,0x6326,0x6327,/* 0xA0-0xA7 */ 0x6329,0x632C,0x632D,0x632E,0x6330,0x6331,0x6333,0x6334,/* 0xA8-0xAF */ 0x6335,0x6336,0x6337,0x6338,0x633B,0x633C,0x633E,0x633F,/* 0xB0-0xB7 */ 0x6340,0x6341,0x6344,0x6347,0x6348,0x634A,0x6351,0x6352,/* 0xB8-0xBF */ 0x6353,0x6354,0x6356,0x6357,0x6358,0x6359,0x635A,0x635B,/* 0xC0-0xC7 */ 0x635C,0x635D,0x6360,0x6364,0x6365,0x6366,0x6368,0x636A,/* 0xC8-0xCF */ 0x636B,0x636C,0x636F,0x6370,0x6372,0x6373,0x6374,0x6375,/* 0xD0-0xD7 */ 0x6378,0x6379,0x637C,0x637D,0x637E,0x637F,0x6381,0x6383,/* 0xD8-0xDF */ 0x6384,0x6385,0x6386,0x638B,0x638D,0x6391,0x6393,0x6394,/* 0xE0-0xE7 */ 0x6395,0x6397,0x6399,0x639A,0x639B,0x639C,0x639D,0x639E,/* 0xE8-0xEF */ 0x639F,0x63A1,0x63A4,0x63A6,0x63AB,0x63AF,0x63B1,0x63B2,/* 0xF0-0xF7 */ 0x63B5,0x63B6,0x63B9,0x63BB,0x63BD,0x63BF,0x63C0,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_93[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x63C1,0x63C2,0x63C3,0x63C5,0x63C7,0x63C8,0x63CA,0x63CB,/* 0x40-0x47 */ 0x63CC,0x63D1,0x63D3,0x63D4,0x63D5,0x63D7,0x63D8,0x63D9,/* 0x48-0x4F */ 0x63DA,0x63DB,0x63DC,0x63DD,0x63DF,0x63E2,0x63E4,0x63E5,/* 0x50-0x57 */ 0x63E6,0x63E7,0x63E8,0x63EB,0x63EC,0x63EE,0x63EF,0x63F0,/* 0x58-0x5F */ 0x63F1,0x63F3,0x63F5,0x63F7,0x63F9,0x63FA,0x63FB,0x63FC,/* 0x60-0x67 */ 0x63FE,0x6403,0x6404,0x6406,0x6407,0x6408,0x6409,0x640A,/* 0x68-0x6F */ 0x640D,0x640E,0x6411,0x6412,0x6415,0x6416,0x6417,0x6418,/* 0x70-0x77 */ 0x6419,0x641A,0x641D,0x641F,0x6422,0x6423,0x6424,0x0000,/* 0x78-0x7F */ 0x6425,0x6427,0x6428,0x6429,0x642B,0x642E,0x642F,0x6430,/* 0x80-0x87 */ 0x6431,0x6432,0x6433,0x6435,0x6436,0x6437,0x6438,0x6439,/* 0x88-0x8F */ 0x643B,0x643C,0x643E,0x6440,0x6442,0x6443,0x6449,0x644B,/* 0x90-0x97 */ 0x644C,0x644D,0x644E,0x644F,0x6450,0x6451,0x6453,0x6455,/* 0x98-0x9F */ 0x6456,0x6457,0x6459,0x645A,0x645B,0x645C,0x645D,0x645F,/* 0xA0-0xA7 */ 0x6460,0x6461,0x6462,0x6463,0x6464,0x6465,0x6466,0x6468,/* 0xA8-0xAF */ 0x646A,0x646B,0x646C,0x646E,0x646F,0x6470,0x6471,0x6472,/* 0xB0-0xB7 */ 0x6473,0x6474,0x6475,0x6476,0x6477,0x647B,0x647C,0x647D,/* 0xB8-0xBF */ 0x647E,0x647F,0x6480,0x6481,0x6483,0x6486,0x6488,0x6489,/* 0xC0-0xC7 */ 0x648A,0x648B,0x648C,0x648D,0x648E,0x648F,0x6490,0x6493,/* 0xC8-0xCF */ 0x6494,0x6497,0x6498,0x649A,0x649B,0x649C,0x649D,0x649F,/* 0xD0-0xD7 */ 0x64A0,0x64A1,0x64A2,0x64A3,0x64A5,0x64A6,0x64A7,0x64A8,/* 0xD8-0xDF */ 0x64AA,0x64AB,0x64AF,0x64B1,0x64B2,0x64B3,0x64B4,0x64B6,/* 0xE0-0xE7 */ 0x64B9,0x64BB,0x64BD,0x64BE,0x64BF,0x64C1,0x64C3,0x64C4,/* 0xE8-0xEF */ 0x64C6,0x64C7,0x64C8,0x64C9,0x64CA,0x64CB,0x64CC,0x64CF,/* 0xF0-0xF7 */ 0x64D1,0x64D3,0x64D4,0x64D5,0x64D6,0x64D9,0x64DA,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_94[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x64DB,0x64DC,0x64DD,0x64DF,0x64E0,0x64E1,0x64E3,0x64E5,/* 0x40-0x47 */ 0x64E7,0x64E8,0x64E9,0x64EA,0x64EB,0x64EC,0x64ED,0x64EE,/* 0x48-0x4F */ 0x64EF,0x64F0,0x64F1,0x64F2,0x64F3,0x64F4,0x64F5,0x64F6,/* 0x50-0x57 */ 0x64F7,0x64F8,0x64F9,0x64FA,0x64FB,0x64FC,0x64FD,0x64FE,/* 0x58-0x5F */ 0x64FF,0x6501,0x6502,0x6503,0x6504,0x6505,0x6506,0x6507,/* 0x60-0x67 */ 0x6508,0x650A,0x650B,0x650C,0x650D,0x650E,0x650F,0x6510,/* 0x68-0x6F */ 0x6511,0x6513,0x6514,0x6515,0x6516,0x6517,0x6519,0x651A,/* 0x70-0x77 */ 0x651B,0x651C,0x651D,0x651E,0x651F,0x6520,0x6521,0x0000,/* 0x78-0x7F */ 0x6522,0x6523,0x6524,0x6526,0x6527,0x6528,0x6529,0x652A,/* 0x80-0x87 */ 0x652C,0x652D,0x6530,0x6531,0x6532,0x6533,0x6537,0x653A,/* 0x88-0x8F */ 0x653C,0x653D,0x6540,0x6541,0x6542,0x6543,0x6544,0x6546,/* 0x90-0x97 */ 0x6547,0x654A,0x654B,0x654D,0x654E,0x6550,0x6552,0x6553,/* 0x98-0x9F */ 0x6554,0x6557,0x6558,0x655A,0x655C,0x655F,0x6560,0x6561,/* 0xA0-0xA7 */ 0x6564,0x6565,0x6567,0x6568,0x6569,0x656A,0x656D,0x656E,/* 0xA8-0xAF */ 0x656F,0x6571,0x6573,0x6575,0x6576,0x6578,0x6579,0x657A,/* 0xB0-0xB7 */ 0x657B,0x657C,0x657D,0x657E,0x657F,0x6580,0x6581,0x6582,/* 0xB8-0xBF */ 0x6583,0x6584,0x6585,0x6586,0x6588,0x6589,0x658A,0x658D,/* 0xC0-0xC7 */ 0x658E,0x658F,0x6592,0x6594,0x6595,0x6596,0x6598,0x659A,/* 0xC8-0xCF */ 0x659D,0x659E,0x65A0,0x65A2,0x65A3,0x65A6,0x65A8,0x65AA,/* 0xD0-0xD7 */ 0x65AC,0x65AE,0x65B1,0x65B2,0x65B3,0x65B4,0x65B5,0x65B6,/* 0xD8-0xDF */ 0x65B7,0x65B8,0x65BA,0x65BB,0x65BE,0x65BF,0x65C0,0x65C2,/* 0xE0-0xE7 */ 0x65C7,0x65C8,0x65C9,0x65CA,0x65CD,0x65D0,0x65D1,0x65D3,/* 0xE8-0xEF */ 0x65D4,0x65D5,0x65D8,0x65D9,0x65DA,0x65DB,0x65DC,0x65DD,/* 0xF0-0xF7 */ 0x65DE,0x65DF,0x65E1,0x65E3,0x65E4,0x65EA,0x65EB,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_95[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x65F2,0x65F3,0x65F4,0x65F5,0x65F8,0x65F9,0x65FB,0x65FC,/* 0x40-0x47 */ 0x65FD,0x65FE,0x65FF,0x6601,0x6604,0x6605,0x6607,0x6608,/* 0x48-0x4F */ 0x6609,0x660B,0x660D,0x6610,0x6611,0x6612,0x6616,0x6617,/* 0x50-0x57 */ 0x6618,0x661A,0x661B,0x661C,0x661E,0x6621,0x6622,0x6623,/* 0x58-0x5F */ 0x6624,0x6626,0x6629,0x662A,0x662B,0x662C,0x662E,0x6630,/* 0x60-0x67 */ 0x6632,0x6633,0x6637,0x6638,0x6639,0x663A,0x663B,0x663D,/* 0x68-0x6F */ 0x663F,0x6640,0x6642,0x6644,0x6645,0x6646,0x6647,0x6648,/* 0x70-0x77 */ 0x6649,0x664A,0x664D,0x664E,0x6650,0x6651,0x6658,0x0000,/* 0x78-0x7F */ 0x6659,0x665B,0x665C,0x665D,0x665E,0x6660,0x6662,0x6663,/* 0x80-0x87 */ 0x6665,0x6667,0x6669,0x666A,0x666B,0x666C,0x666D,0x6671,/* 0x88-0x8F */ 0x6672,0x6673,0x6675,0x6678,0x6679,0x667B,0x667C,0x667D,/* 0x90-0x97 */ 0x667F,0x6680,0x6681,0x6683,0x6685,0x6686,0x6688,0x6689,/* 0x98-0x9F */ 0x668A,0x668B,0x668D,0x668E,0x668F,0x6690,0x6692,0x6693,/* 0xA0-0xA7 */ 0x6694,0x6695,0x6698,0x6699,0x669A,0x669B,0x669C,0x669E,/* 0xA8-0xAF */ 0x669F,0x66A0,0x66A1,0x66A2,0x66A3,0x66A4,0x66A5,0x66A6,/* 0xB0-0xB7 */ 0x66A9,0x66AA,0x66AB,0x66AC,0x66AD,0x66AF,0x66B0,0x66B1,/* 0xB8-0xBF */ 0x66B2,0x66B3,0x66B5,0x66B6,0x66B7,0x66B8,0x66BA,0x66BB,/* 0xC0-0xC7 */ 0x66BC,0x66BD,0x66BF,0x66C0,0x66C1,0x66C2,0x66C3,0x66C4,/* 0xC8-0xCF */ 0x66C5,0x66C6,0x66C7,0x66C8,0x66C9,0x66CA,0x66CB,0x66CC,/* 0xD0-0xD7 */ 0x66CD,0x66CE,0x66CF,0x66D0,0x66D1,0x66D2,0x66D3,0x66D4,/* 0xD8-0xDF */ 0x66D5,0x66D6,0x66D7,0x66D8,0x66DA,0x66DE,0x66DF,0x66E0,/* 0xE0-0xE7 */ 0x66E1,0x66E2,0x66E3,0x66E4,0x66E5,0x66E7,0x66E8,0x66EA,/* 0xE8-0xEF */ 0x66EB,0x66EC,0x66ED,0x66EE,0x66EF,0x66F1,0x66F5,0x66F6,/* 0xF0-0xF7 */ 0x66F8,0x66FA,0x66FB,0x66FD,0x6701,0x6702,0x6703,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_96[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x6704,0x6705,0x6706,0x6707,0x670C,0x670E,0x670F,0x6711,/* 0x40-0x47 */ 0x6712,0x6713,0x6716,0x6718,0x6719,0x671A,0x671C,0x671E,/* 0x48-0x4F */ 0x6720,0x6721,0x6722,0x6723,0x6724,0x6725,0x6727,0x6729,/* 0x50-0x57 */ 0x672E,0x6730,0x6732,0x6733,0x6736,0x6737,0x6738,0x6739,/* 0x58-0x5F */ 0x673B,0x673C,0x673E,0x673F,0x6741,0x6744,0x6745,0x6747,/* 0x60-0x67 */ 0x674A,0x674B,0x674D,0x6752,0x6754,0x6755,0x6757,0x6758,/* 0x68-0x6F */ 0x6759,0x675A,0x675B,0x675D,0x6762,0x6763,0x6764,0x6766,/* 0x70-0x77 */ 0x6767,0x676B,0x676C,0x676E,0x6771,0x6774,0x6776,0x0000,/* 0x78-0x7F */ 0x6778,0x6779,0x677A,0x677B,0x677D,0x6780,0x6782,0x6783,/* 0x80-0x87 */ 0x6785,0x6786,0x6788,0x678A,0x678C,0x678D,0x678E,0x678F,/* 0x88-0x8F */ 0x6791,0x6792,0x6793,0x6794,0x6796,0x6799,0x679B,0x679F,/* 0x90-0x97 */ 0x67A0,0x67A1,0x67A4,0x67A6,0x67A9,0x67AC,0x67AE,0x67B1,/* 0x98-0x9F */ 0x67B2,0x67B4,0x67B9,0x67BA,0x67BB,0x67BC,0x67BD,0x67BE,/* 0xA0-0xA7 */ 0x67BF,0x67C0,0x67C2,0x67C5,0x67C6,0x67C7,0x67C8,0x67C9,/* 0xA8-0xAF */ 0x67CA,0x67CB,0x67CC,0x67CD,0x67CE,0x67D5,0x67D6,0x67D7,/* 0xB0-0xB7 */ 0x67DB,0x67DF,0x67E1,0x67E3,0x67E4,0x67E6,0x67E7,0x67E8,/* 0xB8-0xBF */ 0x67EA,0x67EB,0x67ED,0x67EE,0x67F2,0x67F5,0x67F6,0x67F7,/* 0xC0-0xC7 */ 0x67F8,0x67F9,0x67FA,0x67FB,0x67FC,0x67FE,0x6801,0x6802,/* 0xC8-0xCF */ 0x6803,0x6804,0x6806,0x680D,0x6810,0x6812,0x6814,0x6815,/* 0xD0-0xD7 */ 0x6818,0x6819,0x681A,0x681B,0x681C,0x681E,0x681F,0x6820,/* 0xD8-0xDF */ 0x6822,0x6823,0x6824,0x6825,0x6826,0x6827,0x6828,0x682B,/* 0xE0-0xE7 */ 0x682C,0x682D,0x682E,0x682F,0x6830,0x6831,0x6834,0x6835,/* 0xE8-0xEF */ 0x6836,0x683A,0x683B,0x683F,0x6847,0x684B,0x684D,0x684F,/* 0xF0-0xF7 */ 0x6852,0x6856,0x6857,0x6858,0x6859,0x685A,0x685B,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_97[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x685C,0x685D,0x685E,0x685F,0x686A,0x686C,0x686D,0x686E,/* 0x40-0x47 */ 0x686F,0x6870,0x6871,0x6872,0x6873,0x6875,0x6878,0x6879,/* 0x48-0x4F */ 0x687A,0x687B,0x687C,0x687D,0x687E,0x687F,0x6880,0x6882,/* 0x50-0x57 */ 0x6884,0x6887,0x6888,0x6889,0x688A,0x688B,0x688C,0x688D,/* 0x58-0x5F */ 0x688E,0x6890,0x6891,0x6892,0x6894,0x6895,0x6896,0x6898,/* 0x60-0x67 */ 0x6899,0x689A,0x689B,0x689C,0x689D,0x689E,0x689F,0x68A0,/* 0x68-0x6F */ 0x68A1,0x68A3,0x68A4,0x68A5,0x68A9,0x68AA,0x68AB,0x68AC,/* 0x70-0x77 */ 0x68AE,0x68B1,0x68B2,0x68B4,0x68B6,0x68B7,0x68B8,0x0000,/* 0x78-0x7F */ 0x68B9,0x68BA,0x68BB,0x68BC,0x68BD,0x68BE,0x68BF,0x68C1,/* 0x80-0x87 */ 0x68C3,0x68C4,0x68C5,0x68C6,0x68C7,0x68C8,0x68CA,0x68CC,/* 0x88-0x8F */ 0x68CE,0x68CF,0x68D0,0x68D1,0x68D3,0x68D4,0x68D6,0x68D7,/* 0x90-0x97 */ 0x68D9,0x68DB,0x68DC,0x68DD,0x68DE,0x68DF,0x68E1,0x68E2,/* 0x98-0x9F */ 0x68E4,0x68E5,0x68E6,0x68E7,0x68E8,0x68E9,0x68EA,0x68EB,/* 0xA0-0xA7 */ 0x68EC,0x68ED,0x68EF,0x68F2,0x68F3,0x68F4,0x68F6,0x68F7,/* 0xA8-0xAF */ 0x68F8,0x68FB,0x68FD,0x68FE,0x68FF,0x6900,0x6902,0x6903,/* 0xB0-0xB7 */ 0x6904,0x6906,0x6907,0x6908,0x6909,0x690A,0x690C,0x690F,/* 0xB8-0xBF */ 0x6911,0x6913,0x6914,0x6915,0x6916,0x6917,0x6918,0x6919,/* 0xC0-0xC7 */ 0x691A,0x691B,0x691C,0x691D,0x691E,0x6921,0x6922,0x6923,/* 0xC8-0xCF */ 0x6925,0x6926,0x6927,0x6928,0x6929,0x692A,0x692B,0x692C,/* 0xD0-0xD7 */ 0x692E,0x692F,0x6931,0x6932,0x6933,0x6935,0x6936,0x6937,/* 0xD8-0xDF */ 0x6938,0x693A,0x693B,0x693C,0x693E,0x6940,0x6941,0x6943,/* 0xE0-0xE7 */ 0x6944,0x6945,0x6946,0x6947,0x6948,0x6949,0x694A,0x694B,/* 0xE8-0xEF */ 0x694C,0x694D,0x694E,0x694F,0x6950,0x6951,0x6952,0x6953,/* 0xF0-0xF7 */ 0x6955,0x6956,0x6958,0x6959,0x695B,0x695C,0x695F,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_98[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x6961,0x6962,0x6964,0x6965,0x6967,0x6968,0x6969,0x696A,/* 0x40-0x47 */ 0x696C,0x696D,0x696F,0x6970,0x6972,0x6973,0x6974,0x6975,/* 0x48-0x4F */ 0x6976,0x697A,0x697B,0x697D,0x697E,0x697F,0x6981,0x6983,/* 0x50-0x57 */ 0x6985,0x698A,0x698B,0x698C,0x698E,0x698F,0x6990,0x6991,/* 0x58-0x5F */ 0x6992,0x6993,0x6996,0x6997,0x6999,0x699A,0x699D,0x699E,/* 0x60-0x67 */ 0x699F,0x69A0,0x69A1,0x69A2,0x69A3,0x69A4,0x69A5,0x69A6,/* 0x68-0x6F */ 0x69A9,0x69AA,0x69AC,0x69AE,0x69AF,0x69B0,0x69B2,0x69B3,/* 0x70-0x77 */ 0x69B5,0x69B6,0x69B8,0x69B9,0x69BA,0x69BC,0x69BD,0x0000,/* 0x78-0x7F */ 0x69BE,0x69BF,0x69C0,0x69C2,0x69C3,0x69C4,0x69C5,0x69C6,/* 0x80-0x87 */ 0x69C7,0x69C8,0x69C9,0x69CB,0x69CD,0x69CF,0x69D1,0x69D2,/* 0x88-0x8F */ 0x69D3,0x69D5,0x69D6,0x69D7,0x69D8,0x69D9,0x69DA,0x69DC,/* 0x90-0x97 */ 0x69DD,0x69DE,0x69E1,0x69E2,0x69E3,0x69E4,0x69E5,0x69E6,/* 0x98-0x9F */ 0x69E7,0x69E8,0x69E9,0x69EA,0x69EB,0x69EC,0x69EE,0x69EF,/* 0xA0-0xA7 */ 0x69F0,0x69F1,0x69F3,0x69F4,0x69F5,0x69F6,0x69F7,0x69F8,/* 0xA8-0xAF */ 0x69F9,0x69FA,0x69FB,0x69FC,0x69FE,0x6A00,0x6A01,0x6A02,/* 0xB0-0xB7 */ 0x6A03,0x6A04,0x6A05,0x6A06,0x6A07,0x6A08,0x6A09,0x6A0B,/* 0xB8-0xBF */ 0x6A0C,0x6A0D,0x6A0E,0x6A0F,0x6A10,0x6A11,0x6A12,0x6A13,/* 0xC0-0xC7 */ 0x6A14,0x6A15,0x6A16,0x6A19,0x6A1A,0x6A1B,0x6A1C,0x6A1D,/* 0xC8-0xCF */ 0x6A1E,0x6A20,0x6A22,0x6A23,0x6A24,0x6A25,0x6A26,0x6A27,/* 0xD0-0xD7 */ 0x6A29,0x6A2B,0x6A2C,0x6A2D,0x6A2E,0x6A30,0x6A32,0x6A33,/* 0xD8-0xDF */ 0x6A34,0x6A36,0x6A37,0x6A38,0x6A39,0x6A3A,0x6A3B,0x6A3C,/* 0xE0-0xE7 */ 0x6A3F,0x6A40,0x6A41,0x6A42,0x6A43,0x6A45,0x6A46,0x6A48,/* 0xE8-0xEF */ 0x6A49,0x6A4A,0x6A4B,0x6A4C,0x6A4D,0x6A4E,0x6A4F,0x6A51,/* 0xF0-0xF7 */ 0x6A52,0x6A53,0x6A54,0x6A55,0x6A56,0x6A57,0x6A5A,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_99[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x6A5C,0x6A5D,0x6A5E,0x6A5F,0x6A60,0x6A62,0x6A63,0x6A64,/* 0x40-0x47 */ 0x6A66,0x6A67,0x6A68,0x6A69,0x6A6A,0x6A6B,0x6A6C,0x6A6D,/* 0x48-0x4F */ 0x6A6E,0x6A6F,0x6A70,0x6A72,0x6A73,0x6A74,0x6A75,0x6A76,/* 0x50-0x57 */ 0x6A77,0x6A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CF */ 0x6AFA,0x6AFB,0x6AFC,0x6AFD,0x6AFE,0x6AFF,0x6B00,0x6B01,/* 0xD0-0xD7 */ 0x6B02,0x6B03,0x6B04,0x6B05,0x6B06,0x6B07,0x6B08,0x6B09,/* 0xD8-0xDF */ 0x6B0A,0x6B0B,0x6B0C,0x6B0D,0x6B0E,0x6B0F,0x6B10,0x6B11,/* 0xE0-0xE7 */ 0x6B12,0x6B13,0x6B14,0x6B15,0x6B16,0x6B17,0x6B18,0x6B19,/* 0xE8-0xEF */ 0x6B1A,0x6B1B,0x6B1C,0x6B1D,0x6B1E,0x6B1F,0x6B25,0x6B26,/* 0xF0-0xF7 */ 0x6B28,0x6B29,0x6B2A,0x6B2B,0x6B2C,0x6B2D,0x6B2E,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_9A[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x6B2F,0x6B30,0x6B31,0x6B33,0x6B34,0x6B35,0x6B36,0x6B38,/* 0x40-0x47 */ 0x6B3B,0x6B3C,0x6B3D,0x6B3F,0x6B40,0x6B41,0x6B42,0x6B44,/* 0x48-0x4F */ 0x6B45,0x6B48,0x6B4A,0x6B4B,0x6B4D,0x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BFB,0x6BFC,0x6BFE,/* 0xC8-0xCF */ 0x6BFF,0x6C00,0x6C01,0x6C02,0x6C03,0x6C04,0x6C08,0x6C09,/* 0xD0-0xD7 */ 0x6C0A,0x6C0B,0x6C0C,0x6C0E,0x6C12,0x6C17,0x6C1C,0x6C1D,/* 0xD8-0xDF */ 0x6C1E,0x6C20,0x6C23,0x6C25,0x6C2B,0x6C2C,0x6C2D,0x6C31,/* 0xE0-0xE7 */ 0x6C33,0x6C36,0x6C37,0x6C39,0x6C3A,0x6C3B,0x6C3C,0x6C3E,/* 0xE8-0xEF */ 0x6C3F,0x6C43,0x6C44,0x6C45,0x6C48,0x6C4B,0x6C4C,0x6C4D,/* 0xF0-0xF7 */ 0x6C4E,0x6C4F,0x6C51,0x6C52,0x6C53,0x6C56,0x6C58,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_9B[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x6C59,0x6C5A,0x6C62,0x6C63,0x6C65,0x6C66,0x6C67,0x6C6B,/* 0x40-0x47 */ 0x6C6C,0x6C6D,0x6C6E,0x6C6F,0x6C71,0x6C73,0x6C75,0x6C77,/* 0x48-0x4F */ 0x6C78,0x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6D71,0x6D72,0x6D73,0x6D75,/* 0xC8-0xCF */ 0x6D76,0x6D79,0x6D7A,0x6D7B,0x6D7D,0x6D7E,0x6D7F,0x6D80,/* 0xD0-0xD7 */ 0x6D81,0x6D83,0x6D84,0x6D86,0x6D87,0x6D8A,0x6D8B,0x6D8D,/* 0xD8-0xDF */ 0x6D8F,0x6D90,0x6D92,0x6D96,0x6D97,0x6D98,0x6D99,0x6D9A,/* 0xE0-0xE7 */ 0x6D9C,0x6DA2,0x6DA5,0x6DAC,0x6DAD,0x6DB0,0x6DB1,0x6DB3,/* 0xE8-0xEF */ 0x6DB4,0x6DB6,0x6DB7,0x6DB9,0x6DBA,0x6DBB,0x6DBC,0x6DBD,/* 0xF0-0xF7 */ 0x6DBE,0x6DC1,0x6DC2,0x6DC3,0x6DC8,0x6DC9,0x6DCA,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_9C[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x6DCD,0x6DCE,0x6DCF,0x6DD0,0x6DD2,0x6DD3,0x6DD4,0x6DD5,/* 0x40-0x47 */ 0x6DD7,0x6DDA,0x6DDB,0x6DDC,0x6DDF,0x6DE2,0x6DE3,0x6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x6E97,0x6E99,0x6E9A,0x6E9B,0x6E9D,/* 0xC8-0xCF */ 0x6E9E,0x6EA0,0x6EA1,0x6EA3,0x6EA4,0x6EA6,0x6EA8,0x6EA9,/* 0xD0-0xD7 */ 0x6EAB,0x6EAC,0x6EAD,0x6EAE,0x6EB0,0x6EB3,0x6EB5,0x6EB8,/* 0xD8-0xDF */ 0x6EB9,0x6EBC,0x6EBE,0x6EBF,0x6EC0,0x6EC3,0x6EC4,0x6EC5,/* 0xE0-0xE7 */ 0x6EC6,0x6EC8,0x6EC9,0x6ECA,0x6ECC,0x6ECD,0x6ECE,0x6ED0,/* 0xE8-0xEF */ 0x6ED2,0x6ED6,0x6ED8,0x6ED9,0x6EDB,0x6EDC,0x6EDD,0x6EE3,/* 0xF0-0xF7 */ 0x6EE7,0x6EEA,0x6EEB,0x6EEC,0x6EED,0x6EEE,0x6EEF,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_9D[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x6EF0,0x6EF1,0x6EF2,0x6EF3,0x6EF5,0x6EF6,0x6EF7,0x6EF8,/* 0x40-0x47 */ 0x6EFA,0x6EFB,0x6EFC,0x6EFD,0x6EFE,0x6EFF,0x6F00,0x6F01,/* 0x48-0x4F */ 0x6F03,0x6F04,0x6F05,0x6F07,0x6F08,0x6F0A,0x6F0B,0x6F0C,/* 0x50-0x57 */ 0x6F0D,0x6F0E,0x6F10,0x6F11,0x6F12,0x6F16,0x6F17,0x6F18,/* 0x58-0x5F */ 0x6F19,0x6F1A,0x6F1B,0x6F1C,0x6F1D,0x6F1E,0x6F1F,0x6F21,/* 0x60-0x67 */ 0x6F22,0x6F23,0x6F25,0x6F26,0x6F27,0x6F28,0x6F2C,0x6F2E,/* 0x68-0x6F */ 0x6F30,0x6F32,0x6F34,0x6F35,0x6F37,0x6F38,0x6F39,0x6F3A,/* 0x70-0x77 */ 0x6F3B,0x6F3C,0x6F3D,0x6F3F,0x6F40,0x6F41,0x6F42,0x0000,/* 0x78-0x7F */ 0x6F43,0x6F44,0x6F45,0x6F48,0x6F49,0x6F4A,0x6F4C,0x6F4E,/* 0x80-0x87 */ 0x6F4F,0x6F50,0x6F51,0x6F52,0x6F53,0x6F54,0x6F55,0x6F56,/* 0x88-0x8F */ 0x6F57,0x6F59,0x6F5A,0x6F5B,0x6F5D,0x6F5F,0x6F60,0x6F61,/* 0x90-0x97 */ 0x6F63,0x6F64,0x6F65,0x6F67,0x6F68,0x6F69,0x6F6A,0x6F6B,/* 0x98-0x9F */ 0x6F6C,0x6F6F,0x6F70,0x6F71,0x6F73,0x6F75,0x6F76,0x6F77,/* 0xA0-0xA7 */ 0x6F79,0x6F7B,0x6F7D,0x6F7E,0x6F7F,0x6F80,0x6F81,0x6F82,/* 0xA8-0xAF */ 0x6F83,0x6F85,0x6F86,0x6F87,0x6F8A,0x6F8B,0x6F8F,0x6F90,/* 0xB0-0xB7 */ 0x6F91,0x6F92,0x6F93,0x6F94,0x6F95,0x6F96,0x6F97,0x6F98,/* 0xB8-0xBF */ 0x6F99,0x6F9A,0x6F9B,0x6F9D,0x6F9E,0x6F9F,0x6FA0,0x6FA2,/* 0xC0-0xC7 */ 0x6FA3,0x6FA4,0x6FA5,0x6FA6,0x6FA8,0x6FA9,0x6FAA,0x6FAB,/* 0xC8-0xCF */ 0x6FAC,0x6FAD,0x6FAE,0x6FAF,0x6FB0,0x6FB1,0x6FB2,0x6FB4,/* 0xD0-0xD7 */ 0x6FB5,0x6FB7,0x6FB8,0x6FBA,0x6FBB,0x6FBC,0x6FBD,0x6FBE,/* 0xD8-0xDF */ 0x6FBF,0x6FC1,0x6FC3,0x6FC4,0x6FC5,0x6FC6,0x6FC7,0x6FC8,/* 0xE0-0xE7 */ 0x6FCA,0x6FCB,0x6FCC,0x6FCD,0x6FCE,0x6FCF,0x6FD0,0x6FD3,/* 0xE8-0xEF */ 0x6FD4,0x6FD5,0x6FD6,0x6FD7,0x6FD8,0x6FD9,0x6FDA,0x6FDB,/* 0xF0-0xF7 */ 0x6FDC,0x6FDD,0x6FDF,0x6FE2,0x6FE3,0x6FE4,0x6FE5,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_9E[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x6FE6,0x6FE7,0x6FE8,0x6FE9,0x6FEA,0x6FEB,0x6FEC,0x6FED,/* 0x40-0x47 */ 0x6FF0,0x6FF1,0x6FF2,0x6FF3,0x6FF4,0x6FF5,0x6FF6,0x6FF7,/* 0x48-0x4F */ 0x6FF8,0x6FF9,0x6FFA,0x6FFB,0x6FFC,0x6FFD,0x6FFE,0x6FFF,/* 0x50-0x57 */ 0x7000,0x7001,0x7002,0x7003,0x7004,0x7005,0x7006,0x7007,/* 0x58-0x5F */ 0x7008,0x7009,0x700A,0x700B,0x700C,0x700D,0x700E,0x700F,/* 0x60-0x67 */ 0x7010,0x7012,0x7013,0x7014,0x7015,0x7016,0x7017,0x7018,/* 0x68-0x6F */ 0x7019,0x701C,0x701D,0x701E,0x701F,0x7020,0x7021,0x7022,/* 0x70-0x77 */ 0x7024,0x7025,0x7026,0x7027,0x7028,0x7029,0x702A,0x0000,/* 0x78-0x7F */ 0x702B,0x702C,0x702D,0x702E,0x702F,0x7030,0x7031,0x7032,/* 0x80-0x87 */ 0x7033,0x7034,0x7036,0x7037,0x7038,0x703A,0x703B,0x703C,/* 0x88-0x8F */ 0x703D,0x703E,0x703F,0x7040,0x7041,0x7042,0x7043,0x7044,/* 0x90-0x97 */ 0x7045,0x7046,0x7047,0x7048,0x7049,0x704A,0x704B,0x704D,/* 0x98-0x9F */ 0x704E,0x7050,0x7051,0x7052,0x7053,0x7054,0x7055,0x7056,/* 0xA0-0xA7 */ 0x7057,0x7058,0x7059,0x705A,0x705B,0x705C,0x705D,0x705F,/* 0xA8-0xAF */ 0x7060,0x7061,0x7062,0x7063,0x7064,0x7065,0x7066,0x7067,/* 0xB0-0xB7 */ 0x7068,0x7069,0x706A,0x706E,0x7071,0x7072,0x7073,0x7074,/* 0xB8-0xBF */ 0x7077,0x7079,0x707A,0x707B,0x707D,0x7081,0x7082,0x7083,/* 0xC0-0xC7 */ 0x7084,0x7086,0x7087,0x7088,0x708B,0x708C,0x708D,0x708F,/* 0xC8-0xCF */ 0x7090,0x7091,0x7093,0x7097,0x7098,0x709A,0x709B,0x709E,/* 0xD0-0xD7 */ 0x709F,0x70A0,0x70A1,0x70A2,0x70A3,0x70A4,0x70A5,0x70A6,/* 0xD8-0xDF */ 0x70A7,0x70A8,0x70A9,0x70AA,0x70B0,0x70B2,0x70B4,0x70B5,/* 0xE0-0xE7 */ 0x70B6,0x70BA,0x70BE,0x70BF,0x70C4,0x70C5,0x70C6,0x70C7,/* 0xE8-0xEF */ 0x70C9,0x70CB,0x70CC,0x70CD,0x70CE,0x70CF,0x70D0,0x70D1,/* 0xF0-0xF7 */ 0x70D2,0x70D3,0x70D4,0x70D5,0x70D6,0x70D7,0x70DA,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_9F[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x70DC,0x70DD,0x70DE,0x70E0,0x70E1,0x70E2,0x70E3,0x70E5,/* 0x40-0x47 */ 0x70EA,0x70EE,0x70F0,0x70F1,0x70F2,0x70F3,0x70F4,0x70F5,/* 0x48-0x4F */ 0x70F6,0x70F8,0x70FA,0x70FB,0x70FC,0x70FE,0x70FF,0x7100,/* 0x50-0x57 */ 0x7101,0x7102,0x7103,0x7104,0x7105,0x7106,0x7107,0x7108,/* 0x58-0x5F */ 0x710B,0x710C,0x710D,0x710E,0x710F,0x7111,0x7112,0x7114,/* 0x60-0x67 */ 0x7117,0x711B,0x711C,0x711D,0x711E,0x711F,0x7120,0x7121,/* 0x68-0x6F */ 0x7122,0x7123,0x7124,0x7125,0x7127,0x7128,0x7129,0x712A,/* 0x70-0x77 */ 0x712B,0x712C,0x712D,0x712E,0x7132,0x7133,0x7134,0x0000,/* 0x78-0x7F */ 0x7135,0x7137,0x7138,0x7139,0x713A,0x713B,0x713C,0x713D,/* 0x80-0x87 */ 0x713E,0x713F,0x7140,0x7141,0x7142,0x7143,0x7144,0x7146,/* 0x88-0x8F */ 0x7147,0x7148,0x7149,0x714B,0x714D,0x714F,0x7150,0x7151,/* 0x90-0x97 */ 0x7152,0x7153,0x7154,0x7155,0x7156,0x7157,0x7158,0x7159,/* 0x98-0x9F */ 0x715A,0x715B,0x715D,0x715F,0x7160,0x7161,0x7162,0x7163,/* 0xA0-0xA7 */ 0x7165,0x7169,0x716A,0x716B,0x716C,0x716D,0x716F,0x7170,/* 0xA8-0xAF */ 0x7171,0x7174,0x7175,0x7176,0x7177,0x7179,0x717B,0x717C,/* 0xB0-0xB7 */ 0x717E,0x717F,0x7180,0x7181,0x7182,0x7183,0x7185,0x7186,/* 0xB8-0xBF */ 0x7187,0x7188,0x7189,0x718B,0x718C,0x718D,0x718E,0x7190,/* 0xC0-0xC7 */ 0x7191,0x7192,0x7193,0x7195,0x7196,0x7197,0x719A,0x719B,/* 0xC8-0xCF */ 0x719C,0x719D,0x719E,0x71A1,0x71A2,0x71A3,0x71A4,0x71A5,/* 0xD0-0xD7 */ 0x71A6,0x71A7,0x71A9,0x71AA,0x71AB,0x71AD,0x71AE,0x71AF,/* 0xD8-0xDF */ 0x71B0,0x71B1,0x71B2,0x71B4,0x71B6,0x71B7,0x71B8,0x71BA,/* 0xE0-0xE7 */ 0x71BB,0x71BC,0x71BD,0x71BE,0x71BF,0x71C0,0x71C1,0x71C2,/* 0xE8-0xEF */ 0x71C4,0x71C5,0x71C6,0x71C7,0x71C8,0x71C9,0x71CA,0x71CB,/* 0xF0-0xF7 */ 0x71CC,0x71CD,0x71CF,0x71D0,0x71D1,0x71D2,0x71D3,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_A0[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x71D6,0x71D7,0x71D8,0x71D9,0x71DA,0x71DB,0x71DC,0x71DD,/* 0x40-0x47 */ 0x71DE,0x71DF,0x71E1,0x71E2,0x71E3,0x71E4,0x71E6,0x71E8,/* 0x48-0x4F */ 0x71E9,0x71EA,0x71EB,0x71EC,0x71ED,0x71EF,0x71F0,0x71F1,/* 0x50-0x57 */ 0x71F2,0x71F3,0x71F4,0x71F5,0x71F6,0x71F7,0x71F8,0x71FA,/* 0x58-0x5F */ 0x71FB,0x71FC,0x71FD,0x71FE,0x71FF,0x7200,0x7201,0x7202,/* 0x60-0x67 */ 0x7203,0x7204,0x7205,0x7207,0x7208,0x7209,0x720A,0x720B,/* 0x68-0x6F */ 0x720C,0x720D,0x720E,0x720F,0x7210,0x7211,0x7212,0x7213,/* 0x70-0x77 */ 0x7214,0x7215,0x7216,0x7217,0x7218,0x7219,0x721A,0x0000,/* 0x78-0x7F */ 0x721B,0x721C,0x721E,0x721F,0x7220,0x7221,0x7222,0x7223,/* 0x80-0x87 */ 0x7224,0x7225,0x7226,0x7227,0x7229,0x722B,0x722D,0x722E,/* 0x88-0x8F */ 0x722F,0x7232,0x7233,0x7234,0x723A,0x723C,0x723E,0x7240,/* 0x90-0x97 */ 0x7241,0x7242,0x7243,0x7244,0x7245,0x7246,0x7249,0x724A,/* 0x98-0x9F */ 0x724B,0x724E,0x724F,0x7250,0x7251,0x7253,0x7254,0x7255,/* 0xA0-0xA7 */ 0x7257,0x7258,0x725A,0x725C,0x725E,0x7260,0x7263,0x7264,/* 0xA8-0xAF */ 0x7265,0x7268,0x726A,0x726B,0x726C,0x726D,0x7270,0x7271,/* 0xB0-0xB7 */ 0x7273,0x7274,0x7276,0x7277,0x7278,0x727B,0x727C,0x727D,/* 0xB8-0xBF */ 0x7282,0x7283,0x7285,0x7286,0x7287,0x7288,0x7289,0x728C,/* 0xC0-0xC7 */ 0x728E,0x7290,0x7291,0x7293,0x7294,0x7295,0x7296,0x7297,/* 0xC8-0xCF */ 0x7298,0x7299,0x729A,0x729B,0x729C,0x729D,0x729E,0x72A0,/* 0xD0-0xD7 */ 0x72A1,0x72A2,0x72A3,0x72A4,0x72A5,0x72A6,0x72A7,0x72A8,/* 0xD8-0xDF */ 0x72A9,0x72AA,0x72AB,0x72AE,0x72B1,0x72B2,0x72B3,0x72B5,/* 0xE0-0xE7 */ 0x72BA,0x72BB,0x72BC,0x72BD,0x72BE,0x72BF,0x72C0,0x72C5,/* 0xE8-0xEF */ 0x72C6,0x72C7,0x72C9,0x72CA,0x72CB,0x72CC,0x72CF,0x72D1,/* 0xF0-0xF7 */ 0x72D3,0x72D4,0x72D5,0x72D6,0x72D8,0x72DA,0x72DB,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_A1[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x40-0x47 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x48-0x4F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x50-0x57 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x58-0x5F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x60-0x67 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x68-0x6F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x70-0x77 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x78-0x7F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x80-0x87 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x88-0x8F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x90-0x97 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x98-0x9F */ 0x0000,0x3000,0x3001,0x3002,0x00B7,0x02C9,0x02C7,0x00A8,/* 0xA0-0xA7 */ 0x3003,0x3005,0x2014,0xFF5E,0x2016,0x2026,0x2018,0x2019,/* 0xA8-0xAF */ 0x201C,0x201D,0x3014,0x3015,0x3008,0x3009,0x300A,0x300B,/* 0xB0-0xB7 */ 0x300C,0x300D,0x300E,0x300F,0x3016,0x3017,0x3010,0x3011,/* 0xB8-0xBF */ 0x00B1,0x00D7,0x00F7,0x2236,0x2227,0x2228,0x2211,0x220F,/* 0xC0-0xC7 */ 0x222A,0x2229,0x2208,0x2237,0x221A,0x22A5,0x2225,0x2220,/* 0xC8-0xCF */ 0x2312,0x2299,0x222B,0x222E,0x2261,0x224C,0x2248,0x223D,/* 0xD0-0xD7 */ 0x221D,0x2260,0x226E,0x226F,0x2264,0x2265,0x221E,0x2235,/* 0xD8-0xDF */ 0x2234,0x2642,0x2640,0x00B0,0x2032,0x2033,0x2103,0xFF04,/* 0xE0-0xE7 */ 0x00A4,0xFFE0,0xFFE1,0x2030,0x00A7,0x2116,0x2606,0x2605,/* 0xE8-0xEF */ 0x25CB,0x25CF,0x25CE,0x25C7,0x25C6,0x25A1,0x25A0,0x25B3,/* 0xF0-0xF7 */ 0x25B2,0x203B,0x2192,0x2190,0x2191,0x2193,0x3013,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_A2[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x40-0x47 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x48-0x4F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x50-0x57 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x58-0x5F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x60-0x67 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x68-0x6F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x70-0x77 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x78-0x7F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x80-0x87 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x88-0x8F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x90-0x97 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x98-0x9F */ 0x0000,0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,/* 0xA0-0xA7 */ 0x2177,0x2178,0x2179,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA8-0xAF */ 0x0000,0x2488,0x2489,0x248A,0x248B,0x248C,0x248D,0x248E,/* 0xB0-0xB7 */ 0x248F,0x2490,0x2491,0x2492,0x2493,0x2494,0x2495,0x2496,/* 0xB8-0xBF */ 0x2497,0x2498,0x2499,0x249A,0x249B,0x2474,0x2475,0x2476,/* 0xC0-0xC7 */ 0x2477,0x2478,0x2479,0x247A,0x247B,0x247C,0x247D,0x247E,/* 0xC8-0xCF */ 0x247F,0x2480,0x2481,0x2482,0x2483,0x2484,0x2485,0x2486,/* 0xD0-0xD7 */ 0x2487,0x2460,0x2461,0x2462,0x2463,0x2464,0x2465,0x2466,/* 0xD8-0xDF */ 0x2467,0x2468,0x2469,0x0000,0x0000,0x3220,0x3221,0x3222,/* 0xE0-0xE7 */ 0x3223,0x3224,0x3225,0x3226,0x3227,0x3228,0x3229,0x0000,/* 0xE8-0xEF */ 0x0000,0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,/* 0xF0-0xF7 */ 0x2167,0x2168,0x2169,0x216A,0x216B,0x0000,0x0000,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_A3[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x40-0x47 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x48-0x4F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x50-0x57 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x58-0x5F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x60-0x67 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x68-0x6F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x70-0x77 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x78-0x7F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x80-0x87 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x88-0x8F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x90-0x97 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x98-0x9F */ 0x0000,0xFF01,0xFF02,0xFF03,0xFFE5,0xFF05,0xFF06,0xFF07,/* 0xA0-0xA7 */ 0xFF08,0xFF09,0xFF0A,0xFF0B,0xFF0C,0xFF0D,0xFF0E,0xFF0F,/* 0xA8-0xAF */ 0xFF10,0xFF11,0xFF12,0xFF13,0xFF14,0xFF15,0xFF16,0xFF17,/* 0xB0-0xB7 */ 0xFF18,0xFF19,0xFF1A,0xFF1B,0xFF1C,0xFF1D,0xFF1E,0xFF1F,/* 0xB8-0xBF */ 0xFF20,0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,/* 0xC0-0xC7 */ 0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,/* 0xC8-0xCF */ 0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,/* 0xD0-0xD7 */ 0xFF38,0xFF39,0xFF3A,0xFF3B,0xFF3C,0xFF3D,0xFF3E,0xFF3F,/* 0xD8-0xDF */ 0xFF40,0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,/* 0xE0-0xE7 */ 0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,/* 0xE8-0xEF */ 0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,/* 0xF0-0xF7 */ 0xFF58,0xFF59,0xFF5A,0xFF5B,0xFF5C,0xFF5D,0xFFE3,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_A4[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x40-0x47 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x48-0x4F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x50-0x57 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x58-0x5F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x60-0x67 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x68-0x6F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x70-0x77 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x78-0x7F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x80-0x87 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x88-0x8F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x90-0x97 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x98-0x9F */ 0x0000,0x3041,0x3042,0x3043,0x3044,0x3045,0x3046,0x3047,/* 0xA0-0xA7 */ 0x3048,0x3049,0x304A,0x304B,0x304C,0x304D,0x304E,0x304F,/* 0xA8-0xAF */ 0x3050,0x3051,0x3052,0x3053,0x3054,0x3055,0x3056,0x3057,/* 0xB0-0xB7 */ 0x3058,0x3059,0x305A,0x305B,0x305C,0x305D,0x305E,0x305F,/* 0xB8-0xBF */ 0x3060,0x3061,0x3062,0x3063,0x3064,0x3065,0x3066,0x3067,/* 0xC0-0xC7 */ 0x3068,0x3069,0x306A,0x306B,0x306C,0x306D,0x306E,0x306F,/* 0xC8-0xCF */ 0x3070,0x3071,0x3072,0x3073,0x3074,0x3075,0x3076,0x3077,/* 0xD0-0xD7 */ 0x3078,0x3079,0x307A,0x307B,0x307C,0x307D,0x307E,0x307F,/* 0xD8-0xDF */ 0x3080,0x3081,0x3082,0x3083,0x3084,0x3085,0x3086,0x3087,/* 0xE0-0xE7 */ 0x3088,0x3089,0x308A,0x308B,0x308C,0x308D,0x308E,0x308F,/* 0xE8-0xEF */ 0x3090,0x3091,0x3092,0x3093,0x0000,0x0000,0x0000,0x0000,/* 0xF0-0xF7 */ }; static const wchar_t c2u_A5[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x40-0x47 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x48-0x4F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x50-0x57 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x58-0x5F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x60-0x67 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x68-0x6F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x70-0x77 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x78-0x7F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x80-0x87 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x88-0x8F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x90-0x97 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x98-0x9F */ 0x0000,0x30A1,0x30A2,0x30A3,0x30A4,0x30A5,0x30A6,0x30A7,/* 0xA0-0xA7 */ 0x30A8,0x30A9,0x30AA,0x30AB,0x30AC,0x30AD,0x30AE,0x30AF,/* 0xA8-0xAF */ 0x30B0,0x30B1,0x30B2,0x30B3,0x30B4,0x30B5,0x30B6,0x30B7,/* 0xB0-0xB7 */ 0x30B8,0x30B9,0x30BA,0x30BB,0x30BC,0x30BD,0x30BE,0x30BF,/* 0xB8-0xBF */ 0x30C0,0x30C1,0x30C2,0x30C3,0x30C4,0x30C5,0x30C6,0x30C7,/* 0xC0-0xC7 */ 0x30C8,0x30C9,0x30CA,0x30CB,0x30CC,0x30CD,0x30CE,0x30CF,/* 0xC8-0xCF */ 0x30D0,0x30D1,0x30D2,0x30D3,0x30D4,0x30D5,0x30D6,0x30D7,/* 0xD0-0xD7 */ 0x30D8,0x30D9,0x30DA,0x30DB,0x30DC,0x30DD,0x30DE,0x30DF,/* 0xD8-0xDF */ 0x30E0,0x30E1,0x30E2,0x30E3,0x30E4,0x30E5,0x30E6,0x30E7,/* 0xE0-0xE7 */ 0x30E8,0x30E9,0x30EA,0x30EB,0x30EC,0x30ED,0x30EE,0x30EF,/* 0xE8-0xEF */ 0x30F0,0x30F1,0x30F2,0x30F3,0x30F4,0x30F5,0x30F6,0x0000,/* 0xF0-0xF7 */ }; static const wchar_t c2u_A6[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x40-0x47 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x48-0x4F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x50-0x57 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x58-0x5F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x60-0x67 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x68-0x6F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x70-0x77 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x78-0x7F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x80-0x87 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x88-0x8F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x90-0x97 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x98-0x9F */ 0x0000,0x0391,0x0392,0x0393,0x0394,0x0395,0x0396,0x0397,/* 0xA0-0xA7 */ 0x0398,0x0399,0x039A,0x039B,0x039C,0x039D,0x039E,0x039F,/* 0xA8-0xAF */ 0x03A0,0x03A1,0x03A3,0x03A4,0x03A5,0x03A6,0x03A7,0x03A8,/* 0xB0-0xB7 */ 0x03A9,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xB8-0xBF */ 0x0000,0x03B1,0x03B2,0x03B3,0x03B4,0x03B5,0x03B6,0x03B7,/* 0xC0-0xC7 */ 0x03B8,0x03B9,0x03BA,0x03BB,0x03BC,0x03BD,0x03BE,0x03BF,/* 0xC8-0xCF */ 0x03C0,0x03C1,0x03C3,0x03C4,0x03C5,0x03C6,0x03C7,0x03C8,/* 0xD0-0xD7 */ 0x03C9,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xD8-0xDF */ 0xFE35,0xFE36,0xFE39,0xFE3A,0xFE3F,0xFE40,0xFE3D,0xFE3E,/* 0xE0-0xE7 */ 0xFE41,0xFE42,0xFE43,0xFE44,0x0000,0x0000,0xFE3B,0xFE3C,/* 0xE8-0xEF */ 0xFE37,0xFE38,0xFE31,0x0000,0xFE33,0xFE34,0x0000,0x0000,/* 0xF0-0xF7 */ }; static const wchar_t c2u_A7[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x40-0x47 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x48-0x4F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x50-0x57 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x58-0x5F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x60-0x67 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x68-0x6F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x70-0x77 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x78-0x7F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x80-0x87 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x88-0x8F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x90-0x97 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x98-0x9F */ 0x0000,0x0410,0x0411,0x0412,0x0413,0x0414,0x0415,0x0401,/* 0xA0-0xA7 */ 0x0416,0x0417,0x0418,0x0419,0x041A,0x041B,0x041C,0x041D,/* 0xA8-0xAF */ 0x041E,0x041F,0x0420,0x0421,0x0422,0x0423,0x0424,0x0425,/* 0xB0-0xB7 */ 0x0426,0x0427,0x0428,0x0429,0x042A,0x042B,0x042C,0x042D,/* 0xB8-0xBF */ 0x042E,0x042F,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xC0-0xC7 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xC8-0xCF */ 0x0000,0x0430,0x0431,0x0432,0x0433,0x0434,0x0435,0x0451,/* 0xD0-0xD7 */ 0x0436,0x0437,0x0438,0x0439,0x043A,0x043B,0x043C,0x043D,/* 0xD8-0xDF */ 0x043E,0x043F,0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,/* 0xE0-0xE7 */ 0x0446,0x0447,0x0448,0x0449,0x044A,0x044B,0x044C,0x044D,/* 0xE8-0xEF */ 0x044E,0x044F,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xF0-0xF7 */ }; static const wchar_t c2u_A8[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x02CA,0x02CB,0x02D9,0x2013,0x2015,0x2025,0x2035,0x2105,/* 0x40-0x47 */ 0x2109,0x2196,0x2197,0x2198,0x2199,0x2215,0x221F,0x2223,/* 0x48-0x4F */ 0x2252,0x2266,0x2267,0x22BF,0x2550,0x2551,0x2552,0x2553,/* 0x50-0x57 */ 0x2554,0x2555,0x2556,0x2557,0x2558,0x2559,0x255A,0x255B,/* 0x58-0x5F */ 0x255C,0x255D,0x255E,0x255F,0x2560,0x2561,0x2562,0x2563,/* 0x60-0x67 */ 0x2564,0x2565,0x2566,0x2567,0x2568,0x2569,0x256A,0x256B,/* 0x68-0x6F */ 0x256C,0x256D,0x256E,0x256F,0x2570,0x2571,0x2572,0x2573,/* 0x70-0x77 */ 0x2581,0x2582,0x2583,0x2584,0x2585,0x2586,0x2587,0x0000,/* 0x78-0x7F */ 0x2588,0x2589,0x258A,0x258B,0x258C,0x258D,0x258E,0x258F,/* 0x80-0x87 */ 0x2593,0x2594,0x2595,0x25BC,0x25BD,0x25E2,0x25E3,0x25E4,/* 0x88-0x8F */ 0x25E5,0x2609,0x2295,0x3012,0x301D,0x301E,0x0000,0x0000,/* 0x90-0x97 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x98-0x9F */ 0x0000,0x0101,0x00E1,0x01CE,0x00E0,0x0113,0x00E9,0x011B,/* 0xA0-0xA7 */ 0x00E8,0x012B,0x00ED,0x01D0,0x00EC,0x014D,0x00F3,0x01D2,/* 0xA8-0xAF */ 0x00F2,0x016B,0x00FA,0x01D4,0x00F9,0x01D6,0x01D8,0x01DA,/* 0xB0-0xB7 */ 0x01DC,0x00FC,0x00EA,0x0251,0x0000,0x0144,0x0148,0x0000,/* 0xB8-0xBF */ 0x0261,0x0000,0x0000,0x0000,0x0000,0x3105,0x3106,0x3107,/* 0xC0-0xC7 */ 0x3108,0x3109,0x310A,0x310B,0x310C,0x310D,0x310E,0x310F,/* 0xC8-0xCF */ 0x3110,0x3111,0x3112,0x3113,0x3114,0x3115,0x3116,0x3117,/* 0xD0-0xD7 */ 0x3118,0x3119,0x311A,0x311B,0x311C,0x311D,0x311E,0x311F,/* 0xD8-0xDF */ 0x3120,0x3121,0x3122,0x3123,0x3124,0x3125,0x3126,0x3127,/* 0xE0-0xE7 */ 0x3128,0x3129,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xE8-0xEF */ }; static const wchar_t c2u_A9[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x3021,0x3022,0x3023,0x3024,0x3025,0x3026,0x3027,0x3028,/* 0x40-0x47 */ 0x3029,0x32A3,0x338E,0x338F,0x339C,0x339D,0x339E,0x33A1,/* 0x48-0x4F */ 0x33C4,0x33CE,0x33D1,0x33D2,0x33D5,0xFE30,0xFFE2,0xFFE4,/* 0x50-0x57 */ 0x0000,0x2121,0x3231,0x0000,0x2010,0x0000,0x0000,0x0000,/* 0x58-0x5F */ 0x30FC,0x309B,0x309C,0x30FD,0x30FE,0x3006,0x309D,0x309E,/* 0x60-0x67 */ 0xFE49,0xFE4A,0xFE4B,0xFE4C,0xFE4D,0xFE4E,0xFE4F,0xFE50,/* 0x68-0x6F */ 0xFE51,0xFE52,0xFE54,0xFE55,0xFE56,0xFE57,0xFE59,0xFE5A,/* 0x70-0x77 */ 0xFE5B,0xFE5C,0xFE5D,0xFE5E,0xFE5F,0xFE60,0xFE61,0x0000,/* 0x78-0x7F */ 0xFE62,0xFE63,0xFE64,0xFE65,0xFE66,0xFE68,0xFE69,0xFE6A,/* 0x80-0x87 */ 0xFE6B,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x88-0x8F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3007,0x0000,/* 0x90-0x97 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x98-0x9F */ 0x0000,0x0000,0x0000,0x0000,0x2500,0x2501,0x2502,0x2503,/* 0xA0-0xA7 */ 0x2504,0x2505,0x2506,0x2507,0x2508,0x2509,0x250A,0x250B,/* 0xA8-0xAF */ 0x250C,0x250D,0x250E,0x250F,0x2510,0x2511,0x2512,0x2513,/* 0xB0-0xB7 */ 0x2514,0x2515,0x2516,0x2517,0x2518,0x2519,0x251A,0x251B,/* 0xB8-0xBF */ 0x251C,0x251D,0x251E,0x251F,0x2520,0x2521,0x2522,0x2523,/* 0xC0-0xC7 */ 0x2524,0x2525,0x2526,0x2527,0x2528,0x2529,0x252A,0x252B,/* 0xC8-0xCF */ 0x252C,0x252D,0x252E,0x252F,0x2530,0x2531,0x2532,0x2533,/* 0xD0-0xD7 */ 0x2534,0x2535,0x2536,0x2537,0x2538,0x2539,0x253A,0x253B,/* 0xD8-0xDF */ 0x253C,0x253D,0x253E,0x253F,0x2540,0x2541,0x2542,0x2543,/* 0xE0-0xE7 */ 0x2544,0x2545,0x2546,0x2547,0x2548,0x2549,0x254A,0x254B,/* 0xE8-0xEF */ }; static const wchar_t c2u_AA[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x72DC,0x72DD,0x72DF,0x72E2,0x72E3,0x72E4,0x72E5,0x72E6,/* 0x40-0x47 */ 0x72E7,0x72EA,0x72EB,0x72F5,0x72F6,0x72F9,0x72FD,0x72FE,/* 0x48-0x4F */ 0x72FF,0x7300,0x7302,0x7304,0x7305,0x7306,0x7307,0x7308,/* 0x50-0x57 */ 0x7309,0x730B,0x730C,0x730D,0x730F,0x7310,0x7311,0x7312,/* 0x58-0x5F */ 0x7314,0x7318,0x7319,0x731A,0x731F,0x7320,0x7323,0x7324,/* 0x60-0x67 */ 0x7326,0x7327,0x7328,0x732D,0x732F,0x7330,0x7332,0x7333,/* 0x68-0x6F */ 0x7335,0x7336,0x733A,0x733B,0x733C,0x733D,0x7340,0x7341,/* 0x70-0x77 */ 0x7342,0x7343,0x7344,0x7345,0x7346,0x7347,0x7348,0x0000,/* 0x78-0x7F */ 0x7349,0x734A,0x734B,0x734C,0x734E,0x734F,0x7351,0x7353,/* 0x80-0x87 */ 0x7354,0x7355,0x7356,0x7358,0x7359,0x735A,0x735B,0x735C,/* 0x88-0x8F */ 0x735D,0x735E,0x735F,0x7361,0x7362,0x7363,0x7364,0x7365,/* 0x90-0x97 */ 0x7366,0x7367,0x7368,0x7369,0x736A,0x736B,0x736E,0x7370,/* 0x98-0x9F */ 0x7371,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_AB[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7372,0x7373,0x7374,0x7375,0x7376,0x7377,0x7378,0x7379,/* 0x40-0x47 */ 0x737A,0x737B,0x737C,0x737D,0x737F,0x7380,0x7381,0x7382,/* 0x48-0x4F */ 0x7383,0x7385,0x7386,0x7388,0x738A,0x738C,0x738D,0x738F,/* 0x50-0x57 */ 0x7390,0x7392,0x7393,0x7394,0x7395,0x7397,0x7398,0x7399,/* 0x58-0x5F */ 0x739A,0x739C,0x739D,0x739E,0x73A0,0x73A1,0x73A3,0x73A4,/* 0x60-0x67 */ 0x73A5,0x73A6,0x73A7,0x73A8,0x73AA,0x73AC,0x73AD,0x73B1,/* 0x68-0x6F */ 0x73B4,0x73B5,0x73B6,0x73B8,0x73B9,0x73BC,0x73BD,0x73BE,/* 0x70-0x77 */ 0x73BF,0x73C1,0x73C3,0x73C4,0x73C5,0x73C6,0x73C7,0x0000,/* 0x78-0x7F */ 0x73CB,0x73CC,0x73CE,0x73D2,0x73D3,0x73D4,0x73D5,0x73D6,/* 0x80-0x87 */ 0x73D7,0x73D8,0x73DA,0x73DB,0x73DC,0x73DD,0x73DF,0x73E1,/* 0x88-0x8F */ 0x73E2,0x73E3,0x73E4,0x73E6,0x73E8,0x73EA,0x73EB,0x73EC,/* 0x90-0x97 */ 0x73EE,0x73EF,0x73F0,0x73F1,0x73F3,0x73F4,0x73F5,0x73F6,/* 0x98-0x9F */ 0x73F7,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_AC[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x73F8,0x73F9,0x73FA,0x73FB,0x73FC,0x73FD,0x73FE,0x73FF,/* 0x40-0x47 */ 0x7400,0x7401,0x7402,0x7404,0x7407,0x7408,0x740B,0x740C,/* 0x48-0x4F */ 0x740D,0x740E,0x7411,0x7412,0x7413,0x7414,0x7415,0x7416,/* 0x50-0x57 */ 0x7417,0x7418,0x7419,0x741C,0x741D,0x741E,0x741F,0x7420,/* 0x58-0x5F */ 0x7421,0x7423,0x7424,0x7427,0x7429,0x742B,0x742D,0x742F,/* 0x60-0x67 */ 0x7431,0x7432,0x7437,0x7438,0x7439,0x743A,0x743B,0x743D,/* 0x68-0x6F */ 0x743E,0x743F,0x7440,0x7442,0x7443,0x7444,0x7445,0x7446,/* 0x70-0x77 */ 0x7447,0x7448,0x7449,0x744A,0x744B,0x744C,0x744D,0x0000,/* 0x78-0x7F */ 0x744E,0x744F,0x7450,0x7451,0x7452,0x7453,0x7454,0x7456,/* 0x80-0x87 */ 0x7458,0x745D,0x7460,0x7461,0x7462,0x7463,0x7464,0x7465,/* 0x88-0x8F */ 0x7466,0x7467,0x7468,0x7469,0x746A,0x746B,0x746C,0x746E,/* 0x90-0x97 */ 0x746F,0x7471,0x7472,0x7473,0x7474,0x7475,0x7478,0x7479,/* 0x98-0x9F */ 0x747A,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_AD[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x747B,0x747C,0x747D,0x747F,0x7482,0x7484,0x7485,0x7486,/* 0x40-0x47 */ 0x7488,0x7489,0x748A,0x748C,0x748D,0x748F,0x7491,0x7492,/* 0x48-0x4F */ 0x7493,0x7494,0x7495,0x7496,0x7497,0x7498,0x7499,0x749A,/* 0x50-0x57 */ 0x749B,0x749D,0x749F,0x74A0,0x74A1,0x74A2,0x74A3,0x74A4,/* 0x58-0x5F */ 0x74A5,0x74A6,0x74AA,0x74AB,0x74AC,0x74AD,0x74AE,0x74AF,/* 0x60-0x67 */ 0x74B0,0x74B1,0x74B2,0x74B3,0x74B4,0x74B5,0x74B6,0x74B7,/* 0x68-0x6F */ 0x74B8,0x74B9,0x74BB,0x74BC,0x74BD,0x74BE,0x74BF,0x74C0,/* 0x70-0x77 */ 0x74C1,0x74C2,0x74C3,0x74C4,0x74C5,0x74C6,0x74C7,0x0000,/* 0x78-0x7F */ 0x74C8,0x74C9,0x74CA,0x74CB,0x74CC,0x74CD,0x74CE,0x74CF,/* 0x80-0x87 */ 0x74D0,0x74D1,0x74D3,0x74D4,0x74D5,0x74D6,0x74D7,0x74D8,/* 0x88-0x8F */ 0x74D9,0x74DA,0x74DB,0x74DD,0x74DF,0x74E1,0x74E5,0x74E7,/* 0x90-0x97 */ 0x74E8,0x74E9,0x74EA,0x74EB,0x74EC,0x74ED,0x74F0,0x74F1,/* 0x98-0x9F */ 0x74F2,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_AE[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x74F3,0x74F5,0x74F8,0x74F9,0x74FA,0x74FB,0x74FC,0x74FD,/* 0x40-0x47 */ 0x74FE,0x7500,0x7501,0x7502,0x7503,0x7505,0x7506,0x7507,/* 0x48-0x4F */ 0x7508,0x7509,0x750A,0x750B,0x750C,0x750E,0x7510,0x7512,/* 0x50-0x57 */ 0x7514,0x7515,0x7516,0x7517,0x751B,0x751D,0x751E,0x7520,/* 0x58-0x5F */ 0x7521,0x7522,0x7523,0x7524,0x7526,0x7527,0x752A,0x752E,/* 0x60-0x67 */ 0x7534,0x7536,0x7539,0x753C,0x753D,0x753F,0x7541,0x7542,/* 0x68-0x6F */ 0x7543,0x7544,0x7546,0x7547,0x7549,0x754A,0x754D,0x7550,/* 0x70-0x77 */ 0x7551,0x7552,0x7553,0x7555,0x7556,0x7557,0x7558,0x0000,/* 0x78-0x7F */ 0x755D,0x755E,0x755F,0x7560,0x7561,0x7562,0x7563,0x7564,/* 0x80-0x87 */ 0x7567,0x7568,0x7569,0x756B,0x756C,0x756D,0x756E,0x756F,/* 0x88-0x8F */ 0x7570,0x7571,0x7573,0x7575,0x7576,0x7577,0x757A,0x757B,/* 0x90-0x97 */ 0x757C,0x757D,0x757E,0x7580,0x7581,0x7582,0x7584,0x7585,/* 0x98-0x9F */ 0x7587,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_AF[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7588,0x7589,0x758A,0x758C,0x758D,0x758E,0x7590,0x7593,/* 0x40-0x47 */ 0x7595,0x7598,0x759B,0x759C,0x759E,0x75A2,0x75A6,0x75A7,/* 0x48-0x4F */ 0x75A8,0x75A9,0x75AA,0x75AD,0x75B6,0x75B7,0x75BA,0x75BB,/* 0x50-0x57 */ 0x75BF,0x75C0,0x75C1,0x75C6,0x75CB,0x75CC,0x75CE,0x75CF,/* 0x58-0x5F */ 0x75D0,0x75D1,0x75D3,0x75D7,0x75D9,0x75DA,0x75DC,0x75DD,/* 0x60-0x67 */ 0x75DF,0x75E0,0x75E1,0x75E5,0x75E9,0x75EC,0x75ED,0x75EE,/* 0x68-0x6F */ 0x75EF,0x75F2,0x75F3,0x75F5,0x75F6,0x75F7,0x75F8,0x75FA,/* 0x70-0x77 */ 0x75FB,0x75FD,0x75FE,0x7602,0x7604,0x7606,0x7607,0x0000,/* 0x78-0x7F */ 0x7608,0x7609,0x760B,0x760D,0x760E,0x760F,0x7611,0x7612,/* 0x80-0x87 */ 0x7613,0x7614,0x7616,0x761A,0x761C,0x761D,0x761E,0x7621,/* 0x88-0x8F */ 0x7623,0x7627,0x7628,0x762C,0x762E,0x762F,0x7631,0x7632,/* 0x90-0x97 */ 0x7636,0x7637,0x7639,0x763A,0x763B,0x763D,0x7641,0x7642,/* 0x98-0x9F */ 0x7644,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_B0[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7645,0x7646,0x7647,0x7648,0x7649,0x764A,0x764B,0x764E,/* 0x40-0x47 */ 0x764F,0x7650,0x7651,0x7652,0x7653,0x7655,0x7657,0x7658,/* 0x48-0x4F */ 0x7659,0x765A,0x765B,0x765D,0x765F,0x7660,0x7661,0x7662,/* 0x50-0x57 */ 0x7664,0x7665,0x7666,0x7667,0x7668,0x7669,0x766A,0x766C,/* 0x58-0x5F */ 0x766D,0x766E,0x7670,0x7671,0x7672,0x7673,0x7674,0x7675,/* 0x60-0x67 */ 0x7676,0x7677,0x7679,0x767A,0x767C,0x767F,0x7680,0x7681,/* 0x68-0x6F */ 0x7683,0x7685,0x7689,0x768A,0x768C,0x768D,0x768F,0x7690,/* 0x70-0x77 */ 0x7692,0x7694,0x7695,0x7697,0x7698,0x769A,0x769B,0x0000,/* 0x78-0x7F */ 0x769C,0x769D,0x769E,0x769F,0x76A0,0x76A1,0x76A2,0x76A3,/* 0x80-0x87 */ 0x76A5,0x76A6,0x76A7,0x76A8,0x76A9,0x76AA,0x76AB,0x76AC,/* 0x88-0x8F */ 0x76AD,0x76AF,0x76B0,0x76B3,0x76B5,0x76B6,0x76B7,0x76B8,/* 0x90-0x97 */ 0x76B9,0x76BA,0x76BB,0x76BC,0x76BD,0x76BE,0x76C0,0x76C1,/* 0x98-0x9F */ 0x76C3,0x554A,0x963F,0x57C3,0x6328,0x54CE,0x5509,0x54C0,/* 0xA0-0xA7 */ 0x7691,0x764C,0x853C,0x77EE,0x827E,0x788D,0x7231,0x9698,/* 0xA8-0xAF */ 0x978D,0x6C28,0x5B89,0x4FFA,0x6309,0x6697,0x5CB8,0x80FA,/* 0xB0-0xB7 */ 0x6848,0x80AE,0x6602,0x76CE,0x51F9,0x6556,0x71AC,0x7FF1,/* 0xB8-0xBF */ 0x8884,0x50B2,0x5965,0x61CA,0x6FB3,0x82AD,0x634C,0x6252,/* 0xC0-0xC7 */ 0x53ED,0x5427,0x7B06,0x516B,0x75A4,0x5DF4,0x62D4,0x8DCB,/* 0xC8-0xCF */ 0x9776,0x628A,0x8019,0x575D,0x9738,0x7F62,0x7238,0x767D,/* 0xD0-0xD7 */ 0x67CF,0x767E,0x6446,0x4F70,0x8D25,0x62DC,0x7A17,0x6591,/* 0xD8-0xDF */ 0x73ED,0x642C,0x6273,0x822C,0x9881,0x677F,0x7248,0x626E,/* 0xE0-0xE7 */ 0x62CC,0x4F34,0x74E3,0x534A,0x529E,0x7ECA,0x90A6,0x5E2E,/* 0xE8-0xEF */ 0x6886,0x699C,0x8180,0x7ED1,0x68D2,0x78C5,0x868C,0x9551,/* 0xF0-0xF7 */ 0x508D,0x8C24,0x82DE,0x80DE,0x5305,0x8912,0x5265,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_B1[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x76C4,0x76C7,0x76C9,0x76CB,0x76CC,0x76D3,0x76D5,0x76D9,/* 0x40-0x47 */ 0x76DA,0x76DC,0x76DD,0x76DE,0x76E0,0x76E1,0x76E2,0x76E3,/* 0x48-0x4F */ 0x76E4,0x76E6,0x76E7,0x76E8,0x76E9,0x76EA,0x76EB,0x76EC,/* 0x50-0x57 */ 0x76ED,0x76F0,0x76F3,0x76F5,0x76F6,0x76F7,0x76FA,0x76FB,/* 0x58-0x5F */ 0x76FD,0x76FF,0x7700,0x7702,0x7703,0x7705,0x7706,0x770A,/* 0x60-0x67 */ 0x770C,0x770E,0x770F,0x7710,0x7711,0x7712,0x7713,0x7714,/* 0x68-0x6F */ 0x7715,0x7716,0x7717,0x7718,0x771B,0x771C,0x771D,0x771E,/* 0x70-0x77 */ 0x7721,0x7723,0x7724,0x7725,0x7727,0x772A,0x772B,0x0000,/* 0x78-0x7F */ 0x772C,0x772E,0x7730,0x7731,0x7732,0x7733,0x7734,0x7739,/* 0x80-0x87 */ 0x773B,0x773D,0x773E,0x773F,0x7742,0x7744,0x7745,0x7746,/* 0x88-0x8F */ 0x7748,0x7749,0x774A,0x774B,0x774C,0x774D,0x774E,0x774F,/* 0x90-0x97 */ 0x7752,0x7753,0x7754,0x7755,0x7756,0x7757,0x7758,0x7759,/* 0x98-0x9F */ 0x775C,0x8584,0x96F9,0x4FDD,0x5821,0x9971,0x5B9D,0x62B1,/* 0xA0-0xA7 */ 0x62A5,0x66B4,0x8C79,0x9C8D,0x7206,0x676F,0x7891,0x60B2,/* 0xA8-0xAF */ 0x5351,0x5317,0x8F88,0x80CC,0x8D1D,0x94A1,0x500D,0x72C8,/* 0xB0-0xB7 */ 0x5907,0x60EB,0x7119,0x88AB,0x5954,0x82EF,0x672C,0x7B28,/* 0xB8-0xBF */ 0x5D29,0x7EF7,0x752D,0x6CF5,0x8E66,0x8FF8,0x903C,0x9F3B,/* 0xC0-0xC7 */ 0x6BD4,0x9119,0x7B14,0x5F7C,0x78A7,0x84D6,0x853D,0x6BD5,/* 0xC8-0xCF */ 0x6BD9,0x6BD6,0x5E01,0x5E87,0x75F9,0x95ED,0x655D,0x5F0A,/* 0xD0-0xD7 */ 0x5FC5,0x8F9F,0x58C1,0x81C2,0x907F,0x965B,0x97AD,0x8FB9,/* 0xD8-0xDF */ 0x7F16,0x8D2C,0x6241,0x4FBF,0x53D8,0x535E,0x8FA8,0x8FA9,/* 0xE0-0xE7 */ 0x8FAB,0x904D,0x6807,0x5F6A,0x8198,0x8868,0x9CD6,0x618B,/* 0xE8-0xEF */ 0x522B,0x762A,0x5F6C,0x658C,0x6FD2,0x6EE8,0x5BBE,0x6448,/* 0xF0-0xF7 */ 0x5175,0x51B0,0x67C4,0x4E19,0x79C9,0x997C,0x70B3,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_B2[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x775D,0x775E,0x775F,0x7760,0x7764,0x7767,0x7769,0x776A,/* 0x40-0x47 */ 0x776D,0x776E,0x776F,0x7770,0x7771,0x7772,0x7773,0x7774,/* 0x48-0x4F */ 0x7775,0x7776,0x7777,0x7778,0x777A,0x777B,0x777C,0x7781,/* 0x50-0x57 */ 0x7782,0x7783,0x7786,0x7787,0x7788,0x7789,0x778A,0x778B,/* 0x58-0x5F */ 0x778F,0x7790,0x7793,0x7794,0x7795,0x7796,0x7797,0x7798,/* 0x60-0x67 */ 0x7799,0x779A,0x779B,0x779C,0x779D,0x779E,0x77A1,0x77A3,/* 0x68-0x6F */ 0x77A4,0x77A6,0x77A8,0x77AB,0x77AD,0x77AE,0x77AF,0x77B1,/* 0x70-0x77 */ 0x77B2,0x77B4,0x77B6,0x77B7,0x77B8,0x77B9,0x77BA,0x0000,/* 0x78-0x7F */ 0x77BC,0x77BE,0x77C0,0x77C1,0x77C2,0x77C3,0x77C4,0x77C5,/* 0x80-0x87 */ 0x77C6,0x77C7,0x77C8,0x77C9,0x77CA,0x77CB,0x77CC,0x77CE,/* 0x88-0x8F */ 0x77CF,0x77D0,0x77D1,0x77D2,0x77D3,0x77D4,0x77D5,0x77D6,/* 0x90-0x97 */ 0x77D8,0x77D9,0x77DA,0x77DD,0x77DE,0x77DF,0x77E0,0x77E1,/* 0x98-0x9F */ 0x77E4,0x75C5,0x5E76,0x73BB,0x83E0,0x64AD,0x62E8,0x94B5,/* 0xA0-0xA7 */ 0x6CE2,0x535A,0x52C3,0x640F,0x94C2,0x7B94,0x4F2F,0x5E1B,/* 0xA8-0xAF */ 0x8236,0x8116,0x818A,0x6E24,0x6CCA,0x9A73,0x6355,0x535C,/* 0xB0-0xB7 */ 0x54FA,0x8865,0x57E0,0x4E0D,0x5E03,0x6B65,0x7C3F,0x90E8,/* 0xB8-0xBF */ 0x6016,0x64E6,0x731C,0x88C1,0x6750,0x624D,0x8D22,0x776C,/* 0xC0-0xC7 */ 0x8E29,0x91C7,0x5F69,0x83DC,0x8521,0x9910,0x53C2,0x8695,/* 0xC8-0xCF */ 0x6B8B,0x60ED,0x60E8,0x707F,0x82CD,0x8231,0x4ED3,0x6CA7,/* 0xD0-0xD7 */ 0x85CF,0x64CD,0x7CD9,0x69FD,0x66F9,0x8349,0x5395,0x7B56,/* 0xD8-0xDF */ 0x4FA7,0x518C,0x6D4B,0x5C42,0x8E6D,0x63D2,0x53C9,0x832C,/* 0xE0-0xE7 */ 0x8336,0x67E5,0x78B4,0x643D,0x5BDF,0x5C94,0x5DEE,0x8BE7,/* 0xE8-0xEF */ 0x62C6,0x67F4,0x8C7A,0x6400,0x63BA,0x8749,0x998B,0x8C17,/* 0xF0-0xF7 */ 0x7F20,0x94F2,0x4EA7,0x9610,0x98A4,0x660C,0x7316,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_B3[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x77E6,0x77E8,0x77EA,0x77EF,0x77F0,0x77F1,0x77F2,0x77F4,/* 0x40-0x47 */ 0x77F5,0x77F7,0x77F9,0x77FA,0x77FB,0x77FC,0x7803,0x7804,/* 0x48-0x4F */ 0x7805,0x7806,0x7807,0x7808,0x780A,0x780B,0x780E,0x780F,/* 0x50-0x57 */ 0x7810,0x7813,0x7815,0x7819,0x781B,0x781E,0x7820,0x7821,/* 0x58-0x5F */ 0x7822,0x7824,0x7828,0x782A,0x782B,0x782E,0x782F,0x7831,/* 0x60-0x67 */ 0x7832,0x7833,0x7835,0x7836,0x783D,0x783F,0x7841,0x7842,/* 0x68-0x6F */ 0x7843,0x7844,0x7846,0x7848,0x7849,0x784A,0x784B,0x784D,/* 0x70-0x77 */ 0x784F,0x7851,0x7853,0x7854,0x7858,0x7859,0x785A,0x0000,/* 0x78-0x7F */ 0x785B,0x785C,0x785E,0x785F,0x7860,0x7861,0x7862,0x7863,/* 0x80-0x87 */ 0x7864,0x7865,0x7866,0x7867,0x7868,0x7869,0x786F,0x7870,/* 0x88-0x8F */ 0x7871,0x7872,0x7873,0x7874,0x7875,0x7876,0x7878,0x7879,/* 0x90-0x97 */ 0x787A,0x787B,0x787D,0x787E,0x787F,0x7880,0x7881,0x7882,/* 0x98-0x9F */ 0x7883,0x573A,0x5C1D,0x5E38,0x957F,0x507F,0x80A0,0x5382,/* 0xA0-0xA7 */ 0x655E,0x7545,0x5531,0x5021,0x8D85,0x6284,0x949E,0x671D,/* 0xA8-0xAF */ 0x5632,0x6F6E,0x5DE2,0x5435,0x7092,0x8F66,0x626F,0x64A4,/* 0xB0-0xB7 */ 0x63A3,0x5F7B,0x6F88,0x90F4,0x81E3,0x8FB0,0x5C18,0x6668,/* 0xB8-0xBF */ 0x5FF1,0x6C89,0x9648,0x8D81,0x886C,0x6491,0x79F0,0x57CE,/* 0xC0-0xC7 */ 0x6A59,0x6210,0x5448,0x4E58,0x7A0B,0x60E9,0x6F84,0x8BDA,/* 0xC8-0xCF */ 0x627F,0x901E,0x9A8B,0x79E4,0x5403,0x75F4,0x6301,0x5319,/* 0xD0-0xD7 */ 0x6C60,0x8FDF,0x5F1B,0x9A70,0x803B,0x9F7F,0x4F88,0x5C3A,/* 0xD8-0xDF */ 0x8D64,0x7FC5,0x65A5,0x70BD,0x5145,0x51B2,0x866B,0x5D07,/* 0xE0-0xE7 */ 0x5BA0,0x62BD,0x916C,0x7574,0x8E0C,0x7A20,0x6101,0x7B79,/* 0xE8-0xEF */ 0x4EC7,0x7EF8,0x7785,0x4E11,0x81ED,0x521D,0x51FA,0x6A71,/* 0xF0-0xF7 */ 0x53A8,0x8E87,0x9504,0x96CF,0x6EC1,0x9664,0x695A,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_B4[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7884,0x7885,0x7886,0x7888,0x788A,0x788B,0x788F,0x7890,/* 0x40-0x47 */ 0x7892,0x7894,0x7895,0x7896,0x7899,0x789D,0x789E,0x78A0,/* 0x48-0x4F */ 0x78A2,0x78A4,0x78A6,0x78A8,0x78A9,0x78AA,0x78AB,0x78AC,/* 0x50-0x57 */ 0x78AD,0x78AE,0x78AF,0x78B5,0x78B6,0x78B7,0x78B8,0x78BA,/* 0x58-0x5F */ 0x78BB,0x78BC,0x78BD,0x78BF,0x78C0,0x78C2,0x78C3,0x78C4,/* 0x60-0x67 */ 0x78C6,0x78C7,0x78C8,0x78CC,0x78CD,0x78CE,0x78CF,0x78D1,/* 0x68-0x6F */ 0x78D2,0x78D3,0x78D6,0x78D7,0x78D8,0x78DA,0x78DB,0x78DC,/* 0x70-0x77 */ 0x78DD,0x78DE,0x78DF,0x78E0,0x78E1,0x78E2,0x78E3,0x0000,/* 0x78-0x7F */ 0x78E4,0x78E5,0x78E6,0x78E7,0x78E9,0x78EA,0x78EB,0x78ED,/* 0x80-0x87 */ 0x78EE,0x78EF,0x78F0,0x78F1,0x78F3,0x78F5,0x78F6,0x78F8,/* 0x88-0x8F */ 0x78F9,0x78FB,0x78FC,0x78FD,0x78FE,0x78FF,0x7900,0x7902,/* 0x90-0x97 */ 0x7903,0x7904,0x7906,0x7907,0x7908,0x7909,0x790A,0x790B,/* 0x98-0x9F */ 0x790C,0x7840,0x50A8,0x77D7,0x6410,0x89E6,0x5904,0x63E3,/* 0xA0-0xA7 */ 0x5DDD,0x7A7F,0x693D,0x4F20,0x8239,0x5598,0x4E32,0x75AE,/* 0xA8-0xAF */ 0x7A97,0x5E62,0x5E8A,0x95EF,0x521B,0x5439,0x708A,0x6376,/* 0xB0-0xB7 */ 0x9524,0x5782,0x6625,0x693F,0x9187,0x5507,0x6DF3,0x7EAF,/* 0xB8-0xBF */ 0x8822,0x6233,0x7EF0,0x75B5,0x8328,0x78C1,0x96CC,0x8F9E,/* 0xC0-0xC7 */ 0x6148,0x74F7,0x8BCD,0x6B64,0x523A,0x8D50,0x6B21,0x806A,/* 0xC8-0xCF */ 0x8471,0x56F1,0x5306,0x4ECE,0x4E1B,0x51D1,0x7C97,0x918B,/* 0xD0-0xD7 */ 0x7C07,0x4FC3,0x8E7F,0x7BE1,0x7A9C,0x6467,0x5D14,0x50AC,/* 0xD8-0xDF */ 0x8106,0x7601,0x7CB9,0x6DEC,0x7FE0,0x6751,0x5B58,0x5BF8,/* 0xE0-0xE7 */ 0x78CB,0x64AE,0x6413,0x63AA,0x632B,0x9519,0x642D,0x8FBE,/* 0xE8-0xEF */ 0x7B54,0x7629,0x6253,0x5927,0x5446,0x6B79,0x50A3,0x6234,/* 0xF0-0xF7 */ 0x5E26,0x6B86,0x4EE3,0x8D37,0x888B,0x5F85,0x902E,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_B5[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x790D,0x790E,0x790F,0x7910,0x7911,0x7912,0x7914,0x7915,/* 0x40-0x47 */ 0x7916,0x7917,0x7918,0x7919,0x791A,0x791B,0x791C,0x791D,/* 0x48-0x4F */ 0x791F,0x7920,0x7921,0x7922,0x7923,0x7925,0x7926,0x7927,/* 0x50-0x57 */ 0x7928,0x7929,0x792A,0x792B,0x792C,0x792D,0x792E,0x792F,/* 0x58-0x5F */ 0x7930,0x7931,0x7932,0x7933,0x7935,0x7936,0x7937,0x7938,/* 0x60-0x67 */ 0x7939,0x793D,0x793F,0x7942,0x7943,0x7944,0x7945,0x7947,/* 0x68-0x6F */ 0x794A,0x794B,0x794C,0x794D,0x794E,0x794F,0x7950,0x7951,/* 0x70-0x77 */ 0x7952,0x7954,0x7955,0x7958,0x7959,0x7961,0x7963,0x0000,/* 0x78-0x7F */ 0x7964,0x7966,0x7969,0x796A,0x796B,0x796C,0x796E,0x7970,/* 0x80-0x87 */ 0x7971,0x7972,0x7973,0x7974,0x7975,0x7976,0x7979,0x797B,/* 0x88-0x8F */ 0x797C,0x797D,0x797E,0x797F,0x7982,0x7983,0x7986,0x7987,/* 0x90-0x97 */ 0x7988,0x7989,0x798B,0x798C,0x798D,0x798E,0x7990,0x7991,/* 0x98-0x9F */ 0x7992,0x6020,0x803D,0x62C5,0x4E39,0x5355,0x90F8,0x63B8,/* 0xA0-0xA7 */ 0x80C6,0x65E6,0x6C2E,0x4F46,0x60EE,0x6DE1,0x8BDE,0x5F39,/* 0xA8-0xAF */ 0x86CB,0x5F53,0x6321,0x515A,0x8361,0x6863,0x5200,0x6363,/* 0xB0-0xB7 */ 0x8E48,0x5012,0x5C9B,0x7977,0x5BFC,0x5230,0x7A3B,0x60BC,/* 0xB8-0xBF */ 0x9053,0x76D7,0x5FB7,0x5F97,0x7684,0x8E6C,0x706F,0x767B,/* 0xC0-0xC7 */ 0x7B49,0x77AA,0x51F3,0x9093,0x5824,0x4F4E,0x6EF4,0x8FEA,/* 0xC8-0xCF */ 0x654C,0x7B1B,0x72C4,0x6DA4,0x7FDF,0x5AE1,0x62B5,0x5E95,/* 0xD0-0xD7 */ 0x5730,0x8482,0x7B2C,0x5E1D,0x5F1F,0x9012,0x7F14,0x98A0,/* 0xD8-0xDF */ 0x6382,0x6EC7,0x7898,0x70B9,0x5178,0x975B,0x57AB,0x7535,/* 0xE0-0xE7 */ 0x4F43,0x7538,0x5E97,0x60E6,0x5960,0x6DC0,0x6BBF,0x7889,/* 0xE8-0xEF */ 0x53FC,0x96D5,0x51CB,0x5201,0x6389,0x540A,0x9493,0x8C03,/* 0xF0-0xF7 */ 0x8DCC,0x7239,0x789F,0x8776,0x8FED,0x8C0D,0x53E0,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_B6[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7993,0x7994,0x7995,0x7996,0x7997,0x7998,0x7999,0x799B,/* 0x40-0x47 */ 0x799C,0x799D,0x799E,0x799F,0x79A0,0x79A1,0x79A2,0x79A3,/* 0x48-0x4F */ 0x79A4,0x79A5,0x79A6,0x79A8,0x79A9,0x79AA,0x79AB,0x79AC,/* 0x50-0x57 */ 0x79AD,0x79AE,0x79AF,0x79B0,0x79B1,0x79B2,0x79B4,0x79B5,/* 0x58-0x5F */ 0x79B6,0x79B7,0x79B8,0x79BC,0x79BF,0x79C2,0x79C4,0x79C5,/* 0x60-0x67 */ 0x79C7,0x79C8,0x79CA,0x79CC,0x79CE,0x79CF,0x79D0,0x79D3,/* 0x68-0x6F */ 0x79D4,0x79D6,0x79D7,0x79D9,0x79DA,0x79DB,0x79DC,0x79DD,/* 0x70-0x77 */ 0x79DE,0x79E0,0x79E1,0x79E2,0x79E5,0x79E8,0x79EA,0x0000,/* 0x78-0x7F */ 0x79EC,0x79EE,0x79F1,0x79F2,0x79F3,0x79F4,0x79F5,0x79F6,/* 0x80-0x87 */ 0x79F7,0x79F9,0x79FA,0x79FC,0x79FE,0x79FF,0x7A01,0x7A04,/* 0x88-0x8F */ 0x7A05,0x7A07,0x7A08,0x7A09,0x7A0A,0x7A0C,0x7A0F,0x7A10,/* 0x90-0x97 */ 0x7A11,0x7A12,0x7A13,0x7A15,0x7A16,0x7A18,0x7A19,0x7A1B,/* 0x98-0x9F */ 0x7A1C,0x4E01,0x76EF,0x53EE,0x9489,0x9876,0x9F0E,0x952D,/* 0xA0-0xA7 */ 0x5B9A,0x8BA2,0x4E22,0x4E1C,0x51AC,0x8463,0x61C2,0x52A8,/* 0xA8-0xAF */ 0x680B,0x4F97,0x606B,0x51BB,0x6D1E,0x515C,0x6296,0x6597,/* 0xB0-0xB7 */ 0x9661,0x8C46,0x9017,0x75D8,0x90FD,0x7763,0x6BD2,0x728A,/* 0xB8-0xBF */ 0x72EC,0x8BFB,0x5835,0x7779,0x8D4C,0x675C,0x9540,0x809A,/* 0xC0-0xC7 */ 0x5EA6,0x6E21,0x5992,0x7AEF,0x77ED,0x953B,0x6BB5,0x65AD,/* 0xC8-0xCF */ 0x7F0E,0x5806,0x5151,0x961F,0x5BF9,0x58A9,0x5428,0x8E72,/* 0xD0-0xD7 */ 0x6566,0x987F,0x56E4,0x949D,0x76FE,0x9041,0x6387,0x54C6,/* 0xD8-0xDF */ 0x591A,0x593A,0x579B,0x8EB2,0x6735,0x8DFA,0x8235,0x5241,/* 0xE0-0xE7 */ 0x60F0,0x5815,0x86FE,0x5CE8,0x9E45,0x4FC4,0x989D,0x8BB9,/* 0xE8-0xEF */ 0x5A25,0x6076,0x5384,0x627C,0x904F,0x9102,0x997F,0x6069,/* 0xF0-0xF7 */ 0x800C,0x513F,0x8033,0x5C14,0x9975,0x6D31,0x4E8C,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_B7[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7A1D,0x7A1F,0x7A21,0x7A22,0x7A24,0x7A25,0x7A26,0x7A27,/* 0x40-0x47 */ 0x7A28,0x7A29,0x7A2A,0x7A2B,0x7A2C,0x7A2D,0x7A2E,0x7A2F,/* 0x48-0x4F */ 0x7A30,0x7A31,0x7A32,0x7A34,0x7A35,0x7A36,0x7A38,0x7A3A,/* 0x50-0x57 */ 0x7A3E,0x7A40,0x7A41,0x7A42,0x7A43,0x7A44,0x7A45,0x7A47,/* 0x58-0x5F */ 0x7A48,0x7A49,0x7A4A,0x7A4B,0x7A4C,0x7A4D,0x7A4E,0x7A4F,/* 0x60-0x67 */ 0x7A50,0x7A52,0x7A53,0x7A54,0x7A55,0x7A56,0x7A58,0x7A59,/* 0x68-0x6F */ 0x7A5A,0x7A5B,0x7A5C,0x7A5D,0x7A5E,0x7A5F,0x7A60,0x7A61,/* 0x70-0x77 */ 0x7A62,0x7A63,0x7A64,0x7A65,0x7A66,0x7A67,0x7A68,0x0000,/* 0x78-0x7F */ 0x7A69,0x7A6A,0x7A6B,0x7A6C,0x7A6D,0x7A6E,0x7A6F,0x7A71,/* 0x80-0x87 */ 0x7A72,0x7A73,0x7A75,0x7A7B,0x7A7C,0x7A7D,0x7A7E,0x7A82,/* 0x88-0x8F */ 0x7A85,0x7A87,0x7A89,0x7A8A,0x7A8B,0x7A8C,0x7A8E,0x7A8F,/* 0x90-0x97 */ 0x7A90,0x7A93,0x7A94,0x7A99,0x7A9A,0x7A9B,0x7A9E,0x7AA1,/* 0x98-0x9F */ 0x7AA2,0x8D30,0x53D1,0x7F5A,0x7B4F,0x4F10,0x4E4F,0x9600,/* 0xA0-0xA7 */ 0x6CD5,0x73D0,0x85E9,0x5E06,0x756A,0x7FFB,0x6A0A,0x77FE,/* 0xA8-0xAF */ 0x9492,0x7E41,0x51E1,0x70E6,0x53CD,0x8FD4,0x8303,0x8D29,/* 0xB0-0xB7 */ 0x72AF,0x996D,0x6CDB,0x574A,0x82B3,0x65B9,0x80AA,0x623F,/* 0xB8-0xBF */ 0x9632,0x59A8,0x4EFF,0x8BBF,0x7EBA,0x653E,0x83F2,0x975E,/* 0xC0-0xC7 */ 0x5561,0x98DE,0x80A5,0x532A,0x8BFD,0x5420,0x80BA,0x5E9F,/* 0xC8-0xCF */ 0x6CB8,0x8D39,0x82AC,0x915A,0x5429,0x6C1B,0x5206,0x7EB7,/* 0xD0-0xD7 */ 0x575F,0x711A,0x6C7E,0x7C89,0x594B,0x4EFD,0x5FFF,0x6124,/* 0xD8-0xDF */ 0x7CAA,0x4E30,0x5C01,0x67AB,0x8702,0x5CF0,0x950B,0x98CE,/* 0xE0-0xE7 */ 0x75AF,0x70FD,0x9022,0x51AF,0x7F1D,0x8BBD,0x5949,0x51E4,/* 0xE8-0xEF */ 0x4F5B,0x5426,0x592B,0x6577,0x80A4,0x5B75,0x6276,0x62C2,/* 0xF0-0xF7 */ 0x8F90,0x5E45,0x6C1F,0x7B26,0x4F0F,0x4FD8,0x670D,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_B8[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7AA3,0x7AA4,0x7AA7,0x7AA9,0x7AAA,0x7AAB,0x7AAE,0x7AAF,/* 0x40-0x47 */ 0x7AB0,0x7AB1,0x7AB2,0x7AB4,0x7AB5,0x7AB6,0x7AB7,0x7AB8,/* 0x48-0x4F */ 0x7AB9,0x7ABA,0x7ABB,0x7ABC,0x7ABD,0x7ABE,0x7AC0,0x7AC1,/* 0x50-0x57 */ 0x7AC2,0x7AC3,0x7AC4,0x7AC5,0x7AC6,0x7AC7,0x7AC8,0x7AC9,/* 0x58-0x5F */ 0x7ACA,0x7ACC,0x7ACD,0x7ACE,0x7ACF,0x7AD0,0x7AD1,0x7AD2,/* 0x60-0x67 */ 0x7AD3,0x7AD4,0x7AD5,0x7AD7,0x7AD8,0x7ADA,0x7ADB,0x7ADC,/* 0x68-0x6F */ 0x7ADD,0x7AE1,0x7AE2,0x7AE4,0x7AE7,0x7AE8,0x7AE9,0x7AEA,/* 0x70-0x77 */ 0x7AEB,0x7AEC,0x7AEE,0x7AF0,0x7AF1,0x7AF2,0x7AF3,0x0000,/* 0x78-0x7F */ 0x7AF4,0x7AF5,0x7AF6,0x7AF7,0x7AF8,0x7AFB,0x7AFC,0x7AFE,/* 0x80-0x87 */ 0x7B00,0x7B01,0x7B02,0x7B05,0x7B07,0x7B09,0x7B0C,0x7B0D,/* 0x88-0x8F */ 0x7B0E,0x7B10,0x7B12,0x7B13,0x7B16,0x7B17,0x7B18,0x7B1A,/* 0x90-0x97 */ 0x7B1C,0x7B1D,0x7B1F,0x7B21,0x7B22,0x7B23,0x7B27,0x7B29,/* 0x98-0x9F */ 0x7B2D,0x6D6E,0x6DAA,0x798F,0x88B1,0x5F17,0x752B,0x629A,/* 0xA0-0xA7 */ 0x8F85,0x4FEF,0x91DC,0x65A7,0x812F,0x8151,0x5E9C,0x8150,/* 0xA8-0xAF */ 0x8D74,0x526F,0x8986,0x8D4B,0x590D,0x5085,0x4ED8,0x961C,/* 0xB0-0xB7 */ 0x7236,0x8179,0x8D1F,0x5BCC,0x8BA3,0x9644,0x5987,0x7F1A,/* 0xB8-0xBF */ 0x5490,0x5676,0x560E,0x8BE5,0x6539,0x6982,0x9499,0x76D6,/* 0xC0-0xC7 */ 0x6E89,0x5E72,0x7518,0x6746,0x67D1,0x7AFF,0x809D,0x8D76,/* 0xC8-0xCF */ 0x611F,0x79C6,0x6562,0x8D63,0x5188,0x521A,0x94A2,0x7F38,/* 0xD0-0xD7 */ 0x809B,0x7EB2,0x5C97,0x6E2F,0x6760,0x7BD9,0x768B,0x9AD8,/* 0xD8-0xDF */ 0x818F,0x7F94,0x7CD5,0x641E,0x9550,0x7A3F,0x544A,0x54E5,/* 0xE0-0xE7 */ 0x6B4C,0x6401,0x6208,0x9E3D,0x80F3,0x7599,0x5272,0x9769,/* 0xE8-0xEF */ 0x845B,0x683C,0x86E4,0x9601,0x9694,0x94EC,0x4E2A,0x5404,/* 0xF0-0xF7 */ 0x7ED9,0x6839,0x8DDF,0x8015,0x66F4,0x5E9A,0x7FB9,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_B9[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7B2F,0x7B30,0x7B32,0x7B34,0x7B35,0x7B36,0x7B37,0x7B39,/* 0x40-0x47 */ 0x7B3B,0x7B3D,0x7B3F,0x7B40,0x7B41,0x7B42,0x7B43,0x7B44,/* 0x48-0x4F */ 0x7B46,0x7B48,0x7B4A,0x7B4D,0x7B4E,0x7B53,0x7B55,0x7B57,/* 0x50-0x57 */ 0x7B59,0x7B5C,0x7B5E,0x7B5F,0x7B61,0x7B63,0x7B64,0x7B65,/* 0x58-0x5F */ 0x7B66,0x7B67,0x7B68,0x7B69,0x7B6A,0x7B6B,0x7B6C,0x7B6D,/* 0x60-0x67 */ 0x7B6F,0x7B70,0x7B73,0x7B74,0x7B76,0x7B78,0x7B7A,0x7B7C,/* 0x68-0x6F */ 0x7B7D,0x7B7F,0x7B81,0x7B82,0x7B83,0x7B84,0x7B86,0x7B87,/* 0x70-0x77 */ 0x7B88,0x7B89,0x7B8A,0x7B8B,0x7B8C,0x7B8E,0x7B8F,0x0000,/* 0x78-0x7F */ 0x7B91,0x7B92,0x7B93,0x7B96,0x7B98,0x7B99,0x7B9A,0x7B9B,/* 0x80-0x87 */ 0x7B9E,0x7B9F,0x7BA0,0x7BA3,0x7BA4,0x7BA5,0x7BAE,0x7BAF,/* 0x88-0x8F */ 0x7BB0,0x7BB2,0x7BB3,0x7BB5,0x7BB6,0x7BB7,0x7BB9,0x7BBA,/* 0x90-0x97 */ 0x7BBB,0x7BBC,0x7BBD,0x7BBE,0x7BBF,0x7BC0,0x7BC2,0x7BC3,/* 0x98-0x9F */ 0x7BC4,0x57C2,0x803F,0x6897,0x5DE5,0x653B,0x529F,0x606D,/* 0xA0-0xA7 */ 0x9F9A,0x4F9B,0x8EAC,0x516C,0x5BAB,0x5F13,0x5DE9,0x6C5E,/* 0xA8-0xAF */ 0x62F1,0x8D21,0x5171,0x94A9,0x52FE,0x6C9F,0x82DF,0x72D7,/* 0xB0-0xB7 */ 0x57A2,0x6784,0x8D2D,0x591F,0x8F9C,0x83C7,0x5495,0x7B8D,/* 0xB8-0xBF */ 0x4F30,0x6CBD,0x5B64,0x59D1,0x9F13,0x53E4,0x86CA,0x9AA8,/* 0xC0-0xC7 */ 0x8C37,0x80A1,0x6545,0x987E,0x56FA,0x96C7,0x522E,0x74DC,/* 0xC8-0xCF */ 0x5250,0x5BE1,0x6302,0x8902,0x4E56,0x62D0,0x602A,0x68FA,/* 0xD0-0xD7 */ 0x5173,0x5B98,0x51A0,0x89C2,0x7BA1,0x9986,0x7F50,0x60EF,/* 0xD8-0xDF */ 0x704C,0x8D2F,0x5149,0x5E7F,0x901B,0x7470,0x89C4,0x572D,/* 0xE0-0xE7 */ 0x7845,0x5F52,0x9F9F,0x95FA,0x8F68,0x9B3C,0x8BE1,0x7678,/* 0xE8-0xEF */ 0x6842,0x67DC,0x8DEA,0x8D35,0x523D,0x8F8A,0x6EDA,0x68CD,/* 0xF0-0xF7 */ 0x9505,0x90ED,0x56FD,0x679C,0x88F9,0x8FC7,0x54C8,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_BA[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7BC5,0x7BC8,0x7BC9,0x7BCA,0x7BCB,0x7BCD,0x7BCE,0x7BCF,/* 0x40-0x47 */ 0x7BD0,0x7BD2,0x7BD4,0x7BD5,0x7BD6,0x7BD7,0x7BD8,0x7BDB,/* 0x48-0x4F */ 0x7BDC,0x7BDE,0x7BDF,0x7BE0,0x7BE2,0x7BE3,0x7BE4,0x7BE7,/* 0x50-0x57 */ 0x7BE8,0x7BE9,0x7BEB,0x7BEC,0x7BED,0x7BEF,0x7BF0,0x7BF2,/* 0x58-0x5F */ 0x7BF3,0x7BF4,0x7BF5,0x7BF6,0x7BF8,0x7BF9,0x7BFA,0x7BFB,/* 0x60-0x67 */ 0x7BFD,0x7BFF,0x7C00,0x7C01,0x7C02,0x7C03,0x7C04,0x7C05,/* 0x68-0x6F */ 0x7C06,0x7C08,0x7C09,0x7C0A,0x7C0D,0x7C0E,0x7C10,0x7C11,/* 0x70-0x77 */ 0x7C12,0x7C13,0x7C14,0x7C15,0x7C17,0x7C18,0x7C19,0x0000,/* 0x78-0x7F */ 0x7C1A,0x7C1B,0x7C1C,0x7C1D,0x7C1E,0x7C20,0x7C21,0x7C22,/* 0x80-0x87 */ 0x7C23,0x7C24,0x7C25,0x7C28,0x7C29,0x7C2B,0x7C2C,0x7C2D,/* 0x88-0x8F */ 0x7C2E,0x7C2F,0x7C30,0x7C31,0x7C32,0x7C33,0x7C34,0x7C35,/* 0x90-0x97 */ 0x7C36,0x7C37,0x7C39,0x7C3A,0x7C3B,0x7C3C,0x7C3D,0x7C3E,/* 0x98-0x9F */ 0x7C42,0x9AB8,0x5B69,0x6D77,0x6C26,0x4EA5,0x5BB3,0x9A87,/* 0xA0-0xA7 */ 0x9163,0x61A8,0x90AF,0x97E9,0x542B,0x6DB5,0x5BD2,0x51FD,/* 0xA8-0xAF */ 0x558A,0x7F55,0x7FF0,0x64BC,0x634D,0x65F1,0x61BE,0x608D,/* 0xB0-0xB7 */ 0x710A,0x6C57,0x6C49,0x592F,0x676D,0x822A,0x58D5,0x568E,/* 0xB8-0xBF */ 0x8C6A,0x6BEB,0x90DD,0x597D,0x8017,0x53F7,0x6D69,0x5475,/* 0xC0-0xC7 */ 0x559D,0x8377,0x83CF,0x6838,0x79BE,0x548C,0x4F55,0x5408,/* 0xC8-0xCF */ 0x76D2,0x8C89,0x9602,0x6CB3,0x6DB8,0x8D6B,0x8910,0x9E64,/* 0xD0-0xD7 */ 0x8D3A,0x563F,0x9ED1,0x75D5,0x5F88,0x72E0,0x6068,0x54FC,/* 0xD8-0xDF */ 0x4EA8,0x6A2A,0x8861,0x6052,0x8F70,0x54C4,0x70D8,0x8679,/* 0xE0-0xE7 */ 0x9E3F,0x6D2A,0x5B8F,0x5F18,0x7EA2,0x5589,0x4FAF,0x7334,/* 0xE8-0xEF */ 0x543C,0x539A,0x5019,0x540E,0x547C,0x4E4E,0x5FFD,0x745A,/* 0xF0-0xF7 */ 0x58F6,0x846B,0x80E1,0x8774,0x72D0,0x7CCA,0x6E56,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_BB[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7C43,0x7C44,0x7C45,0x7C46,0x7C47,0x7C48,0x7C49,0x7C4A,/* 0x40-0x47 */ 0x7C4B,0x7C4C,0x7C4E,0x7C4F,0x7C50,0x7C51,0x7C52,0x7C53,/* 0x48-0x4F */ 0x7C54,0x7C55,0x7C56,0x7C57,0x7C58,0x7C59,0x7C5A,0x7C5B,/* 0x50-0x57 */ 0x7C5C,0x7C5D,0x7C5E,0x7C5F,0x7C60,0x7C61,0x7C62,0x7C63,/* 0x58-0x5F */ 0x7C64,0x7C65,0x7C66,0x7C67,0x7C68,0x7C69,0x7C6A,0x7C6B,/* 0x60-0x67 */ 0x7C6C,0x7C6D,0x7C6E,0x7C6F,0x7C70,0x7C71,0x7C72,0x7C75,/* 0x68-0x6F */ 0x7C76,0x7C77,0x7C78,0x7C79,0x7C7A,0x7C7E,0x7C7F,0x7C80,/* 0x70-0x77 */ 0x7C81,0x7C82,0x7C83,0x7C84,0x7C85,0x7C86,0x7C87,0x0000,/* 0x78-0x7F */ 0x7C88,0x7C8A,0x7C8B,0x7C8C,0x7C8D,0x7C8E,0x7C8F,0x7C90,/* 0x80-0x87 */ 0x7C93,0x7C94,0x7C96,0x7C99,0x7C9A,0x7C9B,0x7CA0,0x7CA1,/* 0x88-0x8F */ 0x7CA3,0x7CA6,0x7CA7,0x7CA8,0x7CA9,0x7CAB,0x7CAC,0x7CAD,/* 0x90-0x97 */ 0x7CAF,0x7CB0,0x7CB4,0x7CB5,0x7CB6,0x7CB7,0x7CB8,0x7CBA,/* 0x98-0x9F */ 0x7CBB,0x5F27,0x864E,0x552C,0x62A4,0x4E92,0x6CAA,0x6237,/* 0xA0-0xA7 */ 0x82B1,0x54D7,0x534E,0x733E,0x6ED1,0x753B,0x5212,0x5316,/* 0xA8-0xAF */ 0x8BDD,0x69D0,0x5F8A,0x6000,0x6DEE,0x574F,0x6B22,0x73AF,/* 0xB0-0xB7 */ 0x6853,0x8FD8,0x7F13,0x6362,0x60A3,0x5524,0x75EA,0x8C62,/* 0xB8-0xBF */ 0x7115,0x6DA3,0x5BA6,0x5E7B,0x8352,0x614C,0x9EC4,0x78FA,/* 0xC0-0xC7 */ 0x8757,0x7C27,0x7687,0x51F0,0x60F6,0x714C,0x6643,0x5E4C,/* 0xC8-0xCF */ 0x604D,0x8C0E,0x7070,0x6325,0x8F89,0x5FBD,0x6062,0x86D4,/* 0xD0-0xD7 */ 0x56DE,0x6BC1,0x6094,0x6167,0x5349,0x60E0,0x6666,0x8D3F,/* 0xD8-0xDF */ 0x79FD,0x4F1A,0x70E9,0x6C47,0x8BB3,0x8BF2,0x7ED8,0x8364,/* 0xE0-0xE7 */ 0x660F,0x5A5A,0x9B42,0x6D51,0x6DF7,0x8C41,0x6D3B,0x4F19,/* 0xE8-0xEF */ 0x706B,0x83B7,0x6216,0x60D1,0x970D,0x8D27,0x7978,0x51FB,/* 0xF0-0xF7 */ 0x573E,0x57FA,0x673A,0x7578,0x7A3D,0x79EF,0x7B95,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_BC[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7CBF,0x7CC0,0x7CC2,0x7CC3,0x7CC4,0x7CC6,0x7CC9,0x7CCB,/* 0x40-0x47 */ 0x7CCE,0x7CCF,0x7CD0,0x7CD1,0x7CD2,0x7CD3,0x7CD4,0x7CD8,/* 0x48-0x4F */ 0x7CDA,0x7CDB,0x7CDD,0x7CDE,0x7CE1,0x7CE2,0x7CE3,0x7CE4,/* 0x50-0x57 */ 0x7CE5,0x7CE6,0x7CE7,0x7CE9,0x7CEA,0x7CEB,0x7CEC,0x7CED,/* 0x58-0x5F */ 0x7CEE,0x7CF0,0x7CF1,0x7CF2,0x7CF3,0x7CF4,0x7CF5,0x7CF6,/* 0x60-0x67 */ 0x7CF7,0x7CF9,0x7CFA,0x7CFC,0x7CFD,0x7CFE,0x7CFF,0x7D00,/* 0x68-0x6F */ 0x7D01,0x7D02,0x7D03,0x7D04,0x7D05,0x7D06,0x7D07,0x7D08,/* 0x70-0x77 */ 0x7D09,0x7D0B,0x7D0C,0x7D0D,0x7D0E,0x7D0F,0x7D10,0x0000,/* 0x78-0x7F */ 0x7D11,0x7D12,0x7D13,0x7D14,0x7D15,0x7D16,0x7D17,0x7D18,/* 0x80-0x87 */ 0x7D19,0x7D1A,0x7D1B,0x7D1C,0x7D1D,0x7D1E,0x7D1F,0x7D21,/* 0x88-0x8F */ 0x7D23,0x7D24,0x7D25,0x7D26,0x7D28,0x7D29,0x7D2A,0x7D2C,/* 0x90-0x97 */ 0x7D2D,0x7D2E,0x7D30,0x7D31,0x7D32,0x7D33,0x7D34,0x7D35,/* 0x98-0x9F */ 0x7D36,0x808C,0x9965,0x8FF9,0x6FC0,0x8BA5,0x9E21,0x59EC,/* 0xA0-0xA7 */ 0x7EE9,0x7F09,0x5409,0x6781,0x68D8,0x8F91,0x7C4D,0x96C6,/* 0xA8-0xAF */ 0x53CA,0x6025,0x75BE,0x6C72,0x5373,0x5AC9,0x7EA7,0x6324,/* 0xB0-0xB7 */ 0x51E0,0x810A,0x5DF1,0x84DF,0x6280,0x5180,0x5B63,0x4F0E,/* 0xB8-0xBF */ 0x796D,0x5242,0x60B8,0x6D4E,0x5BC4,0x5BC2,0x8BA1,0x8BB0,/* 0xC0-0xC7 */ 0x65E2,0x5FCC,0x9645,0x5993,0x7EE7,0x7EAA,0x5609,0x67B7,/* 0xC8-0xCF */ 0x5939,0x4F73,0x5BB6,0x52A0,0x835A,0x988A,0x8D3E,0x7532,/* 0xD0-0xD7 */ 0x94BE,0x5047,0x7A3C,0x4EF7,0x67B6,0x9A7E,0x5AC1,0x6B7C,/* 0xD8-0xDF */ 0x76D1,0x575A,0x5C16,0x7B3A,0x95F4,0x714E,0x517C,0x80A9,/* 0xE0-0xE7 */ 0x8270,0x5978,0x7F04,0x8327,0x68C0,0x67EC,0x78B1,0x7877,/* 0xE8-0xEF */ 0x62E3,0x6361,0x7B80,0x4FED,0x526A,0x51CF,0x8350,0x69DB,/* 0xF0-0xF7 */ 0x9274,0x8DF5,0x8D31,0x89C1,0x952E,0x7BAD,0x4EF6,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_BD[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7D37,0x7D38,0x7D39,0x7D3A,0x7D3B,0x7D3C,0x7D3D,0x7D3E,/* 0x40-0x47 */ 0x7D3F,0x7D40,0x7D41,0x7D42,0x7D43,0x7D44,0x7D45,0x7D46,/* 0x48-0x4F */ 0x7D47,0x7D48,0x7D49,0x7D4A,0x7D4B,0x7D4C,0x7D4D,0x7D4E,/* 0x50-0x57 */ 0x7D4F,0x7D50,0x7D51,0x7D52,0x7D53,0x7D54,0x7D55,0x7D56,/* 0x58-0x5F */ 0x7D57,0x7D58,0x7D59,0x7D5A,0x7D5B,0x7D5C,0x7D5D,0x7D5E,/* 0x60-0x67 */ 0x7D5F,0x7D60,0x7D61,0x7D62,0x7D63,0x7D64,0x7D65,0x7D66,/* 0x68-0x6F */ 0x7D67,0x7D68,0x7D69,0x7D6A,0x7D6B,0x7D6C,0x7D6D,0x7D6F,/* 0x70-0x77 */ 0x7D70,0x7D71,0x7D72,0x7D73,0x7D74,0x7D75,0x7D76,0x0000,/* 0x78-0x7F */ 0x7D78,0x7D79,0x7D7A,0x7D7B,0x7D7C,0x7D7D,0x7D7E,0x7D7F,/* 0x80-0x87 */ 0x7D80,0x7D81,0x7D82,0x7D83,0x7D84,0x7D85,0x7D86,0x7D87,/* 0x88-0x8F */ 0x7D88,0x7D89,0x7D8A,0x7D8B,0x7D8C,0x7D8D,0x7D8E,0x7D8F,/* 0x90-0x97 */ 0x7D90,0x7D91,0x7D92,0x7D93,0x7D94,0x7D95,0x7D96,0x7D97,/* 0x98-0x9F */ 0x7D98,0x5065,0x8230,0x5251,0x996F,0x6E10,0x6E85,0x6DA7,/* 0xA0-0xA7 */ 0x5EFA,0x50F5,0x59DC,0x5C06,0x6D46,0x6C5F,0x7586,0x848B,/* 0xA8-0xAF */ 0x6868,0x5956,0x8BB2,0x5320,0x9171,0x964D,0x8549,0x6912,/* 0xB0-0xB7 */ 0x7901,0x7126,0x80F6,0x4EA4,0x90CA,0x6D47,0x9A84,0x5A07,/* 0xB8-0xBF */ 0x56BC,0x6405,0x94F0,0x77EB,0x4FA5,0x811A,0x72E1,0x89D2,/* 0xC0-0xC7 */ 0x997A,0x7F34,0x7EDE,0x527F,0x6559,0x9175,0x8F7F,0x8F83,/* 0xC8-0xCF */ 0x53EB,0x7A96,0x63ED,0x63A5,0x7686,0x79F8,0x8857,0x9636,/* 0xD0-0xD7 */ 0x622A,0x52AB,0x8282,0x6854,0x6770,0x6377,0x776B,0x7AED,/* 0xD8-0xDF */ 0x6D01,0x7ED3,0x89E3,0x59D0,0x6212,0x85C9,0x82A5,0x754C,/* 0xE0-0xE7 */ 0x501F,0x4ECB,0x75A5,0x8BEB,0x5C4A,0x5DFE,0x7B4B,0x65A4,/* 0xE8-0xEF */ 0x91D1,0x4ECA,0x6D25,0x895F,0x7D27,0x9526,0x4EC5,0x8C28,/* 0xF0-0xF7 */ 0x8FDB,0x9773,0x664B,0x7981,0x8FD1,0x70EC,0x6D78,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_BE[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7D99,0x7D9A,0x7D9B,0x7D9C,0x7D9D,0x7D9E,0x7D9F,0x7DA0,/* 0x40-0x47 */ 0x7DA1,0x7DA2,0x7DA3,0x7DA4,0x7DA5,0x7DA7,0x7DA8,0x7DA9,/* 0x48-0x4F */ 0x7DAA,0x7DAB,0x7DAC,0x7DAD,0x7DAF,0x7DB0,0x7DB1,0x7DB2,/* 0x50-0x57 */ 0x7DB3,0x7DB4,0x7DB5,0x7DB6,0x7DB7,0x7DB8,0x7DB9,0x7DBA,/* 0x58-0x5F */ 0x7DBB,0x7DBC,0x7DBD,0x7DBE,0x7DBF,0x7DC0,0x7DC1,0x7DC2,/* 0x60-0x67 */ 0x7DC3,0x7DC4,0x7DC5,0x7DC6,0x7DC7,0x7DC8,0x7DC9,0x7DCA,/* 0x68-0x6F */ 0x7DCB,0x7DCC,0x7DCD,0x7DCE,0x7DCF,0x7DD0,0x7DD1,0x7DD2,/* 0x70-0x77 */ 0x7DD3,0x7DD4,0x7DD5,0x7DD6,0x7DD7,0x7DD8,0x7DD9,0x0000,/* 0x78-0x7F */ 0x7DDA,0x7DDB,0x7DDC,0x7DDD,0x7DDE,0x7DDF,0x7DE0,0x7DE1,/* 0x80-0x87 */ 0x7DE2,0x7DE3,0x7DE4,0x7DE5,0x7DE6,0x7DE7,0x7DE8,0x7DE9,/* 0x88-0x8F */ 0x7DEA,0x7DEB,0x7DEC,0x7DED,0x7DEE,0x7DEF,0x7DF0,0x7DF1,/* 0x90-0x97 */ 0x7DF2,0x7DF3,0x7DF4,0x7DF5,0x7DF6,0x7DF7,0x7DF8,0x7DF9,/* 0x98-0x9F */ 0x7DFA,0x5C3D,0x52B2,0x8346,0x5162,0x830E,0x775B,0x6676,/* 0xA0-0xA7 */ 0x9CB8,0x4EAC,0x60CA,0x7CBE,0x7CB3,0x7ECF,0x4E95,0x8B66,/* 0xA8-0xAF */ 0x666F,0x9888,0x9759,0x5883,0x656C,0x955C,0x5F84,0x75C9,/* 0xB0-0xB7 */ 0x9756,0x7ADF,0x7ADE,0x51C0,0x70AF,0x7A98,0x63EA,0x7A76,/* 0xB8-0xBF */ 0x7EA0,0x7396,0x97ED,0x4E45,0x7078,0x4E5D,0x9152,0x53A9,/* 0xC0-0xC7 */ 0x6551,0x65E7,0x81FC,0x8205,0x548E,0x5C31,0x759A,0x97A0,/* 0xC8-0xCF */ 0x62D8,0x72D9,0x75BD,0x5C45,0x9A79,0x83CA,0x5C40,0x5480,/* 0xD0-0xD7 */ 0x77E9,0x4E3E,0x6CAE,0x805A,0x62D2,0x636E,0x5DE8,0x5177,/* 0xD8-0xDF */ 0x8DDD,0x8E1E,0x952F,0x4FF1,0x53E5,0x60E7,0x70AC,0x5267,/* 0xE0-0xE7 */ 0x6350,0x9E43,0x5A1F,0x5026,0x7737,0x5377,0x7EE2,0x6485,/* 0xE8-0xEF */ 0x652B,0x6289,0x6398,0x5014,0x7235,0x89C9,0x51B3,0x8BC0,/* 0xF0-0xF7 */ 0x7EDD,0x5747,0x83CC,0x94A7,0x519B,0x541B,0x5CFB,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_BF[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7DFB,0x7DFC,0x7DFD,0x7DFE,0x7DFF,0x7E00,0x7E01,0x7E02,/* 0x40-0x47 */ 0x7E03,0x7E04,0x7E05,0x7E06,0x7E07,0x7E08,0x7E09,0x7E0A,/* 0x48-0x4F */ 0x7E0B,0x7E0C,0x7E0D,0x7E0E,0x7E0F,0x7E10,0x7E11,0x7E12,/* 0x50-0x57 */ 0x7E13,0x7E14,0x7E15,0x7E16,0x7E17,0x7E18,0x7E19,0x7E1A,/* 0x58-0x5F */ 0x7E1B,0x7E1C,0x7E1D,0x7E1E,0x7E1F,0x7E20,0x7E21,0x7E22,/* 0x60-0x67 */ 0x7E23,0x7E24,0x7E25,0x7E26,0x7E27,0x7E28,0x7E29,0x7E2A,/* 0x68-0x6F */ 0x7E2B,0x7E2C,0x7E2D,0x7E2E,0x7E2F,0x7E30,0x7E31,0x7E32,/* 0x70-0x77 */ 0x7E33,0x7E34,0x7E35,0x7E36,0x7E37,0x7E38,0x7E39,0x0000,/* 0x78-0x7F */ 0x7E3A,0x7E3C,0x7E3D,0x7E3E,0x7E3F,0x7E40,0x7E42,0x7E43,/* 0x80-0x87 */ 0x7E44,0x7E45,0x7E46,0x7E48,0x7E49,0x7E4A,0x7E4B,0x7E4C,/* 0x88-0x8F */ 0x7E4D,0x7E4E,0x7E4F,0x7E50,0x7E51,0x7E52,0x7E53,0x7E54,/* 0x90-0x97 */ 0x7E55,0x7E56,0x7E57,0x7E58,0x7E59,0x7E5A,0x7E5B,0x7E5C,/* 0x98-0x9F */ 0x7E5D,0x4FCA,0x7AE3,0x6D5A,0x90E1,0x9A8F,0x5580,0x5496,/* 0xA0-0xA7 */ 0x5361,0x54AF,0x5F00,0x63E9,0x6977,0x51EF,0x6168,0x520A,/* 0xA8-0xAF */ 0x582A,0x52D8,0x574E,0x780D,0x770B,0x5EB7,0x6177,0x7CE0,/* 0xB0-0xB7 */ 0x625B,0x6297,0x4EA2,0x7095,0x8003,0x62F7,0x70E4,0x9760,/* 0xB8-0xBF */ 0x5777,0x82DB,0x67EF,0x68F5,0x78D5,0x9897,0x79D1,0x58F3,/* 0xC0-0xC7 */ 0x54B3,0x53EF,0x6E34,0x514B,0x523B,0x5BA2,0x8BFE,0x80AF,/* 0xC8-0xCF */ 0x5543,0x57A6,0x6073,0x5751,0x542D,0x7A7A,0x6050,0x5B54,/* 0xD0-0xD7 */ 0x63A7,0x62A0,0x53E3,0x6263,0x5BC7,0x67AF,0x54ED,0x7A9F,/* 0xD8-0xDF */ 0x82E6,0x9177,0x5E93,0x88E4,0x5938,0x57AE,0x630E,0x8DE8,/* 0xE0-0xE7 */ 0x80EF,0x5757,0x7B77,0x4FA9,0x5FEB,0x5BBD,0x6B3E,0x5321,/* 0xE8-0xEF */ 0x7B50,0x72C2,0x6846,0x77FF,0x7736,0x65F7,0x51B5,0x4E8F,/* 0xF0-0xF7 */ 0x76D4,0x5CBF,0x7AA5,0x8475,0x594E,0x9B41,0x5080,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_C0[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7E5E,0x7E5F,0x7E60,0x7E61,0x7E62,0x7E63,0x7E64,0x7E65,/* 0x40-0x47 */ 0x7E66,0x7E67,0x7E68,0x7E69,0x7E6A,0x7E6B,0x7E6C,0x7E6D,/* 0x48-0x4F */ 0x7E6E,0x7E6F,0x7E70,0x7E71,0x7E72,0x7E73,0x7E74,0x7E75,/* 0x50-0x57 */ 0x7E76,0x7E77,0x7E78,0x7E79,0x7E7A,0x7E7B,0x7E7C,0x7E7D,/* 0x58-0x5F */ 0x7E7E,0x7E7F,0x7E80,0x7E81,0x7E83,0x7E84,0x7E85,0x7E86,/* 0x60-0x67 */ 0x7E87,0x7E88,0x7E89,0x7E8A,0x7E8B,0x7E8C,0x7E8D,0x7E8E,/* 0x68-0x6F */ 0x7E8F,0x7E90,0x7E91,0x7E92,0x7E93,0x7E94,0x7E95,0x7E96,/* 0x70-0x77 */ 0x7E97,0x7E98,0x7E99,0x7E9A,0x7E9C,0x7E9D,0x7E9E,0x0000,/* 0x78-0x7F */ 0x7EAE,0x7EB4,0x7EBB,0x7EBC,0x7ED6,0x7EE4,0x7EEC,0x7EF9,/* 0x80-0x87 */ 0x7F0A,0x7F10,0x7F1E,0x7F37,0x7F39,0x7F3B,0x7F3C,0x7F3D,/* 0x88-0x8F */ 0x7F3E,0x7F3F,0x7F40,0x7F41,0x7F43,0x7F46,0x7F47,0x7F48,/* 0x90-0x97 */ 0x7F49,0x7F4A,0x7F4B,0x7F4C,0x7F4D,0x7F4E,0x7F4F,0x7F52,/* 0x98-0x9F */ 0x7F53,0x9988,0x6127,0x6E83,0x5764,0x6606,0x6346,0x56F0,/* 0xA0-0xA7 */ 0x62EC,0x6269,0x5ED3,0x9614,0x5783,0x62C9,0x5587,0x8721,/* 0xA8-0xAF */ 0x814A,0x8FA3,0x5566,0x83B1,0x6765,0x8D56,0x84DD,0x5A6A,/* 0xB0-0xB7 */ 0x680F,0x62E6,0x7BEE,0x9611,0x5170,0x6F9C,0x8C30,0x63FD,/* 0xB8-0xBF */ 0x89C8,0x61D2,0x7F06,0x70C2,0x6EE5,0x7405,0x6994,0x72FC,/* 0xC0-0xC7 */ 0x5ECA,0x90CE,0x6717,0x6D6A,0x635E,0x52B3,0x7262,0x8001,/* 0xC8-0xCF */ 0x4F6C,0x59E5,0x916A,0x70D9,0x6D9D,0x52D2,0x4E50,0x96F7,/* 0xD0-0xD7 */ 0x956D,0x857E,0x78CA,0x7D2F,0x5121,0x5792,0x64C2,0x808B,/* 0xD8-0xDF */ 0x7C7B,0x6CEA,0x68F1,0x695E,0x51B7,0x5398,0x68A8,0x7281,/* 0xE0-0xE7 */ 0x9ECE,0x7BF1,0x72F8,0x79BB,0x6F13,0x7406,0x674E,0x91CC,/* 0xE8-0xEF */ 0x9CA4,0x793C,0x8389,0x8354,0x540F,0x6817,0x4E3D,0x5389,/* 0xF0-0xF7 */ 0x52B1,0x783E,0x5386,0x5229,0x5088,0x4F8B,0x4FD0,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_C1[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7F56,0x7F59,0x7F5B,0x7F5C,0x7F5D,0x7F5E,0x7F60,0x7F63,/* 0x40-0x47 */ 0x7F64,0x7F65,0x7F66,0x7F67,0x7F6B,0x7F6C,0x7F6D,0x7F6F,/* 0x48-0x4F */ 0x7F70,0x7F73,0x7F75,0x7F76,0x7F77,0x7F78,0x7F7A,0x7F7B,/* 0x50-0x57 */ 0x7F7C,0x7F7D,0x7F7F,0x7F80,0x7F82,0x7F83,0x7F84,0x7F85,/* 0x58-0x5F */ 0x7F86,0x7F87,0x7F88,0x7F89,0x7F8B,0x7F8D,0x7F8F,0x7F90,/* 0x60-0x67 */ 0x7F91,0x7F92,0x7F93,0x7F95,0x7F96,0x7F97,0x7F98,0x7F99,/* 0x68-0x6F */ 0x7F9B,0x7F9C,0x7FA0,0x7FA2,0x7FA3,0x7FA5,0x7FA6,0x7FA8,/* 0x70-0x77 */ 0x7FA9,0x7FAA,0x7FAB,0x7FAC,0x7FAD,0x7FAE,0x7FB1,0x0000,/* 0x78-0x7F */ 0x7FB3,0x7FB4,0x7FB5,0x7FB6,0x7FB7,0x7FBA,0x7FBB,0x7FBE,/* 0x80-0x87 */ 0x7FC0,0x7FC2,0x7FC3,0x7FC4,0x7FC6,0x7FC7,0x7FC8,0x7FC9,/* 0x88-0x8F */ 0x7FCB,0x7FCD,0x7FCF,0x7FD0,0x7FD1,0x7FD2,0x7FD3,0x7FD6,/* 0x90-0x97 */ 0x7FD7,0x7FD9,0x7FDA,0x7FDB,0x7FDC,0x7FDD,0x7FDE,0x7FE2,/* 0x98-0x9F */ 0x7FE3,0x75E2,0x7ACB,0x7C92,0x6CA5,0x96B6,0x529B,0x7483,/* 0xA0-0xA7 */ 0x54E9,0x4FE9,0x8054,0x83B2,0x8FDE,0x9570,0x5EC9,0x601C,/* 0xA8-0xAF */ 0x6D9F,0x5E18,0x655B,0x8138,0x94FE,0x604B,0x70BC,0x7EC3,/* 0xB0-0xB7 */ 0x7CAE,0x51C9,0x6881,0x7CB1,0x826F,0x4E24,0x8F86,0x91CF,/* 0xB8-0xBF */ 0x667E,0x4EAE,0x8C05,0x64A9,0x804A,0x50DA,0x7597,0x71CE,/* 0xC0-0xC7 */ 0x5BE5,0x8FBD,0x6F66,0x4E86,0x6482,0x9563,0x5ED6,0x6599,/* 0xC8-0xCF */ 0x5217,0x88C2,0x70C8,0x52A3,0x730E,0x7433,0x6797,0x78F7,/* 0xD0-0xD7 */ 0x9716,0x4E34,0x90BB,0x9CDE,0x6DCB,0x51DB,0x8D41,0x541D,/* 0xD8-0xDF */ 0x62CE,0x73B2,0x83F1,0x96F6,0x9F84,0x94C3,0x4F36,0x7F9A,/* 0xE0-0xE7 */ 0x51CC,0x7075,0x9675,0x5CAD,0x9886,0x53E6,0x4EE4,0x6E9C,/* 0xE8-0xEF */ 0x7409,0x69B4,0x786B,0x998F,0x7559,0x5218,0x7624,0x6D41,/* 0xF0-0xF7 */ 0x67F3,0x516D,0x9F99,0x804B,0x5499,0x7B3C,0x7ABF,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_C2[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x7FE4,0x7FE7,0x7FE8,0x7FEA,0x7FEB,0x7FEC,0x7FED,0x7FEF,/* 0x40-0x47 */ 0x7FF2,0x7FF4,0x7FF5,0x7FF6,0x7FF7,0x7FF8,0x7FF9,0x7FFA,/* 0x48-0x4F */ 0x7FFD,0x7FFE,0x7FFF,0x8002,0x8007,0x8008,0x8009,0x800A,/* 0x50-0x57 */ 0x800E,0x800F,0x8011,0x8013,0x801A,0x801B,0x801D,0x801E,/* 0x58-0x5F */ 0x801F,0x8021,0x8023,0x8024,0x802B,0x802C,0x802D,0x802E,/* 0x60-0x67 */ 0x802F,0x8030,0x8032,0x8034,0x8039,0x803A,0x803C,0x803E,/* 0x68-0x6F */ 0x8040,0x8041,0x8044,0x8045,0x8047,0x8048,0x8049,0x804E,/* 0x70-0x77 */ 0x804F,0x8050,0x8051,0x8053,0x8055,0x8056,0x8057,0x0000,/* 0x78-0x7F */ 0x8059,0x805B,0x805C,0x805D,0x805E,0x805F,0x8060,0x8061,/* 0x80-0x87 */ 0x8062,0x8063,0x8064,0x8065,0x8066,0x8067,0x8068,0x806B,/* 0x88-0x8F */ 0x806C,0x806D,0x806E,0x806F,0x8070,0x8072,0x8073,0x8074,/* 0x90-0x97 */ 0x8075,0x8076,0x8077,0x8078,0x8079,0x807A,0x807B,0x807C,/* 0x98-0x9F */ 0x807D,0x9686,0x5784,0x62E2,0x9647,0x697C,0x5A04,0x6402,/* 0xA0-0xA7 */ 0x7BD3,0x6F0F,0x964B,0x82A6,0x5362,0x9885,0x5E90,0x7089,/* 0xA8-0xAF */ 0x63B3,0x5364,0x864F,0x9C81,0x9E93,0x788C,0x9732,0x8DEF,/* 0xB0-0xB7 */ 0x8D42,0x9E7F,0x6F5E,0x7984,0x5F55,0x9646,0x622E,0x9A74,/* 0xB8-0xBF */ 0x5415,0x94DD,0x4FA3,0x65C5,0x5C65,0x5C61,0x7F15,0x8651,/* 0xC0-0xC7 */ 0x6C2F,0x5F8B,0x7387,0x6EE4,0x7EFF,0x5CE6,0x631B,0x5B6A,/* 0xC8-0xCF */ 0x6EE6,0x5375,0x4E71,0x63A0,0x7565,0x62A1,0x8F6E,0x4F26,/* 0xD0-0xD7 */ 0x4ED1,0x6CA6,0x7EB6,0x8BBA,0x841D,0x87BA,0x7F57,0x903B,/* 0xD8-0xDF */ 0x9523,0x7BA9,0x9AA1,0x88F8,0x843D,0x6D1B,0x9A86,0x7EDC,/* 0xE0-0xE7 */ 0x5988,0x9EBB,0x739B,0x7801,0x8682,0x9A6C,0x9A82,0x561B,/* 0xE8-0xEF */ 0x5417,0x57CB,0x4E70,0x9EA6,0x5356,0x8FC8,0x8109,0x7792,/* 0xF0-0xF7 */ 0x9992,0x86EE,0x6EE1,0x8513,0x66FC,0x6162,0x6F2B,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_C3[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x807E,0x8081,0x8082,0x8085,0x8088,0x808A,0x808D,0x808E,/* 0x40-0x47 */ 0x808F,0x8090,0x8091,0x8092,0x8094,0x8095,0x8097,0x8099,/* 0x48-0x4F */ 0x809E,0x80A3,0x80A6,0x80A7,0x80A8,0x80AC,0x80B0,0x80B3,/* 0x50-0x57 */ 0x80B5,0x80B6,0x80B8,0x80B9,0x80BB,0x80C5,0x80C7,0x80C8,/* 0x58-0x5F */ 0x80C9,0x80CA,0x80CB,0x80CF,0x80D0,0x80D1,0x80D2,0x80D3,/* 0x60-0x67 */ 0x80D4,0x80D5,0x80D8,0x80DF,0x80E0,0x80E2,0x80E3,0x80E6,/* 0x68-0x6F */ 0x80EE,0x80F5,0x80F7,0x80F9,0x80FB,0x80FE,0x80FF,0x8100,/* 0x70-0x77 */ 0x8101,0x8103,0x8104,0x8105,0x8107,0x8108,0x810B,0x0000,/* 0x78-0x7F */ 0x810C,0x8115,0x8117,0x8119,0x811B,0x811C,0x811D,0x811F,/* 0x80-0x87 */ 0x8120,0x8121,0x8122,0x8123,0x8124,0x8125,0x8126,0x8127,/* 0x88-0x8F */ 0x8128,0x8129,0x812A,0x812B,0x812D,0x812E,0x8130,0x8133,/* 0x90-0x97 */ 0x8134,0x8135,0x8137,0x8139,0x813A,0x813B,0x813C,0x813D,/* 0x98-0x9F */ 0x813F,0x8C29,0x8292,0x832B,0x76F2,0x6C13,0x5FD9,0x83BD,/* 0xA0-0xA7 */ 0x732B,0x8305,0x951A,0x6BDB,0x77DB,0x94C6,0x536F,0x8302,/* 0xA8-0xAF */ 0x5192,0x5E3D,0x8C8C,0x8D38,0x4E48,0x73AB,0x679A,0x6885,/* 0xB0-0xB7 */ 0x9176,0x9709,0x7164,0x6CA1,0x7709,0x5A92,0x9541,0x6BCF,/* 0xB8-0xBF */ 0x7F8E,0x6627,0x5BD0,0x59B9,0x5A9A,0x95E8,0x95F7,0x4EEC,/* 0xC0-0xC7 */ 0x840C,0x8499,0x6AAC,0x76DF,0x9530,0x731B,0x68A6,0x5B5F,/* 0xC8-0xCF */ 0x772F,0x919A,0x9761,0x7CDC,0x8FF7,0x8C1C,0x5F25,0x7C73,/* 0xD0-0xD7 */ 0x79D8,0x89C5,0x6CCC,0x871C,0x5BC6,0x5E42,0x68C9,0x7720,/* 0xD8-0xDF */ 0x7EF5,0x5195,0x514D,0x52C9,0x5A29,0x7F05,0x9762,0x82D7,/* 0xE0-0xE7 */ 0x63CF,0x7784,0x85D0,0x79D2,0x6E3A,0x5E99,0x5999,0x8511,/* 0xE8-0xEF */ 0x706D,0x6C11,0x62BF,0x76BF,0x654F,0x60AF,0x95FD,0x660E,/* 0xF0-0xF7 */ 0x879F,0x9E23,0x94ED,0x540D,0x547D,0x8C2C,0x6478,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_C4[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8140,0x8141,0x8142,0x8143,0x8144,0x8145,0x8147,0x8149,/* 0x40-0x47 */ 0x814D,0x814E,0x814F,0x8152,0x8156,0x8157,0x8158,0x815B,/* 0x48-0x4F */ 0x815C,0x815D,0x815E,0x815F,0x8161,0x8162,0x8163,0x8164,/* 0x50-0x57 */ 0x8166,0x8168,0x816A,0x816B,0x816C,0x816F,0x8172,0x8173,/* 0x58-0x5F */ 0x8175,0x8176,0x8177,0x8178,0x8181,0x8183,0x8184,0x8185,/* 0x60-0x67 */ 0x8186,0x8187,0x8189,0x818B,0x818C,0x818D,0x818E,0x8190,/* 0x68-0x6F */ 0x8192,0x8193,0x8194,0x8195,0x8196,0x8197,0x8199,0x819A,/* 0x70-0x77 */ 0x819E,0x819F,0x81A0,0x81A1,0x81A2,0x81A4,0x81A5,0x0000,/* 0x78-0x7F */ 0x81A7,0x81A9,0x81AB,0x81AC,0x81AD,0x81AE,0x81AF,0x81B0,/* 0x80-0x87 */ 0x81B1,0x81B2,0x81B4,0x81B5,0x81B6,0x81B7,0x81B8,0x81B9,/* 0x88-0x8F */ 0x81BC,0x81BD,0x81BE,0x81BF,0x81C4,0x81C5,0x81C7,0x81C8,/* 0x90-0x97 */ 0x81C9,0x81CB,0x81CD,0x81CE,0x81CF,0x81D0,0x81D1,0x81D2,/* 0x98-0x9F */ 0x81D3,0x6479,0x8611,0x6A21,0x819C,0x78E8,0x6469,0x9B54,/* 0xA0-0xA7 */ 0x62B9,0x672B,0x83AB,0x58A8,0x9ED8,0x6CAB,0x6F20,0x5BDE,/* 0xA8-0xAF */ 0x964C,0x8C0B,0x725F,0x67D0,0x62C7,0x7261,0x4EA9,0x59C6,/* 0xB0-0xB7 */ 0x6BCD,0x5893,0x66AE,0x5E55,0x52DF,0x6155,0x6728,0x76EE,/* 0xB8-0xBF */ 0x7766,0x7267,0x7A46,0x62FF,0x54EA,0x5450,0x94A0,0x90A3,/* 0xC0-0xC7 */ 0x5A1C,0x7EB3,0x6C16,0x4E43,0x5976,0x8010,0x5948,0x5357,/* 0xC8-0xCF */ 0x7537,0x96BE,0x56CA,0x6320,0x8111,0x607C,0x95F9,0x6DD6,/* 0xD0-0xD7 */ 0x5462,0x9981,0x5185,0x5AE9,0x80FD,0x59AE,0x9713,0x502A,/* 0xD8-0xDF */ 0x6CE5,0x5C3C,0x62DF,0x4F60,0x533F,0x817B,0x9006,0x6EBA,/* 0xE0-0xE7 */ 0x852B,0x62C8,0x5E74,0x78BE,0x64B5,0x637B,0x5FF5,0x5A18,/* 0xE8-0xEF */ 0x917F,0x9E1F,0x5C3F,0x634F,0x8042,0x5B7D,0x556E,0x954A,/* 0xF0-0xF7 */ 0x954D,0x6D85,0x60A8,0x67E0,0x72DE,0x51DD,0x5B81,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_C5[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x81D4,0x81D5,0x81D6,0x81D7,0x81D8,0x81D9,0x81DA,0x81DB,/* 0x40-0x47 */ 0x81DC,0x81DD,0x81DE,0x81DF,0x81E0,0x81E1,0x81E2,0x81E4,/* 0x48-0x4F */ 0x81E5,0x81E6,0x81E8,0x81E9,0x81EB,0x81EE,0x81EF,0x81F0,/* 0x50-0x57 */ 0x81F1,0x81F2,0x81F5,0x81F6,0x81F7,0x81F8,0x81F9,0x81FA,/* 0x58-0x5F */ 0x81FD,0x81FF,0x8203,0x8207,0x8208,0x8209,0x820A,0x820B,/* 0x60-0x67 */ 0x820E,0x820F,0x8211,0x8213,0x8215,0x8216,0x8217,0x8218,/* 0x68-0x6F */ 0x8219,0x821A,0x821D,0x8220,0x8224,0x8225,0x8226,0x8227,/* 0x70-0x77 */ 0x8229,0x822E,0x8232,0x823A,0x823C,0x823D,0x823F,0x0000,/* 0x78-0x7F */ 0x8240,0x8241,0x8242,0x8243,0x8245,0x8246,0x8248,0x824A,/* 0x80-0x87 */ 0x824C,0x824D,0x824E,0x8250,0x8251,0x8252,0x8253,0x8254,/* 0x88-0x8F */ 0x8255,0x8256,0x8257,0x8259,0x825B,0x825C,0x825D,0x825E,/* 0x90-0x97 */ 0x8260,0x8261,0x8262,0x8263,0x8264,0x8265,0x8266,0x8267,/* 0x98-0x9F */ 0x8269,0x62E7,0x6CDE,0x725B,0x626D,0x94AE,0x7EBD,0x8113,/* 0xA0-0xA7 */ 0x6D53,0x519C,0x5F04,0x5974,0x52AA,0x6012,0x5973,0x6696,/* 0xA8-0xAF */ 0x8650,0x759F,0x632A,0x61E6,0x7CEF,0x8BFA,0x54E6,0x6B27,/* 0xB0-0xB7 */ 0x9E25,0x6BB4,0x85D5,0x5455,0x5076,0x6CA4,0x556A,0x8DB4,/* 0xB8-0xBF */ 0x722C,0x5E15,0x6015,0x7436,0x62CD,0x6392,0x724C,0x5F98,/* 0xC0-0xC7 */ 0x6E43,0x6D3E,0x6500,0x6F58,0x76D8,0x78D0,0x76FC,0x7554,/* 0xC8-0xCF */ 0x5224,0x53DB,0x4E53,0x5E9E,0x65C1,0x802A,0x80D6,0x629B,/* 0xD0-0xD7 */ 0x5486,0x5228,0x70AE,0x888D,0x8DD1,0x6CE1,0x5478,0x80DA,/* 0xD8-0xDF */ 0x57F9,0x88F4,0x8D54,0x966A,0x914D,0x4F69,0x6C9B,0x55B7,/* 0xE0-0xE7 */ 0x76C6,0x7830,0x62A8,0x70F9,0x6F8E,0x5F6D,0x84EC,0x68DA,/* 0xE8-0xEF */ 0x787C,0x7BF7,0x81A8,0x670B,0x9E4F,0x6367,0x78B0,0x576F,/* 0xF0-0xF7 */ 0x7812,0x9739,0x6279,0x62AB,0x5288,0x7435,0x6BD7,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_C6[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x826A,0x826B,0x826C,0x826D,0x8271,0x8275,0x8276,0x8277,/* 0x40-0x47 */ 0x8278,0x827B,0x827C,0x8280,0x8281,0x8283,0x8285,0x8286,/* 0x48-0x4F */ 0x8287,0x8289,0x828C,0x8290,0x8293,0x8294,0x8295,0x8296,/* 0x50-0x57 */ 0x829A,0x829B,0x829E,0x82A0,0x82A2,0x82A3,0x82A7,0x82B2,/* 0x58-0x5F */ 0x82B5,0x82B6,0x82BA,0x82BB,0x82BC,0x82BF,0x82C0,0x82C2,/* 0x60-0x67 */ 0x82C3,0x82C5,0x82C6,0x82C9,0x82D0,0x82D6,0x82D9,0x82DA,/* 0x68-0x6F */ 0x82DD,0x82E2,0x82E7,0x82E8,0x82E9,0x82EA,0x82EC,0x82ED,/* 0x70-0x77 */ 0x82EE,0x82F0,0x82F2,0x82F3,0x82F5,0x82F6,0x82F8,0x0000,/* 0x78-0x7F */ 0x82FA,0x82FC,0x82FD,0x82FE,0x82FF,0x8300,0x830A,0x830B,/* 0x80-0x87 */ 0x830D,0x8310,0x8312,0x8313,0x8316,0x8318,0x8319,0x831D,/* 0x88-0x8F */ 0x831E,0x831F,0x8320,0x8321,0x8322,0x8323,0x8324,0x8325,/* 0x90-0x97 */ 0x8326,0x8329,0x832A,0x832E,0x8330,0x8332,0x8337,0x833B,/* 0x98-0x9F */ 0x833D,0x5564,0x813E,0x75B2,0x76AE,0x5339,0x75DE,0x50FB,/* 0xA0-0xA7 */ 0x5C41,0x8B6C,0x7BC7,0x504F,0x7247,0x9A97,0x98D8,0x6F02,/* 0xA8-0xAF */ 0x74E2,0x7968,0x6487,0x77A5,0x62FC,0x9891,0x8D2B,0x54C1,/* 0xB0-0xB7 */ 0x8058,0x4E52,0x576A,0x82F9,0x840D,0x5E73,0x51ED,0x74F6,/* 0xB8-0xBF */ 0x8BC4,0x5C4F,0x5761,0x6CFC,0x9887,0x5A46,0x7834,0x9B44,/* 0xC0-0xC7 */ 0x8FEB,0x7C95,0x5256,0x6251,0x94FA,0x4EC6,0x8386,0x8461,/* 0xC8-0xCF */ 0x83E9,0x84B2,0x57D4,0x6734,0x5703,0x666E,0x6D66,0x8C31,/* 0xD0-0xD7 */ 0x66DD,0x7011,0x671F,0x6B3A,0x6816,0x621A,0x59BB,0x4E03,/* 0xD8-0xDF */ 0x51C4,0x6F06,0x67D2,0x6C8F,0x5176,0x68CB,0x5947,0x6B67,/* 0xE0-0xE7 */ 0x7566,0x5D0E,0x8110,0x9F50,0x65D7,0x7948,0x7941,0x9A91,/* 0xE8-0xEF */ 0x8D77,0x5C82,0x4E5E,0x4F01,0x542F,0x5951,0x780C,0x5668,/* 0xF0-0xF7 */ 0x6C14,0x8FC4,0x5F03,0x6C7D,0x6CE3,0x8BAB,0x6390,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_C7[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x833E,0x833F,0x8341,0x8342,0x8344,0x8345,0x8348,0x834A,/* 0x40-0x47 */ 0x834B,0x834C,0x834D,0x834E,0x8353,0x8355,0x8356,0x8357,/* 0x48-0x4F */ 0x8358,0x8359,0x835D,0x8362,0x8370,0x8371,0x8372,0x8373,/* 0x50-0x57 */ 0x8374,0x8375,0x8376,0x8379,0x837A,0x837E,0x837F,0x8380,/* 0x58-0x5F */ 0x8381,0x8382,0x8383,0x8384,0x8387,0x8388,0x838A,0x838B,/* 0x60-0x67 */ 0x838C,0x838D,0x838F,0x8390,0x8391,0x8394,0x8395,0x8396,/* 0x68-0x6F */ 0x8397,0x8399,0x839A,0x839D,0x839F,0x83A1,0x83A2,0x83A3,/* 0x70-0x77 */ 0x83A4,0x83A5,0x83A6,0x83A7,0x83AC,0x83AD,0x83AE,0x0000,/* 0x78-0x7F */ 0x83AF,0x83B5,0x83BB,0x83BE,0x83BF,0x83C2,0x83C3,0x83C4,/* 0x80-0x87 */ 0x83C6,0x83C8,0x83C9,0x83CB,0x83CD,0x83CE,0x83D0,0x83D1,/* 0x88-0x8F */ 0x83D2,0x83D3,0x83D5,0x83D7,0x83D9,0x83DA,0x83DB,0x83DE,/* 0x90-0x97 */ 0x83E2,0x83E3,0x83E4,0x83E6,0x83E7,0x83E8,0x83EB,0x83EC,/* 0x98-0x9F */ 0x83ED,0x6070,0x6D3D,0x7275,0x6266,0x948E,0x94C5,0x5343,/* 0xA0-0xA7 */ 0x8FC1,0x7B7E,0x4EDF,0x8C26,0x4E7E,0x9ED4,0x94B1,0x94B3,/* 0xA8-0xAF */ 0x524D,0x6F5C,0x9063,0x6D45,0x8C34,0x5811,0x5D4C,0x6B20,/* 0xB0-0xB7 */ 0x6B49,0x67AA,0x545B,0x8154,0x7F8C,0x5899,0x8537,0x5F3A,/* 0xB8-0xBF */ 0x62A2,0x6A47,0x9539,0x6572,0x6084,0x6865,0x77A7,0x4E54,/* 0xC0-0xC7 */ 0x4FA8,0x5DE7,0x9798,0x64AC,0x7FD8,0x5CED,0x4FCF,0x7A8D,/* 0xC8-0xCF */ 0x5207,0x8304,0x4E14,0x602F,0x7A83,0x94A6,0x4FB5,0x4EB2,/* 0xD0-0xD7 */ 0x79E6,0x7434,0x52E4,0x82B9,0x64D2,0x79BD,0x5BDD,0x6C81,/* 0xD8-0xDF */ 0x9752,0x8F7B,0x6C22,0x503E,0x537F,0x6E05,0x64CE,0x6674,/* 0xE0-0xE7 */ 0x6C30,0x60C5,0x9877,0x8BF7,0x5E86,0x743C,0x7A77,0x79CB,/* 0xE8-0xEF */ 0x4E18,0x90B1,0x7403,0x6C42,0x56DA,0x914B,0x6CC5,0x8D8B,/* 0xF0-0xF7 */ 0x533A,0x86C6,0x66F2,0x8EAF,0x5C48,0x9A71,0x6E20,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_C8[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x83EE,0x83EF,0x83F3,0x83F4,0x83F5,0x83F6,0x83F7,0x83FA,/* 0x40-0x47 */ 0x83FB,0x83FC,0x83FE,0x83FF,0x8400,0x8402,0x8405,0x8407,/* 0x48-0x4F */ 0x8408,0x8409,0x840A,0x8410,0x8412,0x8413,0x8414,0x8415,/* 0x50-0x57 */ 0x8416,0x8417,0x8419,0x841A,0x841B,0x841E,0x841F,0x8420,/* 0x58-0x5F */ 0x8421,0x8422,0x8423,0x8429,0x842A,0x842B,0x842C,0x842D,/* 0x60-0x67 */ 0x842E,0x842F,0x8430,0x8432,0x8433,0x8434,0x8435,0x8436,/* 0x68-0x6F */ 0x8437,0x8439,0x843A,0x843B,0x843E,0x843F,0x8440,0x8441,/* 0x70-0x77 */ 0x8442,0x8443,0x8444,0x8445,0x8447,0x8448,0x8449,0x0000,/* 0x78-0x7F */ 0x844A,0x844B,0x844C,0x844D,0x844E,0x844F,0x8450,0x8452,/* 0x80-0x87 */ 0x8453,0x8454,0x8455,0x8456,0x8458,0x845D,0x845E,0x845F,/* 0x88-0x8F */ 0x8460,0x8462,0x8464,0x8465,0x8466,0x8467,0x8468,0x846A,/* 0x90-0x97 */ 0x846E,0x846F,0x8470,0x8472,0x8474,0x8477,0x8479,0x847B,/* 0x98-0x9F */ 0x847C,0x53D6,0x5A36,0x9F8B,0x8DA3,0x53BB,0x5708,0x98A7,/* 0xA0-0xA7 */ 0x6743,0x919B,0x6CC9,0x5168,0x75CA,0x62F3,0x72AC,0x5238,/* 0xA8-0xAF */ 0x529D,0x7F3A,0x7094,0x7638,0x5374,0x9E4A,0x69B7,0x786E,/* 0xB0-0xB7 */ 0x96C0,0x88D9,0x7FA4,0x7136,0x71C3,0x5189,0x67D3,0x74E4,/* 0xB8-0xBF */ 0x58E4,0x6518,0x56B7,0x8BA9,0x9976,0x6270,0x7ED5,0x60F9,/* 0xC0-0xC7 */ 0x70ED,0x58EC,0x4EC1,0x4EBA,0x5FCD,0x97E7,0x4EFB,0x8BA4,/* 0xC8-0xCF */ 0x5203,0x598A,0x7EAB,0x6254,0x4ECD,0x65E5,0x620E,0x8338,/* 0xD0-0xD7 */ 0x84C9,0x8363,0x878D,0x7194,0x6EB6,0x5BB9,0x7ED2,0x5197,/* 0xD8-0xDF */ 0x63C9,0x67D4,0x8089,0x8339,0x8815,0x5112,0x5B7A,0x5982,/* 0xE0-0xE7 */ 0x8FB1,0x4E73,0x6C5D,0x5165,0x8925,0x8F6F,0x962E,0x854A,/* 0xE8-0xEF */ 0x745E,0x9510,0x95F0,0x6DA6,0x82E5,0x5F31,0x6492,0x6D12,/* 0xF0-0xF7 */ 0x8428,0x816E,0x9CC3,0x585E,0x8D5B,0x4E09,0x53C1,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_C9[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x847D,0x847E,0x847F,0x8480,0x8481,0x8483,0x8484,0x8485,/* 0x40-0x47 */ 0x8486,0x848A,0x848D,0x848F,0x8490,0x8491,0x8492,0x8493,/* 0x48-0x4F */ 0x8494,0x8495,0x8496,0x8498,0x849A,0x849B,0x849D,0x849E,/* 0x50-0x57 */ 0x849F,0x84A0,0x84A2,0x84A3,0x84A4,0x84A5,0x84A6,0x84A7,/* 0x58-0x5F */ 0x84A8,0x84A9,0x84AA,0x84AB,0x84AC,0x84AD,0x84AE,0x84B0,/* 0x60-0x67 */ 0x84B1,0x84B3,0x84B5,0x84B6,0x84B7,0x84BB,0x84BC,0x84BE,/* 0x68-0x6F */ 0x84C0,0x84C2,0x84C3,0x84C5,0x84C6,0x84C7,0x84C8,0x84CB,/* 0x70-0x77 */ 0x84CC,0x84CE,0x84CF,0x84D2,0x84D4,0x84D5,0x84D7,0x0000,/* 0x78-0x7F */ 0x84D8,0x84D9,0x84DA,0x84DB,0x84DC,0x84DE,0x84E1,0x84E2,/* 0x80-0x87 */ 0x84E4,0x84E7,0x84E8,0x84E9,0x84EA,0x84EB,0x84ED,0x84EE,/* 0x88-0x8F */ 0x84EF,0x84F1,0x84F2,0x84F3,0x84F4,0x84F5,0x84F6,0x84F7,/* 0x90-0x97 */ 0x84F8,0x84F9,0x84FA,0x84FB,0x84FD,0x84FE,0x8500,0x8501,/* 0x98-0x9F */ 0x8502,0x4F1E,0x6563,0x6851,0x55D3,0x4E27,0x6414,0x9A9A,/* 0xA0-0xA7 */ 0x626B,0x5AC2,0x745F,0x8272,0x6DA9,0x68EE,0x50E7,0x838E,/* 0xA8-0xAF */ 0x7802,0x6740,0x5239,0x6C99,0x7EB1,0x50BB,0x5565,0x715E,/* 0xB0-0xB7 */ 0x7B5B,0x6652,0x73CA,0x82EB,0x6749,0x5C71,0x5220,0x717D,/* 0xB8-0xBF */ 0x886B,0x95EA,0x9655,0x64C5,0x8D61,0x81B3,0x5584,0x6C55,/* 0xC0-0xC7 */ 0x6247,0x7F2E,0x5892,0x4F24,0x5546,0x8D4F,0x664C,0x4E0A,/* 0xC8-0xCF */ 0x5C1A,0x88F3,0x68A2,0x634E,0x7A0D,0x70E7,0x828D,0x52FA,/* 0xD0-0xD7 */ 0x97F6,0x5C11,0x54E8,0x90B5,0x7ECD,0x5962,0x8D4A,0x86C7,/* 0xD8-0xDF */ 0x820C,0x820D,0x8D66,0x6444,0x5C04,0x6151,0x6D89,0x793E,/* 0xE0-0xE7 */ 0x8BBE,0x7837,0x7533,0x547B,0x4F38,0x8EAB,0x6DF1,0x5A20,/* 0xE8-0xEF */ 0x7EC5,0x795E,0x6C88,0x5BA1,0x5A76,0x751A,0x80BE,0x614E,/* 0xF0-0xF7 */ 0x6E17,0x58F0,0x751F,0x7525,0x7272,0x5347,0x7EF3,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_CA[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8503,0x8504,0x8505,0x8506,0x8507,0x8508,0x8509,0x850A,/* 0x40-0x47 */ 0x850B,0x850D,0x850E,0x850F,0x8510,0x8512,0x8514,0x8515,/* 0x48-0x4F */ 0x8516,0x8518,0x8519,0x851B,0x851C,0x851D,0x851E,0x8520,/* 0x50-0x57 */ 0x8522,0x8523,0x8524,0x8525,0x8526,0x8527,0x8528,0x8529,/* 0x58-0x5F */ 0x852A,0x852D,0x852E,0x852F,0x8530,0x8531,0x8532,0x8533,/* 0x60-0x67 */ 0x8534,0x8535,0x8536,0x853E,0x853F,0x8540,0x8541,0x8542,/* 0x68-0x6F */ 0x8544,0x8545,0x8546,0x8547,0x854B,0x854C,0x854D,0x854E,/* 0x70-0x77 */ 0x854F,0x8550,0x8551,0x8552,0x8553,0x8554,0x8555,0x0000,/* 0x78-0x7F */ 0x8557,0x8558,0x855A,0x855B,0x855C,0x855D,0x855F,0x8560,/* 0x80-0x87 */ 0x8561,0x8562,0x8563,0x8565,0x8566,0x8567,0x8569,0x856A,/* 0x88-0x8F */ 0x856B,0x856C,0x856D,0x856E,0x856F,0x8570,0x8571,0x8573,/* 0x90-0x97 */ 0x8575,0x8576,0x8577,0x8578,0x857C,0x857D,0x857F,0x8580,/* 0x98-0x9F */ 0x8581,0x7701,0x76DB,0x5269,0x80DC,0x5723,0x5E08,0x5931,/* 0xA0-0xA7 */ 0x72EE,0x65BD,0x6E7F,0x8BD7,0x5C38,0x8671,0x5341,0x77F3,/* 0xA8-0xAF */ 0x62FE,0x65F6,0x4EC0,0x98DF,0x8680,0x5B9E,0x8BC6,0x53F2,/* 0xB0-0xB7 */ 0x77E2,0x4F7F,0x5C4E,0x9A76,0x59CB,0x5F0F,0x793A,0x58EB,/* 0xB8-0xBF */ 0x4E16,0x67FF,0x4E8B,0x62ED,0x8A93,0x901D,0x52BF,0x662F,/* 0xC0-0xC7 */ 0x55DC,0x566C,0x9002,0x4ED5,0x4F8D,0x91CA,0x9970,0x6C0F,/* 0xC8-0xCF */ 0x5E02,0x6043,0x5BA4,0x89C6,0x8BD5,0x6536,0x624B,0x9996,/* 0xD0-0xD7 */ 0x5B88,0x5BFF,0x6388,0x552E,0x53D7,0x7626,0x517D,0x852C,/* 0xD8-0xDF */ 0x67A2,0x68B3,0x6B8A,0x6292,0x8F93,0x53D4,0x8212,0x6DD1,/* 0xE0-0xE7 */ 0x758F,0x4E66,0x8D4E,0x5B70,0x719F,0x85AF,0x6691,0x66D9,/* 0xE8-0xEF */ 0x7F72,0x8700,0x9ECD,0x9F20,0x5C5E,0x672F,0x8FF0,0x6811,/* 0xF0-0xF7 */ 0x675F,0x620D,0x7AD6,0x5885,0x5EB6,0x6570,0x6F31,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_CB[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8582,0x8583,0x8586,0x8588,0x8589,0x858A,0x858B,0x858C,/* 0x40-0x47 */ 0x858D,0x858E,0x8590,0x8591,0x8592,0x8593,0x8594,0x8595,/* 0x48-0x4F */ 0x8596,0x8597,0x8598,0x8599,0x859A,0x859D,0x859E,0x859F,/* 0x50-0x57 */ 0x85A0,0x85A1,0x85A2,0x85A3,0x85A5,0x85A6,0x85A7,0x85A9,/* 0x58-0x5F */ 0x85AB,0x85AC,0x85AD,0x85B1,0x85B2,0x85B3,0x85B4,0x85B5,/* 0x60-0x67 */ 0x85B6,0x85B8,0x85BA,0x85BB,0x85BC,0x85BD,0x85BE,0x85BF,/* 0x68-0x6F */ 0x85C0,0x85C2,0x85C3,0x85C4,0x85C5,0x85C6,0x85C7,0x85C8,/* 0x70-0x77 */ 0x85CA,0x85CB,0x85CC,0x85CD,0x85CE,0x85D1,0x85D2,0x0000,/* 0x78-0x7F */ 0x85D4,0x85D6,0x85D7,0x85D8,0x85D9,0x85DA,0x85DB,0x85DD,/* 0x80-0x87 */ 0x85DE,0x85DF,0x85E0,0x85E1,0x85E2,0x85E3,0x85E5,0x85E6,/* 0x88-0x8F */ 0x85E7,0x85E8,0x85EA,0x85EB,0x85EC,0x85ED,0x85EE,0x85EF,/* 0x90-0x97 */ 0x85F0,0x85F1,0x85F2,0x85F3,0x85F4,0x85F5,0x85F6,0x85F7,/* 0x98-0x9F */ 0x85F8,0x6055,0x5237,0x800D,0x6454,0x8870,0x7529,0x5E05,/* 0xA0-0xA7 */ 0x6813,0x62F4,0x971C,0x53CC,0x723D,0x8C01,0x6C34,0x7761,/* 0xA8-0xAF */ 0x7A0E,0x542E,0x77AC,0x987A,0x821C,0x8BF4,0x7855,0x6714,/* 0xB0-0xB7 */ 0x70C1,0x65AF,0x6495,0x5636,0x601D,0x79C1,0x53F8,0x4E1D,/* 0xB8-0xBF */ 0x6B7B,0x8086,0x5BFA,0x55E3,0x56DB,0x4F3A,0x4F3C,0x9972,/* 0xC0-0xC7 */ 0x5DF3,0x677E,0x8038,0x6002,0x9882,0x9001,0x5B8B,0x8BBC,/* 0xC8-0xCF */ 0x8BF5,0x641C,0x8258,0x64DE,0x55FD,0x82CF,0x9165,0x4FD7,/* 0xD0-0xD7 */ 0x7D20,0x901F,0x7C9F,0x50F3,0x5851,0x6EAF,0x5BBF,0x8BC9,/* 0xD8-0xDF */ 0x8083,0x9178,0x849C,0x7B97,0x867D,0x968B,0x968F,0x7EE5,/* 0xE0-0xE7 */ 0x9AD3,0x788E,0x5C81,0x7A57,0x9042,0x96A7,0x795F,0x5B59,/* 0xE8-0xEF */ 0x635F,0x7B0B,0x84D1,0x68AD,0x5506,0x7F29,0x7410,0x7D22,/* 0xF0-0xF7 */ 0x9501,0x6240,0x584C,0x4ED6,0x5B83,0x5979,0x5854,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_CC[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x85F9,0x85FA,0x85FC,0x85FD,0x85FE,0x8600,0x8601,0x8602,/* 0x40-0x47 */ 0x8603,0x8604,0x8606,0x8607,0x8608,0x8609,0x860A,0x860B,/* 0x48-0x4F */ 0x860C,0x860D,0x860E,0x860F,0x8610,0x8612,0x8613,0x8614,/* 0x50-0x57 */ 0x8615,0x8617,0x8618,0x8619,0x861A,0x861B,0x861C,0x861D,/* 0x58-0x5F */ 0x861E,0x861F,0x8620,0x8621,0x8622,0x8623,0x8624,0x8625,/* 0x60-0x67 */ 0x8626,0x8628,0x862A,0x862B,0x862C,0x862D,0x862E,0x862F,/* 0x68-0x6F */ 0x8630,0x8631,0x8632,0x8633,0x8634,0x8635,0x8636,0x8637,/* 0x70-0x77 */ 0x8639,0x863A,0x863B,0x863D,0x863E,0x863F,0x8640,0x0000,/* 0x78-0x7F */ 0x8641,0x8642,0x8643,0x8644,0x8645,0x8646,0x8647,0x8648,/* 0x80-0x87 */ 0x8649,0x864A,0x864B,0x864C,0x8652,0x8653,0x8655,0x8656,/* 0x88-0x8F */ 0x8657,0x8658,0x8659,0x865B,0x865C,0x865D,0x865F,0x8660,/* 0x90-0x97 */ 0x8661,0x8663,0x8664,0x8665,0x8666,0x8667,0x8668,0x8669,/* 0x98-0x9F */ 0x866A,0x736D,0x631E,0x8E4B,0x8E0F,0x80CE,0x82D4,0x62AC,/* 0xA0-0xA7 */ 0x53F0,0x6CF0,0x915E,0x592A,0x6001,0x6C70,0x574D,0x644A,/* 0xA8-0xAF */ 0x8D2A,0x762B,0x6EE9,0x575B,0x6A80,0x75F0,0x6F6D,0x8C2D,/* 0xB0-0xB7 */ 0x8C08,0x5766,0x6BEF,0x8892,0x78B3,0x63A2,0x53F9,0x70AD,/* 0xB8-0xBF */ 0x6C64,0x5858,0x642A,0x5802,0x68E0,0x819B,0x5510,0x7CD6,/* 0xC0-0xC7 */ 0x5018,0x8EBA,0x6DCC,0x8D9F,0x70EB,0x638F,0x6D9B,0x6ED4,/* 0xC8-0xCF */ 0x7EE6,0x8404,0x6843,0x9003,0x6DD8,0x9676,0x8BA8,0x5957,/* 0xD0-0xD7 */ 0x7279,0x85E4,0x817E,0x75BC,0x8A8A,0x68AF,0x5254,0x8E22,/* 0xD8-0xDF */ 0x9511,0x63D0,0x9898,0x8E44,0x557C,0x4F53,0x66FF,0x568F,/* 0xE0-0xE7 */ 0x60D5,0x6D95,0x5243,0x5C49,0x5929,0x6DFB,0x586B,0x7530,/* 0xE8-0xEF */ 0x751C,0x606C,0x8214,0x8146,0x6311,0x6761,0x8FE2,0x773A,/* 0xF0-0xF7 */ 0x8DF3,0x8D34,0x94C1,0x5E16,0x5385,0x542C,0x70C3,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_CD[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x866D,0x866F,0x8670,0x8672,0x8673,0x8674,0x8675,0x8676,/* 0x40-0x47 */ 0x8677,0x8678,0x8683,0x8684,0x8685,0x8686,0x8687,0x8688,/* 0x48-0x4F */ 0x8689,0x868E,0x868F,0x8690,0x8691,0x8692,0x8694,0x8696,/* 0x50-0x57 */ 0x8697,0x8698,0x8699,0x869A,0x869B,0x869E,0x869F,0x86A0,/* 0x58-0x5F */ 0x86A1,0x86A2,0x86A5,0x86A6,0x86AB,0x86AD,0x86AE,0x86B2,/* 0x60-0x67 */ 0x86B3,0x86B7,0x86B8,0x86B9,0x86BB,0x86BC,0x86BD,0x86BE,/* 0x68-0x6F */ 0x86BF,0x86C1,0x86C2,0x86C3,0x86C5,0x86C8,0x86CC,0x86CD,/* 0x70-0x77 */ 0x86D2,0x86D3,0x86D5,0x86D6,0x86D7,0x86DA,0x86DC,0x0000,/* 0x78-0x7F */ 0x86DD,0x86E0,0x86E1,0x86E2,0x86E3,0x86E5,0x86E6,0x86E7,/* 0x80-0x87 */ 0x86E8,0x86EA,0x86EB,0x86EC,0x86EF,0x86F5,0x86F6,0x86F7,/* 0x88-0x8F */ 0x86FA,0x86FB,0x86FC,0x86FD,0x86FF,0x8701,0x8704,0x8705,/* 0x90-0x97 */ 0x8706,0x870B,0x870C,0x870E,0x870F,0x8710,0x8711,0x8714,/* 0x98-0x9F */ 0x8716,0x6C40,0x5EF7,0x505C,0x4EAD,0x5EAD,0x633A,0x8247,/* 0xA0-0xA7 */ 0x901A,0x6850,0x916E,0x77B3,0x540C,0x94DC,0x5F64,0x7AE5,/* 0xA8-0xAF */ 0x6876,0x6345,0x7B52,0x7EDF,0x75DB,0x5077,0x6295,0x5934,/* 0xB0-0xB7 */ 0x900F,0x51F8,0x79C3,0x7A81,0x56FE,0x5F92,0x9014,0x6D82,/* 0xB8-0xBF */ 0x5C60,0x571F,0x5410,0x5154,0x6E4D,0x56E2,0x63A8,0x9893,/* 0xC0-0xC7 */ 0x817F,0x8715,0x892A,0x9000,0x541E,0x5C6F,0x81C0,0x62D6,/* 0xC8-0xCF */ 0x6258,0x8131,0x9E35,0x9640,0x9A6E,0x9A7C,0x692D,0x59A5,/* 0xD0-0xD7 */ 0x62D3,0x553E,0x6316,0x54C7,0x86D9,0x6D3C,0x5A03,0x74E6,/* 0xD8-0xDF */ 0x889C,0x6B6A,0x5916,0x8C4C,0x5F2F,0x6E7E,0x73A9,0x987D,/* 0xE0-0xE7 */ 0x4E38,0x70F7,0x5B8C,0x7897,0x633D,0x665A,0x7696,0x60CB,/* 0xE8-0xEF */ 0x5B9B,0x5A49,0x4E07,0x8155,0x6C6A,0x738B,0x4EA1,0x6789,/* 0xF0-0xF7 */ 0x7F51,0x5F80,0x65FA,0x671B,0x5FD8,0x5984,0x5A01,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_CE[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8719,0x871B,0x871D,0x871F,0x8720,0x8724,0x8726,0x8727,/* 0x40-0x47 */ 0x8728,0x872A,0x872B,0x872C,0x872D,0x872F,0x8730,0x8732,/* 0x48-0x4F */ 0x8733,0x8735,0x8736,0x8738,0x8739,0x873A,0x873C,0x873D,/* 0x50-0x57 */ 0x8740,0x8741,0x8742,0x8743,0x8744,0x8745,0x8746,0x874A,/* 0x58-0x5F */ 0x874B,0x874D,0x874F,0x8750,0x8751,0x8752,0x8754,0x8755,/* 0x60-0x67 */ 0x8756,0x8758,0x875A,0x875B,0x875C,0x875D,0x875E,0x875F,/* 0x68-0x6F */ 0x8761,0x8762,0x8766,0x8767,0x8768,0x8769,0x876A,0x876B,/* 0x70-0x77 */ 0x876C,0x876D,0x876F,0x8771,0x8772,0x8773,0x8775,0x0000,/* 0x78-0x7F */ 0x8777,0x8778,0x8779,0x877A,0x877F,0x8780,0x8781,0x8784,/* 0x80-0x87 */ 0x8786,0x8787,0x8789,0x878A,0x878C,0x878E,0x878F,0x8790,/* 0x88-0x8F */ 0x8791,0x8792,0x8794,0x8795,0x8796,0x8798,0x8799,0x879A,/* 0x90-0x97 */ 0x879B,0x879C,0x879D,0x879E,0x87A0,0x87A1,0x87A2,0x87A3,/* 0x98-0x9F */ 0x87A4,0x5DCD,0x5FAE,0x5371,0x97E6,0x8FDD,0x6845,0x56F4,/* 0xA0-0xA7 */ 0x552F,0x60DF,0x4E3A,0x6F4D,0x7EF4,0x82C7,0x840E,0x59D4,/* 0xA8-0xAF */ 0x4F1F,0x4F2A,0x5C3E,0x7EAC,0x672A,0x851A,0x5473,0x754F,/* 0xB0-0xB7 */ 0x80C3,0x5582,0x9B4F,0x4F4D,0x6E2D,0x8C13,0x5C09,0x6170,/* 0xB8-0xBF */ 0x536B,0x761F,0x6E29,0x868A,0x6587,0x95FB,0x7EB9,0x543B,/* 0xC0-0xC7 */ 0x7A33,0x7D0A,0x95EE,0x55E1,0x7FC1,0x74EE,0x631D,0x8717,/* 0xC8-0xCF */ 0x6DA1,0x7A9D,0x6211,0x65A1,0x5367,0x63E1,0x6C83,0x5DEB,/* 0xD0-0xD7 */ 0x545C,0x94A8,0x4E4C,0x6C61,0x8BEC,0x5C4B,0x65E0,0x829C,/* 0xD8-0xDF */ 0x68A7,0x543E,0x5434,0x6BCB,0x6B66,0x4E94,0x6342,0x5348,/* 0xE0-0xE7 */ 0x821E,0x4F0D,0x4FAE,0x575E,0x620A,0x96FE,0x6664,0x7269,/* 0xE8-0xEF */ 0x52FF,0x52A1,0x609F,0x8BEF,0x6614,0x7199,0x6790,0x897F,/* 0xF0-0xF7 */ 0x7852,0x77FD,0x6670,0x563B,0x5438,0x9521,0x727A,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_CF[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x87A5,0x87A6,0x87A7,0x87A9,0x87AA,0x87AE,0x87B0,0x87B1,/* 0x40-0x47 */ 0x87B2,0x87B4,0x87B6,0x87B7,0x87B8,0x87B9,0x87BB,0x87BC,/* 0x48-0x4F */ 0x87BE,0x87BF,0x87C1,0x87C2,0x87C3,0x87C4,0x87C5,0x87C7,/* 0x50-0x57 */ 0x87C8,0x87C9,0x87CC,0x87CD,0x87CE,0x87CF,0x87D0,0x87D4,/* 0x58-0x5F */ 0x87D5,0x87D6,0x87D7,0x87D8,0x87D9,0x87DA,0x87DC,0x87DD,/* 0x60-0x67 */ 0x87DE,0x87DF,0x87E1,0x87E2,0x87E3,0x87E4,0x87E6,0x87E7,/* 0x68-0x6F */ 0x87E8,0x87E9,0x87EB,0x87EC,0x87ED,0x87EF,0x87F0,0x87F1,/* 0x70-0x77 */ 0x87F2,0x87F3,0x87F4,0x87F5,0x87F6,0x87F7,0x87F8,0x0000,/* 0x78-0x7F */ 0x87FA,0x87FB,0x87FC,0x87FD,0x87FF,0x8800,0x8801,0x8802,/* 0x80-0x87 */ 0x8804,0x8805,0x8806,0x8807,0x8808,0x8809,0x880B,0x880C,/* 0x88-0x8F */ 0x880D,0x880E,0x880F,0x8810,0x8811,0x8812,0x8814,0x8817,/* 0x90-0x97 */ 0x8818,0x8819,0x881A,0x881C,0x881D,0x881E,0x881F,0x8820,/* 0x98-0x9F */ 0x8823,0x7A00,0x606F,0x5E0C,0x6089,0x819D,0x5915,0x60DC,/* 0xA0-0xA7 */ 0x7184,0x70EF,0x6EAA,0x6C50,0x7280,0x6A84,0x88AD,0x5E2D,/* 0xA8-0xAF */ 0x4E60,0x5AB3,0x559C,0x94E3,0x6D17,0x7CFB,0x9699,0x620F,/* 0xB0-0xB7 */ 0x7EC6,0x778E,0x867E,0x5323,0x971E,0x8F96,0x6687,0x5CE1,/* 0xB8-0xBF */ 0x4FA0,0x72ED,0x4E0B,0x53A6,0x590F,0x5413,0x6380,0x9528,/* 0xC0-0xC7 */ 0x5148,0x4ED9,0x9C9C,0x7EA4,0x54B8,0x8D24,0x8854,0x8237,/* 0xC8-0xCF */ 0x95F2,0x6D8E,0x5F26,0x5ACC,0x663E,0x9669,0x73B0,0x732E,/* 0xD0-0xD7 */ 0x53BF,0x817A,0x9985,0x7FA1,0x5BAA,0x9677,0x9650,0x7EBF,/* 0xD8-0xDF */ 0x76F8,0x53A2,0x9576,0x9999,0x7BB1,0x8944,0x6E58,0x4E61,/* 0xE0-0xE7 */ 0x7FD4,0x7965,0x8BE6,0x60F3,0x54CD,0x4EAB,0x9879,0x5DF7,/* 0xE8-0xEF */ 0x6A61,0x50CF,0x5411,0x8C61,0x8427,0x785D,0x9704,0x524A,/* 0xF0-0xF7 */ 0x54EE,0x56A3,0x9500,0x6D88,0x5BB5,0x6DC6,0x6653,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_D0[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8824,0x8825,0x8826,0x8827,0x8828,0x8829,0x882A,0x882B,/* 0x40-0x47 */ 0x882C,0x882D,0x882E,0x882F,0x8830,0x8831,0x8833,0x8834,/* 0x48-0x4F */ 0x8835,0x8836,0x8837,0x8838,0x883A,0x883B,0x883D,0x883E,/* 0x50-0x57 */ 0x883F,0x8841,0x8842,0x8843,0x8846,0x8847,0x8848,0x8849,/* 0x58-0x5F */ 0x884A,0x884B,0x884E,0x884F,0x8850,0x8851,0x8852,0x8853,/* 0x60-0x67 */ 0x8855,0x8856,0x8858,0x885A,0x885B,0x885C,0x885D,0x885E,/* 0x68-0x6F */ 0x885F,0x8860,0x8866,0x8867,0x886A,0x886D,0x886F,0x8871,/* 0x70-0x77 */ 0x8873,0x8874,0x8875,0x8876,0x8878,0x8879,0x887A,0x0000,/* 0x78-0x7F */ 0x887B,0x887C,0x8880,0x8883,0x8886,0x8887,0x8889,0x888A,/* 0x80-0x87 */ 0x888C,0x888E,0x888F,0x8890,0x8891,0x8893,0x8894,0x8895,/* 0x88-0x8F */ 0x8897,0x8898,0x8899,0x889A,0x889B,0x889D,0x889E,0x889F,/* 0x90-0x97 */ 0x88A0,0x88A1,0x88A3,0x88A5,0x88A6,0x88A7,0x88A8,0x88A9,/* 0x98-0x9F */ 0x88AA,0x5C0F,0x5B5D,0x6821,0x8096,0x5578,0x7B11,0x6548,/* 0xA0-0xA7 */ 0x6954,0x4E9B,0x6B47,0x874E,0x978B,0x534F,0x631F,0x643A,/* 0xA8-0xAF */ 0x90AA,0x659C,0x80C1,0x8C10,0x5199,0x68B0,0x5378,0x87F9,/* 0xB0-0xB7 */ 0x61C8,0x6CC4,0x6CFB,0x8C22,0x5C51,0x85AA,0x82AF,0x950C,/* 0xB8-0xBF */ 0x6B23,0x8F9B,0x65B0,0x5FFB,0x5FC3,0x4FE1,0x8845,0x661F,/* 0xC0-0xC7 */ 0x8165,0x7329,0x60FA,0x5174,0x5211,0x578B,0x5F62,0x90A2,/* 0xC8-0xCF */ 0x884C,0x9192,0x5E78,0x674F,0x6027,0x59D3,0x5144,0x51F6,/* 0xD0-0xD7 */ 0x80F8,0x5308,0x6C79,0x96C4,0x718A,0x4F11,0x4FEE,0x7F9E,/* 0xD8-0xDF */ 0x673D,0x55C5,0x9508,0x79C0,0x8896,0x7EE3,0x589F,0x620C,/* 0xE0-0xE7 */ 0x9700,0x865A,0x5618,0x987B,0x5F90,0x8BB8,0x84C4,0x9157,/* 0xE8-0xEF */ 0x53D9,0x65ED,0x5E8F,0x755C,0x6064,0x7D6E,0x5A7F,0x7EEA,/* 0xF0-0xF7 */ 0x7EED,0x8F69,0x55A7,0x5BA3,0x60AC,0x65CB,0x7384,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_D1[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x88AC,0x88AE,0x88AF,0x88B0,0x88B2,0x88B3,0x88B4,0x88B5,/* 0x40-0x47 */ 0x88B6,0x88B8,0x88B9,0x88BA,0x88BB,0x88BD,0x88BE,0x88BF,/* 0x48-0x4F */ 0x88C0,0x88C3,0x88C4,0x88C7,0x88C8,0x88CA,0x88CB,0x88CC,/* 0x50-0x57 */ 0x88CD,0x88CF,0x88D0,0x88D1,0x88D3,0x88D6,0x88D7,0x88DA,/* 0x58-0x5F */ 0x88DB,0x88DC,0x88DD,0x88DE,0x88E0,0x88E1,0x88E6,0x88E7,/* 0x60-0x67 */ 0x88E9,0x88EA,0x88EB,0x88EC,0x88ED,0x88EE,0x88EF,0x88F2,/* 0x68-0x6F */ 0x88F5,0x88F6,0x88F7,0x88FA,0x88FB,0x88FD,0x88FF,0x8900,/* 0x70-0x77 */ 0x8901,0x8903,0x8904,0x8905,0x8906,0x8907,0x8908,0x0000,/* 0x78-0x7F */ 0x8909,0x890B,0x890C,0x890D,0x890E,0x890F,0x8911,0x8914,/* 0x80-0x87 */ 0x8915,0x8916,0x8917,0x8918,0x891C,0x891D,0x891E,0x891F,/* 0x88-0x8F */ 0x8920,0x8922,0x8923,0x8924,0x8926,0x8927,0x8928,0x8929,/* 0x90-0x97 */ 0x892C,0x892D,0x892E,0x892F,0x8931,0x8932,0x8933,0x8935,/* 0x98-0x9F */ 0x8937,0x9009,0x7663,0x7729,0x7EDA,0x9774,0x859B,0x5B66,/* 0xA0-0xA7 */ 0x7A74,0x96EA,0x8840,0x52CB,0x718F,0x5FAA,0x65EC,0x8BE2,/* 0xA8-0xAF */ 0x5BFB,0x9A6F,0x5DE1,0x6B89,0x6C5B,0x8BAD,0x8BAF,0x900A,/* 0xB0-0xB7 */ 0x8FC5,0x538B,0x62BC,0x9E26,0x9E2D,0x5440,0x4E2B,0x82BD,/* 0xB8-0xBF */ 0x7259,0x869C,0x5D16,0x8859,0x6DAF,0x96C5,0x54D1,0x4E9A,/* 0xC0-0xC7 */ 0x8BB6,0x7109,0x54BD,0x9609,0x70DF,0x6DF9,0x76D0,0x4E25,/* 0xC8-0xCF */ 0x7814,0x8712,0x5CA9,0x5EF6,0x8A00,0x989C,0x960E,0x708E,/* 0xD0-0xD7 */ 0x6CBF,0x5944,0x63A9,0x773C,0x884D,0x6F14,0x8273,0x5830,/* 0xD8-0xDF */ 0x71D5,0x538C,0x781A,0x96C1,0x5501,0x5F66,0x7130,0x5BB4,/* 0xE0-0xE7 */ 0x8C1A,0x9A8C,0x6B83,0x592E,0x9E2F,0x79E7,0x6768,0x626C,/* 0xE8-0xEF */ 0x4F6F,0x75A1,0x7F8A,0x6D0B,0x9633,0x6C27,0x4EF0,0x75D2,/* 0xF0-0xF7 */ 0x517B,0x6837,0x6F3E,0x9080,0x8170,0x5996,0x7476,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_D2[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8938,0x8939,0x893A,0x893B,0x893C,0x893D,0x893E,0x893F,/* 0x40-0x47 */ 0x8940,0x8942,0x8943,0x8945,0x8946,0x8947,0x8948,0x8949,/* 0x48-0x4F */ 0x894A,0x894B,0x894C,0x894D,0x894E,0x894F,0x8950,0x8951,/* 0x50-0x57 */ 0x8952,0x8953,0x8954,0x8955,0x8956,0x8957,0x8958,0x8959,/* 0x58-0x5F */ 0x895A,0x895B,0x895C,0x895D,0x8960,0x8961,0x8962,0x8963,/* 0x60-0x67 */ 0x8964,0x8965,0x8967,0x8968,0x8969,0x896A,0x896B,0x896C,/* 0x68-0x6F */ 0x896D,0x896E,0x896F,0x8970,0x8971,0x8972,0x8973,0x8974,/* 0x70-0x77 */ 0x8975,0x8976,0x8977,0x8978,0x8979,0x897A,0x897C,0x0000,/* 0x78-0x7F */ 0x897D,0x897E,0x8980,0x8982,0x8984,0x8985,0x8987,0x8988,/* 0x80-0x87 */ 0x8989,0x898A,0x898B,0x898C,0x898D,0x898E,0x898F,0x8990,/* 0x88-0x8F */ 0x8991,0x8992,0x8993,0x8994,0x8995,0x8996,0x8997,0x8998,/* 0x90-0x97 */ 0x8999,0x899A,0x899B,0x899C,0x899D,0x899E,0x899F,0x89A0,/* 0x98-0x9F */ 0x89A1,0x6447,0x5C27,0x9065,0x7A91,0x8C23,0x59DA,0x54AC,/* 0xA0-0xA7 */ 0x8200,0x836F,0x8981,0x8000,0x6930,0x564E,0x8036,0x7237,/* 0xA8-0xAF */ 0x91CE,0x51B6,0x4E5F,0x9875,0x6396,0x4E1A,0x53F6,0x66F3,/* 0xB0-0xB7 */ 0x814B,0x591C,0x6DB2,0x4E00,0x58F9,0x533B,0x63D6,0x94F1,/* 0xB8-0xBF */ 0x4F9D,0x4F0A,0x8863,0x9890,0x5937,0x9057,0x79FB,0x4EEA,/* 0xC0-0xC7 */ 0x80F0,0x7591,0x6C82,0x5B9C,0x59E8,0x5F5D,0x6905,0x8681,/* 0xC8-0xCF */ 0x501A,0x5DF2,0x4E59,0x77E3,0x4EE5,0x827A,0x6291,0x6613,/* 0xD0-0xD7 */ 0x9091,0x5C79,0x4EBF,0x5F79,0x81C6,0x9038,0x8084,0x75AB,/* 0xD8-0xDF */ 0x4EA6,0x88D4,0x610F,0x6BC5,0x5FC6,0x4E49,0x76CA,0x6EA2,/* 0xE0-0xE7 */ 0x8BE3,0x8BAE,0x8C0A,0x8BD1,0x5F02,0x7FFC,0x7FCC,0x7ECE,/* 0xE8-0xEF */ 0x8335,0x836B,0x56E0,0x6BB7,0x97F3,0x9634,0x59FB,0x541F,/* 0xF0-0xF7 */ 0x94F6,0x6DEB,0x5BC5,0x996E,0x5C39,0x5F15,0x9690,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_D3[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x89A2,0x89A3,0x89A4,0x89A5,0x89A6,0x89A7,0x89A8,0x89A9,/* 0x40-0x47 */ 0x89AA,0x89AB,0x89AC,0x89AD,0x89AE,0x89AF,0x89B0,0x89B1,/* 0x48-0x4F */ 0x89B2,0x89B3,0x89B4,0x89B5,0x89B6,0x89B7,0x89B8,0x89B9,/* 0x50-0x57 */ 0x89BA,0x89BB,0x89BC,0x89BD,0x89BE,0x89BF,0x89C0,0x89C3,/* 0x58-0x5F */ 0x89CD,0x89D3,0x89D4,0x89D5,0x89D7,0x89D8,0x89D9,0x89DB,/* 0x60-0x67 */ 0x89DD,0x89DF,0x89E0,0x89E1,0x89E2,0x89E4,0x89E7,0x89E8,/* 0x68-0x6F */ 0x89E9,0x89EA,0x89EC,0x89ED,0x89EE,0x89F0,0x89F1,0x89F2,/* 0x70-0x77 */ 0x89F4,0x89F5,0x89F6,0x89F7,0x89F8,0x89F9,0x89FA,0x0000,/* 0x78-0x7F */ 0x89FB,0x89FC,0x89FD,0x89FE,0x89FF,0x8A01,0x8A02,0x8A03,/* 0x80-0x87 */ 0x8A04,0x8A05,0x8A06,0x8A08,0x8A09,0x8A0A,0x8A0B,0x8A0C,/* 0x88-0x8F */ 0x8A0D,0x8A0E,0x8A0F,0x8A10,0x8A11,0x8A12,0x8A13,0x8A14,/* 0x90-0x97 */ 0x8A15,0x8A16,0x8A17,0x8A18,0x8A19,0x8A1A,0x8A1B,0x8A1C,/* 0x98-0x9F */ 0x8A1D,0x5370,0x82F1,0x6A31,0x5A74,0x9E70,0x5E94,0x7F28,/* 0xA0-0xA7 */ 0x83B9,0x8424,0x8425,0x8367,0x8747,0x8FCE,0x8D62,0x76C8,/* 0xA8-0xAF */ 0x5F71,0x9896,0x786C,0x6620,0x54DF,0x62E5,0x4F63,0x81C3,/* 0xB0-0xB7 */ 0x75C8,0x5EB8,0x96CD,0x8E0A,0x86F9,0x548F,0x6CF3,0x6D8C,/* 0xB8-0xBF */ 0x6C38,0x607F,0x52C7,0x7528,0x5E7D,0x4F18,0x60A0,0x5FE7,/* 0xC0-0xC7 */ 0x5C24,0x7531,0x90AE,0x94C0,0x72B9,0x6CB9,0x6E38,0x9149,/* 0xC8-0xCF */ 0x6709,0x53CB,0x53F3,0x4F51,0x91C9,0x8BF1,0x53C8,0x5E7C,/* 0xD0-0xD7 */ 0x8FC2,0x6DE4,0x4E8E,0x76C2,0x6986,0x865E,0x611A,0x8206,/* 0xD8-0xDF */ 0x4F59,0x4FDE,0x903E,0x9C7C,0x6109,0x6E1D,0x6E14,0x9685,/* 0xE0-0xE7 */ 0x4E88,0x5A31,0x96E8,0x4E0E,0x5C7F,0x79B9,0x5B87,0x8BED,/* 0xE8-0xEF */ 0x7FBD,0x7389,0x57DF,0x828B,0x90C1,0x5401,0x9047,0x55BB,/* 0xF0-0xF7 */ 0x5CEA,0x5FA1,0x6108,0x6B32,0x72F1,0x80B2,0x8A89,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_D4[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8A1E,0x8A1F,0x8A20,0x8A21,0x8A22,0x8A23,0x8A24,0x8A25,/* 0x40-0x47 */ 0x8A26,0x8A27,0x8A28,0x8A29,0x8A2A,0x8A2B,0x8A2C,0x8A2D,/* 0x48-0x4F */ 0x8A2E,0x8A2F,0x8A30,0x8A31,0x8A32,0x8A33,0x8A34,0x8A35,/* 0x50-0x57 */ 0x8A36,0x8A37,0x8A38,0x8A39,0x8A3A,0x8A3B,0x8A3C,0x8A3D,/* 0x58-0x5F */ 0x8A3F,0x8A40,0x8A41,0x8A42,0x8A43,0x8A44,0x8A45,0x8A46,/* 0x60-0x67 */ 0x8A47,0x8A49,0x8A4A,0x8A4B,0x8A4C,0x8A4D,0x8A4E,0x8A4F,/* 0x68-0x6F */ 0x8A50,0x8A51,0x8A52,0x8A53,0x8A54,0x8A55,0x8A56,0x8A57,/* 0x70-0x77 */ 0x8A58,0x8A59,0x8A5A,0x8A5B,0x8A5C,0x8A5D,0x8A5E,0x0000,/* 0x78-0x7F */ 0x8A5F,0x8A60,0x8A61,0x8A62,0x8A63,0x8A64,0x8A65,0x8A66,/* 0x80-0x87 */ 0x8A67,0x8A68,0x8A69,0x8A6A,0x8A6B,0x8A6C,0x8A6D,0x8A6E,/* 0x88-0x8F */ 0x8A6F,0x8A70,0x8A71,0x8A72,0x8A73,0x8A74,0x8A75,0x8A76,/* 0x90-0x97 */ 0x8A77,0x8A78,0x8A7A,0x8A7B,0x8A7C,0x8A7D,0x8A7E,0x8A7F,/* 0x98-0x9F */ 0x8A80,0x6D74,0x5BD3,0x88D5,0x9884,0x8C6B,0x9A6D,0x9E33,/* 0xA0-0xA7 */ 0x6E0A,0x51A4,0x5143,0x57A3,0x8881,0x539F,0x63F4,0x8F95,/* 0xA8-0xAF */ 0x56ED,0x5458,0x5706,0x733F,0x6E90,0x7F18,0x8FDC,0x82D1,/* 0xB0-0xB7 */ 0x613F,0x6028,0x9662,0x66F0,0x7EA6,0x8D8A,0x8DC3,0x94A5,/* 0xB8-0xBF */ 0x5CB3,0x7CA4,0x6708,0x60A6,0x9605,0x8018,0x4E91,0x90E7,/* 0xC0-0xC7 */ 0x5300,0x9668,0x5141,0x8FD0,0x8574,0x915D,0x6655,0x97F5,/* 0xC8-0xCF */ 0x5B55,0x531D,0x7838,0x6742,0x683D,0x54C9,0x707E,0x5BB0,/* 0xD0-0xD7 */ 0x8F7D,0x518D,0x5728,0x54B1,0x6512,0x6682,0x8D5E,0x8D43,/* 0xD8-0xDF */ 0x810F,0x846C,0x906D,0x7CDF,0x51FF,0x85FB,0x67A3,0x65E9,/* 0xE0-0xE7 */ 0x6FA1,0x86A4,0x8E81,0x566A,0x9020,0x7682,0x7076,0x71E5,/* 0xE8-0xEF */ 0x8D23,0x62E9,0x5219,0x6CFD,0x8D3C,0x600E,0x589E,0x618E,/* 0xF0-0xF7 */ 0x66FE,0x8D60,0x624E,0x55B3,0x6E23,0x672D,0x8F67,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_D5[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0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8,/* 0xA8-0xAF */ 0x77BB,0x6BE1,0x8A79,0x7C98,0x6CBE,0x76CF,0x65A9,0x8F97,/* 0xB0-0xB7 */ 0x5D2D,0x5C55,0x8638,0x6808,0x5360,0x6218,0x7AD9,0x6E5B,/* 0xB8-0xBF */ 0x7EFD,0x6A1F,0x7AE0,0x5F70,0x6F33,0x5F20,0x638C,0x6DA8,/* 0xC0-0xC7 */ 0x6756,0x4E08,0x5E10,0x8D26,0x4ED7,0x80C0,0x7634,0x969C,/* 0xC8-0xCF */ 0x62DB,0x662D,0x627E,0x6CBC,0x8D75,0x7167,0x7F69,0x5146,/* 0xD0-0xD7 */ 0x8087,0x53EC,0x906E,0x6298,0x54F2,0x86F0,0x8F99,0x8005,/* 0xD8-0xDF */ 0x9517,0x8517,0x8FD9,0x6D59,0x73CD,0x659F,0x771F,0x7504,/* 0xE0-0xE7 */ 0x7827,0x81FB,0x8D1E,0x9488,0x4FA6,0x6795,0x75B9,0x8BCA,/* 0xE8-0xEF */ 0x9707,0x632F,0x9547,0x9635,0x84B8,0x6323,0x7741,0x5F81,/* 0xF0-0xF7 */ 0x72F0,0x4E89,0x6014,0x6574,0x62EF,0x6B63,0x653F,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_D6[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8AE4,0x8AE5,0x8AE6,0x8AE7,0x8AE8,0x8AE9,0x8AEA,0x8AEB,/* 0x40-0x47 */ 0x8AEC,0x8AED,0x8AEE,0x8AEF,0x8AF0,0x8AF1,0x8AF2,0x8AF3,/* 0x48-0x4F */ 0x8AF4,0x8AF5,0x8AF6,0x8AF7,0x8AF8,0x8AF9,0x8AFA,0x8AFB,/* 0x50-0x57 */ 0x8AFC,0x8AFD,0x8AFE,0x8AFF,0x8B00,0x8B01,0x8B02,0x8B03,/* 0x58-0x5F */ 0x8B04,0x8B05,0x8B06,0x8B08,0x8B09,0x8B0A,0x8B0B,0x8B0C,/* 0x60-0x67 */ 0x8B0D,0x8B0E,0x8B0F,0x8B10,0x8B11,0x8B12,0x8B13,0x8B14,/* 0x68-0x6F */ 0x8B15,0x8B16,0x8B17,0x8B18,0x8B19,0x8B1A,0x8B1B,0x8B1C,/* 0x70-0x77 */ 0x8B1D,0x8B1E,0x8B1F,0x8B20,0x8B21,0x8B22,0x8B23,0x0000,/* 0x78-0x7F */ 0x8B24,0x8B25,0x8B27,0x8B28,0x8B29,0x8B2A,0x8B2B,0x8B2C,/* 0x80-0x87 */ 0x8B2D,0x8B2E,0x8B2F,0x8B30,0x8B31,0x8B32,0x8B33,0x8B34,/* 0x88-0x8F */ 0x8B35,0x8B36,0x8B37,0x8B38,0x8B39,0x8B3A,0x8B3B,0x8B3C,/* 0x90-0x97 */ 0x8B3D,0x8B3E,0x8B3F,0x8B40,0x8B41,0x8B42,0x8B43,0x8B44,/* 0x98-0x9F */ 0x8B45,0x5E27,0x75C7,0x90D1,0x8BC1,0x829D,0x679D,0x652F,/* 0xA0-0xA7 */ 0x5431,0x8718,0x77E5,0x80A2,0x8102,0x6C41,0x4E4B,0x7EC7,/* 0xA8-0xAF */ 0x804C,0x76F4,0x690D,0x6B96,0x6267,0x503C,0x4F84,0x5740,/* 0xB0-0xB7 */ 0x6307,0x6B62,0x8DBE,0x53EA,0x65E8,0x7EB8,0x5FD7,0x631A,/* 0xB8-0xBF */ 0x63B7,0x81F3,0x81F4,0x7F6E,0x5E1C,0x5CD9,0x5236,0x667A,/* 0xC0-0xC7 */ 0x79E9,0x7A1A,0x8D28,0x7099,0x75D4,0x6EDE,0x6CBB,0x7A92,/* 0xC8-0xCF */ 0x4E2D,0x76C5,0x5FE0,0x949F,0x8877,0x7EC8,0x79CD,0x80BF,/* 0xD0-0xD7 */ 0x91CD,0x4EF2,0x4F17,0x821F,0x5468,0x5DDE,0x6D32,0x8BCC,/* 0xD8-0xDF */ 0x7CA5,0x8F74,0x8098,0x5E1A,0x5492,0x76B1,0x5B99,0x663C,/* 0xE0-0xE7 */ 0x9AA4,0x73E0,0x682A,0x86DB,0x6731,0x732A,0x8BF8,0x8BDB,/* 0xE8-0xEF */ 0x9010,0x7AF9,0x70DB,0x716E,0x62C4,0x77A9,0x5631,0x4E3B,/* 0xF0-0xF7 */ 0x8457,0x67F1,0x52A9,0x86C0,0x8D2E,0x94F8,0x7B51,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_D7[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8B46,0x8B47,0x8B48,0x8B49,0x8B4A,0x8B4B,0x8B4C,0x8B4D,/* 0x40-0x47 */ 0x8B4E,0x8B4F,0x8B50,0x8B51,0x8B52,0x8B53,0x8B54,0x8B55,/* 0x48-0x4F */ 0x8B56,0x8B57,0x8B58,0x8B59,0x8B5A,0x8B5B,0x8B5C,0x8B5D,/* 0x50-0x57 */ 0x8B5E,0x8B5F,0x8B60,0x8B61,0x8B62,0x8B63,0x8B64,0x8B65,/* 0x58-0x5F */ 0x8B67,0x8B68,0x8B69,0x8B6A,0x8B6B,0x8B6D,0x8B6E,0x8B6F,/* 0x60-0x67 */ 0x8B70,0x8B71,0x8B72,0x8B73,0x8B74,0x8B75,0x8B76,0x8B77,/* 0x68-0x6F */ 0x8B78,0x8B79,0x8B7A,0x8B7B,0x8B7C,0x8B7D,0x8B7E,0x8B7F,/* 0x70-0x77 */ 0x8B80,0x8B81,0x8B82,0x8B83,0x8B84,0x8B85,0x8B86,0x0000,/* 0x78-0x7F */ 0x8B87,0x8B88,0x8B89,0x8B8A,0x8B8B,0x8B8C,0x8B8D,0x8B8E,/* 0x80-0x87 */ 0x8B8F,0x8B90,0x8B91,0x8B92,0x8B93,0x8B94,0x8B95,0x8B96,/* 0x88-0x8F */ 0x8B97,0x8B98,0x8B99,0x8B9A,0x8B9B,0x8B9C,0x8B9D,0x8B9E,/* 0x90-0x97 */ 0x8B9F,0x8BAC,0x8BB1,0x8BBB,0x8BC7,0x8BD0,0x8BEA,0x8C09,/* 0x98-0x9F */ 0x8C1E,0x4F4F,0x6CE8,0x795D,0x9A7B,0x6293,0x722A,0x62FD,/* 0xA0-0xA7 */ 0x4E13,0x7816,0x8F6C,0x64B0,0x8D5A,0x7BC6,0x6869,0x5E84,/* 0xA8-0xAF */ 0x88C5,0x5986,0x649E,0x58EE,0x72B6,0x690E,0x9525,0x8FFD,/* 0xB0-0xB7 */ 0x8D58,0x5760,0x7F00,0x8C06,0x51C6,0x6349,0x62D9,0x5353,/* 0xB8-0xBF */ 0x684C,0x7422,0x8301,0x914C,0x5544,0x7740,0x707C,0x6D4A,/* 0xC0-0xC7 */ 0x5179,0x54A8,0x8D44,0x59FF,0x6ECB,0x6DC4,0x5B5C,0x7D2B,/* 0xC8-0xCF */ 0x4ED4,0x7C7D,0x6ED3,0x5B50,0x81EA,0x6E0D,0x5B57,0x9B03,/* 0xD0-0xD7 */ 0x68D5,0x8E2A,0x5B97,0x7EFC,0x603B,0x7EB5,0x90B9,0x8D70,/* 0xD8-0xDF */ 0x594F,0x63CD,0x79DF,0x8DB3,0x5352,0x65CF,0x7956,0x8BC5,/* 0xE0-0xE7 */ 0x963B,0x7EC4,0x94BB,0x7E82,0x5634,0x9189,0x6700,0x7F6A,/* 0xE8-0xEF */ 0x5C0A,0x9075,0x6628,0x5DE6,0x4F50,0x67DE,0x505A,0x4F5C,/* 0xF0-0xF7 */ 0x5750,0x5EA7,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_D8[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8C38,0x8C39,0x8C3A,0x8C3B,0x8C3C,0x8C3D,0x8C3E,0x8C3F,/* 0x40-0x47 */ 0x8C40,0x8C42,0x8C43,0x8C44,0x8C45,0x8C48,0x8C4A,0x8C4B,/* 0x48-0x4F */ 0x8C4D,0x8C4E,0x8C4F,0x8C50,0x8C51,0x8C52,0x8C53,0x8C54,/* 0x50-0x57 */ 0x8C56,0x8C57,0x8C58,0x8C59,0x8C5B,0x8C5C,0x8C5D,0x8C5E,/* 0x58-0x5F */ 0x8C5F,0x8C60,0x8C63,0x8C64,0x8C65,0x8C66,0x8C67,0x8C68,/* 0x60-0x67 */ 0x8C69,0x8C6C,0x8C6D,0x8C6E,0x8C6F,0x8C70,0x8C71,0x8C72,/* 0x68-0x6F */ 0x8C74,0x8C75,0x8C76,0x8C77,0x8C7B,0x8C7C,0x8C7D,0x8C7E,/* 0x70-0x77 */ 0x8C7F,0x8C80,0x8C81,0x8C83,0x8C84,0x8C86,0x8C87,0x0000,/* 0x78-0x7F */ 0x8C88,0x8C8B,0x8C8D,0x8C8E,0x8C8F,0x8C90,0x8C91,0x8C92,/* 0x80-0x87 */ 0x8C93,0x8C95,0x8C96,0x8C97,0x8C99,0x8C9A,0x8C9B,0x8C9C,/* 0x88-0x8F */ 0x8C9D,0x8C9E,0x8C9F,0x8CA0,0x8CA1,0x8CA2,0x8CA3,0x8CA4,/* 0x90-0x97 */ 0x8CA5,0x8CA6,0x8CA7,0x8CA8,0x8CA9,0x8CAA,0x8CAB,0x8CAC,/* 0x98-0x9F */ 0x8CAD,0x4E8D,0x4E0C,0x5140,0x4E10,0x5EFF,0x5345,0x4E15,/* 0xA0-0xA7 */ 0x4E98,0x4E1E,0x9B32,0x5B6C,0x5669,0x4E28,0x79BA,0x4E3F,/* 0xA8-0xAF */ 0x5315,0x4E47,0x592D,0x723B,0x536E,0x6C10,0x56DF,0x80E4,/* 0xB0-0xB7 */ 0x9997,0x6BD3,0x777E,0x9F17,0x4E36,0x4E9F,0x9F10,0x4E5C,/* 0xB8-0xBF */ 0x4E69,0x4E93,0x8288,0x5B5B,0x556C,0x560F,0x4EC4,0x538D,/* 0xC0-0xC7 */ 0x539D,0x53A3,0x53A5,0x53AE,0x9765,0x8D5D,0x531A,0x53F5,/* 0xC8-0xCF */ 0x5326,0x532E,0x533E,0x8D5C,0x5366,0x5363,0x5202,0x5208,/* 0xD0-0xD7 */ 0x520E,0x522D,0x5233,0x523F,0x5240,0x524C,0x525E,0x5261,/* 0xD8-0xDF */ 0x525C,0x84AF,0x527D,0x5282,0x5281,0x5290,0x5293,0x5182,/* 0xE0-0xE7 */ 0x7F54,0x4EBB,0x4EC3,0x4EC9,0x4EC2,0x4EE8,0x4EE1,0x4EEB,/* 0xE8-0xEF */ 0x4EDE,0x4F1B,0x4EF3,0x4F22,0x4F64,0x4EF5,0x4F25,0x4F27,/* 0xF0-0xF7 */ 0x4F09,0x4F2B,0x4F5E,0x4F67,0x6538,0x4F5A,0x4F5D,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_D9[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8CAE,0x8CAF,0x8CB0,0x8CB1,0x8CB2,0x8CB3,0x8CB4,0x8CB5,/* 0x40-0x47 */ 0x8CB6,0x8CB7,0x8CB8,0x8CB9,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C,0x5025,0x5028,0x507E,/* 0xC0-0xC7 */ 0x5043,0x5055,0x5048,0x504E,0x506C,0x507B,0x50A5,0x50A7,/* 0xC8-0xCF */ 0x50A9,0x50BA,0x50D6,0x5106,0x50ED,0x50EC,0x50E6,0x50EE,/* 0xD0-0xD7 */ 0x5107,0x510B,0x4EDD,0x6C3D,0x4F58,0x4F65,0x4FCE,0x9FA0,/* 0xD8-0xDF */ 0x6C46,0x7C74,0x516E,0x5DFD,0x9EC9,0x9998,0x5181,0x5914,/* 0xE0-0xE7 */ 0x52F9,0x530D,0x8A07,0x5310,0x51EB,0x5919,0x5155,0x4EA0,/* 0xE8-0xEF */ 0x5156,0x4EB3,0x886E,0x88A4,0x4EB5,0x8114,0x88D2,0x7980,/* 0xF0-0xF7 */ 0x5B34,0x8803,0x7FB8,0x51AB,0x51B1,0x51BD,0x51BC,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_DA[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8D0E,0x8D0F,0x8D10,0x8D11,0x8D12,0x8D13,0x8D14,0x8D15,/* 0x40-0x47 */ 0x8D16,0x8D17,0x8D18,0x8D19,0x8D1A,0x8D1B,0x8D1C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C07,/* 0xC0-0xC7 */ 0x8C0C,0x8C0F,0x8C11,0x8C12,0x8C14,0x8C15,0x8C16,0x8C19,/* 0xC8-0xCF */ 0x8C1B,0x8C18,0x8C1D,0x8C1F,0x8C20,0x8C21,0x8C25,0x8C27,/* 0xD0-0xD7 */ 0x8C2A,0x8C2B,0x8C2E,0x8C2F,0x8C32,0x8C33,0x8C35,0x8C36,/* 0xD8-0xDF */ 0x5369,0x537A,0x961D,0x9622,0x9621,0x9631,0x962A,0x963D,/* 0xE0-0xE7 */ 0x963C,0x9642,0x9649,0x9654,0x965F,0x9667,0x966C,0x9672,/* 0xE8-0xEF */ 0x9674,0x9688,0x968D,0x9697,0x96B0,0x9097,0x909B,0x909D,/* 0xF0-0xF7 */ 0x9099,0x90AC,0x90A1,0x90B4,0x90B3,0x90B6,0x90BA,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_DB[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8DD5,0x8DD8,0x8DD9,0x8DDC,0x8DE0,0x8DE1,0x8DE2,0x8DE5,/* 0x40-0x47 */ 0x8DE6,0x8DE7,0x8DE9,0x8DED,0x8DEE,0x8DF0,0x8DF1,0x8DF2,/* 0x48-0x4F */ 0x8DF4,0x8DF6,0x8DFC,0x8DFE,0x8DFF,0x8E00,0x8E01,0x8E02,/* 0x50-0x57 */ 0x8E03,0x8E04,0x8E06,0x8E07,0x8E08,0x8E0B,0x8E0D,0x8E0E,/* 0x58-0x5F */ 0x8E10,0x8E11,0x8E12,0x8E13,0x8E15,0x8E16,0x8E17,0x8E18,/* 0x60-0x67 */ 0x8E19,0x8E1A,0x8E1B,0x8E1C,0x8E20,0x8E21,0x8E24,0x8E25,/* 0x68-0x6F */ 0x8E26,0x8E27,0x8E28,0x8E2B,0x8E2D,0x8E30,0x8E32,0x8E33,/* 0x70-0x77 */ 0x8E34,0x8E36,0x8E37,0x8E38,0x8E3B,0x8E3C,0x8E3E,0x0000,/* 0x78-0x7F */ 0x8E3F,0x8E43,0x8E45,0x8E46,0x8E4C,0x8E4D,0x8E4E,0x8E4F,/* 0x80-0x87 */ 0x8E50,0x8E53,0x8E54,0x8E55,0x8E56,0x8E57,0x8E58,0x8E5A,/* 0x88-0x8F */ 0x8E5B,0x8E5C,0x8E5D,0x8E5E,0x8E5F,0x8E60,0x8E61,0x8E62,/* 0x90-0x97 */ 0x8E63,0x8E64,0x8E65,0x8E67,0x8E68,0x8E6A,0x8E6B,0x8E6E,/* 0x98-0x9F */ 0x8E71,0x90B8,0x90B0,0x90CF,0x90C5,0x90BE,0x90D0,0x90C4,/* 0xA0-0xA7 */ 0x90C7,0x90D3,0x90E6,0x90E2,0x90DC,0x90D7,0x90DB,0x90EB,/* 0xA8-0xAF */ 0x90EF,0x90FE,0x9104,0x9122,0x911E,0x9123,0x9131,0x912F,/* 0xB0-0xB7 */ 0x9139,0x9143,0x9146,0x520D,0x5942,0x52A2,0x52AC,0x52AD,/* 0xB8-0xBF */ 0x52BE,0x54FF,0x52D0,0x52D6,0x52F0,0x53DF,0x71EE,0x77CD,/* 0xC0-0xC7 */ 0x5EF4,0x51F5,0x51FC,0x9B2F,0x53B6,0x5F01,0x755A,0x5DEF,/* 0xC8-0xCF */ 0x574C,0x57A9,0x57A1,0x587E,0x58BC,0x58C5,0x58D1,0x5729,/* 0xD0-0xD7 */ 0x572C,0x572A,0x5733,0x5739,0x572E,0x572F,0x575C,0x573B,/* 0xD8-0xDF */ 0x5742,0x5769,0x5785,0x576B,0x5786,0x577C,0x577B,0x5768,/* 0xE0-0xE7 */ 0x576D,0x5776,0x5773,0x57AD,0x57A4,0x578C,0x57B2,0x57CF,/* 0xE8-0xEF */ 0x57A7,0x57B4,0x5793,0x57A0,0x57D5,0x57D8,0x57DA,0x57D9,/* 0xF0-0xF7 */ 0x57D2,0x57B8,0x57F4,0x57EF,0x57F8,0x57E4,0x57DD,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_DC[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8E73,0x8E75,0x8E77,0x8E78,0x8E79,0x8E7A,0x8E7B,0x8E7D,/* 0x40-0x47 */ 0x8E7E,0x8E80,0x8E82,0x8E83,0x8E84,0x8E86,0x8E88,0x8E89,/* 0x48-0x4F */ 0x8E8A,0x8E8B,0x8E8C,0x8E8D,0x8E8E,0x8E91,0x8E92,0x8E93,/* 0x50-0x57 */ 0x8E95,0x8E96,0x8E97,0x8E98,0x8E99,0x8E9A,0x8E9B,0x8E9D,/* 0x58-0x5F */ 0x8E9F,0x8EA0,0x8EA1,0x8EA2,0x8EA3,0x8EA4,0x8EA5,0x8EA6,/* 0x60-0x67 */ 0x8EA7,0x8EA8,0x8EA9,0x8EAA,0x8EAD,0x8EAE,0x8EB0,0x8EB1,/* 0x68-0x6F */ 0x8EB3,0x8EB4,0x8EB5,0x8EB6,0x8EB7,0x8EB8,0x8EB9,0x8EBB,/* 0x70-0x77 */ 0x8EBC,0x8EBD,0x8EBE,0x8EBF,0x8EC0,0x8EC1,0x8EC2,0x0000,/* 0x78-0x7F */ 0x8EC3,0x8EC4,0x8EC5,0x8EC6,0x8EC7,0x8EC8,0x8EC9,0x8ECA,/* 0x80-0x87 */ 0x8ECB,0x8ECC,0x8ECD,0x8ECF,0x8ED0,0x8ED1,0x8ED2,0x8ED3,/* 0x88-0x8F */ 0x8ED4,0x8ED5,0x8ED6,0x8ED7,0x8ED8,0x8ED9,0x8EDA,0x8EDB,/* 0x90-0x97 */ 0x8EDC,0x8EDD,0x8EDE,0x8EDF,0x8EE0,0x8EE1,0x8EE2,0x8EE3,/* 0x98-0x9F */ 0x8EE4,0x580B,0x580D,0x57FD,0x57ED,0x5800,0x581E,0x5819,/* 0xA0-0xA7 */ 0x5844,0x5820,0x5865,0x586C,0x5881,0x5889,0x589A,0x5880,/* 0xA8-0xAF */ 0x99A8,0x9F19,0x61FF,0x8279,0x827D,0x827F,0x828F,0x828A,/* 0xB0-0xB7 */ 0x82A8,0x8284,0x828E,0x8291,0x8297,0x8299,0x82AB,0x82B8,/* 0xB8-0xBF */ 0x82BE,0x82B0,0x82C8,0x82CA,0x82E3,0x8298,0x82B7,0x82AE,/* 0xC0-0xC7 */ 0x82CB,0x82CC,0x82C1,0x82A9,0x82B4,0x82A1,0x82AA,0x829F,/* 0xC8-0xCF */ 0x82C4,0x82CE,0x82A4,0x82E1,0x8309,0x82F7,0x82E4,0x830F,/* 0xD0-0xD7 */ 0x8307,0x82DC,0x82F4,0x82D2,0x82D8,0x830C,0x82FB,0x82D3,/* 0xD8-0xDF */ 0x8311,0x831A,0x8306,0x8314,0x8315,0x82E0,0x82D5,0x831C,/* 0xE0-0xE7 */ 0x8351,0x835B,0x835C,0x8308,0x8392,0x833C,0x8334,0x8331,/* 0xE8-0xEF */ 0x839B,0x835E,0x832F,0x834F,0x8347,0x8343,0x835F,0x8340,/* 0xF0-0xF7 */ 0x8317,0x8360,0x832D,0x833A,0x8333,0x8366,0x8365,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_DD[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8EE5,0x8EE6,0x8EE7,0x8EE8,0x8EE9,0x8EEA,0x8EEB,0x8EEC,/* 0x40-0x47 */ 0x8EED,0x8EEE,0x8EEF,0x8EF0,0x8EF1,0x8EF2,0x8EF3,0x8EF4,/* 0x48-0x4F */ 0x8EF5,0x8EF6,0x8EF7,0x8EF8,0x8EF9,0x8EFA,0x8EFB,0x8EFC,/* 0x50-0x57 */ 0x8EFD,0x8EFE,0x8EFF,0x8F00,0x8F01,0x8F02,0x8F03,0x8F04,/* 0x58-0x5F */ 0x8F05,0x8F06,0x8F07,0x8F08,0x8F09,0x8F0A,0x8F0B,0x8F0C,/* 0x60-0x67 */ 0x8F0D,0x8F0E,0x8F0F,0x8F10,0x8F11,0x8F12,0x8F13,0x8F14,/* 0x68-0x6F */ 0x8F15,0x8F16,0x8F17,0x8F18,0x8F19,0x8F1A,0x8F1B,0x8F1C,/* 0x70-0x77 */ 0x8F1D,0x8F1E,0x8F1F,0x8F20,0x8F21,0x8F22,0x8F23,0x0000,/* 0x78-0x7F */ 0x8F24,0x8F25,0x8F26,0x8F27,0x8F28,0x8F29,0x8F2A,0x8F2B,/* 0x80-0x87 */ 0x8F2C,0x8F2D,0x8F2E,0x8F2F,0x8F30,0x8F31,0x8F32,0x8F33,/* 0x88-0x8F */ 0x8F34,0x8F35,0x8F36,0x8F37,0x8F38,0x8F39,0x8F3A,0x8F3B,/* 0x90-0x97 */ 0x8F3C,0x8F3D,0x8F3E,0x8F3F,0x8F40,0x8F41,0x8F42,0x8F43,/* 0x98-0x9F */ 0x8F44,0x8368,0x831B,0x8369,0x836C,0x836A,0x836D,0x836E,/* 0xA0-0xA7 */ 0x83B0,0x8378,0x83B3,0x83B4,0x83A0,0x83AA,0x8393,0x839C,/* 0xA8-0xAF */ 0x8385,0x837C,0x83B6,0x83A9,0x837D,0x83B8,0x837B,0x8398,/* 0xB0-0xB7 */ 0x839E,0x83A8,0x83BA,0x83BC,0x83C1,0x8401,0x83E5,0x83D8,/* 0xB8-0xBF */ 0x5807,0x8418,0x840B,0x83DD,0x83FD,0x83D6,0x841C,0x8438,/* 0xC0-0xC7 */ 0x8411,0x8406,0x83D4,0x83DF,0x840F,0x8403,0x83F8,0x83F9,/* 0xC8-0xCF */ 0x83EA,0x83C5,0x83C0,0x8426,0x83F0,0x83E1,0x845C,0x8451,/* 0xD0-0xD7 */ 0x845A,0x8459,0x8473,0x8487,0x8488,0x847A,0x8489,0x8478,/* 0xD8-0xDF */ 0x843C,0x8446,0x8469,0x8476,0x848C,0x848E,0x8431,0x846D,/* 0xE0-0xE7 */ 0x84C1,0x84CD,0x84D0,0x84E6,0x84BD,0x84D3,0x84CA,0x84BF,/* 0xE8-0xEF */ 0x84BA,0x84E0,0x84A1,0x84B9,0x84B4,0x8497,0x84E5,0x84E3,/* 0xF0-0xF7 */ 0x850C,0x750D,0x8538,0x84F0,0x8539,0x851F,0x853A,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_DE[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x8F45,0x8F46,0x8F47,0x8F48,0x8F49,0x8F4A,0x8F4B,0x8F4C,/* 0x40-0x47 */ 0x8F4D,0x8F4E,0x8F4F,0x8F50,0x8F51,0x8F52,0x8F53,0x8F54,/* 0x48-0x4F */ 0x8F55,0x8F56,0x8F57,0x8F58,0x8F59,0x8F5A,0x8F5B,0x8F5C,/* 0x50-0x57 */ 0x8F5D,0x8F5E,0x8F5F,0x8F60,0x8F61,0x8F62,0x8F63,0x8F64,/* 0x58-0x5F */ 0x8F65,0x8F6A,0x8F80,0x8F8C,0x8F92,0x8F9D,0x8FA0,0x8FA1,/* 0x60-0x67 */ 0x8FA2,0x8FA4,0x8FA5,0x8FA6,0x8FA7,0x8FAA,0x8FAC,0x8FAD,/* 0x68-0x6F */ 0x8FAE,0x8FAF,0x8FB2,0x8FB3,0x8FB4,0x8FB5,0x8FB7,0x8FB8,/* 0x70-0x77 */ 0x8FBA,0x8FBB,0x8FBC,0x8FBF,0x8FC0,0x8FC3,0x8FC6,0x0000,/* 0x78-0x7F */ 0x8FC9,0x8FCA,0x8FCB,0x8FCC,0x8FCD,0x8FCF,0x8FD2,0x8FD6,/* 0x80-0x87 */ 0x8FD7,0x8FDA,0x8FE0,0x8FE1,0x8FE3,0x8FE7,0x8FEC,0x8FEF,/* 0x88-0x8F */ 0x8FF1,0x8FF2,0x8FF4,0x8FF5,0x8FF6,0x8FFA,0x8FFB,0x8FFC,/* 0x90-0x97 */ 0x8FFE,0x8FFF,0x9007,0x9008,0x900C,0x900E,0x9013,0x9015,/* 0x98-0x9F */ 0x9018,0x8556,0x853B,0x84FF,0x84FC,0x8559,0x8548,0x8568,/* 0xA0-0xA7 */ 0x8564,0x855E,0x857A,0x77A2,0x8543,0x8572,0x857B,0x85A4,/* 0xA8-0xAF */ 0x85A8,0x8587,0x858F,0x8579,0x85AE,0x859C,0x8585,0x85B9,/* 0xB0-0xB7 */ 0x85B7,0x85B0,0x85D3,0x85C1,0x85DC,0x85FF,0x8627,0x8605,/* 0xB8-0xBF */ 0x8629,0x8616,0x863C,0x5EFE,0x5F08,0x593C,0x5941,0x8037,/* 0xC0-0xC7 */ 0x5955,0x595A,0x5958,0x530F,0x5C22,0x5C25,0x5C2C,0x5C34,/* 0xC8-0xCF */ 0x624C,0x626A,0x629F,0x62BB,0x62CA,0x62DA,0x62D7,0x62EE,/* 0xD0-0xD7 */ 0x6322,0x62F6,0x6339,0x634B,0x6343,0x63AD,0x63F6,0x6371,/* 0xD8-0xDF */ 0x637A,0x638E,0x63B4,0x636D,0x63AC,0x638A,0x6369,0x63AE,/* 0xE0-0xE7 */ 0x63BC,0x63F2,0x63F8,0x63E0,0x63FF,0x63C4,0x63DE,0x63CE,/* 0xE8-0xEF */ 0x6452,0x63C6,0x63BE,0x6445,0x6441,0x640B,0x641B,0x6420,/* 0xF0-0xF7 */ 0x640C,0x6426,0x6421,0x645E,0x6484,0x646D,0x6496,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_DF[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9019,0x901C,0x9023,0x9024,0x9025,0x9027,0x9028,0x9029,/* 0x40-0x47 */ 0x902A,0x902B,0x902C,0x9030,0x9031,0x9032,0x9033,0x9034,/* 0x48-0x4F */ 0x9037,0x9039,0x903A,0x903D,0x903F,0x9040,0x9043,0x9045,/* 0x50-0x57 */ 0x9046,0x9048,0x9049,0x904A,0x904B,0x904C,0x904E,0x9054,/* 0x58-0x5F */ 0x9055,0x9056,0x9059,0x905A,0x905C,0x905D,0x905E,0x905F,/* 0x60-0x67 */ 0x9060,0x9061,0x9064,0x9066,0x9067,0x9069,0x906A,0x906B,/* 0x68-0x6F */ 0x906C,0x906F,0x9070,0x9071,0x9072,0x9073,0x9076,0x9077,/* 0x70-0x77 */ 0x9078,0x9079,0x907A,0x907B,0x907C,0x907E,0x9081,0x0000,/* 0x78-0x7F */ 0x9084,0x9085,0x9086,0x9087,0x9089,0x908A,0x908C,0x908D,/* 0x80-0x87 */ 0x908E,0x908F,0x9090,0x9092,0x9094,0x9096,0x9098,0x909A,/* 0x88-0x8F */ 0x909C,0x909E,0x909F,0x90A0,0x90A4,0x90A5,0x90A7,0x90A8,/* 0x90-0x97 */ 0x90A9,0x90AB,0x90AD,0x90B2,0x90B7,0x90BC,0x90BD,0x90BF,/* 0x98-0x9F */ 0x90C0,0x647A,0x64B7,0x64B8,0x6499,0x64BA,0x64C0,0x64D0,/* 0xA0-0xA7 */ 0x64D7,0x64E4,0x64E2,0x6509,0x6525,0x652E,0x5F0B,0x5FD2,/* 0xA8-0xAF */ 0x7519,0x5F11,0x535F,0x53F1,0x53FD,0x53E9,0x53E8,0x53FB,/* 0xB0-0xB7 */ 0x5412,0x5416,0x5406,0x544B,0x5452,0x5453,0x5454,0x5456,/* 0xB8-0xBF */ 0x5443,0x5421,0x5457,0x5459,0x5423,0x5432,0x5482,0x5494,/* 0xC0-0xC7 */ 0x5477,0x5471,0x5464,0x549A,0x549B,0x5484,0x5476,0x5466,/* 0xC8-0xCF */ 0x549D,0x54D0,0x54AD,0x54C2,0x54B4,0x54D2,0x54A7,0x54A6,/* 0xD0-0xD7 */ 0x54D3,0x54D4,0x5472,0x54A3,0x54D5,0x54BB,0x54BF,0x54CC,/* 0xD8-0xDF */ 0x54D9,0x54DA,0x54DC,0x54A9,0x54AA,0x54A4,0x54DD,0x54CF,/* 0xE0-0xE7 */ 0x54DE,0x551B,0x54E7,0x5520,0x54FD,0x5514,0x54F3,0x5522,/* 0xE8-0xEF */ 0x5523,0x550F,0x5511,0x5527,0x552A,0x5567,0x558F,0x55B5,/* 0xF0-0xF7 */ 0x5549,0x556D,0x5541,0x5555,0x553F,0x5550,0x553C,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_E0[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x90C2,0x90C3,0x90C6,0x90C8,0x90C9,0x90CB,0x90CC,0x90CD,/* 0x40-0x47 */ 0x90D2,0x90D4,0x90D5,0x90D6,0x90D8,0x90D9,0x90DA,0x90DE,/* 0x48-0x4F */ 0x90DF,0x90E0,0x90E3,0x90E4,0x90E5,0x90E9,0x90EA,0x90EC,/* 0x50-0x57 */ 0x90EE,0x90F0,0x90F1,0x90F2,0x90F3,0x90F5,0x90F6,0x90F7,/* 0x58-0x5F */ 0x90F9,0x90FA,0x90FB,0x90FC,0x90FF,0x9100,0x9101,0x9103,/* 0x60-0x67 */ 0x9105,0x9106,0x9107,0x9108,0x9109,0x910A,0x910B,0x910C,/* 0x68-0x6F */ 0x910D,0x910E,0x910F,0x9110,0x9111,0x9112,0x9113,0x9114,/* 0x70-0x77 */ 0x9115,0x9116,0x9117,0x9118,0x911A,0x911B,0x911C,0x0000,/* 0x78-0x7F */ 0x911D,0x911F,0x9120,0x9121,0x9124,0x9125,0x9126,0x9127,/* 0x80-0x87 */ 0x9128,0x9129,0x912A,0x912B,0x912C,0x912D,0x912E,0x9130,/* 0x88-0x8F */ 0x9132,0x9133,0x9134,0x9135,0x9136,0x9137,0x9138,0x913A,/* 0x90-0x97 */ 0x913B,0x913C,0x913D,0x913E,0x913F,0x9140,0x9141,0x9142,/* 0x98-0x9F */ 0x9144,0x5537,0x5556,0x5575,0x5576,0x5577,0x5533,0x5530,/* 0xA0-0xA7 */ 0x555C,0x558B,0x55D2,0x5583,0x55B1,0x55B9,0x5588,0x5581,/* 0xA8-0xAF */ 0x559F,0x557E,0x55D6,0x5591,0x557B,0x55DF,0x55BD,0x55BE,/* 0xB0-0xB7 */ 0x5594,0x5599,0x55EA,0x55F7,0x55C9,0x561F,0x55D1,0x55EB,/* 0xB8-0xBF */ 0x55EC,0x55D4,0x55E6,0x55DD,0x55C4,0x55EF,0x55E5,0x55F2,/* 0xC0-0xC7 */ 0x55F3,0x55CC,0x55CD,0x55E8,0x55F5,0x55E4,0x8F94,0x561E,/* 0xC8-0xCF */ 0x5608,0x560C,0x5601,0x5624,0x5623,0x55FE,0x5600,0x5627,/* 0xD0-0xD7 */ 0x562D,0x5658,0x5639,0x5657,0x562C,0x564D,0x5662,0x5659,/* 0xD8-0xDF */ 0x565C,0x564C,0x5654,0x5686,0x5664,0x5671,0x566B,0x567B,/* 0xE0-0xE7 */ 0x567C,0x5685,0x5693,0x56AF,0x56D4,0x56D7,0x56DD,0x56E1,/* 0xE8-0xEF */ 0x56F5,0x56EB,0x56F9,0x56FF,0x5704,0x570A,0x5709,0x571C,/* 0xF0-0xF7 */ 0x5E0F,0x5E19,0x5E14,0x5E11,0x5E31,0x5E3B,0x5E3C,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_E1[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9145,0x9147,0x9148,0x9151,0x9153,0x9154,0x9155,0x9156,/* 0x40-0x47 */ 0x9158,0x9159,0x915B,0x915C,0x915F,0x9160,0x9166,0x9167,/* 0x48-0x4F */ 0x9168,0x916B,0x916D,0x9173,0x917A,0x917B,0x917C,0x9180,/* 0x50-0x57 */ 0x9181,0x9182,0x9183,0x9184,0x9186,0x9188,0x918A,0x918E,/* 0x58-0x5F */ 0x918F,0x9193,0x9194,0x9195,0x9196,0x9197,0x9198,0x9199,/* 0x60-0x67 */ 0x919C,0x919D,0x919E,0x919F,0x91A0,0x91A1,0x91A4,0x91A5,/* 0x68-0x6F */ 0x91A6,0x91A7,0x91A8,0x91A9,0x91AB,0x91AC,0x91B0,0x91B1,/* 0x70-0x77 */ 0x91B2,0x91B3,0x91B6,0x91B7,0x91B8,0x91B9,0x91BB,0x0000,/* 0x78-0x7F */ 0x91BC,0x91BD,0x91BE,0x91BF,0x91C0,0x91C1,0x91C2,0x91C3,/* 0x80-0x87 */ 0x91C4,0x91C5,0x91C6,0x91C8,0x91CB,0x91D0,0x91D2,0x91D3,/* 0x88-0x8F */ 0x91D4,0x91D5,0x91D6,0x91D7,0x91D8,0x91D9,0x91DA,0x91DB,/* 0x90-0x97 */ 0x91DD,0x91DE,0x91DF,0x91E0,0x91E1,0x91E2,0x91E3,0x91E4,/* 0x98-0x9F */ 0x91E5,0x5E37,0x5E44,0x5E54,0x5E5B,0x5E5E,0x5E61,0x5C8C,/* 0xA0-0xA7 */ 0x5C7A,0x5C8D,0x5C90,0x5C96,0x5C88,0x5C98,0x5C99,0x5C91,/* 0xA8-0xAF */ 0x5C9A,0x5C9C,0x5CB5,0x5CA2,0x5CBD,0x5CAC,0x5CAB,0x5CB1,/* 0xB0-0xB7 */ 0x5CA3,0x5CC1,0x5CB7,0x5CC4,0x5CD2,0x5CE4,0x5CCB,0x5CE5,/* 0xB8-0xBF */ 0x5D02,0x5D03,0x5D27,0x5D26,0x5D2E,0x5D24,0x5D1E,0x5D06,/* 0xC0-0xC7 */ 0x5D1B,0x5D58,0x5D3E,0x5D34,0x5D3D,0x5D6C,0x5D5B,0x5D6F,/* 0xC8-0xCF */ 0x5D5D,0x5D6B,0x5D4B,0x5D4A,0x5D69,0x5D74,0x5D82,0x5D99,/* 0xD0-0xD7 */ 0x5D9D,0x8C73,0x5DB7,0x5DC5,0x5F73,0x5F77,0x5F82,0x5F87,/* 0xD8-0xDF */ 0x5F89,0x5F8C,0x5F95,0x5F99,0x5F9C,0x5FA8,0x5FAD,0x5FB5,/* 0xE0-0xE7 */ 0x5FBC,0x8862,0x5F61,0x72AD,0x72B0,0x72B4,0x72B7,0x72B8,/* 0xE8-0xEF */ 0x72C3,0x72C1,0x72CE,0x72CD,0x72D2,0x72E8,0x72EF,0x72E9,/* 0xF0-0xF7 */ 0x72F2,0x72F4,0x72F7,0x7301,0x72F3,0x7303,0x72FA,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_E2[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x91E6,0x91E7,0x91E8,0x91E9,0x91EA,0x91EB,0x91EC,0x91ED,/* 0x40-0x47 */ 0x91EE,0x91EF,0x91F0,0x91F1,0x91F2,0x91F3,0x91F4,0x91F5,/* 0x48-0x4F */ 0x91F6,0x91F7,0x91F8,0x91F9,0x91FA,0x91FB,0x91FC,0x91FD,/* 0x50-0x57 */ 0x91FE,0x91FF,0x9200,0x9201,0x9202,0x9203,0x9204,0x9205,/* 0x58-0x5F */ 0x9206,0x9207,0x9208,0x9209,0x920A,0x920B,0x920C,0x920D,/* 0x60-0x67 */ 0x920E,0x920F,0x9210,0x9211,0x9212,0x9213,0x9214,0x9215,/* 0x68-0x6F */ 0x9216,0x9217,0x9218,0x9219,0x921A,0x921B,0x921C,0x921D,/* 0x70-0x77 */ 0x921E,0x921F,0x9220,0x9221,0x9222,0x9223,0x9224,0x0000,/* 0x78-0x7F */ 0x9225,0x9226,0x9227,0x9228,0x9229,0x922A,0x922B,0x922C,/* 0x80-0x87 */ 0x922D,0x922E,0x922F,0x9230,0x9231,0x9232,0x9233,0x9234,/* 0x88-0x8F */ 0x9235,0x9236,0x9237,0x9238,0x9239,0x923A,0x923B,0x923C,/* 0x90-0x97 */ 0x923D,0x923E,0x923F,0x9240,0x9241,0x9242,0x9243,0x9244,/* 0x98-0x9F */ 0x9245,0x72FB,0x7317,0x7313,0x7321,0x730A,0x731E,0x731D,/* 0xA0-0xA7 */ 0x7315,0x7322,0x7339,0x7325,0x732C,0x7338,0x7331,0x7350,/* 0xA8-0xAF */ 0x734D,0x7357,0x7360,0x736C,0x736F,0x737E,0x821B,0x5925,/* 0xB0-0xB7 */ 0x98E7,0x5924,0x5902,0x9963,0x9967,0x9968,0x9969,0x996A,/* 0xB8-0xBF */ 0x996B,0x996C,0x9974,0x9977,0x997D,0x9980,0x9984,0x9987,/* 0xC0-0xC7 */ 0x998A,0x998D,0x9990,0x9991,0x9993,0x9994,0x9995,0x5E80,/* 0xC8-0xCF */ 0x5E91,0x5E8B,0x5E96,0x5EA5,0x5EA0,0x5EB9,0x5EB5,0x5EBE,/* 0xD0-0xD7 */ 0x5EB3,0x8D53,0x5ED2,0x5ED1,0x5EDB,0x5EE8,0x5EEA,0x81BA,/* 0xD8-0xDF */ 0x5FC4,0x5FC9,0x5FD6,0x5FCF,0x6003,0x5FEE,0x6004,0x5FE1,/* 0xE0-0xE7 */ 0x5FE4,0x5FFE,0x6005,0x6006,0x5FEA,0x5FED,0x5FF8,0x6019,/* 0xE8-0xEF */ 0x6035,0x6026,0x601B,0x600F,0x600D,0x6029,0x602B,0x600A,/* 0xF0-0xF7 */ 0x603F,0x6021,0x6078,0x6079,0x607B,0x607A,0x6042,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_E3[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9246,0x9247,0x9248,0x9249,0x924A,0x924B,0x924C,0x924D,/* 0x40-0x47 */ 0x924E,0x924F,0x9250,0x9251,0x9252,0x9253,0x9254,0x9255,/* 0x48-0x4F */ 0x9256,0x9257,0x9258,0x9259,0x925A,0x925B,0x925C,0x925D,/* 0x50-0x57 */ 0x925E,0x925F,0x9260,0x9261,0x9262,0x9263,0x9264,0x9265,/* 0x58-0x5F */ 0x9266,0x9267,0x9268,0x9269,0x926A,0x926B,0x926C,0x926D,/* 0x60-0x67 */ 0x926E,0x926F,0x9270,0x9271,0x9272,0x9273,0x9275,0x9276,/* 0x68-0x6F */ 0x9277,0x9278,0x9279,0x927A,0x927B,0x927C,0x927D,0x927E,/* 0x70-0x77 */ 0x927F,0x9280,0x9281,0x9282,0x9283,0x9284,0x9285,0x0000,/* 0x78-0x7F */ 0x9286,0x9287,0x9288,0x9289,0x928A,0x928B,0x928C,0x928D,/* 0x80-0x87 */ 0x928F,0x9290,0x9291,0x9292,0x9293,0x9294,0x9295,0x9296,/* 0x88-0x8F */ 0x9297,0x9298,0x9299,0x929A,0x929B,0x929C,0x929D,0x929E,/* 0x90-0x97 */ 0x929F,0x92A0,0x92A1,0x92A2,0x92A3,0x92A4,0x92A5,0x92A6,/* 0x98-0x9F */ 0x92A7,0x606A,0x607D,0x6096,0x609A,0x60AD,0x609D,0x6083,/* 0xA0-0xA7 */ 0x6092,0x608C,0x609B,0x60EC,0x60BB,0x60B1,0x60DD,0x60D8,/* 0xA8-0xAF */ 0x60C6,0x60DA,0x60B4,0x6120,0x6126,0x6115,0x6123,0x60F4,/* 0xB0-0xB7 */ 0x6100,0x610E,0x612B,0x614A,0x6175,0x61AC,0x6194,0x61A7,/* 0xB8-0xBF */ 0x61B7,0x61D4,0x61F5,0x5FDD,0x96B3,0x95E9,0x95EB,0x95F1,/* 0xC0-0xC7 */ 0x95F3,0x95F5,0x95F6,0x95FC,0x95FE,0x9603,0x9604,0x9606,/* 0xC8-0xCF */ 0x9608,0x960A,0x960B,0x960C,0x960D,0x960F,0x9612,0x9615,/* 0xD0-0xD7 */ 0x9616,0x9617,0x9619,0x961A,0x4E2C,0x723F,0x6215,0x6C35,/* 0xD8-0xDF */ 0x6C54,0x6C5C,0x6C4A,0x6CA3,0x6C85,0x6C90,0x6C94,0x6C8C,/* 0xE0-0xE7 */ 0x6C68,0x6C69,0x6C74,0x6C76,0x6C86,0x6CA9,0x6CD0,0x6CD4,/* 0xE8-0xEF */ 0x6CAD,0x6CF7,0x6CF8,0x6CF1,0x6CD7,0x6CB2,0x6CE0,0x6CD6,/* 0xF0-0xF7 */ 0x6CFA,0x6CEB,0x6CEE,0x6CB1,0x6CD3,0x6CEF,0x6CFE,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_E4[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x92A8,0x92A9,0x92AA,0x92AB,0x92AC,0x92AD,0x92AF,0x92B0,/* 0x40-0x47 */ 0x92B1,0x92B2,0x92B3,0x92B4,0x92B5,0x92B6,0x92B7,0x92B8,/* 0x48-0x4F */ 0x92B9,0x92BA,0x92BB,0x92BC,0x92BD,0x92BE,0x92BF,0x92C0,/* 0x50-0x57 */ 0x92C1,0x92C2,0x92C3,0x92C4,0x92C5,0x92C6,0x92C7,0x92C9,/* 0x58-0x5F */ 0x92CA,0x92CB,0x92CC,0x92CD,0x92CE,0x92CF,0x92D0,0x92D1,/* 0x60-0x67 */ 0x92D2,0x92D3,0x92D4,0x92D5,0x92D6,0x92D7,0x92D8,0x92D9,/* 0x68-0x6F */ 0x92DA,0x92DB,0x92DC,0x92DD,0x92DE,0x92DF,0x92E0,0x92E1,/* 0x70-0x77 */ 0x92E2,0x92E3,0x92E4,0x92E5,0x92E6,0x92E7,0x92E8,0x0000,/* 0x78-0x7F */ 0x92E9,0x92EA,0x92EB,0x92EC,0x92ED,0x92EE,0x92EF,0x92F0,/* 0x80-0x87 */ 0x92F1,0x92F2,0x92F3,0x92F4,0x92F5,0x92F6,0x92F7,0x92F8,/* 0x88-0x8F */ 0x92F9,0x92FA,0x92FB,0x92FC,0x92FD,0x92FE,0x92FF,0x9300,/* 0x90-0x97 */ 0x9301,0x9302,0x9303,0x9304,0x9305,0x9306,0x9307,0x9308,/* 0x98-0x9F */ 0x9309,0x6D39,0x6D27,0x6D0C,0x6D43,0x6D48,0x6D07,0x6D04,/* 0xA0-0xA7 */ 0x6D19,0x6D0E,0x6D2B,0x6D4D,0x6D2E,0x6D35,0x6D1A,0x6D4F,/* 0xA8-0xAF */ 0x6D52,0x6D54,0x6D33,0x6D91,0x6D6F,0x6D9E,0x6DA0,0x6D5E,/* 0xB0-0xB7 */ 0x6D93,0x6D94,0x6D5C,0x6D60,0x6D7C,0x6D63,0x6E1A,0x6DC7,/* 0xB8-0xBF */ 0x6DC5,0x6DDE,0x6E0E,0x6DBF,0x6DE0,0x6E11,0x6DE6,0x6DDD,/* 0xC0-0xC7 */ 0x6DD9,0x6E16,0x6DAB,0x6E0C,0x6DAE,0x6E2B,0x6E6E,0x6E4E,/* 0xC8-0xCF */ 0x6E6B,0x6EB2,0x6E5F,0x6E86,0x6E53,0x6E54,0x6E32,0x6E25,/* 0xD0-0xD7 */ 0x6E44,0x6EDF,0x6EB1,0x6E98,0x6EE0,0x6F2D,0x6EE2,0x6EA5,/* 0xD8-0xDF */ 0x6EA7,0x6EBD,0x6EBB,0x6EB7,0x6ED7,0x6EB4,0x6ECF,0x6E8F,/* 0xE0-0xE7 */ 0x6EC2,0x6E9F,0x6F62,0x6F46,0x6F47,0x6F24,0x6F15,0x6EF9,/* 0xE8-0xEF */ 0x6F2F,0x6F36,0x6F4B,0x6F74,0x6F2A,0x6F09,0x6F29,0x6F89,/* 0xF0-0xF7 */ 0x6F8D,0x6F8C,0x6F78,0x6F72,0x6F7C,0x6F7A,0x6FD1,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_E5[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x930A,0x930B,0x930C,0x930D,0x930E,0x930F,0x9310,0x9311,/* 0x40-0x47 */ 0x9312,0x9313,0x9314,0x9315,0x9316,0x9317,0x9318,0x9319,/* 0x48-0x4F */ 0x931A,0x931B,0x931C,0x931D,0x931E,0x931F,0x9320,0x9321,/* 0x50-0x57 */ 0x9322,0x9323,0x9324,0x9325,0x9326,0x9327,0x9328,0x9329,/* 0x58-0x5F */ 0x932A,0x932B,0x932C,0x932D,0x932E,0x932F,0x9330,0x9331,/* 0x60-0x67 */ 0x9332,0x9333,0x9334,0x9335,0x9336,0x9337,0x9338,0x9339,/* 0x68-0x6F */ 0x933A,0x933B,0x933C,0x933D,0x933F,0x9340,0x9341,0x9342,/* 0x70-0x77 */ 0x9343,0x9344,0x9345,0x9346,0x9347,0x9348,0x9349,0x0000,/* 0x78-0x7F */ 0x934A,0x934B,0x934C,0x934D,0x934E,0x934F,0x9350,0x9351,/* 0x80-0x87 */ 0x9352,0x9353,0x9354,0x9355,0x9356,0x9357,0x9358,0x9359,/* 0x88-0x8F */ 0x935A,0x935B,0x935C,0x935D,0x935E,0x935F,0x9360,0x9361,/* 0x90-0x97 */ 0x9362,0x9363,0x9364,0x9365,0x9366,0x9367,0x9368,0x9369,/* 0x98-0x9F */ 0x936B,0x6FC9,0x6FA7,0x6FB9,0x6FB6,0x6FC2,0x6FE1,0x6FEE,/* 0xA0-0xA7 */ 0x6FDE,0x6FE0,0x6FEF,0x701A,0x7023,0x701B,0x7039,0x7035,/* 0xA8-0xAF */ 0x704F,0x705E,0x5B80,0x5B84,0x5B95,0x5B93,0x5BA5,0x5BB8,/* 0xB0-0xB7 */ 0x752F,0x9A9E,0x6434,0x5BE4,0x5BEE,0x8930,0x5BF0,0x8E47,/* 0xB8-0xBF */ 0x8B07,0x8FB6,0x8FD3,0x8FD5,0x8FE5,0x8FEE,0x8FE4,0x8FE9,/* 0xC0-0xC7 */ 0x8FE6,0x8FF3,0x8FE8,0x9005,0x9004,0x900B,0x9026,0x9011,/* 0xC8-0xCF */ 0x900D,0x9016,0x9021,0x9035,0x9036,0x902D,0x902F,0x9044,/* 0xD0-0xD7 */ 0x9051,0x9052,0x9050,0x9068,0x9058,0x9062,0x905B,0x66B9,/* 0xD8-0xDF */ 0x9074,0x907D,0x9082,0x9088,0x9083,0x908B,0x5F50,0x5F57,/* 0xE0-0xE7 */ 0x5F56,0x5F58,0x5C3B,0x54AB,0x5C50,0x5C59,0x5B71,0x5C63,/* 0xE8-0xEF */ 0x5C66,0x7FBC,0x5F2A,0x5F29,0x5F2D,0x8274,0x5F3C,0x9B3B,/* 0xF0-0xF7 */ 0x5C6E,0x5981,0x5983,0x598D,0x59A9,0x59AA,0x59A3,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_E6[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x936C,0x936D,0x936E,0x936F,0x9370,0x9371,0x9372,0x9373,/* 0x40-0x47 */ 0x9374,0x9375,0x9376,0x9377,0x9378,0x9379,0x937A,0x937B,/* 0x48-0x4F */ 0x937C,0x937D,0x937E,0x937F,0x9380,0x9381,0x9382,0x9383,/* 0x50-0x57 */ 0x9384,0x9385,0x9386,0x9387,0x9388,0x9389,0x938A,0x938B,/* 0x58-0x5F */ 0x938C,0x938D,0x938E,0x9390,0x9391,0x9392,0x9393,0x9394,/* 0x60-0x67 */ 0x9395,0x9396,0x9397,0x9398,0x9399,0x939A,0x939B,0x939C,/* 0x68-0x6F */ 0x939D,0x939E,0x939F,0x93A0,0x93A1,0x93A2,0x93A3,0x93A4,/* 0x70-0x77 */ 0x93A5,0x93A6,0x93A7,0x93A8,0x93A9,0x93AA,0x93AB,0x0000,/* 0x78-0x7F */ 0x93AC,0x93AD,0x93AE,0x93AF,0x93B0,0x93B1,0x93B2,0x93B3,/* 0x80-0x87 */ 0x93B4,0x93B5,0x93B6,0x93B7,0x93B8,0x93B9,0x93BA,0x93BB,/* 0x88-0x8F */ 0x93BC,0x93BD,0x93BE,0x93BF,0x93C0,0x93C1,0x93C2,0x93C3,/* 0x90-0x97 */ 0x93C4,0x93C5,0x93C6,0x93C7,0x93C8,0x93C9,0x93CB,0x93CC,/* 0x98-0x9F */ 0x93CD,0x5997,0x59CA,0x59AB,0x599E,0x59A4,0x59D2,0x59B2,/* 0xA0-0xA7 */ 0x59AF,0x59D7,0x59BE,0x5A05,0x5A06,0x59DD,0x5A08,0x59E3,/* 0xA8-0xAF */ 0x59D8,0x59F9,0x5A0C,0x5A09,0x5A32,0x5A34,0x5A11,0x5A23,/* 0xB0-0xB7 */ 0x5A13,0x5A40,0x5A67,0x5A4A,0x5A55,0x5A3C,0x5A62,0x5A75,/* 0xB8-0xBF */ 0x80EC,0x5AAA,0x5A9B,0x5A77,0x5A7A,0x5ABE,0x5AEB,0x5AB2,/* 0xC0-0xC7 */ 0x5AD2,0x5AD4,0x5AB8,0x5AE0,0x5AE3,0x5AF1,0x5AD6,0x5AE6,/* 0xC8-0xCF */ 0x5AD8,0x5ADC,0x5B09,0x5B17,0x5B16,0x5B32,0x5B37,0x5B40,/* 0xD0-0xD7 */ 0x5C15,0x5C1C,0x5B5A,0x5B65,0x5B73,0x5B51,0x5B53,0x5B62,/* 0xD8-0xDF */ 0x9A75,0x9A77,0x9A78,0x9A7A,0x9A7F,0x9A7D,0x9A80,0x9A81,/* 0xE0-0xE7 */ 0x9A85,0x9A88,0x9A8A,0x9A90,0x9A92,0x9A93,0x9A96,0x9A98,/* 0xE8-0xEF */ 0x9A9B,0x9A9C,0x9A9D,0x9A9F,0x9AA0,0x9AA2,0x9AA3,0x9AA5,/* 0xF0-0xF7 */ 0x9AA7,0x7E9F,0x7EA1,0x7EA3,0x7EA5,0x7EA8,0x7EA9,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_E7[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x93CE,0x93CF,0x93D0,0x93D1,0x93D2,0x93D3,0x93D4,0x93D5,/* 0x40-0x47 */ 0x93D7,0x93D8,0x93D9,0x93DA,0x93DB,0x93DC,0x93DD,0x93DE,/* 0x48-0x4F */ 0x93DF,0x93E0,0x93E1,0x93E2,0x93E3,0x93E4,0x93E5,0x93E6,/* 0x50-0x57 */ 0x93E7,0x93E8,0x93E9,0x93EA,0x93EB,0x93EC,0x93ED,0x93EE,/* 0x58-0x5F */ 0x93EF,0x93F0,0x93F1,0x93F2,0x93F3,0x93F4,0x93F5,0x93F6,/* 0x60-0x67 */ 0x93F7,0x93F8,0x93F9,0x93FA,0x93FB,0x93FC,0x93FD,0x93FE,/* 0x68-0x6F */ 0x93FF,0x9400,0x9401,0x9402,0x9403,0x9404,0x9405,0x9406,/* 0x70-0x77 */ 0x9407,0x9408,0x9409,0x940A,0x940B,0x940C,0x940D,0x0000,/* 0x78-0x7F */ 0x940E,0x940F,0x9410,0x9411,0x9412,0x9413,0x9414,0x9415,/* 0x80-0x87 */ 0x9416,0x9417,0x9418,0x9419,0x941A,0x941B,0x941C,0x941D,/* 0x88-0x8F */ 0x941E,0x941F,0x9420,0x9421,0x9422,0x9423,0x9424,0x9425,/* 0x90-0x97 */ 0x9426,0x9427,0x9428,0x9429,0x942A,0x942B,0x942C,0x942D,/* 0x98-0x9F */ 0x942E,0x7EAD,0x7EB0,0x7EBE,0x7EC0,0x7EC1,0x7EC2,0x7EC9,/* 0xA0-0xA7 */ 0x7ECB,0x7ECC,0x7ED0,0x7ED4,0x7ED7,0x7EDB,0x7EE0,0x7EE1,/* 0xA8-0xAF */ 0x7EE8,0x7EEB,0x7EEE,0x7EEF,0x7EF1,0x7EF2,0x7F0D,0x7EF6,/* 0xB0-0xB7 */ 0x7EFA,0x7EFB,0x7EFE,0x7F01,0x7F02,0x7F03,0x7F07,0x7F08,/* 0xB8-0xBF */ 0x7F0B,0x7F0C,0x7F0F,0x7F11,0x7F12,0x7F17,0x7F19,0x7F1C,/* 0xC0-0xC7 */ 0x7F1B,0x7F1F,0x7F21,0x7F22,0x7F23,0x7F24,0x7F25,0x7F26,/* 0xC8-0xCF */ 0x7F27,0x7F2A,0x7F2B,0x7F2C,0x7F2D,0x7F2F,0x7F30,0x7F31,/* 0xD0-0xD7 */ 0x7F32,0x7F33,0x7F35,0x5E7A,0x757F,0x5DDB,0x753E,0x9095,/* 0xD8-0xDF */ 0x738E,0x7391,0x73AE,0x73A2,0x739F,0x73CF,0x73C2,0x73D1,/* 0xE0-0xE7 */ 0x73B7,0x73B3,0x73C0,0x73C9,0x73C8,0x73E5,0x73D9,0x987C,/* 0xE8-0xEF */ 0x740A,0x73E9,0x73E7,0x73DE,0x73BA,0x73F2,0x740F,0x742A,/* 0xF0-0xF7 */ 0x745B,0x7426,0x7425,0x7428,0x7430,0x742E,0x742C,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_E8[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x942F,0x9430,0x9431,0x9432,0x9433,0x9434,0x9435,0x9436,/* 0x40-0x47 */ 0x9437,0x9438,0x9439,0x943A,0x943B,0x943C,0x943D,0x943F,/* 0x48-0x4F */ 0x9440,0x9441,0x9442,0x9443,0x9444,0x9445,0x9446,0x9447,/* 0x50-0x57 */ 0x9448,0x9449,0x944A,0x944B,0x944C,0x944D,0x944E,0x944F,/* 0x58-0x5F */ 0x9450,0x9451,0x9452,0x9453,0x9454,0x9455,0x9456,0x9457,/* 0x60-0x67 */ 0x9458,0x9459,0x945A,0x945B,0x945C,0x945D,0x945E,0x945F,/* 0x68-0x6F */ 0x9460,0x9461,0x9462,0x9463,0x9464,0x9465,0x9466,0x9467,/* 0x70-0x77 */ 0x9468,0x9469,0x946A,0x946C,0x946D,0x946E,0x946F,0x0000,/* 0x78-0x7F */ 0x9470,0x9471,0x9472,0x9473,0x9474,0x9475,0x9476,0x9477,/* 0x80-0x87 */ 0x9478,0x9479,0x947A,0x947B,0x947C,0x947D,0x947E,0x947F,/* 0x88-0x8F */ 0x9480,0x9481,0x9482,0x9483,0x9484,0x9491,0x9496,0x9498,/* 0x90-0x97 */ 0x94C7,0x94CF,0x94D3,0x94D4,0x94DA,0x94E6,0x94FB,0x951C,/* 0x98-0x9F */ 0x9520,0x741B,0x741A,0x7441,0x745C,0x7457,0x7455,0x7459,/* 0xA0-0xA7 */ 0x7477,0x746D,0x747E,0x749C,0x748E,0x7480,0x7481,0x7487,/* 0xA8-0xAF */ 0x748B,0x749E,0x74A8,0x74A9,0x7490,0x74A7,0x74D2,0x74BA,/* 0xB0-0xB7 */ 0x97EA,0x97EB,0x97EC,0x674C,0x6753,0x675E,0x6748,0x6769,/* 0xB8-0xBF */ 0x67A5,0x6787,0x676A,0x6773,0x6798,0x67A7,0x6775,0x67A8,/* 0xC0-0xC7 */ 0x679E,0x67AD,0x678B,0x6777,0x677C,0x67F0,0x6809,0x67D8,/* 0xC8-0xCF */ 0x680A,0x67E9,0x67B0,0x680C,0x67D9,0x67B5,0x67DA,0x67B3,/* 0xD0-0xD7 */ 0x67DD,0x6800,0x67C3,0x67B8,0x67E2,0x680E,0x67C1,0x67FD,/* 0xD8-0xDF */ 0x6832,0x6833,0x6860,0x6861,0x684E,0x6862,0x6844,0x6864,/* 0xE0-0xE7 */ 0x6883,0x681D,0x6855,0x6866,0x6841,0x6867,0x6840,0x683E,/* 0xE8-0xEF */ 0x684A,0x6849,0x6829,0x68B5,0x688F,0x6874,0x6877,0x6893,/* 0xF0-0xF7 */ 0x686B,0x68C2,0x696E,0x68FC,0x691F,0x6920,0x68F9,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_E9[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9527,0x9533,0x953D,0x9543,0x9548,0x954B,0x9555,0x955A,/* 0x40-0x47 */ 0x9560,0x956E,0x9574,0x9575,0x9577,0x9578,0x9579,0x957A,/* 0x48-0x4F */ 0x957B,0x957C,0x957D,0x957E,0x9580,0x9581,0x9582,0x9583,/* 0x50-0x57 */ 0x9584,0x9585,0x9586,0x9587,0x9588,0x9589,0x958A,0x958B,/* 0x58-0x5F */ 0x958C,0x958D,0x958E,0x958F,0x9590,0x9591,0x9592,0x9593,/* 0x60-0x67 */ 0x9594,0x9595,0x9596,0x9597,0x9598,0x9599,0x959A,0x959B,/* 0x68-0x6F */ 0x959C,0x959D,0x959E,0x959F,0x95A0,0x95A1,0x95A2,0x95A3,/* 0x70-0x77 */ 0x95A4,0x95A5,0x95A6,0x95A7,0x95A8,0x95A9,0x95AA,0x0000,/* 0x78-0x7F */ 0x95AB,0x95AC,0x95AD,0x95AE,0x95AF,0x95B0,0x95B1,0x95B2,/* 0x80-0x87 */ 0x95B3,0x95B4,0x95B5,0x95B6,0x95B7,0x95B8,0x95B9,0x95BA,/* 0x88-0x8F */ 0x95BB,0x95BC,0x95BD,0x95BE,0x95BF,0x95C0,0x95C1,0x95C2,/* 0x90-0x97 */ 0x95C3,0x95C4,0x95C5,0x95C6,0x95C7,0x95C8,0x95C9,0x95CA,/* 0x98-0x9F */ 0x95CB,0x6924,0x68F0,0x690B,0x6901,0x6957,0x68E3,0x6910,/* 0xA0-0xA7 */ 0x6971,0x6939,0x6960,0x6942,0x695D,0x6984,0x696B,0x6980,/* 0xA8-0xAF */ 0x6998,0x6978,0x6934,0x69CC,0x6987,0x6988,0x69CE,0x6989,/* 0xB0-0xB7 */ 0x6966,0x6963,0x6979,0x699B,0x69A7,0x69BB,0x69AB,0x69AD,/* 0xB8-0xBF */ 0x69D4,0x69B1,0x69C1,0x69CA,0x69DF,0x6995,0x69E0,0x698D,/* 0xC0-0xC7 */ 0x69FF,0x6A2F,0x69ED,0x6A17,0x6A18,0x6A65,0x69F2,0x6A44,/* 0xC8-0xCF */ 0x6A3E,0x6AA0,0x6A50,0x6A5B,0x6A35,0x6A8E,0x6A79,0x6A3D,/* 0xD0-0xD7 */ 0x6A28,0x6A58,0x6A7C,0x6A91,0x6A90,0x6AA9,0x6A97,0x6AAB,/* 0xD8-0xDF */ 0x7337,0x7352,0x6B81,0x6B82,0x6B87,0x6B84,0x6B92,0x6B93,/* 0xE0-0xE7 */ 0x6B8D,0x6B9A,0x6B9B,0x6BA1,0x6BAA,0x8F6B,0x8F6D,0x8F71,/* 0xE8-0xEF */ 0x8F72,0x8F73,0x8F75,0x8F76,0x8F78,0x8F77,0x8F79,0x8F7A,/* 0xF0-0xF7 */ 0x8F7C,0x8F7E,0x8F81,0x8F82,0x8F84,0x8F87,0x8F8B,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_EA[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x95CC,0x95CD,0x95CE,0x95CF,0x95D0,0x95D1,0x95D2,0x95D3,/* 0x40-0x47 */ 0x95D4,0x95D5,0x95D6,0x95D7,0x95D8,0x95D9,0x95DA,0x95DB,/* 0x48-0x4F */ 0x95DC,0x95DD,0x95DE,0x95DF,0x95E0,0x95E1,0x95E2,0x95E3,/* 0x50-0x57 */ 0x95E4,0x95E5,0x95E6,0x95E7,0x95EC,0x95FF,0x9607,0x9613,/* 0x58-0x5F */ 0x9618,0x961B,0x961E,0x9620,0x9623,0x9624,0x9625,0x9626,/* 0x60-0x67 */ 0x9627,0x9628,0x9629,0x962B,0x962C,0x962D,0x962F,0x9630,/* 0x68-0x6F */ 0x9637,0x9638,0x9639,0x963A,0x963E,0x9641,0x9643,0x964A,/* 0x70-0x77 */ 0x964E,0x964F,0x9651,0x9652,0x9653,0x9656,0x9657,0x0000,/* 0x78-0x7F */ 0x9658,0x9659,0x965A,0x965C,0x965D,0x965E,0x9660,0x9663,/* 0x80-0x87 */ 0x9665,0x9666,0x966B,0x966D,0x966E,0x966F,0x9670,0x9671,/* 0x88-0x8F */ 0x9673,0x9678,0x9679,0x967A,0x967B,0x967C,0x967D,0x967E,/* 0x90-0x97 */ 0x967F,0x9680,0x9681,0x9682,0x9683,0x9684,0x9687,0x9689,/* 0x98-0x9F */ 0x968A,0x8F8D,0x8F8E,0x8F8F,0x8F98,0x8F9A,0x8ECE,0x620B,/* 0xA0-0xA7 */ 0x6217,0x621B,0x621F,0x6222,0x6221,0x6225,0x6224,0x622C,/* 0xA8-0xAF */ 0x81E7,0x74EF,0x74F4,0x74FF,0x750F,0x7511,0x7513,0x6534,/* 0xB0-0xB7 */ 0x65EE,0x65EF,0x65F0,0x660A,0x6619,0x6772,0x6603,0x6615,/* 0xB8-0xBF */ 0x6600,0x7085,0x66F7,0x661D,0x6634,0x6631,0x6636,0x6635,/* 0xC0-0xC7 */ 0x8006,0x665F,0x6654,0x6641,0x664F,0x6656,0x6661,0x6657,/* 0xC8-0xCF */ 0x6677,0x6684,0x668C,0x66A7,0x669D,0x66BE,0x66DB,0x66DC,/* 0xD0-0xD7 */ 0x66E6,0x66E9,0x8D32,0x8D33,0x8D36,0x8D3B,0x8D3D,0x8D40,/* 0xD8-0xDF */ 0x8D45,0x8D46,0x8D48,0x8D49,0x8D47,0x8D4D,0x8D55,0x8D59,/* 0xE0-0xE7 */ 0x89C7,0x89CA,0x89CB,0x89CC,0x89CE,0x89CF,0x89D0,0x89D1,/* 0xE8-0xEF */ 0x726E,0x729F,0x725D,0x7266,0x726F,0x727E,0x727F,0x7284,/* 0xF0-0xF7 */ 0x728B,0x728D,0x728F,0x7292,0x6308,0x6332,0x63B0,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_EB[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x968C,0x968E,0x9691,0x9692,0x9693,0x9695,0x9696,0x969A,/* 0x40-0x47 */ 0x969B,0x969D,0x969E,0x969F,0x96A0,0x96A1,0x96A2,0x96A3,/* 0x48-0x4F */ 0x96A4,0x96A5,0x96A6,0x96A8,0x96A9,0x96AA,0x96AB,0x96AC,/* 0x50-0x57 */ 0x96AD,0x96AE,0x96AF,0x96B1,0x96B2,0x96B4,0x96B5,0x96B7,/* 0x58-0x5F */ 0x96B8,0x96BA,0x96BB,0x96BF,0x96C2,0x96C3,0x96C8,0x96CA,/* 0x60-0x67 */ 0x96CB,0x96D0,0x96D1,0x96D3,0x96D4,0x96D6,0x96D7,0x96D8,/* 0x68-0x6F */ 0x96D9,0x96DA,0x96DB,0x96DC,0x96DD,0x96DE,0x96DF,0x96E1,/* 0x70-0x77 */ 0x96E2,0x96E3,0x96E4,0x96E5,0x96E6,0x96E7,0x96EB,0x0000,/* 0x78-0x7F */ 0x96EC,0x96ED,0x96EE,0x96F0,0x96F1,0x96F2,0x96F4,0x96F5,/* 0x80-0x87 */ 0x96F8,0x96FA,0x96FB,0x96FC,0x96FD,0x96FF,0x9702,0x9703,/* 0x88-0x8F */ 0x9705,0x970A,0x970B,0x970C,0x9710,0x9711,0x9712,0x9714,/* 0x90-0x97 */ 0x9715,0x9717,0x9718,0x9719,0x971A,0x971B,0x971D,0x971F,/* 0x98-0x9F */ 0x9720,0x643F,0x64D8,0x8004,0x6BEA,0x6BF3,0x6BFD,0x6BF5,/* 0xA0-0xA7 */ 0x6BF9,0x6C05,0x6C07,0x6C06,0x6C0D,0x6C15,0x6C18,0x6C19,/* 0xA8-0xAF */ 0x6C1A,0x6C21,0x6C29,0x6C24,0x6C2A,0x6C32,0x6535,0x6555,/* 0xB0-0xB7 */ 0x656B,0x724D,0x7252,0x7256,0x7230,0x8662,0x5216,0x809F,/* 0xB8-0xBF */ 0x809C,0x8093,0x80BC,0x670A,0x80BD,0x80B1,0x80AB,0x80AD,/* 0xC0-0xC7 */ 0x80B4,0x80B7,0x80E7,0x80E8,0x80E9,0x80EA,0x80DB,0x80C2,/* 0xC8-0xCF */ 0x80C4,0x80D9,0x80CD,0x80D7,0x6710,0x80DD,0x80EB,0x80F1,/* 0xD0-0xD7 */ 0x80F4,0x80ED,0x810D,0x810E,0x80F2,0x80FC,0x6715,0x8112,/* 0xD8-0xDF */ 0x8C5A,0x8136,0x811E,0x812C,0x8118,0x8132,0x8148,0x814C,/* 0xE0-0xE7 */ 0x8153,0x8174,0x8159,0x815A,0x8171,0x8160,0x8169,0x817C,/* 0xE8-0xEF */ 0x817D,0x816D,0x8167,0x584D,0x5AB5,0x8188,0x8182,0x8191,/* 0xF0-0xF7 */ 0x6ED5,0x81A3,0x81AA,0x81CC,0x6726,0x81CA,0x81BB,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_EC[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9721,0x9722,0x9723,0x9724,0x9725,0x9726,0x9727,0x9728,/* 0x40-0x47 */ 0x9729,0x972B,0x972C,0x972E,0x972F,0x9731,0x9733,0x9734,/* 0x48-0x4F */ 0x9735,0x9736,0x9737,0x973A,0x973B,0x973C,0x973D,0x973F,/* 0x50-0x57 */ 0x9740,0x9741,0x9742,0x9743,0x9744,0x9745,0x9746,0x9747,/* 0x58-0x5F */ 0x9748,0x9749,0x974A,0x974B,0x974C,0x974D,0x974E,0x974F,/* 0x60-0x67 */ 0x9750,0x9751,0x9754,0x9755,0x9757,0x9758,0x975A,0x975C,/* 0x68-0x6F */ 0x975D,0x975F,0x9763,0x9764,0x9766,0x9767,0x9768,0x976A,/* 0x70-0x77 */ 0x976B,0x976C,0x976D,0x976E,0x976F,0x9770,0x9771,0x0000,/* 0x78-0x7F */ 0x9772,0x9775,0x9777,0x9778,0x9779,0x977A,0x977B,0x977D,/* 0x80-0x87 */ 0x977E,0x977F,0x9780,0x9781,0x9782,0x9783,0x9784,0x9786,/* 0x88-0x8F */ 0x9787,0x9788,0x9789,0x978A,0x978C,0x978E,0x978F,0x9790,/* 0x90-0x97 */ 0x9793,0x9795,0x9796,0x9797,0x9799,0x979A,0x979B,0x979C,/* 0x98-0x9F */ 0x979D,0x81C1,0x81A6,0x6B24,0x6B37,0x6B39,0x6B43,0x6B46,/* 0xA0-0xA7 */ 0x6B59,0x98D1,0x98D2,0x98D3,0x98D5,0x98D9,0x98DA,0x6BB3,/* 0xA8-0xAF */ 0x5F40,0x6BC2,0x89F3,0x6590,0x9F51,0x6593,0x65BC,0x65C6,/* 0xB0-0xB7 */ 0x65C4,0x65C3,0x65CC,0x65CE,0x65D2,0x65D6,0x7080,0x709C,/* 0xB8-0xBF */ 0x7096,0x709D,0x70BB,0x70C0,0x70B7,0x70AB,0x70B1,0x70E8,/* 0xC0-0xC7 */ 0x70CA,0x7110,0x7113,0x7116,0x712F,0x7131,0x7173,0x715C,/* 0xC8-0xCF */ 0x7168,0x7145,0x7172,0x714A,0x7178,0x717A,0x7198,0x71B3,/* 0xD0-0xD7 */ 0x71B5,0x71A8,0x71A0,0x71E0,0x71D4,0x71E7,0x71F9,0x721D,/* 0xD8-0xDF */ 0x7228,0x706C,0x7118,0x7166,0x71B9,0x623E,0x623D,0x6243,/* 0xE0-0xE7 */ 0x6248,0x6249,0x793B,0x7940,0x7946,0x7949,0x795B,0x795C,/* 0xE8-0xEF */ 0x7953,0x795A,0x7962,0x7957,0x7960,0x796F,0x7967,0x797A,/* 0xF0-0xF7 */ 0x7985,0x798A,0x799A,0x79A7,0x79B3,0x5FD1,0x5FD0,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_ED[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x979E,0x979F,0x97A1,0x97A2,0x97A4,0x97A5,0x97A6,0x97A7,/* 0x40-0x47 */ 0x97A8,0x97A9,0x97AA,0x97AC,0x97AE,0x97B0,0x97B1,0x97B3,/* 0x48-0x4F */ 0x97B5,0x97B6,0x97B7,0x97B8,0x97B9,0x97BA,0x97BB,0x97BC,/* 0x50-0x57 */ 0x97BD,0x97BE,0x97BF,0x97C0,0x97C1,0x97C2,0x97C3,0x97C4,/* 0x58-0x5F */ 0x97C5,0x97C6,0x97C7,0x97C8,0x97C9,0x97CA,0x97CB,0x97CC,/* 0x60-0x67 */ 0x97CD,0x97CE,0x97CF,0x97D0,0x97D1,0x97D2,0x97D3,0x97D4,/* 0x68-0x6F */ 0x97D5,0x97D6,0x97D7,0x97D8,0x97D9,0x97DA,0x97DB,0x97DC,/* 0x70-0x77 */ 0x97DD,0x97DE,0x97DF,0x97E0,0x97E1,0x97E2,0x97E3,0x0000,/* 0x78-0x7F */ 0x97E4,0x97E5,0x97E8,0x97EE,0x97EF,0x97F0,0x97F1,0x97F2,/* 0x80-0x87 */ 0x97F4,0x97F7,0x97F8,0x97F9,0x97FA,0x97FB,0x97FC,0x97FD,/* 0x88-0x8F */ 0x97FE,0x97FF,0x9800,0x9801,0x9802,0x9803,0x9804,0x9805,/* 0x90-0x97 */ 0x9806,0x9807,0x9808,0x9809,0x980A,0x980B,0x980C,0x980D,/* 0x98-0x9F */ 0x980E,0x603C,0x605D,0x605A,0x6067,0x6041,0x6059,0x6063,/* 0xA0-0xA7 */ 0x60AB,0x6106,0x610D,0x615D,0x61A9,0x619D,0x61CB,0x61D1,/* 0xA8-0xAF */ 0x6206,0x8080,0x807F,0x6C93,0x6CF6,0x6DFC,0x77F6,0x77F8,/* 0xB0-0xB7 */ 0x7800,0x7809,0x7817,0x7818,0x7811,0x65AB,0x782D,0x781C,/* 0xB8-0xBF */ 0x781D,0x7839,0x783A,0x783B,0x781F,0x783C,0x7825,0x782C,/* 0xC0-0xC7 */ 0x7823,0x7829,0x784E,0x786D,0x7856,0x7857,0x7826,0x7850,/* 0xC8-0xCF */ 0x7847,0x784C,0x786A,0x789B,0x7893,0x789A,0x7887,0x789C,/* 0xD0-0xD7 */ 0x78A1,0x78A3,0x78B2,0x78B9,0x78A5,0x78D4,0x78D9,0x78C9,/* 0xD8-0xDF */ 0x78EC,0x78F2,0x7905,0x78F4,0x7913,0x7924,0x791E,0x7934,/* 0xE0-0xE7 */ 0x9F9B,0x9EF9,0x9EFB,0x9EFC,0x76F1,0x7704,0x770D,0x76F9,/* 0xE8-0xEF */ 0x7707,0x7708,0x771A,0x7722,0x7719,0x772D,0x7726,0x7735,/* 0xF0-0xF7 */ 0x7738,0x7750,0x7751,0x7747,0x7743,0x775A,0x7768,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_EE[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x980F,0x9810,0x9811,0x9812,0x9813,0x9814,0x9815,0x9816,/* 0x40-0x47 */ 0x9817,0x9818,0x9819,0x981A,0x981B,0x981C,0x981D,0x981E,/* 0x48-0x4F */ 0x981F,0x9820,0x9821,0x9822,0x9823,0x9824,0x9825,0x9826,/* 0x50-0x57 */ 0x9827,0x9828,0x9829,0x982A,0x982B,0x982C,0x982D,0x982E,/* 0x58-0x5F */ 0x982F,0x9830,0x9831,0x9832,0x9833,0x9834,0x9835,0x9836,/* 0x60-0x67 */ 0x9837,0x9838,0x9839,0x983A,0x983B,0x983C,0x983D,0x983E,/* 0x68-0x6F */ 0x983F,0x9840,0x9841,0x9842,0x9843,0x9844,0x9845,0x9846,/* 0x70-0x77 */ 0x9847,0x9848,0x9849,0x984A,0x984B,0x984C,0x984D,0x0000,/* 0x78-0x7F */ 0x984E,0x984F,0x9850,0x9851,0x9852,0x9853,0x9854,0x9855,/* 0x80-0x87 */ 0x9856,0x9857,0x9858,0x9859,0x985A,0x985B,0x985C,0x985D,/* 0x88-0x8F */ 0x985E,0x985F,0x9860,0x9861,0x9862,0x9863,0x9864,0x9865,/* 0x90-0x97 */ 0x9866,0x9867,0x9868,0x9869,0x986A,0x986B,0x986C,0x986D,/* 0x98-0x9F */ 0x986E,0x7762,0x7765,0x777F,0x778D,0x777D,0x7780,0x778C,/* 0xA0-0xA7 */ 0x7791,0x779F,0x77A0,0x77B0,0x77B5,0x77BD,0x753A,0x7540,/* 0xA8-0xAF */ 0x754E,0x754B,0x7548,0x755B,0x7572,0x7579,0x7583,0x7F58,/* 0xB0-0xB7 */ 0x7F61,0x7F5F,0x8A48,0x7F68,0x7F74,0x7F71,0x7F79,0x7F81,/* 0xB8-0xBF */ 0x7F7E,0x76CD,0x76E5,0x8832,0x9485,0x9486,0x9487,0x948B,/* 0xC0-0xC7 */ 0x948A,0x948C,0x948D,0x948F,0x9490,0x9494,0x9497,0x9495,/* 0xC8-0xCF */ 0x949A,0x949B,0x949C,0x94A3,0x94A4,0x94AB,0x94AA,0x94AD,/* 0xD0-0xD7 */ 0x94AC,0x94AF,0x94B0,0x94B2,0x94B4,0x94B6,0x94B7,0x94B8,/* 0xD8-0xDF */ 0x94B9,0x94BA,0x94BC,0x94BD,0x94BF,0x94C4,0x94C8,0x94C9,/* 0xE0-0xE7 */ 0x94CA,0x94CB,0x94CC,0x94CD,0x94CE,0x94D0,0x94D1,0x94D2,/* 0xE8-0xEF */ 0x94D5,0x94D6,0x94D7,0x94D9,0x94D8,0x94DB,0x94DE,0x94DF,/* 0xF0-0xF7 */ 0x94E0,0x94E2,0x94E4,0x94E5,0x94E7,0x94E8,0x94EA,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_EF[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x986F,0x9870,0x9871,0x9872,0x9873,0x9874,0x988B,0x988E,/* 0x40-0x47 */ 0x9892,0x9895,0x9899,0x98A3,0x98A8,0x98A9,0x98AA,0x98AB,/* 0x48-0x4F */ 0x98AC,0x98AD,0x98AE,0x98AF,0x98B0,0x98B1,0x98B2,0x98B3,/* 0x50-0x57 */ 0x98B4,0x98B5,0x98B6,0x98B7,0x98B8,0x98B9,0x98BA,0x98BB,/* 0x58-0x5F */ 0x98BC,0x98BD,0x98BE,0x98BF,0x98C0,0x98C1,0x98C2,0x98C3,/* 0x60-0x67 */ 0x98C4,0x98C5,0x98C6,0x98C7,0x98C8,0x98C9,0x98CA,0x98CB,/* 0x68-0x6F */ 0x98CC,0x98CD,0x98CF,0x98D0,0x98D4,0x98D6,0x98D7,0x98DB,/* 0x70-0x77 */ 0x98DC,0x98DD,0x98E0,0x98E1,0x98E2,0x98E3,0x98E4,0x0000,/* 0x78-0x7F */ 0x98E5,0x98E6,0x98E9,0x98EA,0x98EB,0x98EC,0x98ED,0x98EE,/* 0x80-0x87 */ 0x98EF,0x98F0,0x98F1,0x98F2,0x98F3,0x98F4,0x98F5,0x98F6,/* 0x88-0x8F */ 0x98F7,0x98F8,0x98F9,0x98FA,0x98FB,0x98FC,0x98FD,0x98FE,/* 0x90-0x97 */ 0x98FF,0x9900,0x9901,0x9902,0x9903,0x9904,0x9905,0x9906,/* 0x98-0x9F */ 0x9907,0x94E9,0x94EB,0x94EE,0x94EF,0x94F3,0x94F4,0x94F5,/* 0xA0-0xA7 */ 0x94F7,0x94F9,0x94FC,0x94FD,0x94FF,0x9503,0x9502,0x9506,/* 0xA8-0xAF */ 0x9507,0x9509,0x950A,0x950D,0x950E,0x950F,0x9512,0x9513,/* 0xB0-0xB7 */ 0x9514,0x9515,0x9516,0x9518,0x951B,0x951D,0x951E,0x951F,/* 0xB8-0xBF */ 0x9522,0x952A,0x952B,0x9529,0x952C,0x9531,0x9532,0x9534,/* 0xC0-0xC7 */ 0x9536,0x9537,0x9538,0x953C,0x953E,0x953F,0x9542,0x9535,/* 0xC8-0xCF */ 0x9544,0x9545,0x9546,0x9549,0x954C,0x954E,0x954F,0x9552,/* 0xD0-0xD7 */ 0x9553,0x9554,0x9556,0x9557,0x9558,0x9559,0x955B,0x955E,/* 0xD8-0xDF */ 0x955F,0x955D,0x9561,0x9562,0x9564,0x9565,0x9566,0x9567,/* 0xE0-0xE7 */ 0x9568,0x9569,0x956A,0x956B,0x956C,0x956F,0x9571,0x9572,/* 0xE8-0xEF */ 0x9573,0x953A,0x77E7,0x77EC,0x96C9,0x79D5,0x79ED,0x79E3,/* 0xF0-0xF7 */ 0x79EB,0x7A06,0x5D47,0x7A03,0x7A02,0x7A1E,0x7A14,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_F0[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9908,0x9909,0x990A,0x990B,0x990C,0x990E,0x990F,0x9911,/* 0x40-0x47 */ 0x9912,0x9913,0x9914,0x9915,0x9916,0x9917,0x9918,0x9919,/* 0x48-0x4F */ 0x991A,0x991B,0x991C,0x991D,0x991E,0x991F,0x9920,0x9921,/* 0x50-0x57 */ 0x9922,0x9923,0x9924,0x9925,0x9926,0x9927,0x9928,0x9929,/* 0x58-0x5F */ 0x992A,0x992B,0x992C,0x992D,0x992F,0x9930,0x9931,0x9932,/* 0x60-0x67 */ 0x9933,0x9934,0x9935,0x9936,0x9937,0x9938,0x9939,0x993A,/* 0x68-0x6F */ 0x993B,0x993C,0x993D,0x993E,0x993F,0x9940,0x9941,0x9942,/* 0x70-0x77 */ 0x9943,0x9944,0x9945,0x9946,0x9947,0x9948,0x9949,0x0000,/* 0x78-0x7F */ 0x994A,0x994B,0x994C,0x994D,0x994E,0x994F,0x9950,0x9951,/* 0x80-0x87 */ 0x9952,0x9953,0x9956,0x9957,0x9958,0x9959,0x995A,0x995B,/* 0x88-0x8F */ 0x995C,0x995D,0x995E,0x995F,0x9960,0x9961,0x9962,0x9964,/* 0x90-0x97 */ 0x9966,0x9973,0x9978,0x9979,0x997B,0x997E,0x9982,0x9983,/* 0x98-0x9F */ 0x9989,0x7A39,0x7A37,0x7A51,0x9ECF,0x99A5,0x7A70,0x7688,/* 0xA0-0xA7 */ 0x768E,0x7693,0x7699,0x76A4,0x74DE,0x74E0,0x752C,0x9E20,/* 0xA8-0xAF */ 0x9E22,0x9E28,0x9E29,0x9E2A,0x9E2B,0x9E2C,0x9E32,0x9E31,/* 0xB0-0xB7 */ 0x9E36,0x9E38,0x9E37,0x9E39,0x9E3A,0x9E3E,0x9E41,0x9E42,/* 0xB8-0xBF */ 0x9E44,0x9E46,0x9E47,0x9E48,0x9E49,0x9E4B,0x9E4C,0x9E4E,/* 0xC0-0xC7 */ 0x9E51,0x9E55,0x9E57,0x9E5A,0x9E5B,0x9E5C,0x9E5E,0x9E63,/* 0xC8-0xCF */ 0x9E66,0x9E67,0x9E68,0x9E69,0x9E6A,0x9E6B,0x9E6C,0x9E71,/* 0xD0-0xD7 */ 0x9E6D,0x9E73,0x7592,0x7594,0x7596,0x75A0,0x759D,0x75AC,/* 0xD8-0xDF */ 0x75A3,0x75B3,0x75B4,0x75B8,0x75C4,0x75B1,0x75B0,0x75C3,/* 0xE0-0xE7 */ 0x75C2,0x75D6,0x75CD,0x75E3,0x75E8,0x75E6,0x75E4,0x75EB,/* 0xE8-0xEF */ 0x75E7,0x7603,0x75F1,0x75FC,0x75FF,0x7610,0x7600,0x7605,/* 0xF0-0xF7 */ 0x760C,0x7617,0x760A,0x7625,0x7618,0x7615,0x7619,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_F1[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x998C,0x998E,0x999A,0x999B,0x999C,0x999D,0x999E,0x999F,/* 0x40-0x47 */ 0x99A0,0x99A1,0x99A2,0x99A3,0x99A4,0x99A6,0x99A7,0x99A9,/* 0x48-0x4F */ 0x99AA,0x99AB,0x99AC,0x99AD,0x99AE,0x99AF,0x99B0,0x99B1,/* 0x50-0x57 */ 0x99B2,0x99B3,0x99B4,0x99B5,0x99B6,0x99B7,0x99B8,0x99B9,/* 0x58-0x5F */ 0x99BA,0x99BB,0x99BC,0x99BD,0x99BE,0x99BF,0x99C0,0x99C1,/* 0x60-0x67 */ 0x99C2,0x99C3,0x99C4,0x99C5,0x99C6,0x99C7,0x99C8,0x99C9,/* 0x68-0x6F */ 0x99CA,0x99CB,0x99CC,0x99CD,0x99CE,0x99CF,0x99D0,0x99D1,/* 0x70-0x77 */ 0x99D2,0x99D3,0x99D4,0x99D5,0x99D6,0x99D7,0x99D8,0x0000,/* 0x78-0x7F */ 0x99D9,0x99DA,0x99DB,0x99DC,0x99DD,0x99DE,0x99DF,0x99E0,/* 0x80-0x87 */ 0x99E1,0x99E2,0x99E3,0x99E4,0x99E5,0x99E6,0x99E7,0x99E8,/* 0x88-0x8F */ 0x99E9,0x99EA,0x99EB,0x99EC,0x99ED,0x99EE,0x99EF,0x99F0,/* 0x90-0x97 */ 0x99F1,0x99F2,0x99F3,0x99F4,0x99F5,0x99F6,0x99F7,0x99F8,/* 0x98-0x9F */ 0x99F9,0x761B,0x763C,0x7622,0x7620,0x7640,0x762D,0x7630,/* 0xA0-0xA7 */ 0x763F,0x7635,0x7643,0x763E,0x7633,0x764D,0x765E,0x7654,/* 0xA8-0xAF */ 0x765C,0x7656,0x766B,0x766F,0x7FCA,0x7AE6,0x7A78,0x7A79,/* 0xB0-0xB7 */ 0x7A80,0x7A86,0x7A88,0x7A95,0x7AA6,0x7AA0,0x7AAC,0x7AA8,/* 0xB8-0xBF */ 0x7AAD,0x7AB3,0x8864,0x8869,0x8872,0x887D,0x887F,0x8882,/* 0xC0-0xC7 */ 0x88A2,0x88C6,0x88B7,0x88BC,0x88C9,0x88E2,0x88CE,0x88E3,/* 0xC8-0xCF */ 0x88E5,0x88F1,0x891A,0x88FC,0x88E8,0x88FE,0x88F0,0x8921,/* 0xD0-0xD7 */ 0x8919,0x8913,0x891B,0x890A,0x8934,0x892B,0x8936,0x8941,/* 0xD8-0xDF */ 0x8966,0x897B,0x758B,0x80E5,0x76B2,0x76B4,0x77DC,0x8012,/* 0xE0-0xE7 */ 0x8014,0x8016,0x801C,0x8020,0x8022,0x8025,0x8026,0x8027,/* 0xE8-0xEF */ 0x8029,0x8028,0x8031,0x800B,0x8035,0x8043,0x8046,0x804D,/* 0xF0-0xF7 */ 0x8052,0x8069,0x8071,0x8983,0x9878,0x9880,0x9883,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_F2[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x99FA,0x99FB,0x99FC,0x99FD,0x99FE,0x99FF,0x9A00,0x9A01,/* 0x40-0x47 */ 0x9A02,0x9A03,0x9A04,0x9A05,0x9A06,0x9A07,0x9A08,0x9A09,/* 0x48-0x4F */ 0x9A0A,0x9A0B,0x9A0C,0x9A0D,0x9A0E,0x9A0F,0x9A10,0x9A11,/* 0x50-0x57 */ 0x9A12,0x9A13,0x9A14,0x9A15,0x9A16,0x9A17,0x9A18,0x9A19,/* 0x58-0x5F */ 0x9A1A,0x9A1B,0x9A1C,0x9A1D,0x9A1E,0x9A1F,0x9A20,0x9A21,/* 0x60-0x67 */ 0x9A22,0x9A23,0x9A24,0x9A25,0x9A26,0x9A27,0x9A28,0x9A29,/* 0x68-0x6F */ 0x9A2A,0x9A2B,0x9A2C,0x9A2D,0x9A2E,0x9A2F,0x9A30,0x9A31,/* 0x70-0x77 */ 0x9A32,0x9A33,0x9A34,0x9A35,0x9A36,0x9A37,0x9A38,0x0000,/* 0x78-0x7F */ 0x9A39,0x9A3A,0x9A3B,0x9A3C,0x9A3D,0x9A3E,0x9A3F,0x9A40,/* 0x80-0x87 */ 0x9A41,0x9A42,0x9A43,0x9A44,0x9A45,0x9A46,0x9A47,0x9A48,/* 0x88-0x8F */ 0x9A49,0x9A4A,0x9A4B,0x9A4C,0x9A4D,0x9A4E,0x9A4F,0x9A50,/* 0x90-0x97 */ 0x9A51,0x9A52,0x9A53,0x9A54,0x9A55,0x9A56,0x9A57,0x9A58,/* 0x98-0x9F */ 0x9A59,0x9889,0x988C,0x988D,0x988F,0x9894,0x989A,0x989B,/* 0xA0-0xA7 */ 0x989E,0x989F,0x98A1,0x98A2,0x98A5,0x98A6,0x864D,0x8654,/* 0xA8-0xAF */ 0x866C,0x866E,0x867F,0x867A,0x867C,0x867B,0x86A8,0x868D,/* 0xB0-0xB7 */ 0x868B,0x86AC,0x869D,0x86A7,0x86A3,0x86AA,0x8693,0x86A9,/* 0xB8-0xBF */ 0x86B6,0x86C4,0x86B5,0x86CE,0x86B0,0x86BA,0x86B1,0x86AF,/* 0xC0-0xC7 */ 0x86C9,0x86CF,0x86B4,0x86E9,0x86F1,0x86F2,0x86ED,0x86F3,/* 0xC8-0xCF */ 0x86D0,0x8713,0x86DE,0x86F4,0x86DF,0x86D8,0x86D1,0x8703,/* 0xD0-0xD7 */ 0x8707,0x86F8,0x8708,0x870A,0x870D,0x8709,0x8723,0x873B,/* 0xD8-0xDF */ 0x871E,0x8725,0x872E,0x871A,0x873E,0x8748,0x8734,0x8731,/* 0xE0-0xE7 */ 0x8729,0x8737,0x873F,0x8782,0x8722,0x877D,0x877E,0x877B,/* 0xE8-0xEF */ 0x8760,0x8770,0x874C,0x876E,0x878B,0x8753,0x8763,0x877C,/* 0xF0-0xF7 */ 0x8764,0x8759,0x8765,0x8793,0x87AF,0x87A8,0x87D2,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_F3[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9A5A,0x9A5B,0x9A5C,0x9A5D,0x9A5E,0x9A5F,0x9A60,0x9A61,/* 0x40-0x47 */ 0x9A62,0x9A63,0x9A64,0x9A65,0x9A66,0x9A67,0x9A68,0x9A69,/* 0x48-0x4F */ 0x9A6A,0x9A6B,0x9A72,0x9A83,0x9A89,0x9A8D,0x9A8E,0x9A94,/* 0x50-0x57 */ 0x9A95,0x9A99,0x9AA6,0x9AA9,0x9AAA,0x9AAB,0x9AAC,0x9AAD,/* 0x58-0x5F */ 0x9AAE,0x9AAF,0x9AB2,0x9AB3,0x9AB4,0x9AB5,0x9AB9,0x9ABB,/* 0x60-0x67 */ 0x9ABD,0x9ABE,0x9ABF,0x9AC3,0x9AC4,0x9AC6,0x9AC7,0x9AC8,/* 0x68-0x6F */ 0x9AC9,0x9ACA,0x9ACD,0x9ACE,0x9ACF,0x9AD0,0x9AD2,0x9AD4,/* 0x70-0x77 */ 0x9AD5,0x9AD6,0x9AD7,0x9AD9,0x9ADA,0x9ADB,0x9ADC,0x0000,/* 0x78-0x7F */ 0x9ADD,0x9ADE,0x9AE0,0x9AE2,0x9AE3,0x9AE4,0x9AE5,0x9AE7,/* 0x80-0x87 */ 0x9AE8,0x9AE9,0x9AEA,0x9AEC,0x9AEE,0x9AF0,0x9AF1,0x9AF2,/* 0x88-0x8F */ 0x9AF3,0x9AF4,0x9AF5,0x9AF6,0x9AF7,0x9AF8,0x9AFA,0x9AFC,/* 0x90-0x97 */ 0x9AFD,0x9AFE,0x9AFF,0x9B00,0x9B01,0x9B02,0x9B04,0x9B05,/* 0x98-0x9F */ 0x9B06,0x87C6,0x8788,0x8785,0x87AD,0x8797,0x8783,0x87AB,/* 0xA0-0xA7 */ 0x87E5,0x87AC,0x87B5,0x87B3,0x87CB,0x87D3,0x87BD,0x87D1,/* 0xA8-0xAF */ 0x87C0,0x87CA,0x87DB,0x87EA,0x87E0,0x87EE,0x8816,0x8813,/* 0xB0-0xB7 */ 0x87FE,0x880A,0x881B,0x8821,0x8839,0x883C,0x7F36,0x7F42,/* 0xB8-0xBF */ 0x7F44,0x7F45,0x8210,0x7AFA,0x7AFD,0x7B08,0x7B03,0x7B04,/* 0xC0-0xC7 */ 0x7B15,0x7B0A,0x7B2B,0x7B0F,0x7B47,0x7B38,0x7B2A,0x7B19,/* 0xC8-0xCF */ 0x7B2E,0x7B31,0x7B20,0x7B25,0x7B24,0x7B33,0x7B3E,0x7B1E,/* 0xD0-0xD7 */ 0x7B58,0x7B5A,0x7B45,0x7B75,0x7B4C,0x7B5D,0x7B60,0x7B6E,/* 0xD8-0xDF */ 0x7B7B,0x7B62,0x7B72,0x7B71,0x7B90,0x7BA6,0x7BA7,0x7BB8,/* 0xE0-0xE7 */ 0x7BAC,0x7B9D,0x7BA8,0x7B85,0x7BAA,0x7B9C,0x7BA2,0x7BAB,/* 0xE8-0xEF */ 0x7BB4,0x7BD1,0x7BC1,0x7BCC,0x7BDD,0x7BDA,0x7BE5,0x7BE6,/* 0xF0-0xF7 */ 0x7BEA,0x7C0C,0x7BFE,0x7BFC,0x7C0F,0x7C16,0x7C0B,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_F4[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9B07,0x9B09,0x9B0A,0x9B0B,0x9B0C,0x9B0D,0x9B0E,0x9B10,/* 0x40-0x47 */ 0x9B11,0x9B12,0x9B14,0x9B15,0x9B16,0x9B17,0x9B18,0x9B19,/* 0x48-0x4F */ 0x9B1A,0x9B1B,0x9B1C,0x9B1D,0x9B1E,0x9B20,0x9B21,0x9B22,/* 0x50-0x57 */ 0x9B24,0x9B25,0x9B26,0x9B27,0x9B28,0x9B29,0x9B2A,0x9B2B,/* 0x58-0x5F */ 0x9B2C,0x9B2D,0x9B2E,0x9B30,0x9B31,0x9B33,0x9B34,0x9B35,/* 0x60-0x67 */ 0x9B36,0x9B37,0x9B38,0x9B39,0x9B3A,0x9B3D,0x9B3E,0x9B3F,/* 0x68-0x6F */ 0x9B40,0x9B46,0x9B4A,0x9B4B,0x9B4C,0x9B4E,0x9B50,0x9B52,/* 0x70-0x77 */ 0x9B53,0x9B55,0x9B56,0x9B57,0x9B58,0x9B59,0x9B5A,0x0000,/* 0x78-0x7F */ 0x9B5B,0x9B5C,0x9B5D,0x9B5E,0x9B5F,0x9B60,0x9B61,0x9B62,/* 0x80-0x87 */ 0x9B63,0x9B64,0x9B65,0x9B66,0x9B67,0x9B68,0x9B69,0x9B6A,/* 0x88-0x8F */ 0x9B6B,0x9B6C,0x9B6D,0x9B6E,0x9B6F,0x9B70,0x9B71,0x9B72,/* 0x90-0x97 */ 0x9B73,0x9B74,0x9B75,0x9B76,0x9B77,0x9B78,0x9B79,0x9B7A,/* 0x98-0x9F */ 0x9B7B,0x7C1F,0x7C2A,0x7C26,0x7C38,0x7C41,0x7C40,0x81FE,/* 0xA0-0xA7 */ 0x8201,0x8202,0x8204,0x81EC,0x8844,0x8221,0x8222,0x8223,/* 0xA8-0xAF */ 0x822D,0x822F,0x8228,0x822B,0x8238,0x823B,0x8233,0x8234,/* 0xB0-0xB7 */ 0x823E,0x8244,0x8249,0x824B,0x824F,0x825A,0x825F,0x8268,/* 0xB8-0xBF */ 0x887E,0x8885,0x8888,0x88D8,0x88DF,0x895E,0x7F9D,0x7F9F,/* 0xC0-0xC7 */ 0x7FA7,0x7FAF,0x7FB0,0x7FB2,0x7C7C,0x6549,0x7C91,0x7C9D,/* 0xC8-0xCF */ 0x7C9C,0x7C9E,0x7CA2,0x7CB2,0x7CBC,0x7CBD,0x7CC1,0x7CC7,/* 0xD0-0xD7 */ 0x7CCC,0x7CCD,0x7CC8,0x7CC5,0x7CD7,0x7CE8,0x826E,0x66A8,/* 0xD8-0xDF */ 0x7FBF,0x7FCE,0x7FD5,0x7FE5,0x7FE1,0x7FE6,0x7FE9,0x7FEE,/* 0xE0-0xE7 */ 0x7FF3,0x7CF8,0x7D77,0x7DA6,0x7DAE,0x7E47,0x7E9B,0x9EB8,/* 0xE8-0xEF */ 0x9EB4,0x8D73,0x8D84,0x8D94,0x8D91,0x8DB1,0x8D67,0x8D6D,/* 0xF0-0xF7 */ 0x8C47,0x8C49,0x914A,0x9150,0x914E,0x914F,0x9164,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_F5[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9B7C,0x9B7D,0x9B7E,0x9B7F,0x9B80,0x9B81,0x9B82,0x9B83,/* 0x40-0x47 */ 0x9B84,0x9B85,0x9B86,0x9B87,0x9B88,0x9B89,0x9B8A,0x9B8B,/* 0x48-0x4F */ 0x9B8C,0x9B8D,0x9B8E,0x9B8F,0x9B90,0x9B91,0x9B92,0x9B93,/* 0x50-0x57 */ 0x9B94,0x9B95,0x9B96,0x9B97,0x9B98,0x9B99,0x9B9A,0x9B9B,/* 0x58-0x5F */ 0x9B9C,0x9B9D,0x9B9E,0x9B9F,0x9BA0,0x9BA1,0x9BA2,0x9BA3,/* 0x60-0x67 */ 0x9BA4,0x9BA5,0x9BA6,0x9BA7,0x9BA8,0x9BA9,0x9BAA,0x9BAB,/* 0x68-0x6F */ 0x9BAC,0x9BAD,0x9BAE,0x9BAF,0x9BB0,0x9BB1,0x9BB2,0x9BB3,/* 0x70-0x77 */ 0x9BB4,0x9BB5,0x9BB6,0x9BB7,0x9BB8,0x9BB9,0x9BBA,0x0000,/* 0x78-0x7F */ 0x9BBB,0x9BBC,0x9BBD,0x9BBE,0x9BBF,0x9BC0,0x9BC1,0x9BC2,/* 0x80-0x87 */ 0x9BC3,0x9BC4,0x9BC5,0x9BC6,0x9BC7,0x9BC8,0x9BC9,0x9BCA,/* 0x88-0x8F */ 0x9BCB,0x9BCC,0x9BCD,0x9BCE,0x9BCF,0x9BD0,0x9BD1,0x9BD2,/* 0x90-0x97 */ 0x9BD3,0x9BD4,0x9BD5,0x9BD6,0x9BD7,0x9BD8,0x9BD9,0x9BDA,/* 0x98-0x9F */ 0x9BDB,0x9162,0x9161,0x9170,0x9169,0x916F,0x917D,0x917E,/* 0xA0-0xA7 */ 0x9172,0x9174,0x9179,0x918C,0x9185,0x9190,0x918D,0x9191,/* 0xA8-0xAF */ 0x91A2,0x91A3,0x91AA,0x91AD,0x91AE,0x91AF,0x91B5,0x91B4,/* 0xB0-0xB7 */ 0x91BA,0x8C55,0x9E7E,0x8DB8,0x8DEB,0x8E05,0x8E59,0x8E69,/* 0xB8-0xBF */ 0x8DB5,0x8DBF,0x8DBC,0x8DBA,0x8DC4,0x8DD6,0x8DD7,0x8DDA,/* 0xC0-0xC7 */ 0x8DDE,0x8DCE,0x8DCF,0x8DDB,0x8DC6,0x8DEC,0x8DF7,0x8DF8,/* 0xC8-0xCF */ 0x8DE3,0x8DF9,0x8DFB,0x8DE4,0x8E09,0x8DFD,0x8E14,0x8E1D,/* 0xD0-0xD7 */ 0x8E1F,0x8E2C,0x8E2E,0x8E23,0x8E2F,0x8E3A,0x8E40,0x8E39,/* 0xD8-0xDF */ 0x8E35,0x8E3D,0x8E31,0x8E49,0x8E41,0x8E42,0x8E51,0x8E52,/* 0xE0-0xE7 */ 0x8E4A,0x8E70,0x8E76,0x8E7C,0x8E6F,0x8E74,0x8E85,0x8E8F,/* 0xE8-0xEF */ 0x8E94,0x8E90,0x8E9C,0x8E9E,0x8C78,0x8C82,0x8C8A,0x8C85,/* 0xF0-0xF7 */ 0x8C98,0x8C94,0x659B,0x89D6,0x89DE,0x89DA,0x89DC,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_F6[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9BDC,0x9BDD,0x9BDE,0x9BDF,0x9BE0,0x9BE1,0x9BE2,0x9BE3,/* 0x40-0x47 */ 0x9BE4,0x9BE5,0x9BE6,0x9BE7,0x9BE8,0x9BE9,0x9BEA,0x9BEB,/* 0x48-0x4F */ 0x9BEC,0x9BED,0x9BEE,0x9BEF,0x9BF0,0x9BF1,0x9BF2,0x9BF3,/* 0x50-0x57 */ 0x9BF4,0x9BF5,0x9BF6,0x9BF7,0x9BF8,0x9BF9,0x9BFA,0x9BFB,/* 0x58-0x5F */ 0x9BFC,0x9BFD,0x9BFE,0x9BFF,0x9C00,0x9C01,0x9C02,0x9C03,/* 0x60-0x67 */ 0x9C04,0x9C05,0x9C06,0x9C07,0x9C08,0x9C09,0x9C0A,0x9C0B,/* 0x68-0x6F */ 0x9C0C,0x9C0D,0x9C0E,0x9C0F,0x9C10,0x9C11,0x9C12,0x9C13,/* 0x70-0x77 */ 0x9C14,0x9C15,0x9C16,0x9C17,0x9C18,0x9C19,0x9C1A,0x0000,/* 0x78-0x7F */ 0x9C1B,0x9C1C,0x9C1D,0x9C1E,0x9C1F,0x9C20,0x9C21,0x9C22,/* 0x80-0x87 */ 0x9C23,0x9C24,0x9C25,0x9C26,0x9C27,0x9C28,0x9C29,0x9C2A,/* 0x88-0x8F */ 0x9C2B,0x9C2C,0x9C2D,0x9C2E,0x9C2F,0x9C30,0x9C31,0x9C32,/* 0x90-0x97 */ 0x9C33,0x9C34,0x9C35,0x9C36,0x9C37,0x9C38,0x9C39,0x9C3A,/* 0x98-0x9F */ 0x9C3B,0x89E5,0x89EB,0x89EF,0x8A3E,0x8B26,0x9753,0x96E9,/* 0xA0-0xA7 */ 0x96F3,0x96EF,0x9706,0x9701,0x9708,0x970F,0x970E,0x972A,/* 0xA8-0xAF */ 0x972D,0x9730,0x973E,0x9F80,0x9F83,0x9F85,0x9F86,0x9F87,/* 0xB0-0xB7 */ 0x9F88,0x9F89,0x9F8A,0x9F8C,0x9EFE,0x9F0B,0x9F0D,0x96B9,/* 0xB8-0xBF */ 0x96BC,0x96BD,0x96CE,0x96D2,0x77BF,0x96E0,0x928E,0x92AE,/* 0xC0-0xC7 */ 0x92C8,0x933E,0x936A,0x93CA,0x938F,0x943E,0x946B,0x9C7F,/* 0xC8-0xCF */ 0x9C82,0x9C85,0x9C86,0x9C87,0x9C88,0x7A23,0x9C8B,0x9C8E,/* 0xD0-0xD7 */ 0x9C90,0x9C91,0x9C92,0x9C94,0x9C95,0x9C9A,0x9C9B,0x9C9E,/* 0xD8-0xDF */ 0x9C9F,0x9CA0,0x9CA1,0x9CA2,0x9CA3,0x9CA5,0x9CA6,0x9CA7,/* 0xE0-0xE7 */ 0x9CA8,0x9CA9,0x9CAB,0x9CAD,0x9CAE,0x9CB0,0x9CB1,0x9CB2,/* 0xE8-0xEF */ 0x9CB3,0x9CB4,0x9CB5,0x9CB6,0x9CB7,0x9CBA,0x9CBB,0x9CBC,/* 0xF0-0xF7 */ 0x9CBD,0x9CC4,0x9CC5,0x9CC6,0x9CC7,0x9CCA,0x9CCB,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_F7[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9C3C,0x9C3D,0x9C3E,0x9C3F,0x9C40,0x9C41,0x9C42,0x9C43,/* 0x40-0x47 */ 0x9C44,0x9C45,0x9C46,0x9C47,0x9C48,0x9C49,0x9C4A,0x9C4B,/* 0x48-0x4F */ 0x9C4C,0x9C4D,0x9C4E,0x9C4F,0x9C50,0x9C51,0x9C52,0x9C53,/* 0x50-0x57 */ 0x9C54,0x9C55,0x9C56,0x9C57,0x9C58,0x9C59,0x9C5A,0x9C5B,/* 0x58-0x5F */ 0x9C5C,0x9C5D,0x9C5E,0x9C5F,0x9C60,0x9C61,0x9C62,0x9C63,/* 0x60-0x67 */ 0x9C64,0x9C65,0x9C66,0x9C67,0x9C68,0x9C69,0x9C6A,0x9C6B,/* 0x68-0x6F */ 0x9C6C,0x9C6D,0x9C6E,0x9C6F,0x9C70,0x9C71,0x9C72,0x9C73,/* 0x70-0x77 */ 0x9C74,0x9C75,0x9C76,0x9C77,0x9C78,0x9C79,0x9C7A,0x0000,/* 0x78-0x7F */ 0x9C7B,0x9C7D,0x9C7E,0x9C80,0x9C83,0x9C84,0x9C89,0x9C8A,/* 0x80-0x87 */ 0x9C8C,0x9C8F,0x9C93,0x9C96,0x9C97,0x9C98,0x9C99,0x9C9D,/* 0x88-0x8F */ 0x9CAA,0x9CAC,0x9CAF,0x9CB9,0x9CBE,0x9CBF,0x9CC0,0x9CC1,/* 0x90-0x97 */ 0x9CC2,0x9CC8,0x9CC9,0x9CD1,0x9CD2,0x9CDA,0x9CDB,0x9CE0,/* 0x98-0x9F */ 0x9CE1,0x9CCC,0x9CCD,0x9CCE,0x9CCF,0x9CD0,0x9CD3,0x9CD4,/* 0xA0-0xA7 */ 0x9CD5,0x9CD7,0x9CD8,0x9CD9,0x9CDC,0x9CDD,0x9CDF,0x9CE2,/* 0xA8-0xAF */ 0x977C,0x9785,0x9791,0x9792,0x9794,0x97AF,0x97AB,0x97A3,/* 0xB0-0xB7 */ 0x97B2,0x97B4,0x9AB1,0x9AB0,0x9AB7,0x9E58,0x9AB6,0x9ABA,/* 0xB8-0xBF */ 0x9ABC,0x9AC1,0x9AC0,0x9AC5,0x9AC2,0x9ACB,0x9ACC,0x9AD1,/* 0xC0-0xC7 */ 0x9B45,0x9B43,0x9B47,0x9B49,0x9B48,0x9B4D,0x9B51,0x98E8,/* 0xC8-0xCF */ 0x990D,0x992E,0x9955,0x9954,0x9ADF,0x9AE1,0x9AE6,0x9AEF,/* 0xD0-0xD7 */ 0x9AEB,0x9AFB,0x9AED,0x9AF9,0x9B08,0x9B0F,0x9B13,0x9B1F,/* 0xD8-0xDF */ 0x9B23,0x9EBD,0x9EBE,0x7E3B,0x9E82,0x9E87,0x9E88,0x9E8B,/* 0xE0-0xE7 */ 0x9E92,0x93D6,0x9E9D,0x9E9F,0x9EDB,0x9EDC,0x9EDD,0x9EE0,/* 0xE8-0xEF */ 0x9EDF,0x9EE2,0x9EE9,0x9EE7,0x9EE5,0x9EEA,0x9EEF,0x9F22,/* 0xF0-0xF7 */ 0x9F2C,0x9F2F,0x9F39,0x9F37,0x9F3D,0x9F3E,0x9F44,0x0000,/* 0xF8-0xFF */ }; static const wchar_t c2u_F8[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9CE3,0x9CE4,0x9CE5,0x9CE6,0x9CE7,0x9CE8,0x9CE9,0x9CEA,/* 0x40-0x47 */ 0x9CEB,0x9CEC,0x9CED,0x9CEE,0x9CEF,0x9CF0,0x9CF1,0x9CF2,/* 0x48-0x4F */ 0x9CF3,0x9CF4,0x9CF5,0x9CF6,0x9CF7,0x9CF8,0x9CF9,0x9CFA,/* 0x50-0x57 */ 0x9CFB,0x9CFC,0x9CFD,0x9CFE,0x9CFF,0x9D00,0x9D01,0x9D02,/* 0x58-0x5F */ 0x9D03,0x9D04,0x9D05,0x9D06,0x9D07,0x9D08,0x9D09,0x9D0A,/* 0x60-0x67 */ 0x9D0B,0x9D0C,0x9D0D,0x9D0E,0x9D0F,0x9D10,0x9D11,0x9D12,/* 0x68-0x6F */ 0x9D13,0x9D14,0x9D15,0x9D16,0x9D17,0x9D18,0x9D19,0x9D1A,/* 0x70-0x77 */ 0x9D1B,0x9D1C,0x9D1D,0x9D1E,0x9D1F,0x9D20,0x9D21,0x0000,/* 0x78-0x7F */ 0x9D22,0x9D23,0x9D24,0x9D25,0x9D26,0x9D27,0x9D28,0x9D29,/* 0x80-0x87 */ 0x9D2A,0x9D2B,0x9D2C,0x9D2D,0x9D2E,0x9D2F,0x9D30,0x9D31,/* 0x88-0x8F */ 0x9D32,0x9D33,0x9D34,0x9D35,0x9D36,0x9D37,0x9D38,0x9D39,/* 0x90-0x97 */ 0x9D3A,0x9D3B,0x9D3C,0x9D3D,0x9D3E,0x9D3F,0x9D40,0x9D41,/* 0x98-0x9F */ 0x9D42,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_F9[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9D43,0x9D44,0x9D45,0x9D46,0x9D47,0x9D48,0x9D49,0x9D4A,/* 0x40-0x47 */ 0x9D4B,0x9D4C,0x9D4D,0x9D4E,0x9D4F,0x9D50,0x9D51,0x9D52,/* 0x48-0x4F */ 0x9D53,0x9D54,0x9D55,0x9D56,0x9D57,0x9D58,0x9D59,0x9D5A,/* 0x50-0x57 */ 0x9D5B,0x9D5C,0x9D5D,0x9D5E,0x9D5F,0x9D60,0x9D61,0x9D62,/* 0x58-0x5F */ 0x9D63,0x9D64,0x9D65,0x9D66,0x9D67,0x9D68,0x9D69,0x9D6A,/* 0x60-0x67 */ 0x9D6B,0x9D6C,0x9D6D,0x9D6E,0x9D6F,0x9D70,0x9D71,0x9D72,/* 0x68-0x6F */ 0x9D73,0x9D74,0x9D75,0x9D76,0x9D77,0x9D78,0x9D79,0x9D7A,/* 0x70-0x77 */ 0x9D7B,0x9D7C,0x9D7D,0x9D7E,0x9D7F,0x9D80,0x9D81,0x0000,/* 0x78-0x7F */ 0x9D82,0x9D83,0x9D84,0x9D85,0x9D86,0x9D87,0x9D88,0x9D89,/* 0x80-0x87 */ 0x9D8A,0x9D8B,0x9D8C,0x9D8D,0x9D8E,0x9D8F,0x9D90,0x9D91,/* 0x88-0x8F */ 0x9D92,0x9D93,0x9D94,0x9D95,0x9D96,0x9D97,0x9D98,0x9D99,/* 0x90-0x97 */ 0x9D9A,0x9D9B,0x9D9C,0x9D9D,0x9D9E,0x9D9F,0x9DA0,0x9DA1,/* 0x98-0x9F */ 0x9DA2,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_FA[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9DA3,0x9DA4,0x9DA5,0x9DA6,0x9DA7,0x9DA8,0x9DA9,0x9DAA,/* 0x40-0x47 */ 0x9DAB,0x9DAC,0x9DAD,0x9DAE,0x9DAF,0x9DB0,0x9DB1,0x9DB2,/* 0x48-0x4F */ 0x9DB3,0x9DB4,0x9DB5,0x9DB6,0x9DB7,0x9DB8,0x9DB9,0x9DBA,/* 0x50-0x57 */ 0x9DBB,0x9DBC,0x9DBD,0x9DBE,0x9DBF,0x9DC0,0x9DC1,0x9DC2,/* 0x58-0x5F */ 0x9DC3,0x9DC4,0x9DC5,0x9DC6,0x9DC7,0x9DC8,0x9DC9,0x9DCA,/* 0x60-0x67 */ 0x9DCB,0x9DCC,0x9DCD,0x9DCE,0x9DCF,0x9DD0,0x9DD1,0x9DD2,/* 0x68-0x6F */ 0x9DD3,0x9DD4,0x9DD5,0x9DD6,0x9DD7,0x9DD8,0x9DD9,0x9DDA,/* 0x70-0x77 */ 0x9DDB,0x9DDC,0x9DDD,0x9DDE,0x9DDF,0x9DE0,0x9DE1,0x0000,/* 0x78-0x7F */ 0x9DE2,0x9DE3,0x9DE4,0x9DE5,0x9DE6,0x9DE7,0x9DE8,0x9DE9,/* 0x80-0x87 */ 0x9DEA,0x9DEB,0x9DEC,0x9DED,0x9DEE,0x9DEF,0x9DF0,0x9DF1,/* 0x88-0x8F */ 0x9DF2,0x9DF3,0x9DF4,0x9DF5,0x9DF6,0x9DF7,0x9DF8,0x9DF9,/* 0x90-0x97 */ 0x9DFA,0x9DFB,0x9DFC,0x9DFD,0x9DFE,0x9DFF,0x9E00,0x9E01,/* 0x98-0x9F */ 0x9E02,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_FB[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9E03,0x9E04,0x9E05,0x9E06,0x9E07,0x9E08,0x9E09,0x9E0A,/* 0x40-0x47 */ 0x9E0B,0x9E0C,0x9E0D,0x9E0E,0x9E0F,0x9E10,0x9E11,0x9E12,/* 0x48-0x4F */ 0x9E13,0x9E14,0x9E15,0x9E16,0x9E17,0x9E18,0x9E19,0x9E1A,/* 0x50-0x57 */ 0x9E1B,0x9E1C,0x9E1D,0x9E1E,0x9E24,0x9E27,0x9E2E,0x9E30,/* 0x58-0x5F */ 0x9E34,0x9E3B,0x9E3C,0x9E40,0x9E4D,0x9E50,0x9E52,0x9E53,/* 0x60-0x67 */ 0x9E54,0x9E56,0x9E59,0x9E5D,0x9E5F,0x9E60,0x9E61,0x9E62,/* 0x68-0x6F */ 0x9E65,0x9E6E,0x9E6F,0x9E72,0x9E74,0x9E75,0x9E76,0x9E77,/* 0x70-0x77 */ 0x9E78,0x9E79,0x9E7A,0x9E7B,0x9E7C,0x9E7D,0x9E80,0x0000,/* 0x78-0x7F */ 0x9E81,0x9E83,0x9E84,0x9E85,0x9E86,0x9E89,0x9E8A,0x9E8C,/* 0x80-0x87 */ 0x9E8D,0x9E8E,0x9E8F,0x9E90,0x9E91,0x9E94,0x9E95,0x9E96,/* 0x88-0x8F */ 0x9E97,0x9E98,0x9E99,0x9E9A,0x9E9B,0x9E9C,0x9E9E,0x9EA0,/* 0x90-0x97 */ 0x9EA1,0x9EA2,0x9EA3,0x9EA4,0x9EA5,0x9EA7,0x9EA8,0x9EA9,/* 0x98-0x9F */ 0x9EAA,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_FC[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9EAB,0x9EAC,0x9EAD,0x9EAE,0x9EAF,0x9EB0,0x9EB1,0x9EB2,/* 0x40-0x47 */ 0x9EB3,0x9EB5,0x9EB6,0x9EB7,0x9EB9,0x9EBA,0x9EBC,0x9EBF,/* 0x48-0x4F */ 0x9EC0,0x9EC1,0x9EC2,0x9EC3,0x9EC5,0x9EC6,0x9EC7,0x9EC8,/* 0x50-0x57 */ 0x9ECA,0x9ECB,0x9ECC,0x9ED0,0x9ED2,0x9ED3,0x9ED5,0x9ED6,/* 0x58-0x5F */ 0x9ED7,0x9ED9,0x9EDA,0x9EDE,0x9EE1,0x9EE3,0x9EE4,0x9EE6,/* 0x60-0x67 */ 0x9EE8,0x9EEB,0x9EEC,0x9EED,0x9EEE,0x9EF0,0x9EF1,0x9EF2,/* 0x68-0x6F */ 0x9EF3,0x9EF4,0x9EF5,0x9EF6,0x9EF7,0x9EF8,0x9EFA,0x9EFD,/* 0x70-0x77 */ 0x9EFF,0x9F00,0x9F01,0x9F02,0x9F03,0x9F04,0x9F05,0x0000,/* 0x78-0x7F */ 0x9F06,0x9F07,0x9F08,0x9F09,0x9F0A,0x9F0C,0x9F0F,0x9F11,/* 0x80-0x87 */ 0x9F12,0x9F14,0x9F15,0x9F16,0x9F18,0x9F1A,0x9F1B,0x9F1C,/* 0x88-0x8F */ 0x9F1D,0x9F1E,0x9F1F,0x9F21,0x9F23,0x9F24,0x9F25,0x9F26,/* 0x90-0x97 */ 0x9F27,0x9F28,0x9F29,0x9F2A,0x9F2B,0x9F2D,0x9F2E,0x9F30,/* 0x98-0x9F */ 0x9F31,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_FD[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0x9F32,0x9F33,0x9F34,0x9F35,0x9F36,0x9F38,0x9F3A,0x9F3C,/* 0x40-0x47 */ 0x9F3F,0x9F40,0x9F41,0x9F42,0x9F43,0x9F45,0x9F46,0x9F47,/* 0x48-0x4F */ 0x9F48,0x9F49,0x9F4A,0x9F4B,0x9F4C,0x9F4D,0x9F4E,0x9F4F,/* 0x50-0x57 */ 0x9F52,0x9F53,0x9F54,0x9F55,0x9F56,0x9F57,0x9F58,0x9F59,/* 0x58-0x5F */ 0x9F5A,0x9F5B,0x9F5C,0x9F5D,0x9F5E,0x9F5F,0x9F60,0x9F61,/* 0x60-0x67 */ 0x9F62,0x9F63,0x9F64,0x9F65,0x9F66,0x9F67,0x9F68,0x9F69,/* 0x68-0x6F */ 0x9F6A,0x9F6B,0x9F6C,0x9F6D,0x9F6E,0x9F6F,0x9F70,0x9F71,/* 0x70-0x77 */ 0x9F72,0x9F73,0x9F74,0x9F75,0x9F76,0x9F77,0x9F78,0x0000,/* 0x78-0x7F */ 0x9F79,0x9F7A,0x9F7B,0x9F7C,0x9F7D,0x9F7E,0x9F81,0x9F82,/* 0x80-0x87 */ 0x9F8D,0x9F8E,0x9F8F,0x9F90,0x9F91,0x9F92,0x9F93,0x9F94,/* 0x88-0x8F */ 0x9F95,0x9F96,0x9F97,0x9F98,0x9F9C,0x9F9D,0x9F9E,0x9FA1,/* 0x90-0x97 */ 0x9FA2,0x9FA3,0x9FA4,0x9FA5,0xF92C,0xF979,0xF995,0xF9E7,/* 0x98-0x9F */ 0xF9F1,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0xA0-0xA7 */ }; static const wchar_t c2u_FE[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x00-0x07 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x08-0x0F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x10-0x17 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x18-0x1F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x20-0x27 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x28-0x2F */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x30-0x37 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,/* 0x38-0x3F */ 0xFA0C,0xFA0D,0xFA0E,0xFA0F,0xFA11,0xFA13,0xFA14,0xFA18,/* 0x40-0x47 */ 0xFA1F,0xFA20,0xFA21,0xFA23,0xFA24,0xFA27,0xFA28,0xFA29,/* 0x48-0x4F */ }; static const wchar_t *page_charset2uni[256] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, c2u_81, c2u_82, c2u_83, c2u_84, c2u_85, c2u_86, c2u_87, c2u_88, c2u_89, c2u_8A, c2u_8B, c2u_8C, c2u_8D, c2u_8E, c2u_8F, c2u_90, c2u_91, c2u_92, c2u_93, c2u_94, c2u_95, c2u_96, c2u_97, c2u_98, c2u_99, c2u_9A, c2u_9B, c2u_9C, c2u_9D, c2u_9E, c2u_9F, c2u_A0, c2u_A1, c2u_A2, c2u_A3, c2u_A4, c2u_A5, c2u_A6, c2u_A7, c2u_A8, c2u_A9, c2u_AA, c2u_AB, c2u_AC, c2u_AD, c2u_AE, c2u_AF, c2u_B0, c2u_B1, c2u_B2, c2u_B3, c2u_B4, c2u_B5, c2u_B6, c2u_B7, c2u_B8, c2u_B9, c2u_BA, c2u_BB, c2u_BC, c2u_BD, c2u_BE, c2u_BF, c2u_C0, c2u_C1, c2u_C2, c2u_C3, c2u_C4, c2u_C5, c2u_C6, c2u_C7, c2u_C8, c2u_C9, c2u_CA, c2u_CB, c2u_CC, c2u_CD, c2u_CE, c2u_CF, c2u_D0, c2u_D1, c2u_D2, c2u_D3, c2u_D4, c2u_D5, c2u_D6, c2u_D7, c2u_D8, c2u_D9, c2u_DA, c2u_DB, c2u_DC, c2u_DD, c2u_DE, c2u_DF, c2u_E0, c2u_E1, c2u_E2, c2u_E3, c2u_E4, c2u_E5, c2u_E6, c2u_E7, c2u_E8, c2u_E9, c2u_EA, c2u_EB, c2u_EC, c2u_ED, c2u_EE, c2u_EF, c2u_F0, c2u_F1, c2u_F2, c2u_F3, c2u_F4, c2u_F5, c2u_F6, c2u_F7, c2u_F8, c2u_F9, c2u_FA, c2u_FB, c2u_FC, c2u_FD, c2u_FE, NULL, }; static const unsigned char u2c_00[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x93 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x94-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x9C-0x9F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA0-0xA3 */ 0xA1, 0xE8, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xEC, /* 0xA4-0xA7 */ 0xA1, 0xA7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */ 0xA1, 0xE3, 0xA1, 0xC0, 0x00, 0x00, 0x00, 0x00, /* 0xB0-0xB3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA4, /* 0xB4-0xB7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB8-0xBB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xBC-0xBF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0-0xC3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC4-0xC7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC8-0xCB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xCC-0xCF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD0-0xD3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xC1, /* 0xD4-0xD7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD8-0xDB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xDC-0xDF */ 0xA8, 0xA4, 0xA8, 0xA2, 0x00, 0x00, 0x00, 0x00, /* 0xE0-0xE3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xE4-0xE7 */ 0xA8, 0xA8, 0xA8, 0xA6, 0xA8, 0xBA, 0x00, 0x00, /* 0xE8-0xEB */ 0xA8, 0xAC, 0xA8, 0xAA, 0x00, 0x00, 0x00, 0x00, /* 0xEC-0xEF */ 0x00, 0x00, 0x00, 0x00, 0xA8, 0xB0, 0xA8, 0xAE, /* 0xF0-0xF3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xC2, /* 0xF4-0xF7 */ 0x00, 0x00, 0xA8, 0xB4, 0xA8, 0xB2, 0x00, 0x00, /* 0xF8-0xFB */ 0xA8, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xFC-0xFF */ }; static const unsigned char u2c_01[512] = { 0xA8, 0xA1, 0xA8, 0xA1, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA5, 0xA8, 0xA5, /* 0x10-0x13 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA7, 0xA8, 0xA7, /* 0x18-0x1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */ 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA9, 0xA8, 0xA9, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */ 0xA8, 0xBD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0xA8, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */ 0xA8, 0xAD, 0xA8, 0xAD, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */ 0x00, 0x00, 0x00, 0x00, 0xA8, 0xB1, 0xA8, 0xB1, /* 0x68-0x6B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x93 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x94-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x9C-0x9F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA0-0xA3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA4-0xA7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB0-0xB3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB4-0xB7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB8-0xBB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xBC-0xBF */ 0x00, 0x00, 0xA1, 0xCE, 0x00, 0x00, 0x00, 0x00, /* 0xC0-0xC3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC4-0xC7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC8-0xCB */ 0x00, 0x00, 0xA8, 0xA3, 0xA8, 0xA3, 0xA8, 0xAB, /* 0xCC-0xCF */ 0xA8, 0xAB, 0xA8, 0xAF, 0xA8, 0xAF, 0xA8, 0xB3, /* 0xD0-0xD3 */ 0xA8, 0xB3, 0xA8, 0xB5, 0xA8, 0xB5, 0xA8, 0xB6, /* 0xD4-0xD7 */ 0xA8, 0xB6, 0xA8, 0xB7, 0xA8, 0xB7, 0xA8, 0xB8, /* 0xD8-0xDB */ 0xA8, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xDC-0xDF */ }; static const unsigned char u2c_02[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */ 0x00, 0x00, 0xA8, 0xBB, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */ 0x00, 0x00, 0xA8, 0xC0, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x93 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x94-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x9C-0x9F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA0-0xA3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA4-0xA7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB0-0xB3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB4-0xB7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB8-0xBB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xBC-0xBF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0-0xC3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA6, /* 0xC4-0xC7 */ 0x00, 0x00, 0xA1, 0xA5, 0xA8, 0x40, 0xA8, 0x41, /* 0xC8-0xCB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xCC-0xCF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD0-0xD3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD4-0xD7 */ 0x00, 0x00, 0xA8, 0x42, 0x00, 0x00, 0x00, 0x00, /* 0xD8-0xDB */ }; static const unsigned char u2c_03[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */ 0x00, 0x00, 0xA6, 0xA1, 0xA6, 0xA2, 0xA6, 0xA3, /* 0x90-0x93 */ 0xA6, 0xA4, 0xA6, 0xA5, 0xA6, 0xA6, 0xA6, 0xA7, /* 0x94-0x97 */ 0xA6, 0xA8, 0xA6, 0xA9, 0xA6, 0xAA, 0xA6, 0xAB, /* 0x98-0x9B */ 0xA6, 0xAC, 0xA6, 0xAD, 0xA6, 0xAE, 0xA6, 0xAF, /* 0x9C-0x9F */ 0xA6, 0xB0, 0xA6, 0xB1, 0x00, 0x00, 0xA6, 0xB2, /* 0xA0-0xA3 */ 0xA6, 0xB3, 0xA6, 0xB4, 0xA6, 0xB5, 0xA6, 0xB6, /* 0xA4-0xA7 */ 0xA6, 0xB7, 0xA6, 0xB8, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */ 0x00, 0x00, 0xA6, 0xC1, 0xA6, 0xC2, 0xA6, 0xC3, /* 0xB0-0xB3 */ 0xA6, 0xC4, 0xA6, 0xC5, 0xA6, 0xC6, 0xA6, 0xC7, /* 0xB4-0xB7 */ 0xA6, 0xC8, 0xA6, 0xC9, 0xA6, 0xCA, 0xA6, 0xCB, /* 0xB8-0xBB */ 0xA6, 0xCC, 0xA6, 0xCD, 0xA6, 0xCE, 0xA6, 0xCF, /* 0xBC-0xBF */ 0xA6, 0xD0, 0xA6, 0xD1, 0x00, 0x00, 0xA6, 0xD2, /* 0xC0-0xC3 */ 0xA6, 0xD3, 0xA6, 0xD4, 0xA6, 0xD5, 0xA6, 0xD6, /* 0xC4-0xC7 */ 0xA6, 0xD7, 0xA6, 0xD8, 0x00, 0x00, 0x00, 0x00, /* 0xC8-0xCB */ }; static const unsigned char u2c_04[512] = { 0x00, 0x00, 0xA7, 0xA7, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0xA7, 0xA1, 0xA7, 0xA2, 0xA7, 0xA3, 0xA7, 0xA4, /* 0x10-0x13 */ 0xA7, 0xA5, 0xA7, 0xA6, 0xA7, 0xA8, 0xA7, 0xA9, /* 0x14-0x17 */ 0xA7, 0xAA, 0xA7, 0xAB, 0xA7, 0xAC, 0xA7, 0xAD, /* 0x18-0x1B */ 0xA7, 0xAE, 0xA7, 0xAF, 0xA7, 0xB0, 0xA7, 0xB1, /* 0x1C-0x1F */ 0xA7, 0xB2, 0xA7, 0xB3, 0xA7, 0xB4, 0xA7, 0xB5, /* 0x20-0x23 */ 0xA7, 0xB6, 0xA7, 0xB7, 0xA7, 0xB8, 0xA7, 0xB9, /* 0x24-0x27 */ 0xA7, 0xBA, 0xA7, 0xBB, 0xA7, 0xBC, 0xA7, 0xBD, /* 0x28-0x2B */ 0xA7, 0xBE, 0xA7, 0xBF, 0xA7, 0xC0, 0xA7, 0xC1, /* 0x2C-0x2F */ 0xA7, 0xD1, 0xA7, 0xD2, 0xA7, 0xD3, 0xA7, 0xD4, /* 0x30-0x33 */ 0xA7, 0xD5, 0xA7, 0xD6, 0xA7, 0xD8, 0xA7, 0xD9, /* 0x34-0x37 */ 0xA7, 0xDA, 0xA7, 0xDB, 0xA7, 0xDC, 0xA7, 0xDD, /* 0x38-0x3B */ 0xA7, 0xDE, 0xA7, 0xDF, 0xA7, 0xE0, 0xA7, 0xE1, /* 0x3C-0x3F */ 0xA7, 0xE2, 0xA7, 0xE3, 0xA7, 0xE4, 0xA7, 0xE5, /* 0x40-0x43 */ 0xA7, 0xE6, 0xA7, 0xE7, 0xA7, 0xE8, 0xA7, 0xE9, /* 0x44-0x47 */ 0xA7, 0xEA, 0xA7, 0xEB, 0xA7, 0xEC, 0xA7, 0xED, /* 0x48-0x4B */ 0xA7, 0xEE, 0xA7, 0xEF, 0xA7, 0xF0, 0xA7, 0xF1, /* 0x4C-0x4F */ 0x00, 0x00, 0xA7, 0xD7, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */ }; static const unsigned char u2c_20[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0xA9, 0x5C, 0x00, 0x00, 0x00, 0x00, 0xA8, 0x43, /* 0x10-0x13 */ 0xA1, 0xAA, 0xA8, 0x44, 0xA1, 0xAC, 0x00, 0x00, /* 0x14-0x17 */ 0xA1, 0xAE, 0xA1, 0xAF, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0xA1, 0xB0, 0xA1, 0xB1, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */ 0x00, 0x00, 0xA8, 0x45, 0xA1, 0xAD, 0x00, 0x00, /* 0x24-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0xA1, 0xEB, 0x00, 0x00, 0xA1, 0xE4, 0xA1, 0xE5, /* 0x30-0x33 */ 0x00, 0x00, 0xA8, 0x46, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xF9, /* 0x38-0x3B */ 0x00, 0x00, 0x00, 0x00, 0xA3, 0xFE, 0x00, 0x00, /* 0x3C-0x3F */ }; static const unsigned char u2c_21[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xE6, /* 0x00-0x03 */ 0x00, 0x00, 0xA8, 0x47, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0xA8, 0x48, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */ 0x00, 0x00, 0x00, 0x00, 0xA1, 0xED, 0x00, 0x00, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0xA9, 0x59, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */ 0xA2, 0xF1, 0xA2, 0xF2, 0xA2, 0xF3, 0xA2, 0xF4, /* 0x60-0x63 */ 0xA2, 0xF5, 0xA2, 0xF6, 0xA2, 0xF7, 0xA2, 0xF8, /* 0x64-0x67 */ 0xA2, 0xF9, 0xA2, 0xFA, 0xA2, 0xFB, 0xA2, 0xFC, /* 0x68-0x6B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */ 0xA2, 0xA1, 0xA2, 0xA2, 0xA2, 0xA3, 0xA2, 0xA4, /* 0x70-0x73 */ 0xA2, 0xA5, 0xA2, 0xA6, 0xA2, 0xA7, 0xA2, 0xA8, /* 0x74-0x77 */ 0xA2, 0xA9, 0xA2, 0xAA, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */ 0xA1, 0xFB, 0xA1, 0xFC, 0xA1, 0xFA, 0xA1, 0xFD, /* 0x90-0x93 */ 0x00, 0x00, 0x00, 0x00, 0xA8, 0x49, 0xA8, 0x4A, /* 0x94-0x97 */ 0xA8, 0x4B, 0xA8, 0x4C, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */ }; static const unsigned char u2c_22[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0xA1, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xC7, /* 0x0C-0x0F */ 0x00, 0x00, 0xA1, 0xC6, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */ 0x00, 0x00, 0xA8, 0x4D, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */ 0xA1, 0xE3, 0x00, 0x00, 0xA1, 0xCC, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0xA1, 0xD8, 0xA1, 0xDE, 0xA8, 0x4E, /* 0x1C-0x1F */ 0xA1, 0xCF, 0x00, 0x00, 0x00, 0x00, 0xA8, 0x4F, /* 0x20-0x23 */ 0x00, 0x00, 0xA1, 0xCE, 0x00, 0x00, 0xA1, 0xC4, /* 0x24-0x27 */ 0xA1, 0xC5, 0xA1, 0xC9, 0xA1, 0xC8, 0xA1, 0xD2, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0xA1, 0xD3, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0xA1, 0xE0, 0xA1, 0xDF, 0xA1, 0xC3, 0xA1, 0xCB, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */ 0xA1, 0xAB, 0xA1, 0xD7, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0xA1, 0xD6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */ 0xA1, 0xD5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */ 0x00, 0x00, 0x00, 0x00, 0xA8, 0x50, 0x00, 0x00, /* 0x50-0x53 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */ 0xA1, 0xD9, 0xA1, 0xD4, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */ 0xA1, 0xDC, 0xA1, 0xDD, 0xA8, 0x51, 0xA8, 0x52, /* 0x64-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */ 0x00, 0x00, 0x00, 0x00, 0xA1, 0xDA, 0xA1, 0xDB, /* 0x6C-0x6F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x93 */ 0x00, 0x00, 0xA8, 0x92, 0x00, 0x00, 0x00, 0x00, /* 0x94-0x97 */ 0x00, 0x00, 0xA1, 0xD1, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x9C-0x9F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA0-0xA3 */ 0x00, 0x00, 0xA1, 0xCD, 0x00, 0x00, 0x00, 0x00, /* 0xA4-0xA7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB0-0xB3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB4-0xB7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB8-0xBB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA8, 0x53, /* 0xBC-0xBF */ }; static const unsigned char u2c_23[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0xA1, 0xD0, 0x00, 0x00, /* 0x10-0x13 */ }; static const unsigned char u2c_24[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */ 0xA2, 0xD9, 0xA2, 0xDA, 0xA2, 0xDB, 0xA2, 0xDC, /* 0x60-0x63 */ 0xA2, 0xDD, 0xA2, 0xDE, 0xA2, 0xDF, 0xA2, 0xE0, /* 0x64-0x67 */ 0xA2, 0xE1, 0xA2, 0xE2, 0x00, 0x00, 0x00, 0x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 0xA8, 0x5A, 0xA8, 0x5B, /* 0x54-0x57 */ 0xA8, 0x5C, 0xA8, 0x5D, 0xA8, 0x5E, 0xA8, 0x5F, /* 0x58-0x5B */ 0xA8, 0x60, 0xA8, 0x61, 0xA8, 0x62, 0xA8, 0x63, /* 0x5C-0x5F */ 0xA8, 0x64, 0xA8, 0x65, 0xA8, 0x66, 0xA8, 0x67, /* 0x60-0x63 */ 0xA8, 0x68, 0xA8, 0x69, 0xA8, 0x6A, 0xA8, 0x6B, /* 0x64-0x67 */ 0xA8, 0x6C, 0xA8, 0x6D, 0xA8, 0x6E, 0xA8, 0x6F, /* 0x68-0x6B */ 0xA8, 0x70, 0xA8, 0x71, 0xA8, 0x72, 0xA8, 0x73, /* 0x6C-0x6F */ 0xA8, 0x74, 0xA8, 0x75, 0xA8, 0x76, 0xA8, 0x77, /* 0x70-0x73 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0x00, 0x00, 0xA8, 0x78, 0xA8, 0x79, 0xA8, 0x7A, /* 0x80-0x83 */ 0xA8, 0x7B, 0xA8, 0x7C, 0xA8, 0x7D, 0xA8, 0x7E, /* 0x84-0x87 */ 0xA8, 0x80, 0xA8, 0x81, 0xA8, 0x82, 0xA8, 0x83, /* 0x88-0x8B */ 0xA8, 0x84, 0xA8, 0x85, 0xA8, 0x86, 0xA8, 0x87, /* 0x8C-0x8F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA8, 0x88, /* 0x90-0x93 */ 0xA8, 0x89, 0xA8, 0x8A, 0x00, 0x00, 0x00, 0x00, /* 0x94-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x9C-0x9F */ 0xA1, 0xF6, 0xA1, 0xF5, 0x00, 0x00, 0x00, 0x00, /* 0xA0-0xA3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA4-0xA7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */ 0x00, 0x00, 0x00, 0x00, 0xA1, 0xF8, 0xA1, 0xF7, /* 0xB0-0xB3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB4-0xB7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB8-0xBB */ 0xA8, 0x8B, 0xA8, 0x8C, 0x00, 0x00, 0x00, 0x00, /* 0xBC-0xBF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0-0xC3 */ 0x00, 0x00, 0x00, 0x00, 0xA1, 0xF4, 0xA1, 0xF3, /* 0xC4-0xC7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xF0, /* 0xC8-0xCB */ 0x00, 0x00, 0x00, 0x00, 0xA1, 0xF2, 0xA1, 0xF1, /* 0xCC-0xCF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD0-0xD3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD4-0xD7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD8-0xDB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xDC-0xDF */ 0x00, 0x00, 0x00, 0x00, 0xA8, 0x8D, 0xA8, 0x8E, /* 0xE0-0xE3 */ 0xA8, 0x8F, 0xA8, 0x90, 0x00, 0x00, 0x00, 0x00, /* 0xE4-0xE7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xE8-0xEB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xEC-0xEF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xF0-0xF3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xF4-0xF7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xF8-0xFB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xFC-0xFF */ }; static const unsigned char u2c_26[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0xA1, 0xEF, 0xA1, 0xEE, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0xA8, 0x91, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */ 0xA1, 0xE2, 0x00, 0x00, 0xA1, 0xE1, 0x00, 0x00, /* 0x40-0x43 */ }; static const unsigned char u2c_30[512] = { 0xA1, 0xA1, 0xA1, 0xA2, 0xA1, 0xA3, 0xA1, 0xA8, /* 0x00-0x03 */ 0x00, 0x00, 0xA1, 0xA9, 0xA9, 0x65, 0xA9, 0x96, /* 0x04-0x07 */ 0xA1, 0xB4, 0xA1, 0xB5, 0xA1, 0xB6, 0xA1, 0xB7, /* 0x08-0x0B */ 0xA1, 0xB8, 0xA1, 0xB9, 0xA1, 0xBA, 0xA1, 0xBB, /* 0x0C-0x0F */ 0xA1, 0xBE, 0xA1, 0xBF, 0xA8, 0x93, 0xA1, 0xFE, /* 0x10-0x13 */ 0xA1, 0xB2, 0xA1, 0xB3, 0xA1, 0xBC, 0xA1, 0xBD, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0xA8, 0x94, 0xA8, 0x95, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0xA9, 0x40, 0xA9, 0x41, 0xA9, 0x42, /* 0x20-0x23 */ 0xA9, 0x43, 0xA9, 0x44, 0xA9, 0x45, 0xA9, 0x46, /* 0x24-0x27 */ 0xA9, 0x47, 0xA9, 0x48, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0x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/* 0xFC-0xFF */ }; static const unsigned char u2c_31[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0xA8, 0xC5, 0xA8, 0xC6, 0xA8, 0xC7, /* 0x04-0x07 */ 0xA8, 0xC8, 0xA8, 0xC9, 0xA8, 0xCA, 0xA8, 0xCB, /* 0x08-0x0B */ 0xA8, 0xCC, 0xA8, 0xCD, 0xA8, 0xCE, 0xA8, 0xCF, /* 0x0C-0x0F */ 0xA8, 0xD0, 0xA8, 0xD1, 0xA8, 0xD2, 0xA8, 0xD3, /* 0x10-0x13 */ 0xA8, 0xD4, 0xA8, 0xD5, 0xA8, 0xD6, 0xA8, 0xD7, /* 0x14-0x17 */ 0xA8, 0xD8, 0xA8, 0xD9, 0xA8, 0xDA, 0xA8, 0xDB, /* 0x18-0x1B */ 0xA8, 0xDC, 0xA8, 0xDD, 0xA8, 0xDE, 0xA8, 0xDF, /* 0x1C-0x1F */ 0xA8, 0xE0, 0xA8, 0xE1, 0xA8, 0xE2, 0xA8, 0xE3, /* 0x20-0x23 */ 0xA8, 0xE4, 0xA8, 0xE5, 0xA8, 0xE6, 0xA8, 0xE7, /* 0x24-0x27 */ 0xA8, 0xE8, 0xA8, 0xE9, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */ 0x00, 0x00, 0x00, 0x00, 0xD2, 0xBB, 0xB6, 0xFE, /* 0x90-0x93 */ 0xC8, 0xFD, 0xCB, 0xC4, 0xC9, 0xCF, 0xD6, 0xD0, /* 0x94-0x97 */ 0xCF, 0xC2, 0xBC, 0xD7, 0xD2, 0xD2, 0xB1, 0xFB, /* 0x98-0x9B */ 0xB6, 0xA1, 0xCC, 0xEC, 0xB5, 0xD8, 0xC8, 0xCB, /* 0x9C-0x9F */ }; static const unsigned char u2c_32[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0xA2, 0xE5, 0xA2, 0xE6, 0xA2, 0xE7, 0xA2, 0xE8, /* 0x20-0x23 */ 0xA2, 0xE9, 0xA2, 0xEA, 0xA2, 0xEB, 0xA2, 0xEC, /* 0x24-0x27 */ 0xA2, 0xED, 0xA2, 0xEE, 0xD4, 0xC2, 0xBB, 0xF0, /* 0x28-0x2B */ 0xCB, 0xAE, 0xC4, 0xBE, 0xBD, 0xF0, 0xCD, 0xC1, /* 0x2C-0x2F */ 0xC8, 0xD5, 0xA9, 0x5A, 0xD3, 0xD0, 0xC9, 0xE7, /* 0x30-0x33 */ 0xC3, 0xFB, 0xCC, 0xD8, 0xB2, 0xC6, 0xD7, 0xA3, /* 0x34-0x37 */ 0xC0, 0xCD, 0xB4, 0xFA, 0xBA, 0xF4, 0xD1, 0xA7, /* 0x38-0x3B */ 0xBC, 0xE0, 0xC6, 0xF3, 0xD7, 0xCA, 0xD0, 0xAD, /* 0x3C-0x3F */ 0xBC, 0xC0, 0xD0, 0xDD, 0xD7, 0xD4, 0xD6, 0xC1, /* 0x40-0x43 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0xD2, 0xBB, 0xB6, 0xFE, 0xC8, 0xFD, 0xCB, 0xC4, /* 0x80-0x83 */ 0xCE, 0xE5, 0xC1, 0xF9, 0xC6, 0xDF, 0xB0, 0xCB, /* 0x84-0x87 */ 0xBE, 0xC5, 0xCA, 0xAE, 0xD4, 0xC2, 0xBB, 0xF0, /* 0x88-0x8B */ 0xCB, 0xAE, 0xC4, 0xBE, 0xBD, 0xF0, 0xCD, 0xC1, /* 0x8C-0x8F */ 0xC8, 0xD5, 0xD6, 0xEA, 0xD3, 0xD0, 0xC9, 0xE7, /* 0x90-0x93 */ 0xC3, 0xFB, 0xCC, 0xD8, 0xB2, 0xC6, 0xD7, 0xA3, /* 0x94-0x97 */ 0xC0, 0xCD, 0xC3, 0xD8, 0xC4, 0xD0, 0xC5, 0xAE, /* 0x98-0x9B */ 0xCA, 0xCA, 0xD3, 0xC5, 0x00, 0x00, 0xD7, 0xA2, /* 0x9C-0x9F */ 0xCF, 0xEE, 0xD0, 0xDD, 0xD0, 0xB4, 0xA9, 0x49, /* 0xA0-0xA3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA4-0xA7 */ 0x00, 0x00, 0xD2, 0xBD, 0xD7, 0xDA, 0xD1, 0xA7, /* 0xA8-0xAB */ 0xBC, 0xE0, 0xC6, 0xF3, 0xD7, 0xCA, 0xD0, 0xAD, /* 0xAC-0xAF */ 0xD2, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB0-0xB3 */ }; static const unsigned char u2c_33[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */ 0x00, 0x00, 0x00, 0x00, 0xA9, 0x4A, 0xA9, 0x4B, /* 0x8C-0x8F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x93 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x94-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */ 0xA9, 0x4C, 0xA9, 0x4D, 0xA9, 0x4E, 0x00, 0x00, /* 0x9C-0x9F */ 0x00, 0x00, 0xA9, 0x4F, 0x00, 0x00, 0x00, 0x00, /* 0xA0-0xA3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA4-0xA7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB0-0xB3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB4-0xB7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB8-0xBB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xBC-0xBF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0-0xC3 */ 0xA9, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC4-0xC7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC8-0xCB */ 0x00, 0x00, 0x00, 0x00, 0xA9, 0x51, 0x00, 0x00, /* 0xCC-0xCF */ 0x00, 0x00, 0xA9, 0x52, 0xA9, 0x53, 0x00, 0x00, /* 0xD0-0xD3 */ 0x00, 0x00, 0xA9, 0x54, 0x00, 0x00, 0x00, 0x00, /* 0xD4-0xD7 */ }; static const unsigned char u2c_4E[512] = { 0xD2, 0xBB, 0xB6, 0xA1, 0x81, 0x40, 0xC6, 0xDF, /* 0x00-0x03 */ 0x81, 0x41, 0x81, 0x42, 0x81, 0x43, 0xCD, 0xF2, /* 0x04-0x07 */ 0xD5, 0xC9, 0xC8, 0xFD, 0xC9, 0xCF, 0xCF, 0xC2, /* 0x08-0x0B */ 0xD8, 0xA2, 0xB2, 0xBB, 0xD3, 0xEB, 0x81, 0x44, /* 0x0C-0x0F */ 0xD8, 0xA4, 0xB3, 0xF3, 0x81, 0x45, 0xD7, 0xA8, /* 0x10-0x13 */ 0xC7, 0xD2, 0xD8, 0xA7, 0xCA, 0xC0, 0x81, 0x46, /* 0x14-0x17 */ 0xC7, 0xF0, 0xB1, 0xFB, 0xD2, 0xB5, 0xB4, 0xD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F, 0xB0, 0xCF, 0xE7, 0x81, 0x5F, 0x81, 0x60, /* 0x60-0x63 */ 0x81, 0x61, 0x81, 0x62, 0xCA, 0xE9, 0x81, 0x63, /* 0x64-0x67 */ 0x81, 0x64, 0xD8, 0xC0, 0x81, 0x65, 0x81, 0x66, /* 0x68-0x6B */ 0x81, 0x67, 0x81, 0x68, 0x81, 0x69, 0x81, 0x6A, /* 0x6C-0x6F */ 0xC2, 0xF2, 0xC2, 0xD2, 0x81, 0x6B, 0xC8, 0xE9, /* 0x70-0x73 */ 0x81, 0x6C, 0x81, 0x6D, 0x81, 0x6E, 0x81, 0x6F, /* 0x74-0x77 */ 0x81, 0x70, 0x81, 0x71, 0x81, 0x72, 0x81, 0x73, /* 0x78-0x7B */ 0x81, 0x74, 0x81, 0x75, 0xC7, 0xAC, 0x81, 0x76, /* 0x7C-0x7F */ 0x81, 0x77, 0x81, 0x78, 0x81, 0x79, 0x81, 0x7A, /* 0x80-0x83 */ 0x81, 0x7B, 0x81, 0x7C, 0xC1, 0xCB, 0x81, 0x7D, /* 0x84-0x87 */ 0xD3, 0xE8, 0xD5, 0xF9, 0x81, 0x7E, 0xCA, 0xC2, /* 0x88-0x8B */ 0xB6, 0xFE, 0xD8, 0xA1, 0xD3, 0xDA, 0xBF, 0xF7, /* 0x8C-0x8F */ 0x81, 0x80, 0xD4, 0xC6, 0xBB, 0xA5, 0xD8, 0xC1, /* 0x90-0x93 */ 0xCE, 0xE5, 0xBE, 0xAE, 0x81, 0x81, 0x81, 0x82, /* 0x94-0x97 */ 0xD8, 0xA8, 0x81, 0x83, 0xD1, 0xC7, 0xD0, 0xA9, /* 0x98-0x9B */ 0x81, 0x84, 0x81, 0x85, 0x81, 0x86, 0xD8, 0xBD, /* 0x9C-0x9F */ 0xD9, 0xEF, 0xCD, 0xF6, 0xBF, 0xBA, 0x81, 0x87, /* 0xA0-0xA3 */ 0xBD, 0xBB, 0xBA, 0xA5, 0xD2, 0xE0, 0xB2, 0xFA, /* 0x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* 0xFC-0xFF */ }; static const unsigned char u2c_50[512] = { 0x82, 0x74, 0x82, 0x75, 0x82, 0x76, 0x82, 0x77, /* 0x00-0x03 */ 0x82, 0x78, 0x82, 0x79, 0x82, 0x7A, 0x82, 0x7B, /* 0x04-0x07 */ 0x82, 0x7C, 0x82, 0x7D, 0x82, 0x7E, 0x82, 0x80, /* 0x08-0x0B */ 0xD9, 0xC4, 0xB1, 0xB6, 0x82, 0x81, 0xD9, 0xBF, /* 0x0C-0x0F */ 0x82, 0x82, 0x82, 0x83, 0xB5, 0xB9, 0x82, 0x84, /* 0x10-0x13 */ 0xBE, 0xF3, 0x82, 0x85, 0x82, 0x86, 0x82, 0x87, /* 0x14-0x17 */ 0xCC, 0xC8, 0xBA, 0xF2, 0xD2, 0xD0, 0x82, 0x88, /* 0x18-0x1B */ 0xD9, 0xC3, 0x82, 0x89, 0x82, 0x8A, 0xBD, 0xE8, /* 0x1C-0x1F */ 0x82, 0x8B, 0xB3, 0xAB, 0x82, 0x8C, 0x82, 0x8D, /* 0x20-0x23 */ 0x82, 0x8E, 0xD9, 0xC5, 0xBE, 0xEB, 0x82, 0x8F, /* 0x24-0x27 */ 0xD9, 0xC6, 0xD9, 0xBB, 0xC4, 0xDF, 0x82, 0x90, /* 0x28-0x2B */ 0xD9, 0xBE, 0xD9, 0xC1, 0xD9, 0xC0, 0x82, 0x91, /* 0x2C-0x2F */ 0x82, 0x92, 0x82, 0x93, 0x82, 0x94, 0x82, 0x95, /* 0x30-0x33 */ 0x82, 0x96, 0x82, 0x97, 0x82, 0x98, 0x82, 0x99, /* 0x34-0x37 */ 0x82, 0x9A, 0x82, 0x9B, 0xD5, 0xAE, 0x82, 0x9C, /* 0x38-0x3B */ 0xD6, 0xB5, 0x82, 0x9D, 0xC7, 0xE3, 0x82, 0x9E, /* 0x3C-0x3F */ 0x82, 0x9F, 0x82, 0xA0, 0x82, 0xA1, 0xD9, 0xC8, /* 0x40-0x43 */ 0x82, 0xA2, 0x82, 0xA3,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*/ 0x82, 0xD8, 0xB0, 0xF8, 0x82, 0xD9, 0x82, 0xDA, /* 0x8C-0x8F */ 0x82, 0xDB, 0x82, 0xDC, 0x82, 0xDD, 0x82, 0xDE, /* 0x90-0x93 */ 0x82, 0xDF, 0x82, 0xE0, 0x82, 0xE1, 0x82, 0xE2, /* 0x94-0x97 */ 0x82, 0xE3, 0x82, 0xE4, 0x82, 0xE5, 0x82, 0xE6, /* 0x98-0x9B */ 0x82, 0xE7, 0x82, 0xE8, 0x82, 0xE9, 0x82, 0xEA, /* 0x9C-0x9F */ 0x82, 0xEB, 0x82, 0xEC, 0x82, 0xED, 0xB4, 0xF6, /* 0xA0-0xA3 */ 0x82, 0xEE, 0xD9, 0xCE, 0x82, 0xEF, 0xD9, 0xCF, /* 0xA4-0xA7 */ 0xB4, 0xA2, 0xD9, 0xD0, 0x82, 0xF0, 0x82, 0xF1, /* 0xA8-0xAB */ 0xB4, 0xDF, 0x82, 0xF2, 0x82, 0xF3, 0x82, 0xF4, /* 0xAC-0xAF */ 0x82, 0xF5, 0x82, 0xF6, 0xB0, 0xC1, 0x82, 0xF7, /* 0xB0-0xB3 */ 0x82, 0xF8, 0x82, 0xF9, 0x82, 0xFA, 0x82, 0xFB, /* 0xB4-0xB7 */ 0x82, 0xFC, 0x82, 0xFD, 0xD9, 0xD1, 0xC9, 0xB5, /* 0xB8-0xBB */ 0x82, 0xFE, 0x83, 0x40, 0x83, 0x41, 0x83, 0x42, /* 0xBC-0xBF */ 0x83, 0x43, 0x83, 0x44, 0x83, 0x45, 0x83, 0x46, /* 0xC0-0xC3 */ 0x83, 0x47, 0x83, 0x48, 0x83, 0x49, 0x83, 0x4A, /* 0xC4-0xC7 */ 0x83, 0x4B, 0x83, 0x4C, 0x83, 0x4D, 0x83, 0x4E, /* 0xC8-0xCB */ 0x83, 0x4F, 0x83, 0x50, 0x83, 0x51, 0xCF, 0xF1, /* 0xCC-0xCF */ 0x83, 0x52, 0x83, 0x53, 0x83, 0x54, 0x83, 0x55, /* 0xD0-0xD3 */ 0x83, 0x56, 0x83, 0x57, 0xD9, 0xD2, 0x83, 0x58, /* 0xD4-0xD7 */ 0x83, 0x59, 0x83, 0x5A, 0xC1, 0xC5, 0x83, 0x5B, /* 0xD8-0xDB */ 0x83, 0x5C, 0x83, 0x5D, 0x83, 0x5E, 0x83, 0x5F, /* 0xDC-0xDF */ 0x83, 0x60, 0x83, 0x61, 0x83, 0x62, 0x83, 0x63, /* 0xE0-0xE3 */ 0x83, 0x64, 0x83, 0x65, 0xD9, 0xD6, 0xC9, 0xAE, /* 0xE4-0xE7 */ 0x83, 0x66, 0x83, 0x67, 0x83, 0x68, 0x83, 0x69, /* 0xE8-0xEB */ 0xD9, 0xD5, 0xD9, 0xD4, 0xD9, 0xD7, 0x83, 0x6A, /* 0xEC-0xEF */ 0x83, 0x6B, 0x83, 0x6C, 0x83, 0x6D, 0xCB, 0xDB, /* 0xF0-0xF3 */ 0x83, 0x6E, 0xBD, 0xA9, 0x83, 0x6F, 0x83, 0x70, /* 0xF4-0xF7 */ 0x83, 0x71, 0x83, 0x72, 0x83, 0x73, 0xC6, 0xA7, /* 0xF8-0xFB */ 0x83, 0x74, 0x83, 0x75, 0x83, 0x76, 0x83, 0x77, /* 0xFC-0xFF */ }; static const unsigned char u2c_51[512] = { 0x83, 0x78, 0x83, 0x79, 0x83, 0x7A, 0x83, 0x7B, /* 0x00-0x03 */ 0x83, 0x7C, 0x83, 0x7D, 0xD9, 0xD3, 0xD9, 0xD8, /* 0x04-0x07 */ 0x83, 0x7E, 0x83, 0x80, 0x83, 0x81, 0xD9, 0xD9, /* 0x08-0x0B */ 0x83, 0x82, 0x83, 0x83, 0x83, 0x84, 0x83, 0x85, /* 0x0C-0x0F */ 0x83, 0x86, 0x83, 0x87, 0xC8, 0xE5, 0x83, 0x88, /* 0x10-0x13 */ 0x83, 0x89, 0x83, 0x8A, 0x83, 0x8B, 0x83, 0x8C, /* 0x14-0x17 */ 0x83, 0x8D, 0x83, 0x8E, 0x83, 0x8F, 0x83, 0x90, /* 0x18-0x1B */ 0x83, 0x91, 0x83, 0x92, 0x83, 0x93, 0x83, 0x94, /* 0x1C-0x1F */ 0x83, 0x95, 0xC0, 0xDC, 0x83, 0x96, 0x83, 0x97, /* 0x20-0x23 */ 0x83, 0x98, 0x83, 0x99, 0x83, 0x9A, 0x83, 0x9B, /* 0x24-0x27 */ 0x83, 0x9C, 0x83, 0x9D, 0x83, 0x9E, 0x83, 0x9F, /* 0x28-0x2B */ 0x83, 0xA0, 0x83, 0xA1, 0x83, 0xA2, 0x83, 0xA3, /* 0x2C-0x2F */ 0x83, 0xA4, 0x83, 0xA5, 0x83, 0xA6, 0x83, 0xA7, /* 0x30-0x33 */ 0x83, 0xA8, 0x83, 0xA9, 0x83, 0xAA, 0x83, 0xAB, /* 0x34-0x37 */ 0x83, 0xAC, 0x83, 0xAD, 0x83, 0xAE, 0x83, 0xAF, /* 0x38-0x3B */ 0x83, 0xB0, 0x83, 0xB1, 0x83, 0xB2, 0xB6, 0xF9, /* 0x3C-0x3F */ 0xD8, 0xA3, 0xD4, 0xCA, 0x83, 0xB3, 0xD4, 0xAA, /* 0x40-0x43 */ 0xD0, 0xD6, 0xB3, 0xE4, 0xD5, 0xD7, 0x83, 0xB4, /* 0x44-0x47 */ 0xCF, 0xC8, 0xB9, 0xE2, 0x83, 0xB5, 0xBF, 0xCB, /* 0x48-0x4B */ 0x83, 0xB6, 0xC3, 0xE2, 0x83, 0xB7, 0x83, 0xB8, /* 0x4C-0x4F */ 0x83, 0xB9, 0xB6, 0xD2, 0x83, 0xBA, 0x83, 0xBB, /* 0x50-0x53 */ 0xCD, 0xC3, 0xD9, 0xEE, 0xD9, 0xF0, 0x83, 0xBC, /* 0x54-0x57 */ 0x83, 0xBD, 0x83, 0xBE, 0xB5, 0xB3, 0x83, 0xBF, /* 0x58-0x5B */ 0xB6, 0xB5, 0x83, 0xC0, 0x83, 0xC1, 0x83, 0xC2, /* 0x5C-0x5F */ 0x83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0x4D, 0xD9, 0xEC, /* 0xE8-0xEB */ 0x84, 0x4E, 0xC6, 0xBE, 0x84, 0x4F, 0xBF, 0xAD, /* 0xEC-0xEF */ 0xBB, 0xCB, 0x84, 0x50, 0x84, 0x51, 0xB5, 0xCA, /* 0xF0-0xF3 */ 0x84, 0x52, 0xDB, 0xC9, 0xD0, 0xD7, 0x84, 0x53, /* 0xF4-0xF7 */ 0xCD, 0xB9, 0xB0, 0xBC, 0xB3, 0xF6, 0xBB, 0xF7, /* 0xF8-0xFB */ 0xDB, 0xCA, 0xBA, 0xAF, 0x84, 0x54, 0xD4, 0xE4, /* 0xFC-0xFF */ }; static const unsigned char u2c_52[512] = { 0xB5, 0xB6, 0xB5, 0xF3, 0xD8, 0xD6, 0xC8, 0xD0, /* 0x00-0x03 */ 0x84, 0x55, 0x84, 0x56, 0xB7, 0xD6, 0xC7, 0xD0, /* 0x04-0x07 */ 0xD8, 0xD7, 0x84, 0x57, 0xBF, 0xAF, 0x84, 0x58, /* 0x08-0x0B */ 0x84, 0x59, 0xDB, 0xBB, 0xD8, 0xD8, 0x84, 0x5A, /* 0x0C-0x0F */ 0x84, 0x5B, 0xD0, 0xCC, 0xBB, 0xAE, 0x84, 0x5C, /* 0x10-0x13 */ 0x84, 0x5D, 0x84, 0x5E, 0xEB, 0xBE, 0xC1, 0xD0, /* 0x14-0x17 */ 0xC1, 0xF5, 0xD4, 0xF2, 0xB8, 0xD5, 0xB4, 0xB4, /* 0x18-0x1B */ 0x84, 0x5F, 0xB3, 0xF5, 0x84, 0x60, 0x84, 0x61, /* 0x1C-0x1F */ 0xC9, 0xBE, 0x84, 0x62, 0x84, 0x63, 0x84, 0x64, /* 0x20-0x23 */ 0xC5, 0xD0, 0x84, 0x65, 0x84, 0x66, 0x84, 0x67, /* 0x24-0x27 */ 0xC5, 0xD9, 0xC0, 0xFB, 0x84, 0x68, 0xB1, 0xF0, /* 0x28-0x2B */ 0x84, 0x69, 0xD8, 0xD9, 0xB9, 0xCE, 0x84, 0x6A, /* 0x2C-0x2F */ 0xB5, 0xBD, 0x84, 0x6B, 0x84, 0x6C, 0xD8, 0xDA, /* 0x30-0x33 */ 0x84, 0x6D, 0x84, 0x6E, 0xD6, 0xC6, 0xCB, 0xA2, /* 0x34-0x37 */ 0xC8, 0xAF, 0xC9, 0xB2, 0xB4, 0xCC, 0xBF, 0xCC, /* 0x38-0x3B */ 0x84, 0x6F, 0xB9, 0xF4, 0x84, 0x70, 0xD8, 0xDB, /* 0x3C-0x3F */ 0xD8, 0xDC, 0xB6, 0xE7, 0xBC, 0xC1, 0xCC, 0xEA, /* 0x40-0x43 */ 0x84, 0x71, 0x84, 0x72, 0x84, 0x73, 0x84, 0x74, /* 0x44-0x47 */ 0x84, 0x75, 0x84, 0x76, 0xCF, 0xF7, 0x84, 0x77, /* 0x48-0x4B */ 0xD8, 0xDD, 0xC7, 0xB0, 0x84, 0x78, 0x84, 0x79, /* 0x4C-0x4F */ 0xB9, 0xD0, 0xBD, 0xA3, 0x84, 0x7A, 0x84, 0x7B, /* 0x50-0x53 */ 0xCC, 0xDE, 0x84, 0x7C, 0xC6, 0xCA, 0x84, 0x7D, /* 0x54-0x57 */ 0x84, 0x7E, 0x84, 0x80, 0x84, 0x81, 0x84, 0x82, /* 0x58-0x5B */ 0xD8, 0xE0, 0x84, 0x83, 0xD8, 0xDE, 0x84, 0x84, /* 0x5C-0x5F */ 0x84, 0x85, 0xD8, 0xDF, 0x84, 0x86, 0x84, 0x87, /* 0x60-0x63 */ 0x84, 0x88, 0xB0, 0xFE, 0x84, 0x89, 0xBE, 0xE7, /* 0x64-0x67 */ 0x84, 0x8A, 0xCA, 0xA3, 0xBC, 0xF4, 0x84, 0x8B, /* 0x68-0x6B */ 0x84, 0x8C, 0x84, 0x8D, 0x84, 0x8E, 0xB8, 0xB1, /* 0x6C-0x6F */ 0x84, 0x8F, 0x84, 0x90, 0xB8, 0xEE, 0x84, 0x91, /* 0x70-0x73 */ 0x84, 0x92, 0x84, 0x93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; static const unsigned char u2c_53[512] = { 0xD4, 0xC8, 0x84, 0xF5, 0x84, 0xF6, 0x84, 0xF7, /* 0x00-0x03 */ 0x84, 0xF8, 0xB0, 0xFC, 0xB4, 0xD2, 0x84, 0xF9, /* 0x04-0x07 */ 0xD0, 0xD9, 0x84, 0xFA, 0x84, 0xFB, 0x84, 0xFC, /* 0x08-0x0B */ 0x84, 0xFD, 0xD9, 0xE9, 0x84, 0xFE, 0xDE, 0xCB, /* 0x0C-0x0F */ 0xD9, 0xEB, 0x85, 0x40, 0x85, 0x41, 0x85, 0x42, /* 0x10-0x13 */ 0x85, 0x43, 0xD8, 0xB0, 0xBB, 0xAF, 0xB1, 0xB1, /* 0x14-0x17 */ 0x85, 0x44, 0xB3, 0xD7, 0xD8, 0xCE, 0x85, 0x45, /* 0x18-0x1B */ 0x85, 0x46, 0xD4, 0xD1, 0x85, 0x47, 0x85, 0x48, /* 0x1C-0x1F */ 0xBD, 0xB3, 0xBF, 0xEF, 0x85, 0x49, 0xCF, 0xBB, /* 0x20-0x23 */ 0x85, 0x4A, 0x85, 0x4B, 0xD8, 0xD0, 0x85, 0x4C, /* 0x24-0x27 */ 0x85, 0x4D, 0x85, 0x4E, 0xB7, 0xCB, 0x85, 0x4F, /* 0x28-0x2B */ 0x85, 0x50, 0x85, 0x51, 0xD8, 0xD1, 0x85, 0x52, /* 0x2C-0x2F */ 0x85, 0x53, 0x85, 0x54, 0x85, 0x55, 0x85, 0x56, /* 0x30-0x33 */ 0x85, 0x57, 0x85, 0x58, 0x85, 0x59, 0x85, 0x5A, /* 0x34-0x37 */ 0x85, 0x5B, 0xC6, 0xA5, 0xC7, 0xF8, 0xD2, 0xBD, /* 0x38-0x3B */ 0x85, 0x5C, 0x85, 0x5D, 0xD8, 0xD2, 0xC4, 0xE4, /* 0x3C-0x3F */ 0x85, 0x5E, 0xCA, 0xAE, 0x85, 0x5F, 0xC7, 0xA7, /* 0x40-0x43 */ 0x85, 0x60, 0xD8, 0xA6, 0x85,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0x55, 0x86, 0x56, /* 0xE0-0xE3 */ 0x86, 0x57, 0xB8, 0xE7, 0xC5, 0xB6, 0xDF, 0xEA, /* 0xE4-0xE7 */ 0xC9, 0xDA, 0xC1, 0xA8, 0xC4, 0xC4, 0x86, 0x58, /* 0xE8-0xEB */ 0x86, 0x59, 0xBF, 0xDE, 0xCF, 0xF8, 0x86, 0x5A, /* 0xEC-0xEF */ 0x86, 0x5B, 0x86, 0x5C, 0xD5, 0xDC, 0xDF, 0xEE, /* 0xF0-0xF3 */ 0x86, 0x5D, 0x86, 0x5E, 0x86, 0x5F, 0x86, 0x60, /* 0xF4-0xF7 */ 0x86, 0x61, 0x86, 0x62, 0xB2, 0xB8, 0x86, 0x63, /* 0xF8-0xFB */ 0xBA, 0xDF, 0xDF, 0xEC, 0x86, 0x64, 0xDB, 0xC1, /* 0xFC-0xFF */ }; static const unsigned char u2c_55[512] = { 0x86, 0x65, 0xD1, 0xE4, 0x86, 0x66, 0x86, 0x67, /* 0x00-0x03 */ 0x86, 0x68, 0x86, 0x69, 0xCB, 0xF4, 0xB4, 0xBD, /* 0x04-0x07 */ 0x86, 0x6A, 0xB0, 0xA6, 0x86, 0x6B, 0x86, 0x6C, /* 0x08-0x0B */ 0x86, 0x6D, 0x86, 0x6E, 0x86, 0x6F, 0xDF, 0xF1, /* 0x0C-0x0F */ 0xCC, 0xC6, 0xDF, 0xF2, 0x86, 0x70, 0x86, 0x71, /* 0x10-0x13 */ 0xDF, 0xED, 0x86, 0x72, 0x86, 0x73, 0x86, 0x74, /* 0x14-0x17 */ 0x86, 0x75, 0x86, 0x76, 0x86, 0x77, 0xDF, 0xE9, /* 0x18-0x1B */ 0x86, 0x78, 0x86, 0x79, 0x86, 0x7A, 0x86, 0x7B, /* 0x1C-0x1F */ 0xDF, 0xEB, 0x86, 0x7C, 0xDF, 0xEF, 0xDF, 0xF0, /* 0x20-0x23 */ 0xBB, 0xBD, 0x86, 0x7D, 0x86, 0x7E, 0xDF, 0xF3, /* 0x24-0x27 */ 0x86, 0x80, 0x86, 0x81, 0xDF, 0xF4, 0x86, 0x82, /* 0x28-0x2B */ 0xBB, 0xA3, 0x86, 0x83, 0xCA, 0xDB, 0xCE, 0xA8, /* 0x2C-0x2F */ 0xE0, 0xA7, 0xB3, 0xAA, 0x86, 0x84, 0xE0, 0xA6, /* 0x30-0x33 */ 0x86, 0x85, 0x86, 0x86, 0x86, 0x87, 0xE0, 0xA1, /* 0x34-0x37 */ 0x86, 0x88, 0x86, 0x89, 0x86, 0x8A, 0x86, 0x8B, /* 0x38-0x3B */ 0xDF, 0xFE, 0x86, 0x8C, 0xCD, 0xD9, 0xDF, 0xFC, /* 0x3C-0x3F */ 0x86, 0x8D, 0xDF, 0xFA, 0x86, 0x8E, 0xBF, 0xD0, /* 0x40-0x43 */ 0xD7, 0xC4, 0x86, 0x8F, 0xC9, 0xCC, 0x86, 0x90, /* 0x44-0x47 */ 0x86, 0x91, 0xDF, 0xF8, 0xB0, 0xA1, 0x86, 0x92, /* 0x48-0x4B */ 0x86, 0x93, 0x86, 0x94, 0x86, 0x95, 0x86, 0x96, /* 0x4C-0x4F */ 0xDF, 0xFD, 0x86, 0x97, 0x86, 0x98, 0x86, 0x99, /* 0x50-0x53 */ 0x86, 0x9A, 0xDF, 0xFB, 0xE0, 0xA2, 0x86, 0x9B, /* 0x54-0x57 */ 0x86, 0x9C, 0x86, 0x9D, 0x86, 0x9E, 0x86, 0x9F, /* 0x58-0x5B */ 0xE0, 0xA8, 0x86, 0xA0, 0x86, 0xA1, 0x86, 0xA2, /* 0x5C-0x5F */ 0x86, 0xA3, 0xB7, 0xC8, 0x86, 0xA4, 0x86, 0xA5, /* 0x60-0x63 */ 0xC6, 0xA1, 0xC9, 0xB6, 0xC0, 0xB2, 0xDF, 0xF5, /* 0x64-0x67 */ 0x86, 0xA6, 0x86, 0xA7, 0xC5, 0xBE, 0x86, 0xA8, /* 0x68-0x6B */ 0xD8, 0xC4, 0xDF, 0xF9, 0xC4, 0xF6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0xF4-0xF7 */ 0x86, 0xF5, 0x86, 0xF6, 0x86, 0xF7, 0x86, 0xF8, /* 0xF8-0xFB */ 0x86, 0xF9, 0xCB, 0xD4, 0xE0, 0xD5, 0x86, 0xFA, /* 0xFC-0xFF */ }; static const unsigned char u2c_56[512] = { 0xE0, 0xD6, 0xE0, 0xD2, 0x86, 0xFB, 0x86, 0xFC, /* 0x00-0x03 */ 0x86, 0xFD, 0x86, 0xFE, 0x87, 0x40, 0x87, 0x41, /* 0x04-0x07 */ 0xE0, 0xD0, 0xBC, 0xCE, 0x87, 0x42, 0x87, 0x43, /* 0x08-0x0B */ 0xE0, 0xD1, 0x87, 0x44, 0xB8, 0xC2, 0xD8, 0xC5, /* 0x0C-0x0F */ 0x87, 0x45, 0x87, 0x46, 0x87, 0x47, 0x87, 0x48, /* 0x10-0x13 */ 0x87, 0x49, 0x87, 0x4A, 0x87, 0x4B, 0x87, 0x4C, /* 0x14-0x17 */ 0xD0, 0xEA, 0x87, 0x4D, 0x87, 0x4E, 0xC2, 0xEF, /* 0x18-0x1B */ 0x87, 0x4F, 0x87, 0x50, 0xE0, 0xCF, 0xE0, 0xBD, /* 0x1C-0x1F */ 0x87, 0x51, 0x87, 0x52, 0x87, 0x53, 0xE0, 0xD4, /* 0x20-0x23 */ 0xE0, 0xD3, 0x87, 0x54, 0x87, 0x55, 0xE0, 0xD7, /* 0x24-0x27 */ 0x87, 0x56, 0x87, 0x57, 0x87, 0x58, 0x87, 0x59, /* 0x28-0x2B */ 0xE0, 0xDC, 0xE0, 0xD8, 0x87, 0x5A, 0x87, 0x5B, /* 0x2C-0x2F */ 0x87, 0x5C, 0xD6, 0xF6, 0xB3, 0xB0, 0x87, 0x5D, /* 0x30-0x33 */ 0xD7, 0xEC, 0x87, 0x5E, 0xCB, 0xBB, 0x87, 0x5F, /* 0x34-0x37 */ 0x87, 0x60, 0xE0, 0xDA, 0x87, 0x61, 0xCE, 0xFB, /* 0x38-0x3B */ 0x87, 0x62, 0x87, 0x63, 0x87, 0x64, 0xBA, 0xD9, /* 0x3C-0x3F */ 0x87, 0x65, 0x87, 0x66, 0x87, 0x67, 0x87, 0x68, /* 0x40-0x43 */ 0x87, 0x69, 0x87, 0x6A, 0x87, 0x6B, 0x87, 0x6C, /* 0x44-0x47 */ 0x87, 0x6D, 0x87, 0x6E, 0x87, 0x6F, 0x87, 0x70, /* 0x48-0x4B */ 0xE0, 0xE1, 0xE0, 0xDD, 0xD2, 0xAD, 0x87, 0x71, /* 0x4C-0x4F */ 0x87, 0x72, 0x87, 0x73, 0x87, 0x74, 0x87, 0x75, /* 0x50-0x53 */ 0xE0, 0xE2, 0x87, 0x76, 0x87, 0x77, 0xE0, 0xDB, /* 0x54-0x57 */ 0xE0, 0xD9, 0xE0, 0xDF, 0x87, 0x78, 0x87, 0x79, /* 0x58-0x5B */ 0xE0, 0xE0, 0x87, 0x7A, 0x87, 0x7B, 0x87, 0x7C, /* 0x5C-0x5F */ 0x87, 0x7D, 0x87, 0x7E, 0xE0, 0xDE, 0x87, 0x80, /* 0x60-0x63 */ 0xE0, 0xE4, 0x87, 0x81, 0x87, 0x82, 0x87, 0x83, /* 0x64-0x67 */ 0xC6, 0xF7, 0xD8, 0xAC, 0xD4, 0xEB, 0xE0, 0xE6, /* 0x68-0x6B */ 0xCA, 0xC9, 0x87, 0x84, 0x87, 0x85, 0x87, 0x86, /* 0x6C-0x6F */ 0x87, 0x87, 0xE0, 0xE5, 0x87, 0x88, 0x87, 0x89, /* 0x70-0x73 */ 0x87, 0x8A, 0x87, 0x8B, 0xB8, 0xC1, 0x87, 0x8C, /* 0x74-0x77 */ 0x87, 0x8D, 0x87, 0x8E, 0x87, 0x8F, 0xE0, 0xE7, /* 0x78-0x7B */ 0xE0, 0xE8, 0x87, 0x90, 0x87, 0x91, 0x87, 0x92, /* 0x7C-0x7F */ 0x87, 0x93, 0x87, 0x94, 0x87, 0x95, 0x87, 0x96, /* 0x80-0x83 */ 0x87, 0x97, 0xE0, 0xE9, 0x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* 0x0C-0x0F */ 0x87, 0xFD, 0x87, 0xFE, 0x88, 0x40, 0x88, 0x41, /* 0x10-0x13 */ 0x88, 0x42, 0x88, 0x43, 0x88, 0x44, 0x88, 0x45, /* 0x14-0x17 */ 0x88, 0x46, 0x88, 0x47, 0x88, 0x48, 0x88, 0x49, /* 0x18-0x1B */ 0xE0, 0xF7, 0x88, 0x4A, 0x88, 0x4B, 0xCD, 0xC1, /* 0x1C-0x1F */ 0x88, 0x4C, 0x88, 0x4D, 0x88, 0x4E, 0xCA, 0xA5, /* 0x20-0x23 */ 0x88, 0x4F, 0x88, 0x50, 0x88, 0x51, 0x88, 0x52, /* 0x24-0x27 */ 0xD4, 0xDA, 0xDB, 0xD7, 0xDB, 0xD9, 0x88, 0x53, /* 0x28-0x2B */ 0xDB, 0xD8, 0xB9, 0xE7, 0xDB, 0xDC, 0xDB, 0xDD, /* 0x2C-0x2F */ 0xB5, 0xD8, 0x88, 0x54, 0x88, 0x55, 0xDB, 0xDA, /* 0x30-0x33 */ 0x88, 0x56, 0x88, 0x57, 0x88, 0x58, 0x88, 0x59, /* 0x34-0x37 */ 0x88, 0x5A, 0xDB, 0xDB, 0xB3, 0xA1, 0xDB, 0xDF, /* 0x38-0x3B */ 0x88, 0x5B, 0x88, 0x5C, 0xBB, 0xF8, 0x88, 0x5D, /* 0x3C-0x3F */ 0xD6, 0xB7, 0x88, 0x5E, 0xDB, 0xE0, 0x88, 0x5F, /* 0x40-0x43 */ 0x88, 0x60, 0x88, 0x61, 0x88, 0x62, 0xBE, 0xF9, /* 0x44-0x47 */ 0x88, 0x63, 0x88, 0x64, 0xB7, 0xBB, 0x88, 0x65, /* 0x48-0x4B */ 0xDB, 0xD0, 0xCC, 0xAE, 0xBF, 0xB2, 0xBB, 0xB5, /* 0x4C-0x4F */ 0xD7, 0xF8, 0xBF, 0xD3, 0x88, 0x66, 0x88, 0x67, /* 0x50-0x53 */ 0x88, 0x68, 0x88, 0x69, 0x88, 0x6A, 0xBF, 0xE9, /* 0x54-0x57 */ 0x88, 0x6B, 0x88, 0x6C, 0xBC, 0xE1, 0xCC, 0xB3, /* 0x58-0x5B */ 0xDB, 0xDE, 0xB0, 0xD3, 0xCE, 0xEB, 0xB7, 0xD8, /* 0x5C-0x5F */ 0xD7, 0xB9, 0xC6, 0xC2, 0x88, 0x6D, 0x88, 0x6E, /* 0x60-0x63 */ 0xC0, 0xA4, 0x88, 0x6F, 0xCC, 0xB9, 0x88, 0x70, /* 0x64-0x67 */ 0xDB, 0xE7, 0xDB, 0xE1, 0xC6, 0xBA, 0xDB, 0xE3, /* 0x68-0x6B */ 0x88, 0x71, 0xDB, 0xE8, 0x88, 0x72, 0xC5, 0xF7, /* 0x6C-0x6F */ 0x88, 0x73, 0x88, 0x74, 0x88, 0x75, 0xDB, 0xEA, /* 0x70-0x73 */ 0x88, 0x76, 0x88, 0x77, 0xDB, 0xE9, 0xBF, 0xC0, /* 0x74-0x77 */ 0x88, 0x78, 0x88, 0x79, 0x88, 0x7A, 0xDB, 0xE6, /* 0x78-0x7B */ 0xDB, 0xE5, 0x88, 0x7B, 0x88, 0x7C, 0x88, 0x7D, /* 0x7C-0x7F */ 0x88, 0x7E, 0x88, 0x80, 0xB4, 0xB9, 0xC0, 0xAC, /* 0x80-0x83 */ 0xC2, 0xA2, 0xDB, 0xE2, 0xDB, 0xE4, 0x88, 0x81, /* 0x84-0x87 */ 0x88, 0x82, 0x88, 0x83, 0x88, 0x84, 0xD0, 0xCD, /* 0x88-0x8B */ 0xDB, 0xED, 0x88, 0x85, 0x88, 0x86, 0x88, 0x87, /* 0x8C-0x8F */ 0x88, 0x88, 0x88, 0x89, 0xC0, 0xDD, 0xDB, 0xF2, /* 0x90-0x93 */ 0x88, 0x8A, 0x88, 0x8B, 0x88, 0x8C, 0x88, 0x8D, /* 0x94-0x97 */ 0x88, 0x8E, 0x88, 0x8F, 0x88, 0x90, 0xB6, 0xE2, /* 0x98-0x9B */ 0x88, 0x91, 0x88, 0x92, 0x88, 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, 0xBC, /* 0xE0-0xE3 */ 0xDB, 0xFD, 0x88, 0xBD, 0x88, 0xBE, 0x88, 0xBF, /* 0xE4-0xE7 */ 0x88, 0xC0, 0x88, 0xC1, 0x88, 0xC2, 0x88, 0xC3, /* 0xE8-0xEB */ 0x88, 0xC4, 0xDC, 0xA4, 0x88, 0xC5, 0xDB, 0xFB, /* 0xEC-0xEF */ 0x88, 0xC6, 0x88, 0xC7, 0x88, 0xC8, 0x88, 0xC9, /* 0xF0-0xF3 */ 0xDB, 0xFA, 0x88, 0xCA, 0x88, 0xCB, 0x88, 0xCC, /* 0xF4-0xF7 */ 0xDB, 0xFC, 0xC5, 0xE0, 0xBB, 0xF9, 0x88, 0xCD, /* 0xF8-0xFB */ 0x88, 0xCE, 0xDC, 0xA3, 0x88, 0xCF, 0x88, 0xD0, /* 0xFC-0xFF */ }; static const unsigned char u2c_58[512] = { 0xDC, 0xA5, 0x88, 0xD1, 0xCC, 0xC3, 0x88, 0xD2, /* 0x00-0x03 */ 0x88, 0xD3, 0x88, 0xD4, 0xB6, 0xD1, 0xDD, 0xC0, /* 0x04-0x07 */ 0x88, 0xD5, 0x88, 0xD6, 0x88, 0xD7, 0xDC, 0xA1, /* 0x08-0x0B */ 0x88, 0xD8, 0xDC, 0xA2, 0x88, 0xD9, 0x88, 0xDA, /* 0x0C-0x0F */ 0x88, 0xDB, 0xC7, 0xB5, 0x88, 0xDC, 0x88, 0xDD, /* 0x10-0x13 */ 0x88, 0xDE, 0xB6, 0xE9, 0x88, 0xDF, 0x88, 0xE0, /* 0x14-0x17 */ 0x88, 0xE1, 0xDC, 0xA7, 0x88, 0xE2, 0x88, 0xE3, /* 0x18-0x1B */ 0x88, 0xE4, 0x88, 0xE5, 0xDC, 0xA6, 0x88, 0xE6, /* 0x1C-0x1F */ 0xDC, 0xA9, 0xB1, 0xA4, 0x88, 0xE7, 0x88, 0xE8, /* 0x20-0x23 */ 0xB5, 0xCC, 0x88, 0xE9, 0x88, 0xEA, 0x88, 0xEB, /* 0x24-0x27 */ 0x88, 0xEC, 0x88, 0xED, 0xBF, 0xB0, 0x88, 0xEE, /* 0x28-0x2B */ 0x88, 0xEF, 0x88, 0xF0, 0x88, 0xF1, 0x88, 0xF2, /* 0x2C-0x2F */ 0xD1, 0xDF, 0x88, 0xF3, 0x88, 0xF4, 0x88, 0xF5, /* 0x30-0x33 */ 0x88, 0xF6, 0xB6, 0xC2, 0x88, 0xF7, 0x88, 0xF8, /* 0x34-0x37 */ 0x88, 0xF9, 0x88, 0xFA, 0x88, 0xFB, 0x88, 0xFC, /* 0x38-0x3B */ 0x88, 0xFD, 0x88, 0xFE, 0x89, 0x40, 0x89, 0x41, /* 0x3C-0x3F */ 0x89, 0x42, 0x89, 0x43, 0x89, 0x44, 0x89, 0x45, /* 0x40-0x43 */ 0xDC, 0xA8, 0x89, 0x46, 0x89, 0x47, 0x89, 0x48, /* 0x44-0x47 */ 0x89, 0x49, 0x89, 0x4A, 0x89, 0x4B, 0x89, 0x4C, /* 0x48-0x4B */ 0xCB, 0xFA, 0xEB, 0xF3, 0x89, 0x4D, 0x89, 0x4E, /* 0x4C-0x4F */ 0x89, 0x4F, 0xCB, 0xDC, 0x89, 0x50, 0x89, 0x51, /* 0x50-0x53 */ 0xCB, 0xFE, 0x89, 0x52, 0x89, 0x53, 0x89, 0x54, /* 0x54-0x57 */ 0xCC, 0xC1, 0x89, 0x55, 0x89, 0x56, 0x89, 0x57, /* 0x58-0x5B */ 0x89, 0x58, 0x89, 0x59, 0xC8, 0xFB, 0x89, 0x5A, /* 0x5C-0x5F */ 0x89, 0x5B, 0x89, 0x5C, 0x89, 0x5D, 0x89, 0x5E, /* 0x60-0x63 */ 0x89, 0x5F, 0xDC, 0xAA, 0x89, 0x60, 0x89, 0x61, /* 0x64-0x67 */ 0x89, 0x62, 0x89, 0x63, 0x89, 0x64, 0xCC, 0xEE, /* 0x68-0x6B */ 0xDC, 0xAB, 0x89, 0x65, 0x89, 0x66, 0x89, 0x67, /* 0x6C-0x6F */ 0x89, 0x68, 0x89, 0x69, 0x89, 0x6A, 0x89, 0x6B, /* 0x70-0x73 */ 0x89, 0x6C, 0x89, 0x6D, 0x89, 0x6E, 0x89, 0x6F, /* 0x74-0x77 */ 0x89, 0x70, 0x89, 0x71, 0x89, 0x72, 0x89, 0x73, /* 0x78-0x7B */ 0x89, 0x74, 0x89, 0x75, 0xDB, 0xD3, 0x89, 0x76, /* 0x7C-0x7F */ 0xDC, 0xAF, 0xDC, 0xAC, 0x89, 0x77, 0xBE, 0xB3, /* 0x80-0x83 */ 0x89, 0x78, 0xCA, 0xFB, 0x89, 0x79, 0x89, 0x7A, /* 0x84-0x87 */ 0x89, 0x7B, 0xDC, 0xAD, 0x89, 0x7C, 0x89, 0x7D, /* 0x88-0x8B */ 0x89, 0x7E, 0x89, 0x80, 0x89, 0x81, 0x89, 0x82, /* 0x8C-0x8F */ 0x89, 0x83, 0x89, 0x84, 0xC9, 0xCA, 0xC4, 0xB9, /* 0x90-0x93 */ 0x89, 0x85, 0x89, 0x86, 0x89, 0x87, 0x89, 0x88, /* 0x94-0x97 */ 0x89, 0x89, 0xC7, 0xBD, 0xDC, 0xAE, 0x89, 0x8A, /* 0x98-0x9B */ 0x89, 0x8B, 0x89, 0x8C, 0xD4, 0xF6, 0xD0, 0xE6, /* 0x9C-0x9F */ 0x89, 0x8D, 0x89, 0x8E, 0x89, 0x8F, 0x89, 0x90, /* 0xA0-0xA3 */ 0x89, 0x91, 0x89, 0x92, 0x89, 0x93, 0x89, 0x94, /* 0xA4-0xA7 */ 0xC4, 0xAB, 0xB6, 0xD5, 0x89, 0x95, 0x89, 0x96, /* 0xA8-0xAB */ 0x89, 0x97, 0x89, 0x98, 0x89, 0x99, 0x89, 0x9A, /* 0xAC-0xAF */ 0x89, 0x9B, 0x89, 0x9C, 0x89, 0x9D, 0x89, 0x9E, /* 0xB0-0xB3 */ 0x89, 0x9F, 0x89, 0xA0, 0x89, 0xA1, 0x89, 0xA2, /* 0xB4-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, 0x89, 0xDB, 0x89, 0xDC, 0x89, 0xDD, /* 0xFC-0xFF */ }; static const unsigned char u2c_59[512] = { 0x89, 0xDE, 0x89, 0xDF, 0xE2, 0xBA, 0x89, 0xE0, /* 0x00-0x03 */ 0xB4, 0xA6, 0x89, 0xE1, 0x89, 0xE2, 0xB1, 0xB8, /* 0x04-0x07 */ 0x89, 0xE3, 0x89, 0xE4, 0x89, 0xE5, 0x89, 0xE6, /* 0x08-0x0B */ 0x89, 0xE7, 0xB8, 0xB4, 0x89, 0xE8, 0xCF, 0xC4, /* 0x0C-0x0F */ 0x89, 0xE9, 0x89, 0xEA, 0x89, 0xEB, 0x89, 0xEC, /* 0x10-0x13 */ 0xD9, 0xE7, 0xCF, 0xA6, 0xCD, 0xE2, 0x89, 0xED, /* 0x14-0x17 */ 0x89, 0xEE, 0xD9, 0xED, 0xB6, 0xE0, 0x89, 0xEF, /* 0x18-0x1B */ 0xD2, 0xB9, 0x89, 0xF0, 0x89, 0xF1, 0xB9, 0xBB, /* 0x1C-0x1F */ 0x89, 0xF2, 0x89, 0xF3, 0x89, 0xF4, 0x89, 0xF5, /* 0x20-0x23 */ 0xE2, 0xB9, 0xE2, 0xB7, 0x89, 0xF6, 0xB4, 0xF3, /* 0x24-0x27 */ 0x89, 0xF7, 0xCC, 0xEC, 0xCC, 0xAB, 0xB7, 0xF2, /* 0x28-0x2B */ 0x89, 0xF8, 0xD8, 0xB2, 0xD1, 0xEB, 0xBA, 0xBB, /* 0x2C-0x2F */ 0x89, 0xF9, 0xCA, 0xA7, 0x89, 0xFA, 0x89, 0xFB, /* 0x30-0x33 */ 0xCD, 0xB7, 0x89, 0xFC, 0x89, 0xFD, 0xD2, 0xC4, /* 0x34-0x37 */ 0xBF, 0xE4, 0xBC, 0xD0, 0xB6, 0xE1, 0x89, 0xFE, /* 0x38-0x3B */ 0xDE, 0xC5, 0x8A, 0x40, 0x8A, 0x41, 0x8A, 0x42, /* 0x3C-0x3F */ 0x8A, 0x43, 0xD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0xD4, 0xF5, 0xE2, 0xF3, /* 0x0C-0x0F */ 0x90, 0x44, 0x90, 0x45, 0xC5, 0xAD, 0x90, 0x46, /* 0x10-0x13 */ 0xD5, 0xFA, 0xC5, 0xC2, 0xB2, 0xC0, 0x90, 0x47, /* 0x14-0x17 */ 0x90, 0x48, 0xE2, 0xEF, 0x90, 0x49, 0xE2, 0xF2, /* 0x18-0x1B */ 0xC1, 0xAF, 0xCB, 0xBC, 0x90, 0x4A, 0x90, 0x4B, /* 0x1C-0x1F */ 0xB5, 0xA1, 0xE2, 0xF9, 0x90, 0x4C, 0x90, 0x4D, /* 0x20-0x23 */ 0x90, 0x4E, 0xBC, 0xB1, 0xE2, 0xF1, 0xD0, 0xD4, /* 0x24-0x27 */ 0xD4, 0xB9, 0xE2, 0xF5, 0xB9, 0xD6, 0xE2, 0xF6, /* 0x28-0x2B */ 0x90, 0x4F, 0x90, 0x50, 0x90, 0x51, 0xC7, 0xD3, /* 0x2C-0x2F */ 0x90, 0x52, 0x90, 0x53, 0x90, 0x54, 0x90, 0x55, /* 0x30-0x33 */ 0x90, 0x56, 0xE2, 0xF0, 0x90, 0x57, 0x90, 0x58, /* 0x34-0x37 */ 0x90, 0x59, 0x90, 0x5A, 0x90, 0x5B, 0xD7, 0xDC, /* 0x38-0x3B */ 0xED, 0xA1, 0x90, 0x5C, 0x90, 0x5D, 0xE2, 0xF8, /* 0x3C-0x3F */ 0x90, 0x5E, 0xED, 0xA5, 0xE2, 0xFE, 0xCA, 0xD1, /* 0x40-0x43 */ 0x90, 0x5F, 0x90, 0x60, 0x90, 0x61, 0x90, 0x62, /* 0x44-0x47 */ 0x90, 0x63, 0x90, 0x64, 0x90, 0x65, 0xC1, 0xB5, /* 0x48-0x4B */ 0x90, 0x66, 0xBB, 0xD0, 0x90, 0x67, 0x90, 0x68, /* 0x4C-0x4F */ 0xBF, 0xD6, 0x90, 0x69, 0xBA, 0xE3, 0x90, 0x6A, /* 0x50-0x53 */ 0x90, 0x6B, 0xCB, 0xA1, 0x90, 0x6C, 0x90, 0x6D, /* 0x54-0x57 */ 0x90, 0x6E, 0xED, 0xA6, 0xED, 0xA3, 0x90, 0x6F, /* 0x58-0x5B */ 0x90, 0x70, 0xED, 0xA2, 0x90, 0x71, 0x90, 0x72, /* 0x5C-0x5F */ 0x90, 0x73, 0x90, 0x74, 0xBB, 0xD6, 0xED, 0xA7, /* 0x60-0x63 */ 0xD0, 0xF4, 0x90, 0x75, 0x90, 0x76, 0xED, 0xA4, /* 0x64-0x67 */ 0xBA, 0xDE, 0xB6, 0xF7, 0xE3, 0xA1, 0xB6, 0xB2, /* 0x68-0x6B */ 0xCC, 0xF1, 0xB9, 0xA7, 0x90, 0x77, 0xCF, 0xA2, /* 0x6C-0x6F */ 0xC7, 0xA1, 0x90, 0x78, 0x90, 0x79, 0xBF, 0xD2, /* 0x70-0x73 */ 0x90, 0x7A, 0x90, 0x7B, 0xB6, 0xF1, 0x90, 0x7C, /* 0x74-0x77 */ 0xE2, 0xFA, 0xE2, 0xFB, 0xE2, 0xFD, 0xE2, 0xFC, /* 0x78-0x7B */ 0xC4, 0xD5, 0xE3, 0xA2, 0x90, 0x7D, 0xD3, 0xC1, /* 0x7C-0x7F */ 0x90, 0x7E, 0x90, 0x80, 0x90, 0x81, 0xE3, 0xA7, /* 0x80-0x83 */ 0xC7, 0xC4, 0x90, 0x82, 0x90, 0x83, 0x90, 0x84, /* 0x84-0x87 */ 0x90, 0x85, 0xCF, 0xA4, 0x90, 0x86, 0x90, 0x87, /* 0x88-0x8B */ 0xE3, 0xA9, 0xBA, 0xB7, 0x90, 0x88, 0x90, 0x89, /* 0x8C-0x8F */ 0x90, 0x8A, 0x90, 0x8B, 0xE3, 0xA8, 0x90, 0x8C, /* 0x90-0x93 */ 0xBB, 0xDA, 0x90, 0x8D, 0xE3, 0xA3, 0x90, 0x8E, /* 0x94-0x97 */ 0x90, 0x8F, 0x90, 0x90, 0xE3, 0xA4, 0xE3, 0xAA, /* 0x98-0x9B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, 0x90, 0xBA, 0x90, 0xBB, 0x90, 0xBC, /* 0xE0-0xE3 */ 0x90, 0xBD, 0x90, 0xBE, 0xB5, 0xEB, 0xBE, 0xE5, /* 0xE4-0xE7 */ 0xB2, 0xD2, 0xB3, 0xCD, 0x90, 0xBF, 0xB1, 0xB9, /* 0xE8-0xEB */ 0xE3, 0xAB, 0xB2, 0xD1, 0xB5, 0xAC, 0xB9, 0xDF, /* 0xEC-0xEF */ 0xB6, 0xE8, 0x90, 0xC0, 0x90, 0xC1, 0xCF, 0xEB, /* 0xF0-0xF3 */ 0xE3, 0xB7, 0x90, 0xC2, 0xBB, 0xCC, 0x90, 0xC3, /* 0xF4-0xF7 */ 0x90, 0xC4, 0xC8, 0xC7, 0xD0, 0xCA, 0x90, 0xC5, /* 0xF8-0xFB */ 0x90, 0xC6, 0x90, 0xC7, 0x90, 0xC8, 0x90, 0xC9, /* 0xFC-0xFF */ }; static const unsigned char u2c_61[512] = { 0xE3, 0xB8, 0xB3, 0xEE, 0x90, 0xCA, 0x90, 0xCB, /* 0x00-0x03 */ 0x90, 0xCC, 0x90, 0xCD, 0xED, 0xA9, 0x90, 0xCE, /* 0x04-0x07 */ 0xD3, 0xFA, 0xD3, 0xE4, 0x90, 0xCF, 0x90, 0xD0, /* 0x08-0x0B */ 0x90, 0xD1, 0xED, 0xAA, 0xE3, 0xB9, 0xD2, 0xE2, /* 0x0C-0x0F */ 0x90, 0xD2, 0x90, 0xD3, 0x90, 0xD4, 0x90, 0xD5, /* 0x10-0x13 */ 0x90, 0xD6, 0xE3, 0xB5, 0x90, 0xD7, 0x90, 0xD8, /* 0x14-0x17 */ 0x90, 0xD9, 0x90, 0xDA, 0xD3, 0xDE, 0x90, 0xDB, /* 0x18-0x1B */ 0x90, 0xDC, 0x90, 0xDD, 0x90, 0xDE, 0xB8, 0xD0, /* 0x1C-0x1F */ 0xE3, 0xB3, 0x90, 0xDF, 0x90, 0xE0, 0xE3, 0xB6, /* 0x20-0x23 */ 0xB7, 0xDF, 0x90, 0xE1, 0xE3, 0xB4, 0xC0, 0xA2, /* 0x24-0x27 */ 0x90, 0xE2, 0x90, 0xE3, 0x90, 0xE4, 0xE3, 0xBA, /* 0x28-0x2B */ 0x90, 0xE5, 0x90, 0xE6, 0x90, 0xE7, 0x90, 0xE8, /* 0x2C-0x2F */ 0x90, 0xE9, 0x90, 0xEA, 0x90, 0xEB, 0x90, 0xEC, /* 0x30-0x33 */ 0x90, 0xED, 0x90, 0xEE, 0x90, 0xEF, 0x90, 0xF0, /* 0x34-0x37 */ 0x90, 0xF1, 0x90, 0xF2, 0x90, 0xF3, 0x90, 0xF4, /* 0x38-0x3B */ 0x90, 0xF5, 0x90, 0xF6, 0x90, 0xF7, 0xD4, 0xB8, /* 0x3C-0x3F */ 0x90, 0xF8, 0x90, 0xF9, 0x90, 0xFA, 0x90, 0xFB, /* 0x40-0x43 */ 0x90, 0xFC, 0x90, 0xFD, 0x90, 0xFE, 0x91, 0x40, /* 0x44-0x47 */ 0xB4, 0xC8, 0x91, 0x41, 0xE3, 0xBB, 0x91, 0x42, /* 0x48-0x4B */ 0xBB, 0xC5, 0x91, 0x43, 0xC9, 0xF7, 0x91, 0x44, /* 0x4C-0x4F */ 0x91, 0x45, 0xC9, 0xE5, 0x91, 0x46, 0x91, 0x47, /* 0x50-0x53 */ 0x91, 0x48, 0xC4, 0xBD, 0x91, 0x49, 0x91, 0x4A, /* 0x54-0x57 */ 0x91, 0x4B, 0x91, 0x4C, 0x91, 0x4D, 0x91, 0x4E, /* 0x58-0x5B */ 0x91, 0x4F, 0xED, 0xAB, 0x91, 0x50, 0x91, 0x51, /* 0x5C-0x5F */ 0x91, 0x52, 0x91, 0x53, 0xC2, 0xFD, 0x91, 0x54, /* 0x60-0x63 */ 0x91, 0x55, 0x91, 0x56, 0x91, 0x57, 0xBB, 0xDB, /* 0x64-0x67 */ 0xBF, 0xAE, 0x91, 0x58, 0x91, 0x59, 0x91, 0x5A, /* 0x68-0x6B */ 0x91, 0x5B, 0x91, 0x5C, 0x91, 0x5D, 0x91, 0x5E, /* 0x6C-0x6F */ 0xCE, 0xBF, 0x91, 0x5F, 0x91, 0x60, 0x91, 0x61, /* 0x70-0x73 */ 0x91, 0x62, 0xE3, 0xBC, 0x91, 0x63, 0xBF, 0xB6, /* 0x74-0x77 */ 0x91, 0x64, 0x91, 0x65, 0x91, 0x66, 0x91, 0x67, /* 0x78-0x7B */ 0x91, 0x68, 0x91, 0x69, 0x91, 0x6A, 0x91, 0x6B, /* 0x7C-0x7F */ 0x91, 0x6C, 0x91, 0x6D, 0x91, 0x6E, 0x91, 0x6F, /* 0x80-0x83 */ 0x91, 0x70, 0x91, 0x71, 0x91, 0x72, 0x91, 0x73, /* 0x84-0x87 */ 0x91, 0x74, 0x91, 0x75, 0x91, 0x76, 0xB1, 0xEF, /* 0x88-0x8B */ 0x91, 0x77, 0x91, 0x78, 0xD4, 0xF7, 0x91, 0x79, /* 0x8C-0x8F */ 0x91, 0x7A, 0x91, 0x7B, 0x91, 0x7C, 0x91, 0x7D, /* 0x90-0x93 */ 0xE3, 0xBE, 0x91, 0x7E, 0x91, 0x80, 0x91, 0x81, /* 0x94-0x97 */ 0x91, 0x82, 0x91, 0x83, 0x91, 0x84, 0x91, 0x85, /* 0x98-0x9B */ 0x91, 0x86, 0xED, 0xAD, 0x91, 0x87, 0x91, 0x88, /* 0x9C-0x9F */ 0x91, 0x89, 0x91, 0x8A, 0x91, 0x8B, 0x91, 0x8C, /* 0xA0-0xA3 */ 0x91, 0x8D, 0x91, 0x8E, 0x91, 0x8F, 0xE3, 0xBF, /* 0xA4-0xA7 */ 0xBA, 0xA9, 0xED, 0xAC, 0x91, 0x90, 0x91, 0x91, /* 0xA8-0xAB */ 0xE3, 0xBD, 0x91, 0x92, 0x91, 0x93, 0x91, 0x94, /* 0xAC-0xAF */ 0x91, 0x95, 0x91, 0x96, 0x91, 0x97, 0x91, 0x98, /* 0xB0-0xB3 */ 0x91, 0x99, 0x91, 0x9A, 0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/* 0xF8-0xFB */ 0x91, 0xD6, 0x91, 0xD7, 0x91, 0xD8, 0xDC, 0xB2, /* 0xFC-0xFF */ }; static const unsigned char u2c_62[512] = { 0x91, 0xD9, 0x91, 0xDA, 0x91, 0xDB, 0x91, 0xDC, /* 0x00-0x03 */ 0x91, 0xDD, 0x91, 0xDE, 0xED, 0xB0, 0x91, 0xDF, /* 0x04-0x07 */ 0xB8, 0xEA, 0x91, 0xE0, 0xCE, 0xEC, 0xEA, 0xA7, /* 0x08-0x0B */ 0xD0, 0xE7, 0xCA, 0xF9, 0xC8, 0xD6, 0xCF, 0xB7, /* 0x0C-0x0F */ 0xB3, 0xC9, 0xCE, 0xD2, 0xBD, 0xE4, 0x91, 0xE1, /* 0x10-0x13 */ 0x91, 0xE2, 0xE3, 0xDE, 0xBB, 0xF2, 0xEA, 0xA8, /* 0x14-0x17 */ 0xD5, 0xBD, 0x91, 0xE3, 0xC6, 0xDD, 0xEA, 0xA9, /* 0x18-0x1B */ 0x91, 0xE4, 0x91, 0xE5, 0x91, 0xE6, 0xEA, 0xAA, /* 0x1C-0x1F */ 0x91, 0xE7, 0xEA, 0xAC, 0xEA, 0xAB, 0x91, 0xE8, /* 0x20-0x23 */ 0xEA, 0xAE, 0xEA, 0xAD, 0x91, 0xE9, 0x91, 0xEA, /* 0x24-0x27 */ 0x91, 0xEB, 0x91, 0xEC, 0xBD, 0xD8, 0x91, 0xED, /* 0x28-0x2B */ 0xEA, 0xAF, 0x91, 0xEE, 0xC2, 0xBE, 0x91, 0xEF, /* 0x2C-0x2F */ 0x91, 0xF0, 0x91, 0xF1, 0x91, 0xF2, 0xB4, 0xC1, /* 0x30-0x33 */ 0xB4, 0xF7, 0x91, 0xF3, 0x91, 0xF4, 0xBB, 0xA7, /* 0x34-0x37 */ 0x91, 0xF5, 0x91, 0xF6, 0x91, 0xF7, 0x91, 0xF8, /* 0x38-0x3B */ 0x91, 0xF9, 0xEC, 0xE6, 0xEC, 0xE5, 0xB7, 0xBF, /* 0x3C-0x3F */ 0xCB, 0xF9, 0xB1, 0xE2, 0x91, 0xFA, 0xEC, 0xE7, /* 0x40-0x43 */ 0x91, 0xFB, 0x91, 0xFC, 0x91, 0xFD, 0xC9, 0xC8, /* 0x44-0x47 */ 0xEC, 0xE8, 0xEC, 0xE9, 0x91, 0xFE, 0xCA, 0xD6, /* 0x48-0x4B */ 0xDE, 0xD0, 0xB2, 0xC5, 0xD4, 0xFA, 0x92, 0x40, /* 0x4C-0x4F */ 0x92, 0x41, 0xC6, 0xCB, 0xB0, 0xC7, 0xB4, 0xF2, /* 0x50-0x53 */ 0xC8, 0xD3, 0x92, 0x42, 0x92, 0x43, 0x92, 0x44, /* 0x54-0x57 */ 0xCD, 0xD0, 0x92, 0x45, 0x92, 0x46, 0xBF, 0xB8, /* 0x58-0x5B */ 0x92, 0x47, 0x92, 0x48, 0x92, 0x49, 0x92, 0x4A, /* 0x5C-0x5F */ 0x92, 0x4B, 0x92, 0x4C, 0x92, 0x4D, 0xBF, 0xDB, /* 0x60-0x63 */ 0x92, 0x4E, 0x92, 0x4F, 0xC7, 0xA4, 0xD6, 0xB4, /* 0x64-0x67 */ 0x92, 0x50, 0xC0, 0xA9, 0xDE, 0xD1, 0xC9, 0xA8, /* 0x68-0x6B */ 0xD1, 0xEF, 0xC5, 0xA4, 0xB0, 0xE7, 0xB3, 0xB6, /* 0x6C-0x6F */ 0xC8, 0xC5, 0x92, 0x51, 0x92, 0x52, 0xB0, 0xE2, /* 0x70-0x73 */ 0x92, 0x53, 0x92, 0x54, 0xB7, 0xF6, 0x92, 0x55, /* 0x74-0x77 */ 0x92, 0x56, 0xC5, 0xFA, 0x92, 0x57, 0x92, 0x58, /* 0x78-0x7B */ 0xB6, 0xF3, 0x92, 0x59, 0xD5, 0xD2, 0xB3, 0xD0, /* 0x7C-0x7F */ 0xBC, 0xBC, 0x92, 0x5A, 0x92, 0x5B, 0x92, 0x5C, /* 0x80-0x83 */ 0xB3, 0xAD, 0x92, 0x5D, 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/* 0xDC-0xDF */ 0xDE, 0xEB, 0xCE, 0xD5, 0x93, 0x55, 0xB4, 0xA7, /* 0xE0-0xE3 */ 0x93, 0x56, 0x93, 0x57, 0x93, 0x58, 0x93, 0x59, /* 0xE4-0xE7 */ 0x93, 0x5A, 0xBF, 0xAB, 0xBE, 0xBE, 0x93, 0x5B, /* 0xE8-0xEB */ 0x93, 0x5C, 0xBD, 0xD2, 0x93, 0x5D, 0x93, 0x5E, /* 0xEC-0xEF */ 0x93, 0x5F, 0x93, 0x60, 0xDE, 0xE9, 0x93, 0x61, /* 0xF0-0xF3 */ 0xD4, 0xAE, 0x93, 0x62, 0xDE, 0xDE, 0x93, 0x63, /* 0xF4-0xF7 */ 0xDE, 0xEA, 0x93, 0x64, 0x93, 0x65, 0x93, 0x66, /* 0xF8-0xFB */ 0x93, 0x67, 0xC0, 0xBF, 0x93, 0x68, 0xDE, 0xEC, /* 0xFC-0xFF */ }; static const unsigned char u2c_64[512] = { 0xB2, 0xF3, 0xB8, 0xE9, 0xC2, 0xA7, 0x93, 0x69, /* 0x00-0x03 */ 0x93, 0x6A, 0xBD, 0xC1, 0x93, 0x6B, 0x93, 0x6C, /* 0x04-0x07 */ 0x93, 0x6D, 0x93, 0x6E, 0x93, 0x6F, 0xDE, 0xF5, /* 0x08-0x0B */ 0xDE, 0xF8, 0x93, 0x70, 0x93, 0x71, 0xB2, 0xAB, /* 0x0C-0x0F */ 0xB4, 0xA4, 0x93, 0x72, 0x93, 0x73, 0xB4, 0xEA, /* 0x10-0x13 */ 0xC9, 0xA6, 0x93, 0x74, 0x93, 0x75, 0x93, 0x76, /* 0x14-0x17 */ 0x93, 0x77, 0x93, 0x78, 0x93, 0x79, 0xDE, 0xF6, /* 0x18-0x1B */ 0xCB, 0xD1, 0x93, 0x7A, 0xB8, 0xE3, 0x93, 0x7B, /* 0x1C-0x1F */ 0xDE, 0xF7, 0xDE, 0xFA, 0x93, 0x7C, 0x93, 0x7D, /* 0x20-0x23 */ 0x93, 0x7E, 0x93, 0x80, 0xDE, 0xF9, 0x93, 0x81, /* 0x24-0x27 */ 0x93, 0x82, 0x93, 0x83, 0xCC, 0xC2, 0x93, 0x84, /* 0x28-0x2B */ 0xB0, 0xE1, 0xB4, 0xEE, 0x93, 0x85, 0x93, 0x86, /* 0x2C-0x2F */ 0x93, 0x87, 0x93, 0x88, 0x93, 0x89, 0x93, 0x8A, /* 0x30-0x33 */ 0xE5, 0xBA, 0x93, 0x8B, 0x93, 0x8C, 0x93, 0x8D, /* 0x34-0x37 */ 0x93, 0x8E, 0x93, 0x8F, 0xD0, 0xAF, 0x93, 0x90, /* 0x38-0x3B */ 0x93, 0x91, 0xB2, 0xEB, 0x93, 0x92, 0xEB, 0xA1, /* 0x3C-0x3F */ 0x93, 0x93, 0xDE, 0xF4, 0x93, 0x94, 0x93, 0x95, /* 0x40-0x43 */ 0xC9, 0xE3, 0xDE, 0xF3, 0xB0, 0xDA, 0xD2, 0xA1, /* 0x44-0x47 */ 0xB1, 0xF7, 0x93, 0x96, 0xCC, 0xAF, 0x93, 0x97, /* 0x48-0x4B */ 0x93, 0x98, 0x93, 0x99, 0x93, 0x9A, 0x93, 0x9B, /* 0x4C-0x4F */ 0x93, 0x9C, 0x93, 0x9D, 0xDE, 0xF0, 0x93, 0x9E, /* 0x50-0x53 */ 0xCB, 0xA4, 0x93, 0x9F, 0x93, 0xA0, 0x93, 0xA1, /* 0x54-0x57 */ 0xD5, 0xAA, 0x93, 0xA2, 0x93, 0xA3, 0x93, 0xA4, /* 0x58-0x5B */ 0x93, 0xA5, 0x93, 0xA6, 0xDE, 0xFB, 0x93, 0xA7, /* 0x5C-0x5F */ 0x93, 0xA8, 0x93, 0xA9, 0x93, 0xAA, 0x93, 0xAB, /* 0x60-0x63 */ 0x93, 0xAC, 0x93, 0xAD, 0x93, 0xAE, 0xB4, 0xDD, /* 0x64-0x67 */ 0x93, 0xAF, 0xC4, 0xA6, 0x93, 0xB0, 0x93, 0xB1, /* 0x68-0x6B */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7 */ 0x94, 0x59, 0x94, 0x5A, 0x94, 0x5B, 0x94, 0x5C, /* 0xF8-0xFB */ 0x94, 0x5D, 0x94, 0x5E, 0x94, 0x5F, 0x94, 0x60, /* 0xFC-0xFF */ }; static const unsigned char u2c_65[512] = { 0xC5, 0xCA, 0x94, 0x61, 0x94, 0x62, 0x94, 0x63, /* 0x00-0x03 */ 0x94, 0x64, 0x94, 0x65, 0x94, 0x66, 0x94, 0x67, /* 0x04-0x07 */ 0x94, 0x68, 0xDF, 0xAB, 0x94, 0x69, 0x94, 0x6A, /* 0x08-0x0B */ 0x94, 0x6B, 0x94, 0x6C, 0x94, 0x6D, 0x94, 0x6E, /* 0x0C-0x0F */ 0x94, 0x6F, 0x94, 0x70, 0xD4, 0xDC, 0x94, 0x71, /* 0x10-0x13 */ 0x94, 0x72, 0x94, 0x73, 0x94, 0x74, 0x94, 0x75, /* 0x14-0x17 */ 0xC8, 0xC1, 0x94, 0x76, 0x94, 0x77, 0x94, 0x78, /* 0x18-0x1B */ 0x94, 0x79, 0x94, 0x7A, 0x94, 0x7B, 0x94, 0x7C, /* 0x1C-0x1F */ 0x94, 0x7D, 0x94, 0x7E, 0x94, 0x80, 0x94, 0x81, /* 0x20-0x23 */ 0x94, 0x82, 0xDF, 0xAC, 0x94, 0x83, 0x94, 0x84, /* 0x24-0x27 */ 0x94, 0x85, 0x94, 0x86, 0x94, 0x87, 0xBE, 0xF0, /* 0x28-0x2B */ 0x94, 0x88, 0x94, 0x89, 0xDF, 0xAD, 0xD6, 0xA7, /* 0x2C-0x2F */ 0x94, 0x8A, 0x94, 0x8B, 0x94, 0x8C, 0x94, 0x8D, /* 0x30-0x33 */ 0xEA, 0xB7, 0xEB, 0xB6, 0xCA, 0xD5, 0x94, 0x8E, /* 0x34-0x37 */ 0xD8, 0xFC, 0xB8, 0xC4, 0x94, 0x8F, 0xB9, 0xA5, /* 0x38-0x3B */ 0x94, 0x90, 0x94, 0x91, 0xB7, 0xC5, 0xD5, 0xFE, /* 0x3C-0x3F */ 0x94, 0x92, 0x94, 0x93, 0x94, 0x94, 0x94, 0x95, /* 0x40-0x43 */ 0x94, 0x96, 0xB9, 0xCA, 0x94, 0x97, 0x94, 0x98, /* 0x44-0x47 */ 0xD0, 0xA7, 0xF4, 0xCD, 0x94, 0x99, 0x94, 0x9A, /* 0x48-0x4B */ 0xB5, 0xD0, 0x94, 0x9B, 0x94, 0x9C, 0xC3, 0xF4, /* 0x4C-0x4F */ 0x94, 0x9D, 0xBE, 0xC8, 0x94, 0x9E, 0x94, 0x9F, /* 0x50-0x53 */ 0x94, 0xA0, 0xEB, 0xB7, 0xB0, 0xBD, 0x94, 0xA1, /* 0x54-0x57 */ 0x94, 0xA2, 0xBD, 0xCC, 0x94, 0xA3, 0xC1, 0xB2, /* 0x58-0x5B */ 0x94, 0xA4, 0xB1, 0xD6, 0xB3, 0xA8, 0x94, 0xA5, /* 0x5C-0x5F */ 0x94, 0xA6, 0x94, 0xA7, 0xB8, 0xD2, 0xC9, 0xA2, /* 0x60-0x63 */ 0x94, 0xA8, 0x94, 0xA9, 0xB6, 0xD8, 0x94, 0xAA, /* 0x64-0x67 */ 0x94, 0xAB, 0x94, 0xAC, 0x94, 0xAD, 0xEB, 0xB8, /* 0x68-0x6B */ 0xBE, 0xB4, 0x94, 0xAE, 0x94, 0xAF, 0x94, 0xB0, /* 0x6C-0x6F */ 0xCA, 0xFD, 0x94, 0xB1, 0xC7, 0xC3, 0x94, 0xB2, /* 0x70-0x73 */ 0xD5, 0xFB, 0x94, 0xB3, 0x94, 0xB4, 0xB7, 0xF3, /* 0x74-0x77 */ 0x94, 0xB5, 0x94, 0xB6, 0x94, 0xB7, 0x94, 0xB8, /* 0x78-0x7B */ 0x94, 0xB9, 0x94, 0xBA, 0x94, 0xBB, 0x94, 0xBC, /* 0x7C-0x7F */ 0x94, 0xBD, 0x94, 0xBE, 0x94, 0xBF, 0x94, 0xC0, /* 0x80-0x83 */ 0x94, 0xC1, 0x94, 0xC2, 0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0xD0, 0xFD, /* 0xC8-0xCB */ 0xEC, 0xBA, 0x94, 0xEC, 0xEC, 0xBB, 0xD7, 0xE5, /* 0xCC-0xCF */ 0x94, 0xED, 0x94, 0xEE, 0xEC, 0xBC, 0x94, 0xEF, /* 0xD0-0xD3 */ 0x94, 0xF0, 0x94, 0xF1, 0xEC, 0xBD, 0xC6, 0xEC, /* 0xD4-0xD7 */ 0x94, 0xF2, 0x94, 0xF3, 0x94, 0xF4, 0x94, 0xF5, /* 0xD8-0xDB */ 0x94, 0xF6, 0x94, 0xF7, 0x94, 0xF8, 0x94, 0xF9, /* 0xDC-0xDF */ 0xCE, 0xDE, 0x94, 0xFA, 0xBC, 0xC8, 0x94, 0xFB, /* 0xE0-0xE3 */ 0x94, 0xFC, 0xC8, 0xD5, 0xB5, 0xA9, 0xBE, 0xC9, /* 0xE4-0xE7 */ 0xD6, 0xBC, 0xD4, 0xE7, 0x94, 0xFD, 0x94, 0xFE, /* 0xE8-0xEB */ 0xD1, 0xAE, 0xD0, 0xF1, 0xEA, 0xB8, 0xEA, 0xB9, /* 0xEC-0xEF */ 0xEA, 0xBA, 0xBA, 0xB5, 0x95, 0x40, 0x95, 0x41, /* 0xF0-0xF3 */ 0x95, 0x42, 0x95, 0x43, 0xCA, 0xB1, 0xBF, 0xF5, /* 0xF4-0xF7 */ 0x95, 0x44, 0x95, 0x45, 0xCD, 0xFA, 0x95, 0x46, /* 0xF8-0xFB */ 0x95, 0x47, 0x95, 0x48, 0x95, 0x49, 0x95, 0x4A, /* 0xFC-0xFF */ }; static const unsigned char u2c_66[512] = { 0xEA, 0xC0, 0x95, 0x4B, 0xB0, 0xBA, 0xEA, 0xBE, /* 0x00-0x03 */ 0x95, 0x4C, 0x95, 0x4D, 0xC0, 0xA5, 0x95, 0x4E, /* 0x04-0x07 */ 0x95, 0x4F, 0x95, 0x50, 0xEA, 0xBB, 0x95, 0x51, /* 0x08-0x0B */ 0xB2, 0xFD, 0x95, 0x52, 0xC3, 0xF7, 0xBB, 0xE8, /* 0x0C-0x0F */ 0x95, 0x53, 0x95, 0x54, 0x95, 0x55, 0xD2, 0xD7, /* 0x10-0x13 */ 0xCE, 0xF4, 0xEA, 0xBF, 0x95, 0x56, 0x95, 0x57, /* 0x14-0x17 */ 0x95, 0x58, 0xEA, 0xBC, 0x95, 0x59, 0x95, 0x5A, /* 0x18-0x1B */ 0x95, 0x5B, 0xEA, 0xC3, 0x95, 0x5C, 0xD0, 0xC7, /* 0x1C-0x1F */ 0xD3, 0xB3, 0x95, 0x5D, 0x95, 0x5E, 0x95, 0x5F, /* 0x20-0x23 */ 0x95, 0x60, 0xB4, 0xBA, 0x95, 0x61, 0xC3, 0xC1, /* 0x24-0x27 */ 0xD7, 0xF2, 0x95, 0x62, 0x95, 0x63, 0x95, 0x64, /* 0x28-0x2B */ 0x95, 0x65, 0xD5, 0xD1, 0x95, 0x66, 0xCA, 0xC7, /* 0x2C-0x2F */ 0x95, 0x67, 0xEA, 0xC5, 0x95, 0x68, 0x95, 0x69, /* 0x30-0x33 */ 0xEA, 0xC4, 0xEA, 0xC7, 0xEA, 0xC6, 0x95, 0x6A, /* 0x34-0x37 */ 0x95, 0x6B, 0x95, 0x6C, 0x95, 0x6D, 0x95, 0x6E, /* 0x38-0x3B */ 0xD6, 0xE7, 0x95, 0x6F, 0xCF, 0xD4, 0x95, 0x70, /* 0x3C-0x3F */ 0x95, 0x71, 0xEA, 0xCB, 0x95, 0x72, 0xBB, 0xCE, /* 0x40-0x43 */ 0x95, 0x73, 0x95, 0x74, 0x95, 0x75, 0x95, 0x76, /* 0x44-0x47 */ 0x95, 0x77, 0x95, 0x78, 0x95, 0x79, 0xBD, 0xFA, /* 0x48-0x4B */ 0xC9, 0xCE, 0x95, 0x7A, 0x95, 0x7B, 0xEA, 0xCC, /* 0x4C-0x4F */ 0x95, 0x7C, 0x95, 0x7D, 0xC9, 0xB9, 0xCF, 0xFE, /* 0x50-0x53 */ 0xEA, 0xCA, 0xD4, 0xCE, 0xEA, 0xCD, 0xEA, 0xCF, /* 0x54-0x57 */ 0x95, 0x7E, 0x95, 0x80, 0xCD, 0xED, 0x95, 0x81, /* 0x58-0x5B */ 0x95, 0x82, 0x95, 0x83, 0x95, 0x84, 0xEA, 0xC9, /* 0x5C-0x5F */ 0x95, 0x85, 0xEA, 0xCE, 0x95, 0x86, 0x95, 0x87, /* 0x60-0x63 */ 0xCE, 0xEE, 0x95, 0x88, 0xBB, 0xDE, 0x95, 0x89, /* 0x64-0x67 */ 0xB3, 0xBF, 0x95, 0x8A, 0x95, 0x8B, 0x95, 0x8C, /* 0x68-0x6B */ 0x95, 0x8D, 0x95, 0x8E, 0xC6, 0xD5, 0xBE, 0xB0, /* 0x6C-0x6F */ 0xCE, 0xFA, 0x95, 0x8F, 0x95, 0x90, 0x95, 0x91, /* 0x70-0x73 */ 0xC7, 0xE7, 0x95, 0x92, 0xBE, 0xA7, 0xEA, 0xD0, /* 0x74-0x77 */ 0x95, 0x93, 0x95, 0x94, 0xD6, 0xC7, 0x95, 0x95, /* 0x78-0x7B */ 0x95, 0x96, 0x95, 0x97, 0xC1, 0xC0, 0x95, 0x98, /* 0x7C-0x7F */ 0x95, 0x99, 0x95, 0x9A, 0xD4, 0xDD, 0x95, 0x9B, /* 0x80-0x83 */ 0xEA, 0xD1, 0x95, 0x9C, 0x95, 0x9D, 0xCF, 0xBE, /* 0x84-0x87 */ 0x95, 0x9E, 0x95, 0x9F, 0x95, 0xA0, 0x95, 0xA1, /* 0x88-0x8B */ 0xEA, 0xD2, 0x95, 0xA2, 0x95, 0xA3, 0x95, 0xA4, /* 0x8C-0x8F */ 0x95, 0xA5, 0xCA, 0xEE, 0x95, 0xA6, 0x95, 0xA7, /* 0x90-0x93 */ 0x95, 0xA8, 0x95, 0xA9, 0xC5, 0xAF, 0xB0, 0xB5, /* 0x94-0x97 */ 0x95, 0xAA, 0x95, 0xAB, 0x95, 0xAC, 0x95, 0xAD, /* 0x98-0x9B */ 0x95, 0xAE, 0xEA, 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, 0xEA, /* 0xE0-0xE3 */ 0x95, 0xEB, 0x95, 0xEC, 0xEA, 0xD8, 0x95, 0xED, /* 0xE4-0xE7 */ 0x95, 0xEE, 0xEA, 0xD9, 0x95, 0xEF, 0x95, 0xF0, /* 0xE8-0xEB */ 0x95, 0xF1, 0x95, 0xF2, 0x95, 0xF3, 0x95, 0xF4, /* 0xEC-0xEF */ 0xD4, 0xBB, 0x95, 0xF5, 0xC7, 0xFA, 0xD2, 0xB7, /* 0xF0-0xF3 */ 0xB8, 0xFC, 0x95, 0xF6, 0x95, 0xF7, 0xEA, 0xC2, /* 0xF4-0xF7 */ 0x95, 0xF8, 0xB2, 0xDC, 0x95, 0xF9, 0x95, 0xFA, /* 0xF8-0xFB */ 0xC2, 0xFC, 0x95, 0xFB, 0xD4, 0xF8, 0xCC, 0xE6, /* 0xFC-0xFF */ }; static const unsigned char u2c_67[512] = { 0xD7, 0xEE, 0x95, 0xFC, 0x95, 0xFD, 0x95, 0xFE, /* 0x00-0x03 */ 0x96, 0x40, 0x96, 0x41, 0x96, 0x42, 0x96, 0x43, /* 0x04-0x07 */ 0xD4, 0xC2, 0xD3, 0xD0, 0xEB, 0xC3, 0xC5, 0xF3, /* 0x08-0x0B */ 0x96, 0x44, 0xB7, 0xFE, 0x96, 0x45, 0x96, 0x46, /* 0x0C-0x0F */ 0xEB, 0xD4, 0x96, 0x47, 0x96, 0x48, 0x96, 0x49, /* 0x10-0x13 */ 0xCB, 0xB7, 0xEB, 0xDE, 0x96, 0x4A, 0xC0, 0xCA, /* 0x14-0x17 */ 0x96, 0x4B, 0x96, 0x4C, 0x96, 0x4D, 0xCD, 0xFB, /* 0x18-0x1B */ 0x96, 0x4E, 0xB3, 0xAF, 0x96, 0x4F, 0xC6, 0xDA, /* 0x1C-0x1F */ 0x96, 0x50, 0x96, 0x51, 0x96, 0x52, 0x96, 0x53, /* 0x20-0x23 */ 0x96, 0x54, 0x96, 0x55, 0xEB, 0xFC, 0x96, 0x56, /* 0x24-0x27 */ 0xC4, 0xBE, 0x96, 0x57, 0xCE, 0xB4, 0xC4, 0xA9, /* 0x28-0x2B */ 0xB1, 0xBE, 0xD4, 0xFD, 0x96, 0x58, 0xCA, 0xF5, /* 0x2C-0x2F */ 0x96, 0x59, 0xD6, 0xEC, 0x96, 0x5A, 0x96, 0x5B, /* 0x30-0x33 */ 0xC6, 0xD3, 0xB6, 0xE4, 0x96, 0x5C, 0x96, 0x5D, /* 0x34-0x37 */ 0x96, 0x5E, 0x96, 0x5F, 0xBB, 0xFA, 0x96, 0x60, /* 0x38-0x3B */ 0x96, 0x61, 0xD0, 0xE0, 0x96, 0x62, 0x96, 0x63, /* 0x3C-0x3F */ 0xC9, 0xB1, 0x96, 0x64, 0xD4, 0xD3, 0xC8, 0xA8, /* 0x40-0x43 */ 0x96, 0x65, 0x96, 0x66, 0xB8, 0xCB, 0x96, 0x67, /* 0x44-0x47 */ 0xE8, 0xBE, 0xC9, 0xBC, 0x96, 0x68, 0x96, 0x69, /* 0x48-0x4B */ 0xE8, 0xBB, 0x96, 0x6A, 0xC0, 0xEE, 0xD0, 0xD3, /* 0x4C-0x4F */ 0xB2, 0xC4, 0xB4, 0xE5, 0x96, 0x6B, 0xE8, 0xBC, /* 0x50-0x53 */ 0x96, 0x6C, 0x96, 0x6D, 0xD5, 0xC8, 0x96, 0x6E, /* 0x54-0x57 */ 0x96, 0x6F, 0x96, 0x70, 0x96, 0x71, 0x96, 0x72, /* 0x58-0x5B */ 0xB6, 0xC5, 0x96, 0x73, 0xE8, 0xBD, 0xCA, 0xF8, /* 0x5C-0x5F */ 0xB8, 0xDC, 0xCC, 0xF5, 0x96, 0x74, 0x96, 0x75, /* 0x60-0x63 */ 0x96, 0x76, 0xC0, 0xB4, 0x96, 0x77, 0x96, 0x78, /* 0x64-0x67 */ 0xD1, 0xEE, 0xE8, 0xBF, 0xE8, 0xC2, 0x96, 0x79, /* 0x68-0x6B */ 0x96, 0x7A, 0xBA, 0xBC, 0x96, 0x7B, 0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, 0x96, 0xC9, 0x96, 0xCA, 0x96, 0xCB, /* 0xF8-0xFB */ 0x96, 0xCC, 0xE8, 0xDF, 0x96, 0xCD, 0xCA, 0xC1, /* 0xFC-0xFF */ }; static const unsigned char u2c_68[512] = { 0xE8, 0xD9, 0x96, 0xCE, 0x96, 0xCF, 0x96, 0xD0, /* 0x00-0x03 */ 0x96, 0xD1, 0xD5, 0xA4, 0x96, 0xD2, 0xB1, 0xEA, /* 0x04-0x07 */ 0xD5, 0xBB, 0xE8, 0xCE, 0xE8, 0xD0, 0xB6, 0xB0, /* 0x08-0x0B */ 0xE8, 0xD3, 0x96, 0xD3, 0xE8, 0xDD, 0xC0, 0xB8, /* 0x0C-0x0F */ 0x96, 0xD4, 0xCA, 0xF7, 0x96, 0xD5, 0xCB, 0xA8, /* 0x10-0x13 */ 0x96, 0xD6, 0x96, 0xD7, 0xC6, 0xDC, 0xC0, 0xF5, /* 0x14-0x17 */ 0x96, 0xD8, 0x96, 0xD9, 0x96, 0xDA, 0x96, 0xDB, /* 0x18-0x1B */ 0x96, 0xDC, 0xE8, 0xE9, 0x96, 0xDD, 0x96, 0xDE, /* 0x1C-0x1F */ 0x96, 0xDF, 0xD0, 0xA3, 0x96, 0xE0, 0x96, 0xE1, /* 0x20-0x23 */ 0x96, 0xE2, 0x96, 0xE3, 0x96, 0xE4, 0x96, 0xE5, /* 0x24-0x27 */ 0x96, 0xE6, 0xE8, 0xF2, 0xD6, 0xEA, 0x96, 0xE7, /* 0x28-0x2B */ 0x96, 0xE8, 0x96, 0xE9, 0x96, 0xEA, 0x96, 0xEB, /* 0x2C-0x2F */ 0x96, 0xEC, 0x96, 0xED, 0xE8, 0xE0, 0xE8, 0xE1, /* 0x30-0x33 */ 0x96, 0xEE, 0x96, 0xEF, 0x96, 0xF0, 0xD1, 0xF9, /* 0x34-0x37 */ 0xBA, 0xCB, 0xB8, 0xF9, 0x96, 0xF1, 0x96, 0xF2, /* 0x38-0x3B */ 0xB8, 0xF1, 0xD4, 0xD4, 0xE8, 0xEF, 0x96, 0xF3, /* 0x3C-0x3F */ 0xE8, 0xEE, 0xE8, 0xEC, 0xB9, 0xF0, 0xCC, 0xD2, /* 0x40-0x43 */ 0xE8, 0xE6, 0xCE, 0xA6, 0xBF, 0xF2, 0x96, 0xF4, /* 0x44-0x47 */ 0xB0, 0xB8, 0xE8, 0xF1, 0xE8, 0xF0, 0x96, 0xF5, /* 0x48-0x4B */ 0xD7, 0xC0, 0x96, 0xF6, 0xE8, 0xE4, 0x96, 0xF7, /* 0x4C-0x4F */ 0xCD, 0xA9, 0xC9, 0xA3, 0x96, 0xF8, 0xBB, 0xB8, /* 0x50-0x53 */ 0xBD, 0xDB, 0xE8, 0xEA, 0x96, 0xF9, 0x96, 0xFA, /* 0x54-0x57 */ 0x96, 0xFB, 0x96, 0xFC, 0x96, 0xFD, 0x96, 0xFE, /* 0x58-0x5B */ 0x97, 0x40, 0x97, 0x41, 0x97, 0x42, 0x97, 0x43, /* 0x5C-0x5F */ 0xE8, 0xE2, 0xE8, 0xE3, 0xE8, 0xE5, 0xB5, 0xB5, /* 0x60-0x63 */ 0xE8, 0xE7, 0xC7, 0xC5, 0xE8, 0xEB, 0xE8, 0xED, /* 0x64-0x67 */ 0xBD, 0xB0, 0xD7, 0xAE, 0x97, 0x44, 0xE8, 0xF8, /* 0x68-0x6B */ 0x97, 0x45, 0x97, 0x46, 0x97, 0x47, 0x97, 0x48, /* 0x6C-0x6F */ 0x97, 0x49, 0x97, 0x4A, 0x97, 0x4B, 0x97, 0x4C, /* 0x70-0x73 */ 0xE8, 0xF5, 0x97, 0x4D, 0xCD, 0xB0, 0xE8, 0xF6, /* 0x74-0x77 */ 0x97, 0x4E, 0x97, 0x4F, 0x97, 0x50, 0x97, 0x51, /* 0x78-0x7B */ 0x97, 0x52, 0x97, 0x53, 0x97, 0x54, 0x97, 0x55, /* 0x7C-0x7F */ 0x97, 0x56, 0xC1, 0xBA, 0x97, 0x57, 0xE8, 0xE8, /* 0x80-0x83 */ 0x97, 0x58, 0xC3, 0xB7, 0xB0, 0xF0, 0x97, 0x59, /* 0x84-0x87 */ 0x97, 0x5A, 0x97, 0x5B, 0x97, 0x5C, 0x97, 0x5D, /* 0x88-0x8B */ 0x97, 0x5E, 0x97, 0x5F, 0x97, 0x60, 0xE8, 0xF4, /* 0x8C-0x8F */ 0x97, 0x61, 0x97, 0x62, 0x97, 0x63, 0xE8, 0xF7, /* 0x90-0x93 */ 0x97, 0x64, 0x97, 0x65, 0x97, 0x66, 0xB9, 0xA3, /* 0x94-0x97 */ 0x97, 0x67, 0x97, 0x68, 0x97, 0x69, 0x97, 0x6A, /* 0x98-0x9B */ 0x97, 0x6B, 0x97, 0x6C, 0x97, 0x6D, 0x97, 0x6E, /* 0x9C-0x9F */ 0x97, 0x6F, 0x97, 0x70, 0xC9, 0xD2, 0x97, 0x71, /* 0xA0-0xA3 */ 0x97, 0x72, 0x97, 0x73, 0xC3, 0xCE, 0xCE, 0xE0, /* 0xA4-0xA7 */ 0xC0, 0xE6, 0x97, 0x74, 0x97, 0x75, 0x97, 0x76, /* 0xA8-0xAB */ 0x97, 0x77, 0xCB, 0xF3, 0x97, 0x78, 0xCC, 0xDD, /* 0xAC-0xAF */ 0xD0, 0xB5, 0x97, 0x79, 0x97, 0x7A, 0xCA, 0xE1, /* 0xB0-0xB3 */ 0x97, 0x7B, 0xE8, 0xF3, 0x97, 0x7C, 0x97, 0x7D, /* 0xB4-0xB7 */ 0x97, 0x7E, 0x97, 0x80, 0x97, 0x81, 0x97, 0x82, /* 0xB8-0xBB */ 0x97, 0x83, 0x97, 0x84, 0x97, 0x85, 0x97, 0x86, /* 0xBC-0xBF */ 0xBC, 0xEC, 0x97, 0x87, 0xE8, 0xF9, 0x97, 0x88, /* 0xC0-0xC3 */ 0x97, 0x89, 0x97, 0x8A, 0x97, 0x8B, 0x97, 0x8C, /* 0xC4-0xC7 */ 0x97, 0x8D, 0xC3, 0xDE, 0x97, 0x8E, 0xC6, 0xE5, /* 0xC8-0xCB */ 0x97, 0x8F, 0xB9, 0xF7, 0x97, 0x90, 0x97, 0x91, /* 0xCC-0xCF */ 0x97, 0x92, 0x97, 0x93, 0xB0, 0xF4, 0x97, 0x94, /* 0xD0-0xD3 */ 0x97, 0x95, 0xD7, 0xD8, 0x97, 0x96, 0x97, 0x97, /* 0xD4-0xD7 */ 0xBC, 0xAC, 0x97, 0x98, 0xC5, 0xEF, 0x97, 0x99, /* 0xD8-0xDB */ 0x97, 0x9A, 0x97, 0x9B, 0x97, 0x9C, 0x97, 0x9D, /* 0xDC-0xDF */ 0xCC, 0xC4, 0x97, 0x9E, 0x97, 0x9F, 0xE9, 0xA6, /* 0xE0-0xE3 */ 0x97, 0xA0, 0x97, 0xA1, 0x97, 0xA2, 0x97, 0xA3, /* 0xE4-0xE7 */ 0x97, 0xA4, 0x97, 0xA5, 0x97, 0xA6, 0x97, 0xA7, /* 0xE8-0xEB */ 0x97, 0xA8, 0x97, 0xA9, 0xC9, 0xAD, 0x97, 0xAA, /* 0xEC-0xEF */ 0xE9, 0xA2, 0xC0, 0xE2, 0x97, 0xAB, 0x97, 0xAC, /* 0xF0-0xF3 */ 0x97, 0xAD, 0xBF, 0xC3, 0x97, 0xAE, 0x97, 0xAF, /* 0xF4-0xF7 */ 0x97, 0xB0, 0xE8, 0xFE, 0xB9, 0xD7, 0x97, 0xB1, /* 0xF8-0xFB */ 0xE8, 0xFB, 0x97, 0xB2, 0x97, 0xB3, 0x97, 0xB4, /* 0xFC-0xFF */ }; static const unsigned char u2c_69[512] = { 0x97, 0xB5, 0xE9, 0xA4, 0x97, 0xB6, 0x97, 0xB7, /* 0x00-0x03 */ 0x97, 0xB8, 0xD2, 0xCE, 0x97, 0xB9, 0x97, 0xBA, /* 0x04-0x07 */ 0x97, 0xBB, 0x97, 0xBC, 0x97, 0xBD, 0xE9, 0xA3, /* 0x08-0x0B */ 0x97, 0xBE, 0xD6, 0xB2, 0xD7, 0xB5, 0x97, 0xBF, /* 0x0C-0x0F */ 0xE9, 0xA7, 0x97, 0xC0, 0xBD, 0xB7, 0x97, 0xC1, /* 0x10-0x13 */ 0x97, 0xC2, 0x97, 0xC3, 0x97, 0xC4, 0x97, 0xC5, /* 0x14-0x17 */ 0x97, 0xC6, 0x97, 0xC7, 0x97, 0xC8, 0x97, 0xC9, /* 0x18-0x1B */ 0x97, 0xCA, 0x97, 0xCB, 0x97, 0xCC, 0xE8, 0xFC, /* 0x1C-0x1F */ 0xE8, 0xFD, 0x97, 0xCD, 0x97, 0xCE, 0x97, 0xCF, /* 0x20-0x23 */ 0xE9, 0xA1, 0x97, 0xD0, 0x97, 0xD1, 0x97, 0xD2, /* 0x24-0x27 */ 0x97, 0xD3, 0x97, 0xD4, 0x97, 0xD5, 0x97, 0xD6, /* 0x28-0x2B */ 0x97, 0xD7, 0xCD, 0xD6, 0x97, 0xD8, 0x97, 0xD9, /* 0x2C-0x2F */ 0xD2, 0xAC, 0x97, 0xDA, 0x97, 0xDB, 0x97, 0xDC, /* 0x30-0x33 */ 0xE9, 0xB2, 0x97, 0xDD, 0x97, 0xDE, 0x97, 0xDF, /* 0x34-0x37 */ 0x97, 0xE0, 0xE9, 0xA9, 0x97, 0xE1, 0x97, 0xE2, /* 0x38-0x3B */ 0x97, 0xE3, 0xB4, 0xAA, 0x97, 0xE4, 0xB4, 0xBB, /* 0x3C-0x3F */ 0x97, 0xE5, 0x97, 0xE6, 0xE9, 0xAB, 0x97, 0xE7, /* 0x40-0x43 */ 0x97, 0xE8, 0x97, 0xE9, 0x97, 0xEA, 0x97, 0xEB, /* 0x44-0x47 */ 0x97, 0xEC, 0x97, 0xED, 0x97, 0xEE, 0x97, 0xEF, /* 0x48-0x4B */ 0x97, 0xF0, 0x97, 0xF1, 0x97, 0xF2, 0x97, 0xF3, /* 0x4C-0x4F */ 0x97, 0xF4, 0x97, 0xF5, 0x97, 0xF6, 0x97, 0xF7, /* 0x50-0x53 */ 0xD0, 0xA8, 0x97, 0xF8, 0x97, 0xF9, 0xE9, 0xA5, /* 0x54-0x57 */ 0x97, 0xFA, 0x97, 0xFB, 0xB3, 0xFE, 0x97, 0xFC, /* 0x58-0x5B */ 0x97, 0xFD, 0xE9, 0xAC, 0xC0, 0xE3, 0x97, 0xFE, /* 0x5C-0x5F */ 0xE9, 0xAA, 0x98, 0x40, 0x98, 0x41, 0xE9, 0xB9, /* 0x60-0x63 */ 0x98, 0x42, 0x98, 0x43, 0xE9, 0xB8, 0x98, 0x44, /* 0x64-0x67 */ 0x98, 0x45, 0x98, 0x46, 0x98, 0x47, 0xE9, 0xAE, /* 0x68-0x6B */ 0x98, 0x48, 0x98, 0x49, 0xE8, 0xFA, 0x98, 0x4A, /* 0x6C-0x6F */ 0x98, 0x4B, 0xE9, 0xA8, 0x98, 0x4C, 0x98, 0x4D, /* 0x70-0x73 */ 0x98, 0x4E, 0x98, 0x4F, 0x98, 0x50, 0xBF, 0xAC, /* 0x74-0x77 */ 0xE9, 0xB1, 0xE9, 0xBA, 0x98, 0x51, 0x98, 0x52, /* 0x78-0x7B */ 0xC2, 0xA5, 0x98, 0x53, 0x98, 0x54, 0x98, 0x55, /* 0x7C-0x7F */ 0xE9, 0xAF, 0x98, 0x56, 0xB8, 0xC5, 0x98, 0x57, /* 0x80-0x83 */ 0xE9, 0xAD, 0x98, 0x58, 0xD3, 0xDC, 0xE9, 0xB4, /* 0x84-0x87 */ 0xE9, 0xB5, 0xE9, 0xB7, 0x98, 0x59, 0x98, 0x5A, /* 0x88-0x8B */ 0x98, 0x5B, 0xE9, 0xC7, 0x98, 0x5C, 0x98, 0x5D, /* 0x8C-0x8F */ 0x98, 0x5E, 0x98, 0x5F, 0x98, 0x60, 0x98, 0x61, /* 0x90-0x93 */ 0xC0, 0xC6, 0xE9, 0xC5, 0x98, 0x62, 0x98, 0x63, /* 0x94-0x97 */ 0xE9, 0xB0, 0x98, 0x64, 0x98, 0x65, 0xE9, 0xBB, /* 0x98-0x9B */ 0xB0, 0xF1, 0x98, 0x66, 0x98, 0x67, 0x98, 0x68, /* 0x9C-0x9F */ 0x98, 0x69, 0x98, 0x6A, 0x98, 0x6B, 0x98, 0x6C, /* 0xA0-0xA3 */ 0x98, 0x6D, 0x98, 0x6E, 0x98, 0x6F, 0xE9, 0xBC, /* 0xA4-0xA7 */ 0xD5, 0xA5, 0x98, 0x70, 0x98, 0x71, 0xE9, 0xBE, /* 0xA8-0xAB */ 0x98, 0x72, 0xE9, 0xBF, 0x98, 0x73, 0x98, 0x74, /* 0xAC-0xAF */ 0x98, 0x75, 0xE9, 0xC1, 0x98, 0x76, 0x98, 0x77, /* 0xB0-0xB3 */ 0xC1, 0xF1, 0x98, 0x78, 0x98, 0x79, 0xC8, 0xB6, /* 0xB4-0xB7 */ 0x98, 0x7A, 0x98, 0x7B, 0x98, 0x7C, 0xE9, 0xBD, /* 0xB8-0xBB */ 0x98, 0x7D, 0x98, 0x7E, 0x98, 0x80, 0x98, 0x81, /* 0xBC-0xBF */ 0x98, 0x82, 0xE9, 0xC2, 0x98, 0x83, 0x98, 0x84, /* 0xC0-0xC3 */ 0x98, 0x85, 0x98, 0x86, 0x98, 0x87, 0x98, 0x88, /* 0xC4-0xC7 */ 0x98, 0x89, 0x98, 0x8A, 0xE9, 0xC3, 0x98, 0x8B, /* 0xC8-0xCB */ 0xE9, 0xB3, 0x98, 0x8C, 0xE9, 0xB6, 0x98, 0x8D, /* 0xCC-0xCF */ 0xBB, 0xB1, 0x98, 0x8E, 0x98, 0x8F, 0x98, 0x90, /* 0xD0-0xD3 */ 0xE9, 0xC0, 0x98, 0x91, 0x98, 0x92, 0x98, 0x93, /* 0xD4-0xD7 */ 0x98, 0x94, 0x98, 0x95, 0x98, 0x96, 0xBC, 0xF7, /* 0xD8-0xDB */ 0x98, 0x97, 0x98, 0x98, 0x98, 0x99, 0xE9, 0xC4, /* 0xDC-0xDF */ 0xE9, 0xC6, 0x98, 0x9A, 0x98, 0x9B, 0x98, 0x9C, /* 0xE0-0xE3 */ 0x98, 0x9D, 0x98, 0x9E, 0x98, 0x9F, 0x98, 0xA0, /* 0xE4-0xE7 */ 0x98, 0xA1, 0x98, 0xA2, 0x98, 0xA3, 0x98, 0xA4, /* 0xE8-0xEB */ 0x98, 0xA5, 0xE9, 0xCA, 0x98, 0xA6, 0x98, 0xA7, /* 0xEC-0xEF */ 0x98, 0xA8, 0x98, 0xA9, 0xE9, 0xCE, 0x98, 0xAA, /* 0xF0-0xF3 */ 0x98, 0xAB, 0x98, 0xAC, 0x98, 0xAD, 0x98, 0xAE, /* 0xF4-0xF7 */ 0x98, 0xAF, 0x98, 0xB0, 0x98, 0xB1, 0x98, 0xB2, /* 0xF8-0xFB */ 0x98, 0xB3, 0xB2, 0xDB, 0x98, 0xB4, 0xE9, 0xC8, /* 0xFC-0xFF */ }; static const unsigned char u2c_6A[512] = { 0x98, 0xB5, 0x98, 0xB6, 0x98, 0xB7, 0x98, 0xB8, /* 0x00-0x03 */ 0x98, 0xB9, 0x98, 0xBA, 0x98, 0xBB, 0x98, 0xBC, /* 0x04-0x07 */ 0x98, 0xBD, 0x98, 0xBE, 0xB7, 0xAE, 0x98, 0xBF, /* 0x08-0x0B */ 0x98, 0xC0, 0x98, 0xC1, 0x98, 0xC2, 0x98, 0xC3, /* 0x0C-0x0F */ 0x98, 0xC4, 0x98, 0xC5, 0x98, 0xC6, 0x98, 0xC7, /* 0x10-0x13 */ 0x98, 0xC8, 0x98, 0xC9, 0x98, 0xCA, 0xE9, 0xCB, /* 0x14-0x17 */ 0xE9, 0xCC, 0x98, 0xCB, 0x98, 0xCC, 0x98, 0xCD, /* 0x18-0x1B */ 0x98, 0xCE, 0x98, 0xCF, 0x98, 0xD0, 0xD5, 0xC1, /* 0x1C-0x1F */ 0x98, 0xD1, 0xC4, 0xA3, 0x98, 0xD2, 0x98, 0xD3, /* 0x20-0x23 */ 0x98, 0xD4, 0x98, 0xD5, 0x98, 0xD6, 0x98, 0xD7, /* 0x24-0x27 */ 0xE9, 0xD8, 0x98, 0xD8, 0xBA, 0xE1, 0x98, 0xD9, /* 0x28-0x2B */ 0x98, 0xDA, 0x98, 0xDB, 0x98, 0xDC, 0xE9, 0xC9, /* 0x2C-0x2F */ 0x98, 0xDD, 0xD3, 0xA3, 0x98, 0xDE, 0x98, 0xDF, /* 0x30-0x33 */ 0x98, 0xE0, 0xE9, 0xD4, 0x98, 0xE1, 0x98, 0xE2, /* 0x34-0x37 */ 0x98, 0xE3, 0x98, 0xE4, 0x98, 0xE5, 0x98, 0xE6, /* 0x38-0x3B */ 0x98, 0xE7, 0xE9, 0xD7, 0xE9, 0xD0, 0x98, 0xE8, /* 0x3C-0x3F */ 0x98, 0xE9, 0x98, 0xEA, 0x98, 0xEB, 0x98, 0xEC, /* 0x40-0x43 */ 0xE9, 0xCF, 0x98, 0xED, 0x98, 0xEE, 0xC7, 0xC1, /* 0x44-0x47 */ 0x98, 0xEF, 0x98, 0xF0, 0x98, 0xF1, 0x98, 0xF2, /* 0x48-0x4B */ 0x98, 0xF3, 0x98, 0xF4, 0x98, 0xF5, 0x98, 0xF6, /* 0x4C-0x4F */ 0xE9, 0xD2, 0x98, 0xF7, 0x98, 0xF8, 0x98, 0xF9, /* 0x50-0x53 */ 0x98, 0xFA, 0x98, 0xFB, 0x98, 0xFC, 0x98, 0xFD, /* 0x54-0x57 */ 0xE9, 0xD9, 0xB3, 0xC8, 0x98, 0xFE, 0xE9, 0xD3, /* 0x58-0x5B */ 0x99, 0x40, 0x99, 0x41, 0x99, 0x42, 0x99, 0x43, /* 0x5C-0x5F */ 0x99, 0x44, 0xCF, 0xF0, 0x99, 0x45, 0x99, 0x46, /* 0x60-0x63 */ 0x99, 0x47, 0xE9, 0xCD, 0x99, 0x48, 0x99, 0x49, /* 0x64-0x67 */ 0x99, 0x4A, 0x99, 0x4B, 0x99, 0x4C, 0x99, 0x4D, /* 0x68-0x6B */ 0x99, 0x4E, 0x99, 0x4F, 0x99, 0x50, 0x99, 0x51, /* 0x6C-0x6F */ 0x99, 0x52, 0xB3, 0xF7, 0x99, 0x53, 0x99, 0x54, /* 0x70-0x73 */ 0x99, 0x55, 0x99, 0x56, 0x99, 0x57, 0x99, 0x58, /* 0x74-0x77 */ 0x99, 0x59, 0xE9, 0xD6, 0x99, 0x5A, 0x99, 0x5B, /* 0x78-0x7B */ 0xE9, 0xDA, 0x99, 0x5C, 0x99, 0x5D, 0x99, 0x5E, /* 0x7C-0x7F */ 0xCC, 0xB4, 0x99, 0x5F, 0x99, 0x60, 0x99, 0x61, /* 0x80-0x83 */ 0xCF, 0xAD, 0x99, 0x62, 0x99, 0x63, 0x99, 0x64, /* 0x84-0x87 */ 0x99, 0x65, 0x99, 0x66, 0x99, 0x67, 0x99, 0x68, /* 0x88-0x8B */ 0x99, 0x69, 0x99, 0x6A, 0xE9, 0xD5, 0x99, 0x6B, /* 0x8C-0x8F */ 0xE9, 0xDC, 0xE9, 0xDB, 0x99, 0x6C, 0x99, 0x6D, /* 0x90-0x93 */ 0x99, 0x6E, 0x99, 0x6F, 0x99, 0x70, 0xE9, 0xDE, /* 0x94-0x97 */ 0x99, 0x71, 0x99, 0x72, 0x99, 0x73, 0x99, 0x74, /* 0x98-0x9B */ 0x99, 0x75, 0x99, 0x76, 0x99, 0x77, 0x99, 0x78, /* 0x9C-0x9F */ 0xE9, 0xD1, 0x99, 0x79, 0x99, 0x7A, 0x99, 0x7B, /* 0xA0-0xA3 */ 0x99, 0x7C, 0x99, 0x7D, 0x99, 0x7E, 0x99, 0x80, /* 0xA4-0xA7 */ 0x99, 0x81, 0xE9, 0xDD, 0x99, 0x82, 0xE9, 0xDF, /* 0xA8-0xAB */ 0xC3, 0xCA, 0x99, 0x83, 0x99, 0x84, 0x99, 0x85, /* 0xAC-0xAF */ 0x99, 0x86, 0x99, 0x87, 0x99, 0x88, 0x99, 0x89, /* 0xB0-0xB3 */ 0x99, 0x8A, 0x99, 0x8B, 0x99, 0x8C, 0x99, 0x8D, /* 0xB4-0xB7 */ 0x99, 0x8E, 0x99, 0x8F, 0x99, 0x90, 0x99, 0x91, /* 0xB8-0xBB */ 0x99, 0x92, 0x99, 0x93, 0x99, 0x94, 0x99, 0x95, /* 0xBC-0xBF */ 0x99, 0x96, 0x99, 0x97, 0x99, 0x98, 0x99, 0x99, /* 0xC0-0xC3 */ 0x99, 0x9A, 0x99, 0x9B, 0x99, 0x9C, 0x99, 0x9D, /* 0xC4-0xC7 */ 0x99, 0x9E, 0x99, 0x9F, 0x99, 0xA0, 0x99, 0xA1, /* 0xC8-0xCB */ 0x99, 0xA2, 0x99, 0xA3, 0x99, 0xA4, 0x99, 0xA5, /* 0xCC-0xCF */ 0x99, 0xA6, 0x99, 0xA7, 0x99, 0xA8, 0x99, 0xA9, /* 0xD0-0xD3 */ 0x99, 0xAA, 0x99, 0xAB, 0x99, 0xAC, 0x99, 0xAD, /* 0xD4-0xD7 */ 0x99, 0xAE, 0x99, 0xAF, 0x99, 0xB0, 0x99, 0xB1, /* 0xD8-0xDB */ 0x99, 0xB2, 0x99, 0xB3, 0x99, 0xB4, 0x99, 0xB5, /* 0xDC-0xDF */ 0x99, 0xB6, 0x99, 0xB7, 0x99, 0xB8, 0x99, 0xB9, /* 0xE0-0xE3 */ 0x99, 0xBA, 0x99, 0xBB, 0x99, 0xBC, 0x99, 0xBD, /* 0xE4-0xE7 */ 0x99, 0xBE, 0x99, 0xBF, 0x99, 0xC0, 0x99, 0xC1, /* 0xE8-0xEB */ 0x99, 0xC2, 0x99, 0xC3, 0x99, 0xC4, 0x99, 0xC5, /* 0xEC-0xEF */ 0x99, 0xC6, 0x99, 0xC7, 0x99, 0xC8, 0x99, 0xC9, /* 0xF0-0xF3 */ 0x99, 0xCA, 0x99, 0xCB, 0x99, 0xCC, 0x99, 0xCD, /* 0xF4-0xF7 */ 0x99, 0xCE, 0x99, 0xCF, 0x99, 0xD0, 0x99, 0xD1, /* 0xF8-0xFB */ 0x99, 0xD2, 0x99, 0xD3, 0x99, 0xD4, 0x99, 0xD5, /* 0xFC-0xFF */ }; static const unsigned char u2c_6B[512] = { 0x99, 0xD6, 0x99, 0xD7, 0x99, 0xD8, 0x99, 0xD9, /* 0x00-0x03 */ 0x99, 0xDA, 0x99, 0xDB, 0x99, 0xDC, 0x99, 0xDD, /* 0x04-0x07 */ 0x99, 0xDE, 0x99, 0xDF, 0x99, 0xE0, 0x99, 0xE1, /* 0x08-0x0B */ 0x99, 0xE2, 0x99, 0xE3, 0x99, 0xE4, 0x99, 0xE5, /* 0x0C-0x0F */ 0x99, 0xE6, 0x99, 0xE7, 0x99, 0xE8, 0x99, 0xE9, /* 0x10-0x13 */ 0x99, 0xEA, 0x99, 0xEB, 0x99, 0xEC, 0x99, 0xED, /* 0x14-0x17 */ 0x99, 0xEE, 0x99, 0xEF, 0x99, 0xF0, 0x99, 0xF1, /* 0x18-0x1B */ 0x99, 0xF2, 0x99, 0xF3, 0x99, 0xF4, 0x99, 0xF5, /* 0x1C-0x1F */ 0xC7, 0xB7, 0xB4, 0xCE, 0xBB, 0xB6, 0xD0, 0xC0, /* 0x20-0x23 */ 0xEC, 0xA3, 0x99, 0xF6, 0x99, 0xF7, 0xC5, 0xB7, /* 0x24-0x27 */ 0x99, 0xF8, 0x99, 0xF9, 0x99, 0xFA, 0x99, 0xFB, /* 0x28-0x2B */ 0x99, 0xFC, 0x99, 0xFD, 0x99, 0xFE, 0x9A, 0x40, /* 0x2C-0x2F */ 0x9A, 0x41, 0x9A, 0x42, 0xD3, 0xFB, 0x9A, 0x43, /* 0x30-0x33 */ 0x9A, 0x44, 0x9A, 0x45, 0x9A, 0x46, 0xEC, 0xA4, /* 0x34-0x37 */ 0x9A, 0x47, 0xEC, 0xA5, 0xC6, 0xDB, 0x9A, 0x48, /* 0x38-0x3B */ 0x9A, 0x49, 0x9A, 0x4A, 0xBF, 0xEE, 0x9A, 0x4B, /* 0x3C-0x3F */ 0x9A, 0x4C, 0x9A, 0x4D, 0x9A, 0x4E, 0xEC, 0xA6, /* 0x40-0x43 */ 0x9A, 0x4F, 0x9A, 0x50, 0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, /* 0xF8-0xFB */ 0x9E, 0x54, 0x9E, 0x55, 0x9E, 0x56, 0x9E, 0x57, /* 0xFC-0xFF */ }; static const unsigned char u2c_70[512] = { 0x9E, 0x58, 0x9E, 0x59, 0x9E, 0x5A, 0x9E, 0x5B, /* 0x00-0x03 */ 0x9E, 0x5C, 0x9E, 0x5D, 0x9E, 0x5E, 0x9E, 0x5F, /* 0x04-0x07 */ 0x9E, 0x60, 0x9E, 0x61, 0x9E, 0x62, 0x9E, 0x63, /* 0x08-0x0B */ 0x9E, 0x64, 0x9E, 0x65, 0x9E, 0x66, 0x9E, 0x67, /* 0x0C-0x0F */ 0x9E, 0x68, 0xC6, 0xD9, 0x9E, 0x69, 0x9E, 0x6A, /* 0x10-0x13 */ 0x9E, 0x6B, 0x9E, 0x6C, 0x9E, 0x6D, 0x9E, 0x6E, /* 0x14-0x17 */ 0x9E, 0x6F, 0x9E, 0x70, 0xE5, 0xAB, 0xE5, 0xAD, /* 0x18-0x1B */ 0x9E, 0x71, 0x9E, 0x72, 0x9E, 0x73, 0x9E, 0x74, /* 0x1C-0x1F */ 0x9E, 0x75, 0x9E, 0x76, 0x9E, 0x77, 0xE5, 0xAC, /* 0x20-0x23 */ 0x9E, 0x78, 0x9E, 0x79, 0x9E, 0x7A, 0x9E, 0x7B, /* 0x24-0x27 */ 0x9E, 0x7C, 0x9E, 0x7D, 0x9E, 0x7E, 0x9E, 0x80, /* 0x28-0x2B */ 0x9E, 0x81, 0x9E, 0x82, 0x9E, 0x83, 0x9E, 0x84, /* 0x2C-0x2F */ 0x9E, 0x85, 0x9E, 0x86, 0x9E, 0x87, 0x9E, 0x88, /* 0x30-0x33 */ 0x9E, 0x89, 0xE5, 0xAF, 0x9E, 0x8A, 0x9E, 0x8B, /* 0x34-0x37 */ 0x9E, 0x8C, 0xE5, 0xAE, 0x9E, 0x8D, 0x9E, 0x8E, /* 0x38-0x3B */ 0x9E, 0x8F, 0x9E, 0x90, 0x9E, 0x91, 0x9E, 0x92, /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B3, 0x41, 0xBE, 0xD8, 0xB3, 0x42, 0xBD, 0xC3, /* 0xE8-0xEB */ 0xEF, 0xF3, 0xB6, 0xCC, 0xB0, 0xAB, 0xB3, 0x43, /* 0xEC-0xEF */ 0xB3, 0x44, 0xB3, 0x45, 0xB3, 0x46, 0xCA, 0xAF, /* 0xF0-0xF3 */ 0xB3, 0x47, 0xB3, 0x48, 0xED, 0xB6, 0xB3, 0x49, /* 0xF4-0xF7 */ 0xED, 0xB7, 0xB3, 0x4A, 0xB3, 0x4B, 0xB3, 0x4C, /* 0xF8-0xFB */ 0xB3, 0x4D, 0xCE, 0xF9, 0xB7, 0xAF, 0xBF, 0xF3, /* 0xFC-0xFF */ }; static const unsigned char u2c_78[512] = { 0xED, 0xB8, 0xC2, 0xEB, 0xC9, 0xB0, 0xB3, 0x4E, /* 0x00-0x03 */ 0xB3, 0x4F, 0xB3, 0x50, 0xB3, 0x51, 0xB3, 0x52, /* 0x04-0x07 */ 0xB3, 0x53, 0xED, 0xB9, 0xB3, 0x54, 0xB3, 0x55, /* 0x08-0x0B */ 0xC6, 0xF6, 0xBF, 0xB3, 0xB3, 0x56, 0xB3, 0x57, /* 0x0C-0x0F */ 0xB3, 0x58, 0xED, 0xBC, 0xC5, 0xF8, 0xB3, 0x59, /* 0x10-0x13 */ 0xD1, 0xD0, 0xB3, 0x5A, 0xD7, 0xA9, 0xED, 0xBA, /* 0x14-0x17 */ 0xED, 0xBB, 0xB3, 0x5B, 0xD1, 0xE2, 0xB3, 0x5C, /* 0x18-0x1B */ 0xED, 0xBF, 0xED, 0xC0, 0xB3, 0x5D, 0xED, 0xC4, /* 0x1C-0x1F */ 0xB3, 0x5E, 0xB3, 0x5F, 0xB3, 0x60, 0xED, 0xC8, /* 0x20-0x23 */ 0xB3, 0x61, 0xED, 0xC6, 0xED, 0xCE, 0xD5, 0xE8, /* 0x24-0x27 */ 0xB3, 0x62, 0xED, 0xC9, 0xB3, 0x63, 0xB3, 0x64, /* 0x28-0x2B */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7, 0xB4, 0x91, /* 0xF8-0xFB */ 0xB4, 0x92, 0xB4, 0x93, 0xB4, 0x94, 0xB4, 0x95, /* 0xFC-0xFF */ }; static const unsigned char u2c_79[512] = { 0xB4, 0x96, 0xBD, 0xB8, 0xB4, 0x97, 0xB4, 0x98, /* 0x00-0x03 */ 0xB4, 0x99, 0xED, 0xE2, 0xB4, 0x9A, 0xB4, 0x9B, /* 0x04-0x07 */ 0xB4, 0x9C, 0xB4, 0x9D, 0xB4, 0x9E, 0xB4, 0x9F, /* 0x08-0x0B */ 0xB4, 0xA0, 0xB5, 0x40, 0xB5, 0x41, 0xB5, 0x42, /* 0x0C-0x0F */ 0xB5, 0x43, 0xB5, 0x44, 0xB5, 0x45, 0xED, 0xE4, /* 0x10-0x13 */ 0xB5, 0x46, 0xB5, 0x47, 0xB5, 0x48, 0xB5, 0x49, /* 0x14-0x17 */ 0xB5, 0x4A, 0xB5, 0x4B, 0xB5, 0x4C, 0xB5, 0x4D, /* 0x18-0x1B */ 0xB5, 0x4E, 0xB5, 0x4F, 0xED, 0xE6, 0xB5, 0x50, /* 0x1C-0x1F */ 0xB5, 0x51, 0xB5, 0x52, 0xB5, 0x53, 0xB5, 0x54, /* 0x20-0x23 */ 0xED, 0xE5, 0xB5, 0x55, 0xB5, 0x56, 0xB5, 0x57, /* 0x24-0x27 */ 0xB5, 0x58, 0xB5, 0x59, 0xB5, 0x5A, 0xB5, 0x5B, /* 0x28-0x2B */ 0xB5, 0x5C, 0xB5, 0x5D, 0xB5, 0x5E, 0xB5, 0x5F, /* 0x2C-0x2F */ 0xB5, 0x60, 0xB5, 0x61, 0xB5, 0x62, 0xB5, 0x63, /* 0x30-0x33 */ 0xED, 0xE7, 0xB5, 0x64, 0xB5, 0x65, 0xB5, 0x66, /* 0x34-0x37 */ 0xB5, 0x67, 0xB5, 0x68, 0xCA, 0xBE, 0xEC, 0xEA, /* 0x38-0x3B */ 0xC0, 0xF1, 0xB5, 0x69, 0xC9, 0xE7, 0xB5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, /* 0xF4-0xF7 */ 0xF4, 0xE9, 0xBC, 0x69, 0xBC, 0x6A, 0xCF, 0xB5, /* 0xF8-0xFB */ 0xBC, 0x6B, 0xBC, 0x6C, 0xBC, 0x6D, 0xBC, 0x6E, /* 0xFC-0xFF */ }; static const unsigned char u2c_7D[512] = { 0xBC, 0x6F, 0xBC, 0x70, 0xBC, 0x71, 0xBC, 0x72, /* 0x00-0x03 */ 0xBC, 0x73, 0xBC, 0x74, 0xBC, 0x75, 0xBC, 0x76, /* 0x04-0x07 */ 0xBC, 0x77, 0xBC, 0x78, 0xCE, 0xC9, 0xBC, 0x79, /* 0x08-0x0B */ 0xBC, 0x7A, 0xBC, 0x7B, 0xBC, 0x7C, 0xBC, 0x7D, /* 0x0C-0x0F */ 0xBC, 0x7E, 0xBC, 0x80, 0xBC, 0x81, 0xBC, 0x82, /* 0x10-0x13 */ 0xBC, 0x83, 0xBC, 0x84, 0xBC, 0x85, 0xBC, 0x86, /* 0x14-0x17 */ 0xBC, 0x87, 0xBC, 0x88, 0xBC, 0x89, 0xBC, 0x8A, /* 0x18-0x1B */ 0xBC, 0x8B, 0xBC, 0x8C, 0xBC, 0x8D, 0xBC, 0x8E, /* 0x1C-0x1F */ 0xCB, 0xD8, 0xBC, 0x8F, 0xCB, 0xF7, 0xBC, 0x90, /* 0x20-0x23 */ 0xBC, 0x91, 0xBC, 0x92, 0xBC, 0x93, 0xBD, 0xF4, /* 0x24-0x27 */ 0xBC, 0x94, 0xBC, 0x95, 0xBC, 0x96, 0xD7, 0xCF, /* 0x28-0x2B */ 0xBC, 0x97, 0xBC, 0x98, 0xBC, 0x99, 0xC0, 0xDB, /* 0x2C-0x2F */ 0xBC, 0x9A, 0xBC, 0x9B, 0xBC, 0x9C, 0xBC, 0x9D, /* 0x30-0x33 */ 0xBC, 0x9E, 0xBC, 0x9F, 0xBC, 0xA0, 0xBD, 0x40, /* 0x34-0x37 */ 0xBD, 0x41, 0xBD, 0x42, 0xBD, 0x43, 0xBD,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, 0x40, 0xCC, 0x41, 0xD4, 0xE5, /* 0xF8-0xFB */ 0xCC, 0x42, 0xCC, 0x43, 0xCC, 0x44, 0xDE, 0xBD, /* 0xFC-0xFF */ }; static const unsigned char u2c_86[512] = { 0xCC, 0x45, 0xCC, 0x46, 0xCC, 0x47, 0xCC, 0x48, /* 0x00-0x03 */ 0xCC, 0x49, 0xDE, 0xBF, 0xCC, 0x4A, 0xCC, 0x4B, /* 0x04-0x07 */ 0xCC, 0x4C, 0xCC, 0x4D, 0xCC, 0x4E, 0xCC, 0x4F, /* 0x08-0x0B */ 0xCC, 0x50, 0xCC, 0x51, 0xCC, 0x52, 0xCC, 0x53, /* 0x0C-0x0F */ 0xCC, 0x54, 0xC4, 0xA2, 0xCC, 0x55, 0xCC, 0x56, /* 0x10-0x13 */ 0xCC, 0x57, 0xCC, 0x58, 0xDE, 0xC1, 0xCC, 0x59, /* 0x14-0x17 */ 0xCC, 0x5A, 0xCC, 0x5B, 0xCC, 0x5C, 0xCC, 0x5D, /* 0x18-0x1B */ 0xCC, 0x5E, 0xCC, 0x5F, 0xCC, 0x60, 0xCC, 0x61, /* 0x1C-0x1F */ 0xCC, 0x62, 0xCC, 0x63, 0xCC, 0x64, 0xCC, 0x65, /* 0x20-0x23 */ 0xCC, 0x66, 0xCC, 0x67, 0xCC, 0x68, 0xDE, 0xBE, /* 0x24-0x27 */ 0xCC, 0x69, 0xDE, 0xC0, 0xCC, 0x6A, 0xCC, 0x6B, /* 0x28-0x2B */ 0xCC, 0x6C, 0xCC, 0x6D, 0xCC, 0x6E, 0xCC, 0x6F, /* 0x2C-0x2F */ 0xCC, 0x70, 0xCC, 0x71, 0xCC, 0x72, 0xCC, 0x73, /* 0x30-0x33 */ 0xCC, 0x74, 0xCC, 0x75, 0xCC, 0x76, 0xCC, 0x77, /* 0x34-0x37 */ 0xD5, 0xBA, 0xCC, 0x78, 0xCC, 0x79, 0xCC, 0x7A, /* 0x38-0x3B */ 0xDE, 0xC2, 0xCC, 0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D3, 0x7A, 0xD3, 0x7B, /* 0xF4-0xF7 */ 0xD3, 0x7C, 0xD3, 0x7D, 0xD3, 0x7E, 0xD3, 0x80, /* 0xF8-0xFB */ 0xD3, 0x81, 0xD3, 0x82, 0xD3, 0x83, 0xD3, 0x84, /* 0xFC-0xFF */ }; static const unsigned char u2c_8A[512] = { 0xD1, 0xD4, 0xD3, 0x85, 0xD3, 0x86, 0xD3, 0x87, /* 0x00-0x03 */ 0xD3, 0x88, 0xD3, 0x89, 0xD3, 0x8A, 0xD9, 0xEA, /* 0x04-0x07 */ 0xD3, 0x8B, 0xD3, 0x8C, 0xD3, 0x8D, 0xD3, 0x8E, /* 0x08-0x0B */ 0xD3, 0x8F, 0xD3, 0x90, 0xD3, 0x91, 0xD3, 0x92, /* 0x0C-0x0F */ 0xD3, 0x93, 0xD3, 0x94, 0xD3, 0x95, 0xD3, 0x96, /* 0x10-0x13 */ 0xD3, 0x97, 0xD3, 0x98, 0xD3, 0x99, 0xD3, 0x9A, /* 0x14-0x17 */ 0xD3, 0x9B, 0xD3, 0x9C, 0xD3, 0x9D, 0xD3, 0x9E, /* 0x18-0x1B */ 0xD3, 0x9F, 0xD3, 0xA0, 0xD4, 0x40, 0xD4, 0x41, /* 0x1C-0x1F */ 0xD4, 0x42, 0xD4, 0x43, 0xD4, 0x44, 0xD4, 0x45, /* 0x20-0x23 */ 0xD4, 0x46, 0xD4, 0x47, 0xD4, 0x48, 0xD4, 0x49, /* 0x24-0x27 */ 0xD4, 0x4A, 0xD4, 0x4B, 0xD4, 0x4C, 0xD4, 0x4D, /* 0x28-0x2B */ 0xD4, 0x4E, 0xD4, 0x4F, 0xD4, 0x50, 0xD4, 0x51, /* 0x2C-0x2F */ 0xD4, 0x52, 0xD4, 0x53, 0xD4, 0x54, 0xD4, 0x55, /* 0x30-0x33 */ 0xD4, 0x56, 0xD4, 0x57, 0xD4, 0x58, 0xD4, 0x59, /* 0x34-0x37 */ 0xD4, 0x5A, 0xD4, 0x5B, 0x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 0xE8-0xEB */ 0xE2, 0x46, 0xE2, 0x47, 0xE2, 0x48, 0xE2, 0x49, /* 0xEC-0xEF */ 0xE2, 0x4A, 0xE2, 0x4B, 0xE2, 0x4C, 0xE2, 0x4D, /* 0xF0-0xF3 */ 0xE2, 0x4E, 0xE2, 0x4F, 0xE2, 0x50, 0xE2, 0x51, /* 0xF4-0xF7 */ 0xE2, 0x52, 0xE2, 0x53, 0xE2, 0x54, 0xE2, 0x55, /* 0xF8-0xFB */ 0xE2, 0x56, 0xE2, 0x57, 0xE2, 0x58, 0xE2, 0x59, /* 0xFC-0xFF */ }; static const unsigned char u2c_92[512] = { 0xE2, 0x5A, 0xE2, 0x5B, 0xE2, 0x5C, 0xE2, 0x5D, /* 0x00-0x03 */ 0xE2, 0x5E, 0xE2, 0x5F, 0xE2, 0x60, 0xE2, 0x61, /* 0x04-0x07 */ 0xE2, 0x62, 0xE2, 0x63, 0xE2, 0x64, 0xE2, 0x65, /* 0x08-0x0B */ 0xE2, 0x66, 0xE2, 0x67, 0xE2, 0x68, 0xE2, 0x69, /* 0x0C-0x0F */ 0xE2, 0x6A, 0xE2, 0x6B, 0xE2, 0x6C, 0xE2, 0x6D, /* 0x10-0x13 */ 0xE2, 0x6E, 0xE2, 0x6F, 0xE2, 0x70, 0xE2, 0x71, /* 0x14-0x17 */ 0xE2, 0x72, 0xE2, 0x73, 0xE2, 0x74, 0xE2, 0x75, /* 0x18-0x1B */ 0xE2, 0x76, 0xE2, 0x77, 0xE2, 0x78, 0xE2, 0x79, /* 0x1C-0x1F */ 0xE2, 0x7A, 0xE2, 0x7B, 0xE2, 0x7C, 0xE2, 0x7D, /* 0x20-0x23 */ 0xE2, 0x7E, 0xE2, 0x80, 0xE2, 0x81, 0xE2, 0x82, /* 0x24-0x27 */ 0xE2, 0x83, 0xE2, 0x84, 0xE2, 0x85, 0xE2, 0x86, /* 0x28-0x2B */ 0xE2, 0x87, 0xE2, 0x88, 0xE2, 0x89, 0xE2, 0x8A, /* 0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, 0xE4, 0x96, /* 0xFC-0xFF */ }; static const unsigned char u2c_93[512] = { 0xE4, 0x97, 0xE4, 0x98, 0xE4, 0x99, 0xE4, 0x9A, /* 0x00-0x03 */ 0xE4, 0x9B, 0xE4, 0x9C, 0xE4, 0x9D, 0xE4, 0x9E, /* 0x04-0x07 */ 0xE4, 0x9F, 0xE4, 0xA0, 0xE5, 0x40, 0xE5, 0x41, /* 0x08-0x0B */ 0xE5, 0x42, 0xE5, 0x43, 0xE5, 0x44, 0xE5, 0x45, /* 0x0C-0x0F */ 0xE5, 0x46, 0xE5, 0x47, 0xE5, 0x48, 0xE5, 0x49, /* 0x10-0x13 */ 0xE5, 0x4A, 0xE5, 0x4B, 0xE5, 0x4C, 0xE5, 0x4D, /* 0x14-0x17 */ 0xE5, 0x4E, 0xE5, 0x4F, 0xE5, 0x50, 0xE5, 0x51, /* 0x18-0x1B */ 0xE5, 0x52, 0xE5, 0x53, 0xE5, 0x54, 0xE5, 0x55, /* 0x1C-0x1F */ 0xE5, 0x56, 0xE5, 0x57, 0xE5, 0x58, 0xE5, 0x59, /* 0x20-0x23 */ 0xE5, 0x5A, 0xE5, 0x5B, 0xE5, 0x5C, 0xE5, 0x5D, /* 0x24-0x27 */ 0xE5, 0x5E, 0xE5, 0x5F, 0xE5, 0x60, 0xE5, 0x61, /* 0x28-0x2B */ 0xE5, 0x62, 0xE5, 0x63, 0xE5, 0x64, 0xE5, 0x65, /* 0x2C-0x2F */ 0xE5, 0x66, 0xE5, 0x67, 0xE5, 0x68, 0xE5, 0x69, /* 0x30-0x33 */ 0xE5, 0x6A, 0xE5, 0x6B, 0xE5, 0x6C, 0xE5, 0x6D, /* 0x34-0x37 */ 0xE5, 0x6E, 0xE5, 0x6F, 0xE5, 0x70, 0xE5, 0x71, /* 0x38-0x3B */ 0xE5, 0x72, 0xE5, 0x73, 0xF6, 0xC9, 0xE5, 0x74, /* 0x3C-0x3F */ 0xE5, 0x75, 0xE5, 0x76, 0xE5, 0x77, 0xE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x62, /* 0xC4-0xC7 */ 0xED, 0x63, 0xED, 0x64, 0xED, 0x65, 0xED, 0x66, /* 0xC8-0xCB */ 0xED, 0x67, 0xED, 0x68, 0xED, 0x69, 0xED, 0x6A, /* 0xCC-0xCF */ 0xED, 0x6B, 0xED, 0x6C, 0xED, 0x6D, 0xED, 0x6E, /* 0xD0-0xD3 */ 0xED, 0x6F, 0xED, 0x70, 0xED, 0x71, 0xED, 0x72, /* 0xD4-0xD7 */ 0xED, 0x73, 0xED, 0x74, 0xED, 0x75, 0xED, 0x76, /* 0xD8-0xDB */ 0xED, 0x77, 0xED, 0x78, 0xED, 0x79, 0xED, 0x7A, /* 0xDC-0xDF */ 0xED, 0x7B, 0xED, 0x7C, 0xED, 0x7D, 0xED, 0x7E, /* 0xE0-0xE3 */ 0xED, 0x80, 0xED, 0x81, 0xCE, 0xA4, 0xC8, 0xCD, /* 0xE4-0xE7 */ 0xED, 0x82, 0xBA, 0xAB, 0xE8, 0xB8, 0xE8, 0xB9, /* 0xE8-0xEB */ 0xE8, 0xBA, 0xBE, 0xC2, 0xED, 0x83, 0xED, 0x84, /* 0xEC-0xEF */ 0xED, 0x85, 0xED, 0x86, 0xED, 0x87, 0xD2, 0xF4, /* 0xF0-0xF3 */ 0xED, 0x88, 0xD4, 0xCF, 0xC9, 0xD8, 0xED, 0x89, /* 0xF4-0xF7 */ 0xED, 0x8A, 0xED, 0x8B, 0xED, 0x8C, 0xED, 0x8D, /* 0xF8-0xFB */ 0xED, 0x8E, 0xED, 0x8F, 0xED, 0x90, 0xED, 0x91, /* 0xFC-0xFF */ }; static const unsigned char u2c_98[512] = { 0xED, 0x92, 0xED, 0x93, 0xED, 0x94, 0xED, 0x95, /* 0x00-0x03 */ 0xED, 0x96, 0xED, 0x97, 0xED, 0x98, 0xED, 0x99, /* 0x04-0x07 */ 0xED, 0x9A, 0xED, 0x9B, 0xED, 0x9C, 0xED, 0x9D, /* 0x08-0x0B */ 0xED, 0x9E, 0xED, 0x9F, 0x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, 0x93, 0xF1, 0x94, 0xF1, 0x95, 0xF1, 0x96, /* 0xEC-0xEF */ 0xF1, 0x97, 0xF1, 0x98, 0xF1, 0x99, 0xF1, 0x9A, /* 0xF0-0xF3 */ 0xF1, 0x9B, 0xF1, 0x9C, 0xF1, 0x9D, 0xF1, 0x9E, /* 0xF4-0xF7 */ 0xF1, 0x9F, 0xF1, 0xA0, 0xF2, 0x40, 0xF2, 0x41, /* 0xF8-0xFB */ 0xF2, 0x42, 0xF2, 0x43, 0xF2, 0x44, 0xF2, 0x45, /* 0xFC-0xFF */ }; static const unsigned char u2c_9A[512] = { 0xF2, 0x46, 0xF2, 0x47, 0xF2, 0x48, 0xF2, 0x49, /* 0x00-0x03 */ 0xF2, 0x4A, 0xF2, 0x4B, 0xF2, 0x4C, 0xF2, 0x4D, /* 0x04-0x07 */ 0xF2, 0x4E, 0xF2, 0x4F, 0xF2, 0x50, 0xF2, 0x51, /* 0x08-0x0B */ 0xF2, 0x52, 0xF2, 0x53, 0xF2, 0x54, 0xF2, 0x55, /* 0x0C-0x0F */ 0xF2, 0x56, 0xF2, 0x57, 0xF2, 0x58, 0xF2, 0x59, /* 0x10-0x13 */ 0xF2, 0x5A, 0xF2, 0x5B, 0xF2, 0x5C, 0xF2, 0x5D, /* 0x14-0x17 */ 0xF2, 0x5E, 0xF2, 0x5F, 0xF2, 0x60, 0xF2, 0x61, /* 0x18-0x1B */ 0xF2, 0x62, 0xF2, 0x63, 0xF2, 0x64, 0xF2, 0x65, /* 0x1C-0x1F */ 0xF2, 0x66, 0xF2, 0x67, 0xF2, 0x68, 0xF2, 0x69, /* 0x20-0x23 */ 0xF2, 0x6A, 0xF2, 0x6B, 0xF2, 0x6C, 0xF2, 0x6D, /* 0x24-0x27 */ 0xF2, 0x6E, 0xF2, 0x6F, 0xF2, 0x70, 0xF2, 0x71, /* 0x28-0x2B */ 0xF2, 0x72, 0xF2, 0x73, 0xF2, 0x74, 0xF2, 0x75, /* 0x2C-0x2F */ 0xF2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0x97, 0xF3, 0x98, 0xF3, 0x99, 0xF3, 0x9A, /* 0xFC-0xFF */ }; static const unsigned char u2c_9B[512] = { 0xF3, 0x9B, 0xF3, 0x9C, 0xF3, 0x9D, 0xD7, 0xD7, /* 0x00-0x03 */ 0xF3, 0x9E, 0xF3, 0x9F, 0xF3, 0xA0, 0xF4, 0x40, /* 0x04-0x07 */ 0xF7, 0xDC, 0xF4, 0x41, 0xF4, 0x42, 0xF4, 0x43, /* 0x08-0x0B */ 0xF4, 0x44, 0xF4, 0x45, 0xF4, 0x46, 0xF7, 0xDD, /* 0x0C-0x0F */ 0xF4, 0x47, 0xF4, 0x48, 0xF4, 0x49, 0xF7, 0xDE, /* 0x10-0x13 */ 0xF4, 0x4A, 0xF4, 0x4B, 0xF4, 0x4C, 0xF4, 0x4D, /* 0x14-0x17 */ 0xF4, 0x4E, 0xF4, 0x4F, 0xF4, 0x50, 0xF4, 0x51, /* 0x18-0x1B */ 0xF4, 0x52, 0xF4, 0x53, 0xF4, 0x54, 0xF7, 0xDF, /* 0x1C-0x1F */ 0xF4, 0x55, 0xF4, 0x56, 0xF4, 0x57, 0xF7, 0xE0, /* 0x20-0x23 */ 0xF4, 0x58, 0xF4, 0x59, 0xF4, 0x5A, 0xF4, 0x5B, /* 0x24-0x27 */ 0xF4, 0x5C, 0xF4, 0x5D, 0xF4, 0x5E, 0xF4, 0x5F, /* 0x28-0x2B */ 0xF4, 0x60, 0xF4, 0x61, 0xF4, 0x62, 0xDB, 0xCB, /* 0x2C-0x2F */ 0xF4, 0x63, 0xF4, 0x64, 0xD8, 0xAA, 0xF4, 0x65, /* 0x30-0x33 */ 0xF4, 0x66, 0xF4, 0x67, 0xF4, 0x68, 0xF4, 0x69, /* 0x34-0x37 */ 0xF4, 0x6A, 0xF4, 0x6B, 0xF4, 0x6C, 0xE5, 0xF7, /* 0x38-0x3B */ 0xB9, 0xED, 0xF4, 0x6D, 0xF4, 0x6E, 0xF4, 0x6F, /* 0x3C-0x3F */ 0x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0xFC, 0x77, 0xF6, 0xBC, 0xFC, 0x78, /* 0xFC-0xFF */ }; static const unsigned char u2c_9F[512] = { 0xFC, 0x79, 0xFC, 0x7A, 0xFC, 0x7B, 0xFC, 0x7C, /* 0x00-0x03 */ 0xFC, 0x7D, 0xFC, 0x7E, 0xFC, 0x80, 0xFC, 0x81, /* 0x04-0x07 */ 0xFC, 0x82, 0xFC, 0x83, 0xFC, 0x84, 0xF6, 0xBD, /* 0x08-0x0B */ 0xFC, 0x85, 0xF6, 0xBE, 0xB6, 0xA6, 0xFC, 0x86, /* 0x0C-0x0F */ 0xD8, 0xBE, 0xFC, 0x87, 0xFC, 0x88, 0xB9, 0xC4, /* 0x10-0x13 */ 0xFC, 0x89, 0xFC, 0x8A, 0xFC, 0x8B, 0xD8, 0xBB, /* 0x14-0x17 */ 0xFC, 0x8C, 0xDC, 0xB1, 0xFC, 0x8D, 0xFC, 0x8E, /* 0x18-0x1B */ 0xFC, 0x8F, 0xFC, 0x90, 0xFC, 0x91, 0xFC, 0x92, /* 0x1C-0x1F */ 0xCA, 0xF3, 0xFC, 0x93, 0xF7, 0xF7, 0xFC, 0x94, /* 0x20-0x23 */ 0xFC, 0x95, 0xFC, 0x96, 0xFC, 0x97, 0xFC, 0x98, /* 0x24-0x27 */ 0xFC, 0x99, 0xFC, 0x9A, 0xFC, 0x9B, 0xFC, 0x9C, /* 0x28-0x2B */ 0xF7, 0xF8, 0xFC, 0x9D, 0xFC, 0x9E, 0xF7, 0xF9, /* 0x2C-0x2F */ 0xFC, 0x9F, 0xFC, 0xA0, 0xFD, 0x40, 0xFD, 0x41, /* 0x30-0x33 */ 0xFD, 0x42, 0xFD, 0x43, 0xFD, 0x44, 0xF7, 0xFB, /* 0x34-0x37 */ 0xFD, 0x45, 0xF7, 0xFA, 0xFD, 0x46, 0xB1, 0xC7, /* 0x38-0x3B */ 0xFD, 0x47, 0xF7, 0xFC, 0xF7, 0xFD, 0xFD, 0x48, /* 0x3C-0x3F */ 0xFD, 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, 0xB6, 0xF6, 0xB7, /* 0x84-0x87 */ 0xF6, 0xB8, 0xF6, 0xB9, 0xF6, 0xBA, 0xC8, 0xA3, /* 0x88-0x8B */ 0xF6, 0xBB, 0xFD, 0x88, 0xFD, 0x89, 0xFD, 0x8A, /* 0x8C-0x8F */ 0xFD, 0x8B, 0xFD, 0x8C, 0xFD, 0x8D, 0xFD, 0x8E, /* 0x90-0x93 */ 0xFD, 0x8F, 0xFD, 0x90, 0xFD, 0x91, 0xFD, 0x92, /* 0x94-0x97 */ 0xFD, 0x93, 0xC1, 0xFA, 0xB9, 0xA8, 0xED, 0xE8, /* 0x98-0x9B */ 0xFD, 0x94, 0xFD, 0x95, 0xFD, 0x96, 0xB9, 0xEA, /* 0x9C-0x9F */ 0xD9, 0xDF, 0xFD, 0x97, 0xFD, 0x98, 0xFD, 0x99, /* 0xA0-0xA3 */ 0xFD, 0x9A, 0xFD, 0x9B, 0x00, 0x00, 0x00, 0x00, /* 0xA4-0xA7 */ }; static const unsigned char u2c_DC[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ }; static const unsigned char u2c_F9[512] = { 0xD8, 0x4D, 0xB8, 0xFC, 0xDC, 0x87, 0xD9, 0x5A, /* 0x00-0x03 */ 0xBB, 0xAC, 0xB4, 0xAE, 0xBE, 0xE4, 0xFD, 0x94, /* 0x04-0x07 */ 0xFD, 0x94, 0xC6, 0xF5, 0xBD, 0xF0, 0xC0, 0xAE, /* 0x08-0x0B */ 0xC4, 0xCE, 0x91, 0xD0, 0xB0, 0x5D, 0xC1, 0x5F, /* 0x0C-0x0F */ 0xCC, 0x7D, 0xC2, 0xDD, 0xC2, 0xE3, 0xDF, 0x89, /* 0x10-0x13 */ 0x98, 0xB7, 0xC2, 0xE5, 0xC0, 0xD3, 0xE7, 0xF3, /* 0x14-0x17 */ 0xC2, 0xE4, 0xC0, 0xD2, 0xF1, 0x98, 0x81, 0x79, /* 0x18-0x1B */ 0x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 0x28-0x2B */ 0xF0, 0x5E, 0xFA, 0x51, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ }; static const unsigned char u2c_FE[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */ 0xA9, 0x55, 0xA6, 0xF2, 0x00, 0x00, 0xA6, 0xF4, /* 0x30-0x33 */ 0xA6, 0xF5, 0xA6, 0xE0, 0xA6, 0xE1, 0xA6, 0xF0, /* 0x34-0x37 */ 0xA6, 0xF1, 0xA6, 0xE2, 0xA6, 0xE3, 0xA6, 0xEE, /* 0x38-0x3B */ 0xA6, 0xEF, 0xA6, 0xE6, 0xA6, 0xE7, 0xA6, 0xE4, /* 0x3C-0x3F */ 0xA6, 0xE5, 0xA6, 0xE8, 0xA6, 0xE9, 0xA6, 0xEA, /* 0x40-0x43 */ 0xA6, 0xEB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */ 0x00, 0x00, 0xA9, 0x68, 0xA9, 0x69, 0xA9, 0x6A, /* 0x48-0x4B */ 0xA9, 0x6B, 0xA9, 0x6C, 0xA9, 0x6D, 0xA9, 0x6E, /* 0x4C-0x4F */ 0xA9, 0x6F, 0xA9, 0x70, 0xA9, 0x71, 0x00, 0x00, /* 0x50-0x53 */ 0xA9, 0x72, 0xA9, 0x73, 0xA9, 0x74, 0xA9, 0x75, /* 0x54-0x57 */ 0x00, 0x00, 0xA9, 0x76, 0xA9, 0x77, 0xA9, 0x78, /* 0x58-0x5B */ 0xA9, 0x79, 0xA9, 0x7A, 0xA9, 0x7B, 0xA9, 0x7C, /* 0x5C-0x5F */ 0xA9, 0x7D, 0xA9, 0x7E, 0xA9, 0x80, 0xA9, 0x81, /* 0x60-0x63 */ 0xA9, 0x82, 0xA9, 0x83, 0xA9, 0x84, 0x00, 0x00, /* 0x64-0x67 */ 0xA9, 0x85, 0xA9, 0x86, 0xA9, 0x87, 0xA9, 0x88, /* 0x68-0x6B */ }; static const unsigned char u2c_FF[512] = { 0x00, 0x00, 0xA3, 0xA1, 0xA3, 0xA2, 0xA3, 0xA3, /* 0x00-0x03 */ 0xA1, 0xE7, 0xA3, 0xA5, 0xA3, 0xA6, 0xA3, 0xA7, /* 0x04-0x07 */ 0xA3, 0xA8, 0xA3, 0xA9, 0xA3, 0xAA, 0xA3, 0xAB, /* 0x08-0x0B */ 0xA3, 0xAC, 0xA3, 0xAD, 0xA3, 0xAE, 0xA3, 0xAF, /* 0x0C-0x0F */ 0xA3, 0xB0, 0xA3, 0xB1, 0xA3, 0xB2, 0xA3, 0xB3, /* 0x10-0x13 */ 0xA3, 0xB4, 0xA3, 0xB5, 0xA3, 0xB6, 0xA3, 0xB7, /* 0x14-0x17 */ 0xA3, 0xB8, 0xA3, 0xB9, 0xA3, 0xBA, 0xA3, 0xBB, /* 0x18-0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, 0x00, /* 0x5C-0x5F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x93 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x94-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x9C-0x9F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA0-0xA3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA4-0xA7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB0-0xB3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB4-0xB7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB8-0xBB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xBC-0xBF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0-0xC3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC4-0xC7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC8-0xCB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xCC-0xCF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD0-0xD3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD4-0xD7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD8-0xDB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xDC-0xDF */ 0xA1, 0xE9, 0xA1, 0xEA, 0xA9, 0x56, 0xA3, 0xFE, /* 0xE0-0xE3 */ 0xA9, 0x57, 0xA3, 0xA4, 0x00, 0x00, 0x00, 0x00, /* 0xE4-0xE7 */ }; static const unsigned char *const page_uni2charset[256] = { u2c_00, u2c_01, u2c_02, u2c_03, u2c_04, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, u2c_20, u2c_21, u2c_22, u2c_23, u2c_24, u2c_25, u2c_26, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, u2c_30, u2c_31, u2c_32, u2c_33, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, u2c_4E, u2c_4F, u2c_50, u2c_51, u2c_52, u2c_53, u2c_54, u2c_55, u2c_56, u2c_57, u2c_58, u2c_59, u2c_5A, u2c_5B, u2c_5C, u2c_5D, u2c_5E, u2c_5F, u2c_60, u2c_61, u2c_62, u2c_63, u2c_64, u2c_65, u2c_66, u2c_67, u2c_68, u2c_69, u2c_6A, u2c_6B, u2c_6C, u2c_6D, u2c_6E, u2c_6F, u2c_70, u2c_71, u2c_72, u2c_73, u2c_74, u2c_75, u2c_76, u2c_77, u2c_78, u2c_79, u2c_7A, u2c_7B, u2c_7C, u2c_7D, u2c_7E, u2c_7F, u2c_80, u2c_81, u2c_82, u2c_83, u2c_84, u2c_85, u2c_86, u2c_87, u2c_88, u2c_89, u2c_8A, u2c_8B, u2c_8C, u2c_8D, u2c_8E, u2c_8F, u2c_90, u2c_91, u2c_92, u2c_93, u2c_94, u2c_95, u2c_96, u2c_97, u2c_98, u2c_99, u2c_9A, u2c_9B, u2c_9C, u2c_9D, u2c_9E, u2c_9F, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, u2c_DC, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, u2c_F9, u2c_FA, NULL, NULL, NULL, u2c_FE, u2c_FF, }; static const unsigned char charset2lower[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30-0x37 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x40-0x47 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0x48-0x4f */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x50-0x57 */ 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x58-0x5f */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60-0x67 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0x68-0x6f */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70-0x77 */ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 0x78-0x7f */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x80-0x87 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, /* 0x88-0x8f */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x90-0x97 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, /* 0x98-0x9f */ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0xb8-0xbf */ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0-0xc7 */ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0-0xd7 */ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0xd8-0xdf */ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0-0xf7 */ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0xf8-0xff */ }; static const unsigned char charset2upper[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30-0x37 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40-0x47 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x48-0x4f */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50-0x57 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x58-0x5f */ 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x60-0x67 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x68-0x6f */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x70-0x77 */ 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 0x78-0x7f */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x80-0x87 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, /* 0x88-0x8f */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x90-0x97 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, /* 0x98-0x9f */ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0xb8-0xbf */ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0-0xc7 */ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0-0xd7 */ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0xd8-0xdf */ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0-0xf7 */ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0xf8-0xff */ }; static int uni2char(const wchar_t uni, unsigned char *out, int boundlen) { const unsigned char *uni2charset; unsigned char cl = uni&0xFF; unsigned char ch = (uni>>8)&0xFF; unsigned char out0,out1; if (boundlen <= 0) return -ENAMETOOLONG; if (uni == 0x20ac) {/* Euro symbol.The only exception with a non-ascii unicode */ out[0] = 0x80; return 1; } if (ch == 0) { /* handle the U00 plane*/ /* if (cl == 0) return -EINVAL;*/ /*U0000 is legal in cp936*/ out0 = u2c_00[cl*2]; out1 = u2c_00[cl*2+1]; if (out0 == 0x00 && out1 == 0x00) { if (cl<0x80) { out[0] = cl; return 1; } return -EINVAL; } else { if (boundlen <= 1) return -ENAMETOOLONG; out[0] = out0; out[1] = out1; return 2; } } uni2charset = page_uni2charset[ch]; if (uni2charset) { if (boundlen <= 1) return -ENAMETOOLONG; out[0] = uni2charset[cl*2]; out[1] = uni2charset[cl*2+1]; if (out[0] == 0x00 && out[1] == 0x00) return -EINVAL; return 2; } else return -EINVAL; } static int char2uni(const unsigned char *rawstring, int boundlen, wchar_t *uni) { unsigned char ch, cl; const wchar_t *charset2uni; int n; if (boundlen <= 0) return -ENAMETOOLONG; if (boundlen == 1) { if (rawstring[0]==0x80) { /* Euro symbol.The only exception with a non-ascii unicode */ *uni = 0x20ac; } else { *uni = rawstring[0]; } return 1; } ch = rawstring[0]; cl = rawstring[1]; charset2uni = page_charset2uni[ch]; if (charset2uni && cl) { *uni = charset2uni[cl]; if (*uni == 0x0000) return -EINVAL; n = 2; } else{ if (ch==0x80) {/* Euro symbol.The only exception with a non-ascii unicode */ *uni = 0x20ac; } else { *uni = ch; } n = 1; } return n; } static struct nls_table table = { .charset = "cp936", .alias = "gb2312", .uni2char = uni2char, .char2uni = char2uni, .charset2lower = charset2lower, .charset2upper = charset2upper, }; static int __init init_nls_cp936(void) { return register_nls(&table); } static void __exit exit_nls_cp936(void) { unregister_nls(&table); } module_init(init_nls_cp936) module_exit(exit_nls_cp936) MODULE_LICENSE("Dual BSD/GPL"); MODULE_ALIAS_NLS(gb2312);
gpl-2.0
dimon2242/Neuro_kernel
drivers/misc/ibmasm/ibmasmfs.c
2934
15470
/* * IBM ASM Service Processor Device Driver * * 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. * * Copyright (C) IBM Corporation, 2004 * * Author: Max Asböck <amax@us.ibm.com> * */ /* * Parts of this code are based on an article by Jonathan Corbet * that appeared in Linux Weekly News. */ /* * The IBMASM file virtual filesystem. It creates the following hierarchy * dynamically when mounted from user space: * * /ibmasm * |-- 0 * | |-- command * | |-- event * | |-- reverse_heartbeat * | `-- remote_video * | |-- depth * | |-- height * | `-- width * . * . * . * `-- n * |-- command * |-- event * |-- reverse_heartbeat * `-- remote_video * |-- depth * |-- height * `-- width * * For each service processor the following files are created: * * command: execute dot commands * write: execute a dot command on the service processor * read: return the result of a previously executed dot command * * events: listen for service processor events * read: sleep (interruptible) until an event occurs * write: wakeup sleeping event listener * * reverse_heartbeat: send a heartbeat to the service processor * read: sleep (interruptible) until the reverse heartbeat fails * write: wakeup sleeping heartbeat listener * * remote_video/width * remote_video/height * remote_video/width: control remote display settings * write: set value * read: read value */ #include <linux/fs.h> #include <linux/pagemap.h> #include <linux/slab.h> #include <asm/uaccess.h> #include <asm/io.h> #include "ibmasm.h" #include "remote.h" #include "dot_command.h" #define IBMASMFS_MAGIC 0x66726f67 static LIST_HEAD(service_processors); static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode); static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root); static int ibmasmfs_fill_super (struct super_block *sb, void *data, int silent); static struct dentry *ibmasmfs_mount(struct file_system_type *fst, int flags, const char *name, void *data) { return mount_single(fst, flags, data, ibmasmfs_fill_super); } static const struct super_operations ibmasmfs_s_ops = { .statfs = simple_statfs, .drop_inode = generic_delete_inode, }; static const struct file_operations *ibmasmfs_dir_ops = &simple_dir_operations; static struct file_system_type ibmasmfs_type = { .owner = THIS_MODULE, .name = "ibmasmfs", .mount = ibmasmfs_mount, .kill_sb = kill_litter_super, }; static int ibmasmfs_fill_super (struct super_block *sb, void *data, int silent) { struct inode *root; struct dentry *root_dentry; sb->s_blocksize = PAGE_CACHE_SIZE; sb->s_blocksize_bits = PAGE_CACHE_SHIFT; sb->s_magic = IBMASMFS_MAGIC; sb->s_op = &ibmasmfs_s_ops; sb->s_time_gran = 1; root = ibmasmfs_make_inode (sb, S_IFDIR | 0500); if (!root) return -ENOMEM; root->i_op = &simple_dir_inode_operations; root->i_fop = ibmasmfs_dir_ops; root_dentry = d_alloc_root(root); if (!root_dentry) { iput(root); return -ENOMEM; } sb->s_root = root_dentry; ibmasmfs_create_files(sb, root_dentry); return 0; } static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode) { struct inode *ret = new_inode(sb); if (ret) { ret->i_ino = get_next_ino(); ret->i_mode = mode; ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; } return ret; } static struct dentry *ibmasmfs_create_file (struct super_block *sb, struct dentry *parent, const char *name, const struct file_operations *fops, void *data, int mode) { struct dentry *dentry; struct inode *inode; dentry = d_alloc_name(parent, name); if (!dentry) return NULL; inode = ibmasmfs_make_inode(sb, S_IFREG | mode); if (!inode) { dput(dentry); return NULL; } inode->i_fop = fops; inode->i_private = data; d_add(dentry, inode); return dentry; } static struct dentry *ibmasmfs_create_dir (struct super_block *sb, struct dentry *parent, const char *name) { struct dentry *dentry; struct inode *inode; dentry = d_alloc_name(parent, name); if (!dentry) return NULL; inode = ibmasmfs_make_inode(sb, S_IFDIR | 0500); if (!inode) { dput(dentry); return NULL; } inode->i_op = &simple_dir_inode_operations; inode->i_fop = ibmasmfs_dir_ops; d_add(dentry, inode); return dentry; } int ibmasmfs_register(void) { return register_filesystem(&ibmasmfs_type); } void ibmasmfs_unregister(void) { unregister_filesystem(&ibmasmfs_type); } void ibmasmfs_add_sp(struct service_processor *sp) { list_add(&sp->node, &service_processors); } /* struct to save state between command file operations */ struct ibmasmfs_command_data { struct service_processor *sp; struct command *command; }; /* struct to save state between event file operations */ struct ibmasmfs_event_data { struct service_processor *sp; struct event_reader reader; int active; }; /* struct to save state between reverse heartbeat file operations */ struct ibmasmfs_heartbeat_data { struct service_processor *sp; struct reverse_heartbeat heartbeat; int active; }; static int command_file_open(struct inode *inode, struct file *file) { struct ibmasmfs_command_data *command_data; if (!inode->i_private) return -ENODEV; command_data = kmalloc(sizeof(struct ibmasmfs_command_data), GFP_KERNEL); if (!command_data) return -ENOMEM; command_data->command = NULL; command_data->sp = inode->i_private; file->private_data = command_data; return 0; } static int command_file_close(struct inode *inode, struct file *file) { struct ibmasmfs_command_data *command_data = file->private_data; if (command_data->command) command_put(command_data->command); kfree(command_data); return 0; } static ssize_t command_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset) { struct ibmasmfs_command_data *command_data = file->private_data; struct command *cmd; int len; unsigned long flags; if (*offset < 0) return -EINVAL; if (count == 0 || count > IBMASM_CMD_MAX_BUFFER_SIZE) return 0; if (*offset != 0) return 0; spin_lock_irqsave(&command_data->sp->lock, flags); cmd = command_data->command; if (cmd == NULL) { spin_unlock_irqrestore(&command_data->sp->lock, flags); return 0; } command_data->command = NULL; spin_unlock_irqrestore(&command_data->sp->lock, flags); if (cmd->status != IBMASM_CMD_COMPLETE) { command_put(cmd); return -EIO; } len = min(count, cmd->buffer_size); if (copy_to_user(buf, cmd->buffer, len)) { command_put(cmd); return -EFAULT; } command_put(cmd); return len; } static ssize_t command_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset) { struct ibmasmfs_command_data *command_data = file->private_data; struct command *cmd; unsigned long flags; if (*offset < 0) return -EINVAL; if (count == 0 || count > IBMASM_CMD_MAX_BUFFER_SIZE) return 0; if (*offset != 0) return 0; /* commands are executed sequentially, only one command at a time */ if (command_data->command) return -EAGAIN; cmd = ibmasm_new_command(command_data->sp, count); if (!cmd) return -ENOMEM; if (copy_from_user(cmd->buffer, ubuff, count)) { command_put(cmd); return -EFAULT; } spin_lock_irqsave(&command_data->sp->lock, flags); if (command_data->command) { spin_unlock_irqrestore(&command_data->sp->lock, flags); command_put(cmd); return -EAGAIN; } command_data->command = cmd; spin_unlock_irqrestore(&command_data->sp->lock, flags); ibmasm_exec_command(command_data->sp, cmd); ibmasm_wait_for_response(cmd, get_dot_command_timeout(cmd->buffer)); return count; } static int event_file_open(struct inode *inode, struct file *file) { struct ibmasmfs_event_data *event_data; struct service_processor *sp; if (!inode->i_private) return -ENODEV; sp = inode->i_private; event_data = kmalloc(sizeof(struct ibmasmfs_event_data), GFP_KERNEL); if (!event_data) return -ENOMEM; ibmasm_event_reader_register(sp, &event_data->reader); event_data->sp = sp; event_data->active = 0; file->private_data = event_data; return 0; } static int event_file_close(struct inode *inode, struct file *file) { struct ibmasmfs_event_data *event_data = file->private_data; ibmasm_event_reader_unregister(event_data->sp, &event_data->reader); kfree(event_data); return 0; } static ssize_t event_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset) { struct ibmasmfs_event_data *event_data = file->private_data; struct event_reader *reader = &event_data->reader; struct service_processor *sp = event_data->sp; int ret; unsigned long flags; if (*offset < 0) return -EINVAL; if (count == 0 || count > IBMASM_EVENT_MAX_SIZE) return 0; if (*offset != 0) return 0; spin_lock_irqsave(&sp->lock, flags); if (event_data->active) { spin_unlock_irqrestore(&sp->lock, flags); return -EBUSY; } event_data->active = 1; spin_unlock_irqrestore(&sp->lock, flags); ret = ibmasm_get_next_event(sp, reader); if (ret <= 0) goto out; if (count < reader->data_size) { ret = -EINVAL; goto out; } if (copy_to_user(buf, reader->data, reader->data_size)) { ret = -EFAULT; goto out; } ret = reader->data_size; out: event_data->active = 0; return ret; } static ssize_t event_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) { struct ibmasmfs_event_data *event_data = file->private_data; if (*offset < 0) return -EINVAL; if (count != 1) return 0; if (*offset != 0) return 0; ibmasm_cancel_next_event(&event_data->reader); return 0; } static int r_heartbeat_file_open(struct inode *inode, struct file *file) { struct ibmasmfs_heartbeat_data *rhbeat; if (!inode->i_private) return -ENODEV; rhbeat = kmalloc(sizeof(struct ibmasmfs_heartbeat_data), GFP_KERNEL); if (!rhbeat) return -ENOMEM; rhbeat->sp = inode->i_private; rhbeat->active = 0; ibmasm_init_reverse_heartbeat(rhbeat->sp, &rhbeat->heartbeat); file->private_data = rhbeat; return 0; } static int r_heartbeat_file_close(struct inode *inode, struct file *file) { struct ibmasmfs_heartbeat_data *rhbeat = file->private_data; kfree(rhbeat); return 0; } static ssize_t r_heartbeat_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset) { struct ibmasmfs_heartbeat_data *rhbeat = file->private_data; unsigned long flags; int result; if (*offset < 0) return -EINVAL; if (count == 0 || count > 1024) return 0; if (*offset != 0) return 0; /* allow only one reverse heartbeat per process */ spin_lock_irqsave(&rhbeat->sp->lock, flags); if (rhbeat->active) { spin_unlock_irqrestore(&rhbeat->sp->lock, flags); return -EBUSY; } rhbeat->active = 1; spin_unlock_irqrestore(&rhbeat->sp->lock, flags); result = ibmasm_start_reverse_heartbeat(rhbeat->sp, &rhbeat->heartbeat); rhbeat->active = 0; return result; } static ssize_t r_heartbeat_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) { struct ibmasmfs_heartbeat_data *rhbeat = file->private_data; if (*offset < 0) return -EINVAL; if (count != 1) return 0; if (*offset != 0) return 0; if (rhbeat->active) ibmasm_stop_reverse_heartbeat(&rhbeat->heartbeat); return 1; } static int remote_settings_file_open(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } static int remote_settings_file_close(struct inode *inode, struct file *file) { return 0; } static ssize_t remote_settings_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset) { void __iomem *address = (void __iomem *)file->private_data; unsigned char *page; int retval; int len = 0; unsigned int value; if (*offset < 0) return -EINVAL; if (count == 0 || count > 1024) return 0; if (*offset != 0) return 0; page = (unsigned char *)__get_free_page(GFP_KERNEL); if (!page) return -ENOMEM; value = readl(address); len = sprintf(page, "%d\n", value); if (copy_to_user(buf, page, len)) { retval = -EFAULT; goto exit; } *offset += len; retval = len; exit: free_page((unsigned long)page); return retval; } static ssize_t remote_settings_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset) { void __iomem *address = (void __iomem *)file->private_data; char *buff; unsigned int value; if (*offset < 0) return -EINVAL; if (count == 0 || count > 1024) return 0; if (*offset != 0) return 0; buff = kzalloc (count + 1, GFP_KERNEL); if (!buff) return -ENOMEM; if (copy_from_user(buff, ubuff, count)) { kfree(buff); return -EFAULT; } value = simple_strtoul(buff, NULL, 10); writel(value, address); kfree(buff); return count; } static const struct file_operations command_fops = { .open = command_file_open, .release = command_file_close, .read = command_file_read, .write = command_file_write, .llseek = generic_file_llseek, }; static const struct file_operations event_fops = { .open = event_file_open, .release = event_file_close, .read = event_file_read, .write = event_file_write, .llseek = generic_file_llseek, }; static const struct file_operations r_heartbeat_fops = { .open = r_heartbeat_file_open, .release = r_heartbeat_file_close, .read = r_heartbeat_file_read, .write = r_heartbeat_file_write, .llseek = generic_file_llseek, }; static const struct file_operations remote_settings_fops = { .open = remote_settings_file_open, .release = remote_settings_file_close, .read = remote_settings_file_read, .write = remote_settings_file_write, .llseek = generic_file_llseek, }; static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root) { struct list_head *entry; struct service_processor *sp; list_for_each(entry, &service_processors) { struct dentry *dir; struct dentry *remote_dir; sp = list_entry(entry, struct service_processor, node); dir = ibmasmfs_create_dir(sb, root, sp->dirname); if (!dir) continue; ibmasmfs_create_file(sb, dir, "command", &command_fops, sp, S_IRUSR|S_IWUSR); ibmasmfs_create_file(sb, dir, "event", &event_fops, sp, S_IRUSR|S_IWUSR); ibmasmfs_create_file(sb, dir, "reverse_heartbeat", &r_heartbeat_fops, sp, S_IRUSR|S_IWUSR); remote_dir = ibmasmfs_create_dir(sb, dir, "remote_video"); if (!remote_dir) continue; ibmasmfs_create_file(sb, remote_dir, "width", &remote_settings_fops, (void *)display_width(sp), S_IRUSR|S_IWUSR); ibmasmfs_create_file(sb, remote_dir, "height", &remote_settings_fops, (void *)display_height(sp), S_IRUSR|S_IWUSR); ibmasmfs_create_file(sb, remote_dir, "depth", &remote_settings_fops, (void *)display_depth(sp), S_IRUSR|S_IWUSR); } }
gpl-2.0
somcom3x/kernel_samsung_msm8660-common
lib/iomap.c
4470
7565
/* * Implement the default iomap interfaces * * (C) Copyright 2004 Linus Torvalds */ #include <linux/pci.h> #include <linux/io.h> #include <linux/module.h> /* * Read/write from/to an (offsettable) iomem cookie. It might be a PIO * access or a MMIO access, these functions don't care. The info is * encoded in the hardware mapping set up by the mapping functions * (or the cookie itself, depending on implementation and hw). * * The generic routines don't assume any hardware mappings, and just * encode the PIO/MMIO as part of the cookie. They coldly assume that * the MMIO IO mappings are not in the low address range. * * Architectures for which this is not true can't use this generic * implementation and should do their own copy. */ #ifndef HAVE_ARCH_PIO_SIZE /* * We encode the physical PIO addresses (0-0xffff) into the * pointer by offsetting them with a constant (0x10000) and * assuming that all the low addresses are always PIO. That means * we can do some sanity checks on the low bits, and don't * need to just take things for granted. */ #define PIO_OFFSET 0x10000UL #define PIO_MASK 0x0ffffUL #define PIO_RESERVED 0x40000UL #endif static void bad_io_access(unsigned long port, const char *access) { static int count = 10; if (count) { count--; WARN(1, KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access); } } /* * Ugly macros are a way of life. */ #define IO_COND(addr, is_pio, is_mmio) do { \ unsigned long port = (unsigned long __force)addr; \ if (port >= PIO_RESERVED) { \ is_mmio; \ } else if (port > PIO_OFFSET) { \ port &= PIO_MASK; \ is_pio; \ } else \ bad_io_access(port, #is_pio ); \ } while (0) #ifndef pio_read16be #define pio_read16be(port) swab16(inw(port)) #define pio_read32be(port) swab32(inl(port)) #endif #ifndef mmio_read16be #define mmio_read16be(addr) be16_to_cpu(__raw_readw(addr)) #define mmio_read32be(addr) be32_to_cpu(__raw_readl(addr)) #endif unsigned int ioread8(void __iomem *addr) { IO_COND(addr, return inb(port), return readb(addr)); return 0xff; } unsigned int ioread16(void __iomem *addr) { IO_COND(addr, return inw(port), return readw(addr)); return 0xffff; } unsigned int ioread16be(void __iomem *addr) { IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr)); return 0xffff; } unsigned int ioread32(void __iomem *addr) { IO_COND(addr, return inl(port), return readl(addr)); return 0xffffffff; } unsigned int ioread32be(void __iomem *addr) { IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr)); return 0xffffffff; } EXPORT_SYMBOL(ioread8); EXPORT_SYMBOL(ioread16); EXPORT_SYMBOL(ioread16be); EXPORT_SYMBOL(ioread32); EXPORT_SYMBOL(ioread32be); #ifndef pio_write16be #define pio_write16be(val,port) outw(swab16(val),port) #define pio_write32be(val,port) outl(swab32(val),port) #endif #ifndef mmio_write16be #define mmio_write16be(val,port) __raw_writew(be16_to_cpu(val),port) #define mmio_write32be(val,port) __raw_writel(be32_to_cpu(val),port) #endif void iowrite8(u8 val, void __iomem *addr) { IO_COND(addr, outb(val,port), writeb(val, addr)); } void iowrite16(u16 val, void __iomem *addr) { IO_COND(addr, outw(val,port), writew(val, addr)); } void iowrite16be(u16 val, void __iomem *addr) { IO_COND(addr, pio_write16be(val,port), mmio_write16be(val, addr)); } void iowrite32(u32 val, void __iomem *addr) { IO_COND(addr, outl(val,port), writel(val, addr)); } void iowrite32be(u32 val, void __iomem *addr) { IO_COND(addr, pio_write32be(val,port), mmio_write32be(val, addr)); } EXPORT_SYMBOL(iowrite8); EXPORT_SYMBOL(iowrite16); EXPORT_SYMBOL(iowrite16be); EXPORT_SYMBOL(iowrite32); EXPORT_SYMBOL(iowrite32be); /* * These are the "repeat MMIO read/write" functions. * Note the "__raw" accesses, since we don't want to * convert to CPU byte order. We write in "IO byte * order" (we also don't have IO barriers). */ #ifndef mmio_insb static inline void mmio_insb(void __iomem *addr, u8 *dst, int count) { while (--count >= 0) { u8 data = __raw_readb(addr); *dst = data; dst++; } } static inline void mmio_insw(void __iomem *addr, u16 *dst, int count) { while (--count >= 0) { u16 data = __raw_readw(addr); *dst = data; dst++; } } static inline void mmio_insl(void __iomem *addr, u32 *dst, int count) { while (--count >= 0) { u32 data = __raw_readl(addr); *dst = data; dst++; } } #endif #ifndef mmio_outsb static inline void mmio_outsb(void __iomem *addr, const u8 *src, int count) { while (--count >= 0) { __raw_writeb(*src, addr); src++; } } static inline void mmio_outsw(void __iomem *addr, const u16 *src, int count) { while (--count >= 0) { __raw_writew(*src, addr); src++; } } static inline void mmio_outsl(void __iomem *addr, const u32 *src, int count) { while (--count >= 0) { __raw_writel(*src, addr); src++; } } #endif void ioread8_rep(void __iomem *addr, void *dst, unsigned long count) { IO_COND(addr, insb(port,dst,count), mmio_insb(addr, dst, count)); } void ioread16_rep(void __iomem *addr, void *dst, unsigned long count) { IO_COND(addr, insw(port,dst,count), mmio_insw(addr, dst, count)); } void ioread32_rep(void __iomem *addr, void *dst, unsigned long count) { IO_COND(addr, insl(port,dst,count), mmio_insl(addr, dst, count)); } EXPORT_SYMBOL(ioread8_rep); EXPORT_SYMBOL(ioread16_rep); EXPORT_SYMBOL(ioread32_rep); void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count) { IO_COND(addr, outsb(port, src, count), mmio_outsb(addr, src, count)); } void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count) { IO_COND(addr, outsw(port, src, count), mmio_outsw(addr, src, count)); } void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count) { IO_COND(addr, outsl(port, src,count), mmio_outsl(addr, src, count)); } EXPORT_SYMBOL(iowrite8_rep); EXPORT_SYMBOL(iowrite16_rep); EXPORT_SYMBOL(iowrite32_rep); /* Create a virtual mapping cookie for an IO port range */ void __iomem *ioport_map(unsigned long port, unsigned int nr) { if (port > PIO_MASK) return NULL; return (void __iomem *) (unsigned long) (port + PIO_OFFSET); } void ioport_unmap(void __iomem *addr) { /* Nothing to do */ } EXPORT_SYMBOL(ioport_map); EXPORT_SYMBOL(ioport_unmap); /** * pci_iomap - create a virtual mapping cookie for a PCI BAR * @dev: PCI device that owns the BAR * @bar: BAR number * @maxlen: length of the memory to map * * Using this function you will get a __iomem address to your device BAR. * You can access it using ioread*() and iowrite*(). These functions hide * the details if this is a MMIO or PIO address space and will just do what * you expect from them in the correct way. * * @maxlen specifies the maximum length to map. If you want to get access to * the complete BAR without checking for its length first, pass %0 here. * */ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) { resource_size_t start = pci_resource_start(dev, bar); resource_size_t len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len || !start) return NULL; if (maxlen && len > maxlen) len = maxlen; if (flags & IORESOURCE_IO) return ioport_map(start, len); if (flags & IORESOURCE_MEM) { if (flags & IORESOURCE_CACHEABLE) return ioremap(start, len); return ioremap_nocache(start, len); } /* What? */ return NULL; } void pci_iounmap(struct pci_dev *dev, void __iomem * addr) { IO_COND(addr, /* nothing */, iounmap(addr)); } EXPORT_SYMBOL(pci_iomap); EXPORT_SYMBOL(pci_iounmap);
gpl-2.0
srisurya95/android_kernel_motorola_msm8226
drivers/net/wireless/prism54/islpci_dev.c
4726
27491
/* * Copyright (C) 2002 Intersil Americas Inc. * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> * * 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 * * 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/hardirq.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/netdevice.h> #include <linux/ethtool.h> #include <linux/pci.h> #include <linux/sched.h> #include <linux/etherdevice.h> #include <linux/delay.h> #include <linux/if_arp.h> #include <asm/io.h> #include "prismcompat.h" #include "isl_38xx.h" #include "isl_ioctl.h" #include "islpci_dev.h" #include "islpci_mgt.h" #include "islpci_eth.h" #include "oid_mgt.h" #define ISL3877_IMAGE_FILE "isl3877" #define ISL3886_IMAGE_FILE "isl3886" #define ISL3890_IMAGE_FILE "isl3890" MODULE_FIRMWARE(ISL3877_IMAGE_FILE); MODULE_FIRMWARE(ISL3886_IMAGE_FILE); MODULE_FIRMWARE(ISL3890_IMAGE_FILE); static int prism54_bring_down(islpci_private *); static int islpci_alloc_memory(islpci_private *); /* Temporary dummy MAC address to use until firmware is loaded. * The idea there is that some tools (such as nameif) may query * the MAC address before the netdev is 'open'. By using a valid * OUI prefix, they can process the netdev properly. * Of course, this is not the final/real MAC address. It doesn't * matter, as you are suppose to be able to change it anytime via * ndev->set_mac_address. Jean II */ static const unsigned char dummy_mac[6] = { 0x00, 0x30, 0xB4, 0x00, 0x00, 0x00 }; static int isl_upload_firmware(islpci_private *priv) { u32 reg, rc; void __iomem *device_base = priv->device_base; /* clear the RAMBoot and the Reset bit */ reg = readl(device_base + ISL38XX_CTRL_STAT_REG); reg &= ~ISL38XX_CTRL_STAT_RESET; reg &= ~ISL38XX_CTRL_STAT_RAMBOOT; writel(reg, device_base + ISL38XX_CTRL_STAT_REG); wmb(); udelay(ISL38XX_WRITEIO_DELAY); /* set the Reset bit without reading the register ! */ reg |= ISL38XX_CTRL_STAT_RESET; writel(reg, device_base + ISL38XX_CTRL_STAT_REG); wmb(); udelay(ISL38XX_WRITEIO_DELAY); /* clear the Reset bit */ reg &= ~ISL38XX_CTRL_STAT_RESET; writel(reg, device_base + ISL38XX_CTRL_STAT_REG); wmb(); /* wait a while for the device to reboot */ mdelay(50); { const struct firmware *fw_entry = NULL; long fw_len; const u32 *fw_ptr; rc = request_firmware(&fw_entry, priv->firmware, PRISM_FW_PDEV); if (rc) { printk(KERN_ERR "%s: request_firmware() failed for '%s'\n", "prism54", priv->firmware); return rc; } /* prepare the Direct Memory Base register */ reg = ISL38XX_DEV_FIRMWARE_ADDRES; fw_ptr = (u32 *) fw_entry->data; fw_len = fw_entry->size; if (fw_len % 4) { printk(KERN_ERR "%s: firmware '%s' size is not multiple of 32bit, aborting!\n", "prism54", priv->firmware); release_firmware(fw_entry); return -EILSEQ; /* Illegal byte sequence */; } while (fw_len > 0) { long _fw_len = (fw_len > ISL38XX_MEMORY_WINDOW_SIZE) ? ISL38XX_MEMORY_WINDOW_SIZE : fw_len; u32 __iomem *dev_fw_ptr = device_base + ISL38XX_DIRECT_MEM_WIN; /* set the card's base address for writing the data */ isl38xx_w32_flush(device_base, reg, ISL38XX_DIR_MEM_BASE_REG); wmb(); /* be paranoid */ /* increment the write address for next iteration */ reg += _fw_len; fw_len -= _fw_len; /* write the data to the Direct Memory Window 32bit-wise */ /* memcpy_toio() doesn't guarantee 32bit writes :-| */ while (_fw_len > 0) { /* use non-swapping writel() */ __raw_writel(*fw_ptr, dev_fw_ptr); fw_ptr++, dev_fw_ptr++; _fw_len -= 4; } /* flush PCI posting */ (void) readl(device_base + ISL38XX_PCI_POSTING_FLUSH); wmb(); /* be paranoid again */ BUG_ON(_fw_len != 0); } BUG_ON(fw_len != 0); /* Firmware version is at offset 40 (also for "newmac") */ printk(KERN_DEBUG "%s: firmware version: %.8s\n", priv->ndev->name, fw_entry->data + 40); release_firmware(fw_entry); } /* now reset the device * clear the Reset & ClkRun bit, set the RAMBoot bit */ reg = readl(device_base + ISL38XX_CTRL_STAT_REG); reg &= ~ISL38XX_CTRL_STAT_CLKRUN; reg &= ~ISL38XX_CTRL_STAT_RESET; reg |= ISL38XX_CTRL_STAT_RAMBOOT; isl38xx_w32_flush(device_base, reg, ISL38XX_CTRL_STAT_REG); wmb(); udelay(ISL38XX_WRITEIO_DELAY); /* set the reset bit latches the host override and RAMBoot bits * into the device for operation when the reset bit is reset */ reg |= ISL38XX_CTRL_STAT_RESET; writel(reg, device_base + ISL38XX_CTRL_STAT_REG); /* don't do flush PCI posting here! */ wmb(); udelay(ISL38XX_WRITEIO_DELAY); /* clear the reset bit should start the whole circus */ reg &= ~ISL38XX_CTRL_STAT_RESET; writel(reg, device_base + ISL38XX_CTRL_STAT_REG); /* don't do flush PCI posting here! */ wmb(); udelay(ISL38XX_WRITEIO_DELAY); return 0; } /****************************************************************************** Device Interrupt Handler ******************************************************************************/ irqreturn_t islpci_interrupt(int irq, void *config) { u32 reg; islpci_private *priv = config; struct net_device *ndev = priv->ndev; void __iomem *device = priv->device_base; int powerstate = ISL38XX_PSM_POWERSAVE_STATE; /* lock the interrupt handler */ spin_lock(&priv->slock); /* received an interrupt request on a shared IRQ line * first check whether the device is in sleep mode */ reg = readl(device + ISL38XX_CTRL_STAT_REG); if (reg & ISL38XX_CTRL_STAT_SLEEPMODE) /* device is in sleep mode, IRQ was generated by someone else */ { #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_TRACING, "Assuming someone else called the IRQ\n"); #endif spin_unlock(&priv->slock); return IRQ_NONE; } /* check whether there is any source of interrupt on the device */ reg = readl(device + ISL38XX_INT_IDENT_REG); /* also check the contents of the Interrupt Enable Register, because this * will filter out interrupt sources from other devices on the same irq ! */ reg &= readl(device + ISL38XX_INT_EN_REG); reg &= ISL38XX_INT_SOURCES; if (reg != 0) { if (islpci_get_state(priv) != PRV_STATE_SLEEP) powerstate = ISL38XX_PSM_ACTIVE_STATE; /* reset the request bits in the Identification register */ isl38xx_w32_flush(device, reg, ISL38XX_INT_ACK_REG); #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_FUNCTION_CALLS, "IRQ: Identification register 0x%p 0x%x\n", device, reg); #endif /* check for each bit in the register separately */ if (reg & ISL38XX_INT_IDENT_UPDATE) { #if VERBOSE > SHOW_ERROR_MESSAGES /* Queue has been updated */ DEBUG(SHOW_TRACING, "IRQ: Update flag\n"); DEBUG(SHOW_QUEUE_INDEXES, "CB drv Qs: [%i][%i][%i][%i][%i][%i]\n", le32_to_cpu(priv->control_block-> driver_curr_frag[0]), le32_to_cpu(priv->control_block-> driver_curr_frag[1]), le32_to_cpu(priv->control_block-> driver_curr_frag[2]), le32_to_cpu(priv->control_block-> driver_curr_frag[3]), le32_to_cpu(priv->control_block-> driver_curr_frag[4]), le32_to_cpu(priv->control_block-> driver_curr_frag[5]) ); DEBUG(SHOW_QUEUE_INDEXES, "CB dev Qs: [%i][%i][%i][%i][%i][%i]\n", le32_to_cpu(priv->control_block-> device_curr_frag[0]), le32_to_cpu(priv->control_block-> device_curr_frag[1]), le32_to_cpu(priv->control_block-> device_curr_frag[2]), le32_to_cpu(priv->control_block-> device_curr_frag[3]), le32_to_cpu(priv->control_block-> device_curr_frag[4]), le32_to_cpu(priv->control_block-> device_curr_frag[5]) ); #endif /* cleanup the data low transmit queue */ islpci_eth_cleanup_transmit(priv, priv->control_block); /* device is in active state, update the * powerstate flag if necessary */ powerstate = ISL38XX_PSM_ACTIVE_STATE; /* check all three queues in priority order * call the PIMFOR receive function until the * queue is empty */ if (isl38xx_in_queue(priv->control_block, ISL38XX_CB_RX_MGMTQ) != 0) { #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_TRACING, "Received frame in Management Queue\n"); #endif islpci_mgt_receive(ndev); islpci_mgt_cleanup_transmit(ndev); /* Refill slots in receive queue */ islpci_mgmt_rx_fill(ndev); /* no need to trigger the device, next islpci_mgt_transaction does it */ } while (isl38xx_in_queue(priv->control_block, ISL38XX_CB_RX_DATA_LQ) != 0) { #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_TRACING, "Received frame in Data Low Queue\n"); #endif islpci_eth_receive(priv); } /* check whether the data transmit queues were full */ if (priv->data_low_tx_full) { /* check whether the transmit is not full anymore */ if (ISL38XX_CB_TX_QSIZE - isl38xx_in_queue(priv->control_block, ISL38XX_CB_TX_DATA_LQ) >= ISL38XX_MIN_QTHRESHOLD) { /* nope, the driver is ready for more network frames */ netif_wake_queue(priv->ndev); /* reset the full flag */ priv->data_low_tx_full = 0; } } } if (reg & ISL38XX_INT_IDENT_INIT) { /* Device has been initialized */ #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_TRACING, "IRQ: Init flag, device initialized\n"); #endif wake_up(&priv->reset_done); } if (reg & ISL38XX_INT_IDENT_SLEEP) { /* Device intends to move to powersave state */ #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_TRACING, "IRQ: Sleep flag\n"); #endif isl38xx_handle_sleep_request(priv->control_block, &powerstate, priv->device_base); } if (reg & ISL38XX_INT_IDENT_WAKEUP) { /* Device has been woken up to active state */ #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_TRACING, "IRQ: Wakeup flag\n"); #endif isl38xx_handle_wakeup(priv->control_block, &powerstate, priv->device_base); } } else { #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_TRACING, "Assuming someone else called the IRQ\n"); #endif spin_unlock(&priv->slock); return IRQ_NONE; } /* sleep -> ready */ if (islpci_get_state(priv) == PRV_STATE_SLEEP && powerstate == ISL38XX_PSM_ACTIVE_STATE) islpci_set_state(priv, PRV_STATE_READY); /* !sleep -> sleep */ if (islpci_get_state(priv) != PRV_STATE_SLEEP && powerstate == ISL38XX_PSM_POWERSAVE_STATE) islpci_set_state(priv, PRV_STATE_SLEEP); /* unlock the interrupt handler */ spin_unlock(&priv->slock); return IRQ_HANDLED; } /****************************************************************************** Network Interface Control & Statistical functions ******************************************************************************/ static int islpci_open(struct net_device *ndev) { u32 rc; islpci_private *priv = netdev_priv(ndev); /* reset data structures, upload firmware and reset device */ rc = islpci_reset(priv,1); if (rc) { prism54_bring_down(priv); return rc; /* Returns informative message */ } netif_start_queue(ndev); /* Turn off carrier if in STA or Ad-hoc mode. It will be turned on * once the firmware receives a trap of being associated * (GEN_OID_LINKSTATE). In other modes (AP or WDS or monitor) we * should just leave the carrier on as its expected the firmware * won't send us a trigger. */ if (priv->iw_mode == IW_MODE_INFRA || priv->iw_mode == IW_MODE_ADHOC) netif_carrier_off(ndev); else netif_carrier_on(ndev); return 0; } static int islpci_close(struct net_device *ndev) { islpci_private *priv = netdev_priv(ndev); printk(KERN_DEBUG "%s: islpci_close ()\n", ndev->name); netif_stop_queue(ndev); return prism54_bring_down(priv); } static int prism54_bring_down(islpci_private *priv) { void __iomem *device_base = priv->device_base; u32 reg; /* we are going to shutdown the device */ islpci_set_state(priv, PRV_STATE_PREBOOT); /* disable all device interrupts in case they weren't */ isl38xx_disable_interrupts(priv->device_base); /* For safety reasons, we may want to ensure that no DMA transfer is * currently in progress by emptying the TX and RX queues. */ /* wait until interrupts have finished executing on other CPUs */ synchronize_irq(priv->pdev->irq); reg = readl(device_base + ISL38XX_CTRL_STAT_REG); reg &= ~(ISL38XX_CTRL_STAT_RESET | ISL38XX_CTRL_STAT_RAMBOOT); writel(reg, device_base + ISL38XX_CTRL_STAT_REG); wmb(); udelay(ISL38XX_WRITEIO_DELAY); reg |= ISL38XX_CTRL_STAT_RESET; writel(reg, device_base + ISL38XX_CTRL_STAT_REG); wmb(); udelay(ISL38XX_WRITEIO_DELAY); /* clear the Reset bit */ reg &= ~ISL38XX_CTRL_STAT_RESET; writel(reg, device_base + ISL38XX_CTRL_STAT_REG); wmb(); /* wait a while for the device to reset */ schedule_timeout_uninterruptible(msecs_to_jiffies(50)); return 0; } static int islpci_upload_fw(islpci_private *priv) { islpci_state_t old_state; u32 rc; old_state = islpci_set_state(priv, PRV_STATE_BOOT); printk(KERN_DEBUG "%s: uploading firmware...\n", priv->ndev->name); rc = isl_upload_firmware(priv); if (rc) { /* error uploading the firmware */ printk(KERN_ERR "%s: could not upload firmware ('%s')\n", priv->ndev->name, priv->firmware); islpci_set_state(priv, old_state); return rc; } printk(KERN_DEBUG "%s: firmware upload complete\n", priv->ndev->name); islpci_set_state(priv, PRV_STATE_POSTBOOT); return 0; } static int islpci_reset_if(islpci_private *priv) { long remaining; int result = -ETIME; int count; DEFINE_WAIT(wait); prepare_to_wait(&priv->reset_done, &wait, TASK_UNINTERRUPTIBLE); /* now the last step is to reset the interface */ isl38xx_interface_reset(priv->device_base, priv->device_host_address); islpci_set_state(priv, PRV_STATE_PREINIT); for(count = 0; count < 2 && result; count++) { /* The software reset acknowledge needs about 220 msec here. * Be conservative and wait for up to one second. */ remaining = schedule_timeout_uninterruptible(HZ); if(remaining > 0) { result = 0; break; } /* If we're here it's because our IRQ hasn't yet gone through. * Retry a bit more... */ printk(KERN_ERR "%s: no 'reset complete' IRQ seen - retrying\n", priv->ndev->name); } finish_wait(&priv->reset_done, &wait); if (result) { printk(KERN_ERR "%s: interface reset failure\n", priv->ndev->name); return result; } islpci_set_state(priv, PRV_STATE_INIT); /* Now that the device is 100% up, let's allow * for the other interrupts -- * NOTE: this is not *yet* true since we've only allowed the * INIT interrupt on the IRQ line. We can perhaps poll * the IRQ line until we know for sure the reset went through */ isl38xx_enable_common_interrupts(priv->device_base); down_write(&priv->mib_sem); result = mgt_commit(priv); if (result) { printk(KERN_ERR "%s: interface reset failure\n", priv->ndev->name); up_write(&priv->mib_sem); return result; } up_write(&priv->mib_sem); islpci_set_state(priv, PRV_STATE_READY); printk(KERN_DEBUG "%s: interface reset complete\n", priv->ndev->name); return 0; } int islpci_reset(islpci_private *priv, int reload_firmware) { isl38xx_control_block *cb = /* volatile not needed */ (isl38xx_control_block *) priv->control_block; unsigned counter; int rc; if (reload_firmware) islpci_set_state(priv, PRV_STATE_PREBOOT); else islpci_set_state(priv, PRV_STATE_POSTBOOT); printk(KERN_DEBUG "%s: resetting device...\n", priv->ndev->name); /* disable all device interrupts in case they weren't */ isl38xx_disable_interrupts(priv->device_base); /* flush all management queues */ priv->index_mgmt_tx = 0; priv->index_mgmt_rx = 0; /* clear the indexes in the frame pointer */ for (counter = 0; counter < ISL38XX_CB_QCOUNT; counter++) { cb->driver_curr_frag[counter] = cpu_to_le32(0); cb->device_curr_frag[counter] = cpu_to_le32(0); } /* reset the mgmt receive queue */ for (counter = 0; counter < ISL38XX_CB_MGMT_QSIZE; counter++) { isl38xx_fragment *frag = &cb->rx_data_mgmt[counter]; frag->size = cpu_to_le16(MGMT_FRAME_SIZE); frag->flags = 0; frag->address = cpu_to_le32(priv->mgmt_rx[counter].pci_addr); } for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) { cb->rx_data_low[counter].address = cpu_to_le32((u32) priv->pci_map_rx_address[counter]); } /* since the receive queues are filled with empty fragments, now we can * set the corresponding indexes in the Control Block */ priv->control_block->driver_curr_frag[ISL38XX_CB_RX_DATA_LQ] = cpu_to_le32(ISL38XX_CB_RX_QSIZE); priv->control_block->driver_curr_frag[ISL38XX_CB_RX_MGMTQ] = cpu_to_le32(ISL38XX_CB_MGMT_QSIZE); /* reset the remaining real index registers and full flags */ priv->free_data_rx = 0; priv->free_data_tx = 0; priv->data_low_tx_full = 0; if (reload_firmware) { /* Should we load the firmware ? */ /* now that the data structures are cleaned up, upload * firmware and reset interface */ rc = islpci_upload_fw(priv); if (rc) { printk(KERN_ERR "%s: islpci_reset: failure\n", priv->ndev->name); return rc; } } /* finally reset interface */ rc = islpci_reset_if(priv); if (rc) printk(KERN_ERR "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n"); return rc; } /****************************************************************************** Network device configuration functions ******************************************************************************/ static int islpci_alloc_memory(islpci_private *priv) { int counter; #if VERBOSE > SHOW_ERROR_MESSAGES printk(KERN_DEBUG "islpci_alloc_memory\n"); #endif /* remap the PCI device base address to accessible */ if (!(priv->device_base = ioremap(pci_resource_start(priv->pdev, 0), ISL38XX_PCI_MEM_SIZE))) { /* error in remapping the PCI device memory address range */ printk(KERN_ERR "PCI memory remapping failed\n"); return -1; } /* memory layout for consistent DMA region: * * Area 1: Control Block for the device interface * Area 2: Power Save Mode Buffer for temporary frame storage. Be aware that * the number of supported stations in the AP determines the minimal * size of the buffer ! */ /* perform the allocation */ priv->driver_mem_address = pci_alloc_consistent(priv->pdev, HOST_MEM_BLOCK, &priv-> device_host_address); if (!priv->driver_mem_address) { /* error allocating the block of PCI memory */ printk(KERN_ERR "%s: could not allocate DMA memory, aborting!", "prism54"); return -1; } /* assign the Control Block to the first address of the allocated area */ priv->control_block = (isl38xx_control_block *) priv->driver_mem_address; /* set the Power Save Buffer pointer directly behind the CB */ priv->device_psm_buffer = priv->device_host_address + CONTROL_BLOCK_SIZE; /* make sure all buffer pointers are initialized */ for (counter = 0; counter < ISL38XX_CB_QCOUNT; counter++) { priv->control_block->driver_curr_frag[counter] = cpu_to_le32(0); priv->control_block->device_curr_frag[counter] = cpu_to_le32(0); } priv->index_mgmt_rx = 0; memset(priv->mgmt_rx, 0, sizeof(priv->mgmt_rx)); memset(priv->mgmt_tx, 0, sizeof(priv->mgmt_tx)); /* allocate rx queue for management frames */ if (islpci_mgmt_rx_fill(priv->ndev) < 0) goto out_free; /* now get the data rx skb's */ memset(priv->data_low_rx, 0, sizeof (priv->data_low_rx)); memset(priv->pci_map_rx_address, 0, sizeof (priv->pci_map_rx_address)); for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) { struct sk_buff *skb; /* allocate an sk_buff for received data frames storage * each frame on receive size consists of 1 fragment * include any required allignment operations */ if (!(skb = dev_alloc_skb(MAX_FRAGMENT_SIZE_RX + 2))) { /* error allocating an sk_buff structure elements */ printk(KERN_ERR "Error allocating skb.\n"); skb = NULL; goto out_free; } skb_reserve(skb, (4 - (long) skb->data) & 0x03); /* add the new allocated sk_buff to the buffer array */ priv->data_low_rx[counter] = skb; /* map the allocated skb data area to pci */ priv->pci_map_rx_address[counter] = pci_map_single(priv->pdev, (void *) skb->data, MAX_FRAGMENT_SIZE_RX + 2, PCI_DMA_FROMDEVICE); if (!priv->pci_map_rx_address[counter]) { /* error mapping the buffer to device accessible memory address */ printk(KERN_ERR "failed to map skb DMA'able\n"); goto out_free; } } prism54_acl_init(&priv->acl); prism54_wpa_bss_ie_init(priv); if (mgt_init(priv)) goto out_free; return 0; out_free: islpci_free_memory(priv); return -1; } int islpci_free_memory(islpci_private *priv) { int counter; if (priv->device_base) iounmap(priv->device_base); priv->device_base = NULL; /* free consistent DMA area... */ if (priv->driver_mem_address) pci_free_consistent(priv->pdev, HOST_MEM_BLOCK, priv->driver_mem_address, priv->device_host_address); /* clear some dangling pointers */ priv->driver_mem_address = NULL; priv->device_host_address = 0; priv->device_psm_buffer = 0; priv->control_block = NULL; /* clean up mgmt rx buffers */ for (counter = 0; counter < ISL38XX_CB_MGMT_QSIZE; counter++) { struct islpci_membuf *buf = &priv->mgmt_rx[counter]; if (buf->pci_addr) pci_unmap_single(priv->pdev, buf->pci_addr, buf->size, PCI_DMA_FROMDEVICE); buf->pci_addr = 0; kfree(buf->mem); buf->size = 0; buf->mem = NULL; } /* clean up data rx buffers */ for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) { if (priv->pci_map_rx_address[counter]) pci_unmap_single(priv->pdev, priv->pci_map_rx_address[counter], MAX_FRAGMENT_SIZE_RX + 2, PCI_DMA_FROMDEVICE); priv->pci_map_rx_address[counter] = 0; if (priv->data_low_rx[counter]) dev_kfree_skb(priv->data_low_rx[counter]); priv->data_low_rx[counter] = NULL; } /* Free the access control list and the WPA list */ prism54_acl_clean(&priv->acl); prism54_wpa_bss_ie_clean(priv); mgt_clean(priv); return 0; } #if 0 static void islpci_set_multicast_list(struct net_device *dev) { /* put device into promisc mode and let network layer handle it */ } #endif static void islpci_ethtool_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); strlcpy(info->version, DRV_VERSION, sizeof(info->version)); } static const struct ethtool_ops islpci_ethtool_ops = { .get_drvinfo = islpci_ethtool_get_drvinfo, }; static const struct net_device_ops islpci_netdev_ops = { .ndo_open = islpci_open, .ndo_stop = islpci_close, .ndo_start_xmit = islpci_eth_transmit, .ndo_tx_timeout = islpci_eth_tx_timeout, .ndo_set_mac_address = prism54_set_mac_address, .ndo_change_mtu = eth_change_mtu, .ndo_validate_addr = eth_validate_addr, }; struct net_device * islpci_setup(struct pci_dev *pdev) { islpci_private *priv; struct net_device *ndev = alloc_etherdev(sizeof (islpci_private)); if (!ndev) return ndev; pci_set_drvdata(pdev, ndev); #if defined(SET_NETDEV_DEV) SET_NETDEV_DEV(ndev, &pdev->dev); #endif /* setup the structure members */ ndev->base_addr = pci_resource_start(pdev, 0); ndev->irq = pdev->irq; /* initialize the function pointers */ ndev->netdev_ops = &islpci_netdev_ops; ndev->wireless_handlers = &prism54_handler_def; ndev->ethtool_ops = &islpci_ethtool_ops; /* ndev->set_multicast_list = &islpci_set_multicast_list; */ ndev->addr_len = ETH_ALEN; /* Get a non-zero dummy MAC address for nameif. Jean II */ memcpy(ndev->dev_addr, dummy_mac, 6); ndev->watchdog_timeo = ISLPCI_TX_TIMEOUT; /* allocate a private device structure to the network device */ priv = netdev_priv(ndev); priv->ndev = ndev; priv->pdev = pdev; priv->monitor_type = ARPHRD_IEEE80211; priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR) ? priv->monitor_type : ARPHRD_ETHER; /* Add pointers to enable iwspy support. */ priv->wireless_data.spy_data = &priv->spy_data; ndev->wireless_data = &priv->wireless_data; /* save the start and end address of the PCI memory area */ ndev->mem_start = (unsigned long) priv->device_base; ndev->mem_end = ndev->mem_start + ISL38XX_PCI_MEM_SIZE; #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_TRACING, "PCI Memory remapped to 0x%p\n", priv->device_base); #endif init_waitqueue_head(&priv->reset_done); /* init the queue read locks, process wait counter */ mutex_init(&priv->mgmt_lock); priv->mgmt_received = NULL; init_waitqueue_head(&priv->mgmt_wqueue); mutex_init(&priv->stats_lock); spin_lock_init(&priv->slock); /* init state machine with off#1 state */ priv->state = PRV_STATE_OFF; priv->state_off = 1; /* initialize workqueue's */ INIT_WORK(&priv->stats_work, prism54_update_stats); priv->stats_timestamp = 0; INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake); priv->reset_task_pending = 0; /* allocate various memory areas */ if (islpci_alloc_memory(priv)) goto do_free_netdev; /* select the firmware file depending on the device id */ switch (pdev->device) { case 0x3877: strcpy(priv->firmware, ISL3877_IMAGE_FILE); break; case 0x3886: strcpy(priv->firmware, ISL3886_IMAGE_FILE); break; default: strcpy(priv->firmware, ISL3890_IMAGE_FILE); break; } if (register_netdev(ndev)) { DEBUG(SHOW_ERROR_MESSAGES, "ERROR: register_netdev() failed\n"); goto do_islpci_free_memory; } return ndev; do_islpci_free_memory: islpci_free_memory(priv); do_free_netdev: pci_set_drvdata(pdev, NULL); free_netdev(ndev); priv = NULL; return NULL; } islpci_state_t islpci_set_state(islpci_private *priv, islpci_state_t new_state) { islpci_state_t old_state; /* lock */ old_state = priv->state; /* this means either a race condition or some serious error in * the driver code */ switch (new_state) { case PRV_STATE_OFF: priv->state_off++; default: priv->state = new_state; break; case PRV_STATE_PREBOOT: /* there are actually many off-states, enumerated by * state_off */ if (old_state == PRV_STATE_OFF) priv->state_off--; /* only if hw_unavailable is zero now it means we either * were in off#1 state, or came here from * somewhere else */ if (!priv->state_off) priv->state = new_state; break; } #if 0 printk(KERN_DEBUG "%s: state transition %d -> %d (off#%d)\n", priv->ndev->name, old_state, new_state, priv->state_off); #endif /* invariants */ BUG_ON(priv->state_off < 0); BUG_ON(priv->state_off && (priv->state != PRV_STATE_OFF)); BUG_ON(!priv->state_off && (priv->state == PRV_STATE_OFF)); /* unlock */ return old_state; }
gpl-2.0
Radium-Devices/Radium_falcon
arch/arm/mach-davinci/board-dm365-evm.c
4726
15080
/* * TI DaVinci DM365 EVM board support * * Copyright (C) 2009 Texas Instruments Incorporated * * 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 version 2. * * This program is distributed "as is" WITHOUT ANY WARRANTY of any * kind, whether express or implied; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> #include <linux/io.h> #include <linux/clk.h> #include <linux/i2c/at24.h> #include <linux/leds.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> #include <linux/slab.h> #include <linux/mtd/nand.h> #include <linux/input.h> #include <linux/spi/spi.h> #include <linux/spi/eeprom.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> #include <mach/mux.h> #include <mach/common.h> #include <mach/i2c.h> #include <mach/serial.h> #include <mach/mmc.h> #include <mach/nand.h> #include <mach/keyscan.h> #include <media/tvp514x.h> #include "davinci.h" static inline int have_imager(void) { /* REVISIT when it's supported, trigger via Kconfig */ return 0; } static inline int have_tvp7002(void) { /* REVISIT when it's supported, trigger via Kconfig */ return 0; } #define DM365_EVM_PHY_ID "davinci_mdio-0:01" /* * A MAX-II CPLD is used for various board control functions. */ #define CPLD_OFFSET(a13a8,a2a1) (((a13a8) << 10) + ((a2a1) << 3)) #define CPLD_VERSION CPLD_OFFSET(0,0) /* r/o */ #define CPLD_TEST CPLD_OFFSET(0,1) #define CPLD_LEDS CPLD_OFFSET(0,2) #define CPLD_MUX CPLD_OFFSET(0,3) #define CPLD_SWITCH CPLD_OFFSET(1,0) /* r/o */ #define CPLD_POWER CPLD_OFFSET(1,1) #define CPLD_VIDEO CPLD_OFFSET(1,2) #define CPLD_CARDSTAT CPLD_OFFSET(1,3) /* r/o */ #define CPLD_DILC_OUT CPLD_OFFSET(2,0) #define CPLD_DILC_IN CPLD_OFFSET(2,1) /* r/o */ #define CPLD_IMG_DIR0 CPLD_OFFSET(2,2) #define CPLD_IMG_MUX0 CPLD_OFFSET(2,3) #define CPLD_IMG_MUX1 CPLD_OFFSET(3,0) #define CPLD_IMG_DIR1 CPLD_OFFSET(3,1) #define CPLD_IMG_MUX2 CPLD_OFFSET(3,2) #define CPLD_IMG_MUX3 CPLD_OFFSET(3,3) #define CPLD_IMG_DIR2 CPLD_OFFSET(4,0) #define CPLD_IMG_MUX4 CPLD_OFFSET(4,1) #define CPLD_IMG_MUX5 CPLD_OFFSET(4,2) #define CPLD_RESETS CPLD_OFFSET(4,3) #define CPLD_CCD_DIR1 CPLD_OFFSET(0x3e,0) #define CPLD_CCD_IO1 CPLD_OFFSET(0x3e,1) #define CPLD_CCD_DIR2 CPLD_OFFSET(0x3e,2) #define CPLD_CCD_IO2 CPLD_OFFSET(0x3e,3) #define CPLD_CCD_DIR3 CPLD_OFFSET(0x3f,0) #define CPLD_CCD_IO3 CPLD_OFFSET(0x3f,1) static void __iomem *cpld; /* NOTE: this is geared for the standard config, with a socketed * 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors. If you * swap chips with a different block size, partitioning will * need to be changed. This NAND chip MT29F16G08FAA is the default * NAND shipped with the Spectrum Digital DM365 EVM */ #define NAND_BLOCK_SIZE SZ_128K static struct mtd_partition davinci_nand_partitions[] = { { /* UBL (a few copies) plus U-Boot */ .name = "bootloader", .offset = 0, .size = 30 * NAND_BLOCK_SIZE, .mask_flags = MTD_WRITEABLE, /* force read-only */ }, { /* U-Boot environment */ .name = "params", .offset = MTDPART_OFS_APPEND, .size = 2 * NAND_BLOCK_SIZE, .mask_flags = 0, }, { .name = "kernel", .offset = MTDPART_OFS_APPEND, .size = SZ_4M, .mask_flags = 0, }, { .name = "filesystem1", .offset = MTDPART_OFS_APPEND, .size = SZ_512M, .mask_flags = 0, }, { .name = "filesystem2", .offset = MTDPART_OFS_APPEND, .size = MTDPART_SIZ_FULL, .mask_flags = 0, } /* two blocks with bad block table (and mirror) at the end */ }; static struct davinci_nand_pdata davinci_nand_data = { .mask_chipsel = BIT(14), .parts = davinci_nand_partitions, .nr_parts = ARRAY_SIZE(davinci_nand_partitions), .ecc_mode = NAND_ECC_HW, .bbt_options = NAND_BBT_USE_FLASH, .ecc_bits = 4, }; static struct resource davinci_nand_resources[] = { { .start = DM365_ASYNC_EMIF_DATA_CE0_BASE, .end = DM365_ASYNC_EMIF_DATA_CE0_BASE + SZ_32M - 1, .flags = IORESOURCE_MEM, }, { .start = DM365_ASYNC_EMIF_CONTROL_BASE, .end = DM365_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, }; static struct platform_device davinci_nand_device = { .name = "davinci_nand", .id = 0, .num_resources = ARRAY_SIZE(davinci_nand_resources), .resource = davinci_nand_resources, .dev = { .platform_data = &davinci_nand_data, }, }; static struct at24_platform_data eeprom_info = { .byte_len = (256*1024) / 8, .page_size = 64, .flags = AT24_FLAG_ADDR16, .setup = davinci_get_mac_addr, .context = (void *)0x7f00, }; static struct snd_platform_data dm365_evm_snd_data = { .asp_chan_q = EVENTQ_3, }; static struct i2c_board_info i2c_info[] = { { I2C_BOARD_INFO("24c256", 0x50), .platform_data = &eeprom_info, }, { I2C_BOARD_INFO("tlv320aic3x", 0x18), }, }; static struct davinci_i2c_platform_data i2c_pdata = { .bus_freq = 400 /* kHz */, .bus_delay = 0 /* usec */, }; static int dm365evm_keyscan_enable(struct device *dev) { return davinci_cfg_reg(DM365_KEYSCAN); } static unsigned short dm365evm_keymap[] = { KEY_KP2, KEY_LEFT, KEY_EXIT, KEY_DOWN, KEY_ENTER, KEY_UP, KEY_KP1, KEY_RIGHT, KEY_MENU, KEY_RECORD, KEY_REWIND, KEY_KPMINUS, KEY_STOP, KEY_FASTFORWARD, KEY_KPPLUS, KEY_PLAYPAUSE, 0 }; static struct davinci_ks_platform_data dm365evm_ks_data = { .device_enable = dm365evm_keyscan_enable, .keymap = dm365evm_keymap, .keymapsize = ARRAY_SIZE(dm365evm_keymap), .rep = 1, /* Scan period = strobe + interval */ .strobe = 0x5, .interval = 0x2, .matrix_type = DAVINCI_KEYSCAN_MATRIX_4X4, }; static int cpld_mmc_get_cd(int module) { if (!cpld) return -ENXIO; /* low == card present */ return !(__raw_readb(cpld + CPLD_CARDSTAT) & BIT(module ? 4 : 0)); } static int cpld_mmc_get_ro(int module) { if (!cpld) return -ENXIO; /* high == card's write protect switch active */ return !!(__raw_readb(cpld + CPLD_CARDSTAT) & BIT(module ? 5 : 1)); } static struct davinci_mmc_config dm365evm_mmc_config = { .get_cd = cpld_mmc_get_cd, .get_ro = cpld_mmc_get_ro, .wires = 4, .max_freq = 50000000, .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, .version = MMC_CTLR_VERSION_2, }; static void dm365evm_emac_configure(void) { /* * EMAC pins are multiplexed with GPIO and UART * Further details are available at the DM365 ARM * Subsystem Users Guide(sprufg5.pdf) pages 125 - 127 */ davinci_cfg_reg(DM365_EMAC_TX_EN); davinci_cfg_reg(DM365_EMAC_TX_CLK); davinci_cfg_reg(DM365_EMAC_COL); davinci_cfg_reg(DM365_EMAC_TXD3); davinci_cfg_reg(DM365_EMAC_TXD2); davinci_cfg_reg(DM365_EMAC_TXD1); davinci_cfg_reg(DM365_EMAC_TXD0); davinci_cfg_reg(DM365_EMAC_RXD3); davinci_cfg_reg(DM365_EMAC_RXD2); davinci_cfg_reg(DM365_EMAC_RXD1); davinci_cfg_reg(DM365_EMAC_RXD0); davinci_cfg_reg(DM365_EMAC_RX_CLK); davinci_cfg_reg(DM365_EMAC_RX_DV); davinci_cfg_reg(DM365_EMAC_RX_ER); davinci_cfg_reg(DM365_EMAC_CRS); davinci_cfg_reg(DM365_EMAC_MDIO); davinci_cfg_reg(DM365_EMAC_MDCLK); /* * EMAC interrupts are multiplexed with GPIO interrupts * Details are available at the DM365 ARM * Subsystem Users Guide(sprufg5.pdf) pages 133 - 134 */ davinci_cfg_reg(DM365_INT_EMAC_RXTHRESH); davinci_cfg_reg(DM365_INT_EMAC_RXPULSE); davinci_cfg_reg(DM365_INT_EMAC_TXPULSE); davinci_cfg_reg(DM365_INT_EMAC_MISCPULSE); } static void dm365evm_mmc_configure(void) { /* * MMC/SD pins are multiplexed with GPIO and EMIF * Further details are available at the DM365 ARM * Subsystem Users Guide(sprufg5.pdf) pages 118, 128 - 131 */ davinci_cfg_reg(DM365_SD1_CLK); davinci_cfg_reg(DM365_SD1_CMD); davinci_cfg_reg(DM365_SD1_DATA3); davinci_cfg_reg(DM365_SD1_DATA2); davinci_cfg_reg(DM365_SD1_DATA1); davinci_cfg_reg(DM365_SD1_DATA0); } static struct tvp514x_platform_data tvp5146_pdata = { .clk_polarity = 0, .hs_polarity = 1, .vs_polarity = 1 }; #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL) /* Inputs available at the TVP5146 */ static struct v4l2_input tvp5146_inputs[] = { { .index = 0, .name = "Composite", .type = V4L2_INPUT_TYPE_CAMERA, .std = TVP514X_STD_ALL, }, { .index = 1, .name = "S-Video", .type = V4L2_INPUT_TYPE_CAMERA, .std = TVP514X_STD_ALL, }, }; /* * this is the route info for connecting each input to decoder * ouput that goes to vpfe. There is a one to one correspondence * with tvp5146_inputs */ static struct vpfe_route tvp5146_routes[] = { { .input = INPUT_CVBS_VI2B, .output = OUTPUT_10BIT_422_EMBEDDED_SYNC, }, { .input = INPUT_SVIDEO_VI2C_VI1C, .output = OUTPUT_10BIT_422_EMBEDDED_SYNC, }, }; static struct vpfe_subdev_info vpfe_sub_devs[] = { { .name = "tvp5146", .grp_id = 0, .num_inputs = ARRAY_SIZE(tvp5146_inputs), .inputs = tvp5146_inputs, .routes = tvp5146_routes, .can_route = 1, .ccdc_if_params = { .if_type = VPFE_BT656, .hdpol = VPFE_PINPOL_POSITIVE, .vdpol = VPFE_PINPOL_POSITIVE, }, .board_info = { I2C_BOARD_INFO("tvp5146", 0x5d), .platform_data = &tvp5146_pdata, }, }, }; static struct vpfe_config vpfe_cfg = { .num_subdevs = ARRAY_SIZE(vpfe_sub_devs), .sub_devs = vpfe_sub_devs, .i2c_adapter_id = 1, .card_name = "DM365 EVM", .ccdc = "ISIF", }; static void __init evm_init_i2c(void) { davinci_init_i2c(&i2c_pdata); i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info)); } static struct platform_device *dm365_evm_nand_devices[] __initdata = { &davinci_nand_device, }; static inline int have_leds(void) { #ifdef CONFIG_LEDS_CLASS return 1; #else return 0; #endif } struct cpld_led { struct led_classdev cdev; u8 mask; }; static const struct { const char *name; const char *trigger; } cpld_leds[] = { { "dm365evm::ds2", }, { "dm365evm::ds3", }, { "dm365evm::ds4", }, { "dm365evm::ds5", }, { "dm365evm::ds6", "nand-disk", }, { "dm365evm::ds7", "mmc1", }, { "dm365evm::ds8", "mmc0", }, { "dm365evm::ds9", "heartbeat", }, }; static void cpld_led_set(struct led_classdev *cdev, enum led_brightness b) { struct cpld_led *led = container_of(cdev, struct cpld_led, cdev); u8 reg = __raw_readb(cpld + CPLD_LEDS); if (b != LED_OFF) reg &= ~led->mask; else reg |= led->mask; __raw_writeb(reg, cpld + CPLD_LEDS); } static enum led_brightness cpld_led_get(struct led_classdev *cdev) { struct cpld_led *led = container_of(cdev, struct cpld_led, cdev); u8 reg = __raw_readb(cpld + CPLD_LEDS); return (reg & led->mask) ? LED_OFF : LED_FULL; } static int __init cpld_leds_init(void) { int i; if (!have_leds() || !cpld) return 0; /* setup LEDs */ __raw_writeb(0xff, cpld + CPLD_LEDS); for (i = 0; i < ARRAY_SIZE(cpld_leds); i++) { struct cpld_led *led; led = kzalloc(sizeof(*led), GFP_KERNEL); if (!led) break; led->cdev.name = cpld_leds[i].name; led->cdev.brightness_set = cpld_led_set; led->cdev.brightness_get = cpld_led_get; led->cdev.default_trigger = cpld_leds[i].trigger; led->mask = BIT(i); if (led_classdev_register(NULL, &led->cdev) < 0) { kfree(led); break; } } return 0; } /* run after subsys_initcall() for LEDs */ fs_initcall(cpld_leds_init); static void __init evm_init_cpld(void) { u8 mux, resets; const char *label; struct clk *aemif_clk; /* Make sure we can configure the CPLD through CS1. Then * leave it on for later access to MMC and LED registers. */ aemif_clk = clk_get(NULL, "aemif"); if (IS_ERR(aemif_clk)) return; clk_enable(aemif_clk); if (request_mem_region(DM365_ASYNC_EMIF_DATA_CE1_BASE, SECTION_SIZE, "cpld") == NULL) goto fail; cpld = ioremap(DM365_ASYNC_EMIF_DATA_CE1_BASE, SECTION_SIZE); if (!cpld) { release_mem_region(DM365_ASYNC_EMIF_DATA_CE1_BASE, SECTION_SIZE); fail: pr_err("ERROR: can't map CPLD\n"); clk_disable(aemif_clk); return; } /* External muxing for some signals */ mux = 0; /* Read SW5 to set up NAND + keypad _or_ OneNAND (sync read). * NOTE: SW4 bus width setting must match! */ if ((__raw_readb(cpld + CPLD_SWITCH) & BIT(5)) == 0) { /* external keypad mux */ mux |= BIT(7); platform_add_devices(dm365_evm_nand_devices, ARRAY_SIZE(dm365_evm_nand_devices)); } else { /* no OneNAND support yet */ } /* Leave external chips in reset when unused. */ resets = BIT(3) | BIT(2) | BIT(1) | BIT(0); /* Static video input config with SN74CBT16214 1-of-3 mux: * - port b1 == tvp7002 (mux lowbits == 1 or 6) * - port b2 == imager (mux lowbits == 2 or 7) * - port b3 == tvp5146 (mux lowbits == 5) * * Runtime switching could work too, with limitations. */ if (have_imager()) { label = "HD imager"; mux |= 2; /* externally mux MMC1/ENET/AIC33 to imager */ mux |= BIT(6) | BIT(5) | BIT(3); } else { struct davinci_soc_info *soc_info = &davinci_soc_info; /* we can use MMC1 ... */ dm365evm_mmc_configure(); davinci_setup_mmc(1, &dm365evm_mmc_config); /* ... and ENET ... */ dm365evm_emac_configure(); soc_info->emac_pdata->phy_id = DM365_EVM_PHY_ID; resets &= ~BIT(3); /* ... and AIC33 */ resets &= ~BIT(1); if (have_tvp7002()) { mux |= 1; resets &= ~BIT(2); label = "tvp7002 HD"; } else { /* default to tvp5146 */ mux |= 5; resets &= ~BIT(0); label = "tvp5146 SD"; } } __raw_writeb(mux, cpld + CPLD_MUX); __raw_writeb(resets, cpld + CPLD_RESETS); pr_info("EVM: %s video input\n", label); /* REVISIT export switches: NTSC/PAL (SW5.6), EXTRA1 (SW5.2), etc */ } static struct davinci_uart_config uart_config __initdata = { .enabled_uarts = (1 << 0), }; static void __init dm365_evm_map_io(void) { /* setup input configuration for VPFE input devices */ dm365_set_vpfe_config(&vpfe_cfg); dm365_init(); } static struct spi_eeprom at25640 = { .byte_len = SZ_64K / 8, .name = "at25640", .page_size = 32, .flags = EE_ADDR2, }; static struct spi_board_info dm365_evm_spi_info[] __initconst = { { .modalias = "at25", .platform_data = &at25640, .max_speed_hz = 10 * 1000 * 1000, .bus_num = 0, .chip_select = 0, .mode = SPI_MODE_0, }, }; static __init void dm365_evm_init(void) { evm_init_i2c(); davinci_serial_init(&uart_config); dm365evm_emac_configure(); dm365evm_mmc_configure(); davinci_setup_mmc(0, &dm365evm_mmc_config); /* maybe setup mmc1/etc ... _after_ mmc0 */ evm_init_cpld(); #ifdef CONFIG_SND_DM365_AIC3X_CODEC dm365_init_asp(&dm365_evm_snd_data); #elif defined(CONFIG_SND_DM365_VOICE_CODEC) dm365_init_vc(&dm365_evm_snd_data); #endif dm365_init_rtc(); dm365_init_ks(&dm365evm_ks_data); dm365_init_spi0(BIT(0), dm365_evm_spi_info, ARRAY_SIZE(dm365_evm_spi_info)); } MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM365 EVM") .atag_offset = 0x100, .map_io = dm365_evm_map_io, .init_irq = davinci_irq_init, .timer = &davinci_timer, .init_machine = dm365_evm_init, .dma_zone_size = SZ_128M, .restart = davinci_restart, MACHINE_END
gpl-2.0
Droid-Concepts/kernel_samsung_jf
drivers/hwmon/via-cputemp.c
4726
8771
/* * via-cputemp.c - Driver for VIA CPU core temperature monitoring * Copyright (C) 2009 VIA Technologies, Inc. * * based on existing coretemp.c, which is * * Copyright (C) 2007 Rudolf Marek <r.marek@assembler.cz> * * 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; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/hwmon.h> #include <linux/hwmon-vid.h> #include <linux/sysfs.h> #include <linux/hwmon-sysfs.h> #include <linux/err.h> #include <linux/mutex.h> #include <linux/list.h> #include <linux/platform_device.h> #include <linux/cpu.h> #include <asm/msr.h> #include <asm/processor.h> #include <asm/cpu_device_id.h> #define DRVNAME "via_cputemp" enum { SHOW_TEMP, SHOW_LABEL, SHOW_NAME }; /* * Functions declaration */ struct via_cputemp_data { struct device *hwmon_dev; const char *name; u8 vrm; u32 id; u32 msr_temp; u32 msr_vid; }; /* * Sysfs stuff */ static ssize_t show_name(struct device *dev, struct device_attribute *devattr, char *buf) { int ret; struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct via_cputemp_data *data = dev_get_drvdata(dev); if (attr->index == SHOW_NAME) ret = sprintf(buf, "%s\n", data->name); else /* show label */ ret = sprintf(buf, "Core %d\n", data->id); return ret; } static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, char *buf) { struct via_cputemp_data *data = dev_get_drvdata(dev); u32 eax, edx; int err; err = rdmsr_safe_on_cpu(data->id, data->msr_temp, &eax, &edx); if (err) return -EAGAIN; return sprintf(buf, "%lu\n", ((unsigned long)eax & 0xffffff) * 1000); } static ssize_t show_cpu_vid(struct device *dev, struct device_attribute *devattr, char *buf) { struct via_cputemp_data *data = dev_get_drvdata(dev); u32 eax, edx; int err; err = rdmsr_safe_on_cpu(data->id, data->msr_vid, &eax, &edx); if (err) return -EAGAIN; return sprintf(buf, "%d\n", vid_from_reg(~edx & 0x7f, data->vrm)); } static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, SHOW_TEMP); static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_name, NULL, SHOW_LABEL); static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, SHOW_NAME); static struct attribute *via_cputemp_attributes[] = { &sensor_dev_attr_name.dev_attr.attr, &sensor_dev_attr_temp1_label.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr, NULL }; static const struct attribute_group via_cputemp_group = { .attrs = via_cputemp_attributes, }; /* Optional attributes */ static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_cpu_vid, NULL); static int __devinit via_cputemp_probe(struct platform_device *pdev) { struct via_cputemp_data *data; struct cpuinfo_x86 *c = &cpu_data(pdev->id); int err; u32 eax, edx; data = kzalloc(sizeof(struct via_cputemp_data), GFP_KERNEL); if (!data) { err = -ENOMEM; dev_err(&pdev->dev, "Out of memory\n"); goto exit; } data->id = pdev->id; data->name = "via_cputemp"; switch (c->x86_model) { case 0xA: /* C7 A */ case 0xD: /* C7 D */ data->msr_temp = 0x1169; data->msr_vid = 0x198; break; case 0xF: /* Nano */ data->msr_temp = 0x1423; break; default: err = -ENODEV; goto exit_free; } /* test if we can access the TEMPERATURE MSR */ err = rdmsr_safe_on_cpu(data->id, data->msr_temp, &eax, &edx); if (err) { dev_err(&pdev->dev, "Unable to access TEMPERATURE MSR, giving up\n"); goto exit_free; } platform_set_drvdata(pdev, data); err = sysfs_create_group(&pdev->dev.kobj, &via_cputemp_group); if (err) goto exit_free; if (data->msr_vid) data->vrm = vid_which_vrm(); if (data->vrm) { err = device_create_file(&pdev->dev, &dev_attr_cpu0_vid); if (err) goto exit_remove; } data->hwmon_dev = hwmon_device_register(&pdev->dev); if (IS_ERR(data->hwmon_dev)) { err = PTR_ERR(data->hwmon_dev); dev_err(&pdev->dev, "Class registration failed (%d)\n", err); goto exit_remove; } return 0; exit_remove: if (data->vrm) device_remove_file(&pdev->dev, &dev_attr_cpu0_vid); sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group); exit_free: platform_set_drvdata(pdev, NULL); kfree(data); exit: return err; } static int __devexit via_cputemp_remove(struct platform_device *pdev) { struct via_cputemp_data *data = platform_get_drvdata(pdev); hwmon_device_unregister(data->hwmon_dev); if (data->vrm) device_remove_file(&pdev->dev, &dev_attr_cpu0_vid); sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group); platform_set_drvdata(pdev, NULL); kfree(data); return 0; } static struct platform_driver via_cputemp_driver = { .driver = { .owner = THIS_MODULE, .name = DRVNAME, }, .probe = via_cputemp_probe, .remove = __devexit_p(via_cputemp_remove), }; struct pdev_entry { struct list_head list; struct platform_device *pdev; unsigned int cpu; }; static LIST_HEAD(pdev_list); static DEFINE_MUTEX(pdev_list_mutex); static int __cpuinit via_cputemp_device_add(unsigned int cpu) { int err; struct platform_device *pdev; struct pdev_entry *pdev_entry; pdev = platform_device_alloc(DRVNAME, cpu); if (!pdev) { err = -ENOMEM; pr_err("Device allocation failed\n"); goto exit; } pdev_entry = kzalloc(sizeof(struct pdev_entry), GFP_KERNEL); if (!pdev_entry) { err = -ENOMEM; goto exit_device_put; } err = platform_device_add(pdev); if (err) { pr_err("Device addition failed (%d)\n", err); goto exit_device_free; } pdev_entry->pdev = pdev; pdev_entry->cpu = cpu; mutex_lock(&pdev_list_mutex); list_add_tail(&pdev_entry->list, &pdev_list); mutex_unlock(&pdev_list_mutex); return 0; exit_device_free: kfree(pdev_entry); exit_device_put: platform_device_put(pdev); exit: return err; } static void __cpuinit via_cputemp_device_remove(unsigned int cpu) { struct pdev_entry *p; mutex_lock(&pdev_list_mutex); list_for_each_entry(p, &pdev_list, list) { if (p->cpu == cpu) { platform_device_unregister(p->pdev); list_del(&p->list); mutex_unlock(&pdev_list_mutex); kfree(p); return; } } mutex_unlock(&pdev_list_mutex); } static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long) hcpu; switch (action) { case CPU_ONLINE: case CPU_DOWN_FAILED: via_cputemp_device_add(cpu); break; case CPU_DOWN_PREPARE: via_cputemp_device_remove(cpu); break; } return NOTIFY_OK; } static struct notifier_block via_cputemp_cpu_notifier __refdata = { .notifier_call = via_cputemp_cpu_callback, }; static const struct x86_cpu_id cputemp_ids[] = { { X86_VENDOR_CENTAUR, 6, 0xa, }, /* C7 A */ { X86_VENDOR_CENTAUR, 6, 0xd, }, /* C7 D */ { X86_VENDOR_CENTAUR, 6, 0xf, }, /* Nano */ {} }; MODULE_DEVICE_TABLE(x86cpu, cputemp_ids); static int __init via_cputemp_init(void) { int i, err; if (!x86_match_cpu(cputemp_ids)) return -ENODEV; err = platform_driver_register(&via_cputemp_driver); if (err) goto exit; for_each_online_cpu(i) { struct cpuinfo_x86 *c = &cpu_data(i); if (c->x86 != 6) continue; if (c->x86_model < 0x0a) continue; if (c->x86_model > 0x0f) { pr_warn("Unknown CPU model 0x%x\n", c->x86_model); continue; } via_cputemp_device_add(i); } #ifndef CONFIG_HOTPLUG_CPU if (list_empty(&pdev_list)) { err = -ENODEV; goto exit_driver_unreg; } #endif register_hotcpu_notifier(&via_cputemp_cpu_notifier); return 0; #ifndef CONFIG_HOTPLUG_CPU exit_driver_unreg: platform_driver_unregister(&via_cputemp_driver); #endif exit: return err; } static void __exit via_cputemp_exit(void) { struct pdev_entry *p, *n; unregister_hotcpu_notifier(&via_cputemp_cpu_notifier); mutex_lock(&pdev_list_mutex); list_for_each_entry_safe(p, n, &pdev_list, list) { platform_device_unregister(p->pdev); list_del(&p->list); kfree(p); } mutex_unlock(&pdev_list_mutex); platform_driver_unregister(&via_cputemp_driver); } MODULE_AUTHOR("Harald Welte <HaraldWelte@viatech.com>"); MODULE_DESCRIPTION("VIA CPU temperature monitor"); MODULE_LICENSE("GPL"); module_init(via_cputemp_init) module_exit(via_cputemp_exit)
gpl-2.0
mlachwani/Android_4.4.2_MotoG_Kernel
arch/arm/mach-s5pv210/mach-smdkv210.c
4726
8378
/* linux/arch/arm/mach-s5pv210/mach-smdkv210.c * * Copyright (c) 2010 Samsung Electronics Co., Ltd. * http://www.samsung.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/kernel.h> #include <linux/types.h> #include <linux/i2c.h> #include <linux/init.h> #include <linux/serial_core.h> #include <linux/device.h> #include <linux/dm9000.h> #include <linux/fb.h> #include <linux/gpio.h> #include <linux/delay.h> #include <linux/pwm_backlight.h> #include <asm/hardware/vic.h> #include <asm/mach/arch.h> #include <asm/mach/map.h> #include <asm/setup.h> #include <asm/mach-types.h> #include <video/platform_lcd.h> #include <mach/map.h> #include <mach/regs-clock.h> #include <plat/regs-serial.h> #include <plat/regs-srom.h> #include <plat/gpio-cfg.h> #include <plat/devs.h> #include <plat/cpu.h> #include <plat/adc.h> #include <plat/ts.h> #include <plat/ata.h> #include <plat/iic.h> #include <plat/keypad.h> #include <plat/pm.h> #include <plat/fb.h> #include <plat/s5p-time.h> #include <plat/backlight.h> #include <plat/regs-fb-v4.h> #include <plat/mfc.h> #include "common.h" /* Following are default values for UCON, ULCON and UFCON UART registers */ #define SMDKV210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ S3C2410_UCON_RXILEVEL | \ S3C2410_UCON_TXIRQMODE | \ S3C2410_UCON_RXIRQMODE | \ S3C2410_UCON_RXFIFO_TOI | \ S3C2443_UCON_RXERR_IRQEN) #define SMDKV210_ULCON_DEFAULT S3C2410_LCON_CS8 #define SMDKV210_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \ S5PV210_UFCON_TXTRIG4 | \ S5PV210_UFCON_RXTRIG4) static struct s3c2410_uartcfg smdkv210_uartcfgs[] __initdata = { [0] = { .hwport = 0, .flags = 0, .ucon = SMDKV210_UCON_DEFAULT, .ulcon = SMDKV210_ULCON_DEFAULT, .ufcon = SMDKV210_UFCON_DEFAULT, }, [1] = { .hwport = 1, .flags = 0, .ucon = SMDKV210_UCON_DEFAULT, .ulcon = SMDKV210_ULCON_DEFAULT, .ufcon = SMDKV210_UFCON_DEFAULT, }, [2] = { .hwport = 2, .flags = 0, .ucon = SMDKV210_UCON_DEFAULT, .ulcon = SMDKV210_ULCON_DEFAULT, .ufcon = SMDKV210_UFCON_DEFAULT, }, [3] = { .hwport = 3, .flags = 0, .ucon = SMDKV210_UCON_DEFAULT, .ulcon = SMDKV210_ULCON_DEFAULT, .ufcon = SMDKV210_UFCON_DEFAULT, }, }; static struct s3c_ide_platdata smdkv210_ide_pdata __initdata = { .setup_gpio = s5pv210_ide_setup_gpio, }; static uint32_t smdkv210_keymap[] __initdata = { /* KEY(row, col, keycode) */ KEY(0, 3, KEY_1), KEY(0, 4, KEY_2), KEY(0, 5, KEY_3), KEY(0, 6, KEY_4), KEY(0, 7, KEY_5), KEY(1, 3, KEY_A), KEY(1, 4, KEY_B), KEY(1, 5, KEY_C), KEY(1, 6, KEY_D), KEY(1, 7, KEY_E) }; static struct matrix_keymap_data smdkv210_keymap_data __initdata = { .keymap = smdkv210_keymap, .keymap_size = ARRAY_SIZE(smdkv210_keymap), }; static struct samsung_keypad_platdata smdkv210_keypad_data __initdata = { .keymap_data = &smdkv210_keymap_data, .rows = 8, .cols = 8, }; static struct resource smdkv210_dm9000_resources[] = { [0] = { .start = S5PV210_PA_SROM_BANK5, .end = S5PV210_PA_SROM_BANK5, .flags = IORESOURCE_MEM, }, [1] = { .start = S5PV210_PA_SROM_BANK5 + 2, .end = S5PV210_PA_SROM_BANK5 + 2, .flags = IORESOURCE_MEM, }, [2] = { .start = IRQ_EINT(9), .end = IRQ_EINT(9), .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, }, }; static struct dm9000_plat_data smdkv210_dm9000_platdata = { .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM, .dev_addr = { 0x00, 0x09, 0xc0, 0xff, 0xec, 0x48 }, }; static struct platform_device smdkv210_dm9000 = { .name = "dm9000", .id = -1, .num_resources = ARRAY_SIZE(smdkv210_dm9000_resources), .resource = smdkv210_dm9000_resources, .dev = { .platform_data = &smdkv210_dm9000_platdata, }, }; static void smdkv210_lte480wv_set_power(struct plat_lcd_data *pd, unsigned int power) { if (power) { #if !defined(CONFIG_BACKLIGHT_PWM) gpio_request_one(S5PV210_GPD0(3), GPIOF_OUT_INIT_HIGH, "GPD0"); gpio_free(S5PV210_GPD0(3)); #endif /* fire nRESET on power up */ gpio_request_one(S5PV210_GPH0(6), GPIOF_OUT_INIT_HIGH, "GPH0"); gpio_set_value(S5PV210_GPH0(6), 0); mdelay(10); gpio_set_value(S5PV210_GPH0(6), 1); mdelay(10); gpio_free(S5PV210_GPH0(6)); } else { #if !defined(CONFIG_BACKLIGHT_PWM) gpio_request_one(S5PV210_GPD0(3), GPIOF_OUT_INIT_LOW, "GPD0"); gpio_free(S5PV210_GPD0(3)); #endif } } static struct plat_lcd_data smdkv210_lcd_lte480wv_data = { .set_power = smdkv210_lte480wv_set_power, }; static struct platform_device smdkv210_lcd_lte480wv = { .name = "platform-lcd", .dev.parent = &s3c_device_fb.dev, .dev.platform_data = &smdkv210_lcd_lte480wv_data, }; static struct s3c_fb_pd_win smdkv210_fb_win0 = { .win_mode = { .left_margin = 13, .right_margin = 8, .upper_margin = 7, .lower_margin = 5, .hsync_len = 3, .vsync_len = 1, .xres = 800, .yres = 480, }, .max_bpp = 32, .default_bpp = 24, }; static struct s3c_fb_platdata smdkv210_lcd0_pdata __initdata = { .win[0] = &smdkv210_fb_win0, .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB, .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC, .setup_gpio = s5pv210_fb_gpio_setup_24bpp, }; static struct platform_device *smdkv210_devices[] __initdata = { &s3c_device_adc, &s3c_device_cfcon, &s3c_device_fb, &s3c_device_hsmmc0, &s3c_device_hsmmc1, &s3c_device_hsmmc2, &s3c_device_hsmmc3, &s3c_device_i2c0, &s3c_device_i2c1, &s3c_device_i2c2, &s3c_device_rtc, &s3c_device_ts, &s3c_device_wdt, &s5p_device_fimc0, &s5p_device_fimc1, &s5p_device_fimc2, &s5p_device_fimc_md, &s5p_device_jpeg, &s5p_device_mfc, &s5p_device_mfc_l, &s5p_device_mfc_r, &s5pv210_device_ac97, &s5pv210_device_iis0, &s5pv210_device_spdif, &samsung_asoc_dma, &samsung_asoc_idma, &samsung_device_keypad, &smdkv210_dm9000, &smdkv210_lcd_lte480wv, }; static void __init smdkv210_dm9000_init(void) { unsigned int tmp; gpio_request(S5PV210_MP01(5), "nCS5"); s3c_gpio_cfgpin(S5PV210_MP01(5), S3C_GPIO_SFN(2)); gpio_free(S5PV210_MP01(5)); tmp = (5 << S5P_SROM_BCX__TACC__SHIFT); __raw_writel(tmp, S5P_SROM_BC5); tmp = __raw_readl(S5P_SROM_BW); tmp &= (S5P_SROM_BW__CS_MASK << S5P_SROM_BW__NCS5__SHIFT); tmp |= (1 << S5P_SROM_BW__NCS5__SHIFT); __raw_writel(tmp, S5P_SROM_BW); } static struct i2c_board_info smdkv210_i2c_devs0[] __initdata = { { I2C_BOARD_INFO("24c08", 0x50), }, /* Samsung S524AD0XD1 */ { I2C_BOARD_INFO("wm8580", 0x1b), }, }; static struct i2c_board_info smdkv210_i2c_devs1[] __initdata = { /* To Be Updated */ }; static struct i2c_board_info smdkv210_i2c_devs2[] __initdata = { /* To Be Updated */ }; /* LCD Backlight data */ static struct samsung_bl_gpio_info smdkv210_bl_gpio_info = { .no = S5PV210_GPD0(3), .func = S3C_GPIO_SFN(2), }; static struct platform_pwm_backlight_data smdkv210_bl_data = { .pwm_id = 3, .pwm_period_ns = 1000, }; static void __init smdkv210_map_io(void) { s5pv210_init_io(NULL, 0); s3c24xx_init_clocks(24000000); s3c24xx_init_uarts(smdkv210_uartcfgs, ARRAY_SIZE(smdkv210_uartcfgs)); s5p_set_timer_source(S5P_PWM2, S5P_PWM4); } static void __init smdkv210_reserve(void) { s5p_mfc_reserve_mem(0x43000000, 8 << 20, 0x51000000, 8 << 20); } static void __init smdkv210_machine_init(void) { s3c_pm_init(); smdkv210_dm9000_init(); samsung_keypad_set_platdata(&smdkv210_keypad_data); s3c24xx_ts_set_platdata(NULL); s3c_i2c0_set_platdata(NULL); s3c_i2c1_set_platdata(NULL); s3c_i2c2_set_platdata(NULL); i2c_register_board_info(0, smdkv210_i2c_devs0, ARRAY_SIZE(smdkv210_i2c_devs0)); i2c_register_board_info(1, smdkv210_i2c_devs1, ARRAY_SIZE(smdkv210_i2c_devs1)); i2c_register_board_info(2, smdkv210_i2c_devs2, ARRAY_SIZE(smdkv210_i2c_devs2)); s3c_ide_set_platdata(&smdkv210_ide_pdata); s3c_fb_set_platdata(&smdkv210_lcd0_pdata); samsung_bl_set(&smdkv210_bl_gpio_info, &smdkv210_bl_data); platform_add_devices(smdkv210_devices, ARRAY_SIZE(smdkv210_devices)); } MACHINE_START(SMDKV210, "SMDKV210") /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */ .atag_offset = 0x100, .init_irq = s5pv210_init_irq, .handle_irq = vic_handle_irq, .map_io = smdkv210_map_io, .init_machine = smdkv210_machine_init, .timer = &s5p_timer, .restart = s5pv210_restart, .reserve = &smdkv210_reserve, MACHINE_END
gpl-2.0
kprkpr/kernel-e400
crypto/serpent.c
4982
20267
/* * Cryptographic API. * * Serpent Cipher Algorithm. * * Copyright (C) 2002 Dag Arne Osvik <osvik@ii.uib.no> * 2003 Herbert Valerio Riedel <hvr@gnu.org> * * Added tnepres support: Ruben Jesus Garcia Hernandez <ruben@ugr.es>, 18.10.2004 * Based on code by hvr * * 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. */ #include <linux/init.h> #include <linux/module.h> #include <linux/errno.h> #include <asm/byteorder.h> #include <linux/crypto.h> #include <linux/types.h> /* Key is padded to the maximum of 256 bits before round key generation. * Any key length <= 256 bits (32 bytes) is allowed by the algorithm. */ #define SERPENT_MIN_KEY_SIZE 0 #define SERPENT_MAX_KEY_SIZE 32 #define SERPENT_EXPKEY_WORDS 132 #define SERPENT_BLOCK_SIZE 16 #define PHI 0x9e3779b9UL #define keyiter(a,b,c,d,i,j) \ b ^= d; b ^= c; b ^= a; b ^= PHI ^ i; b = rol32(b,11); k[j] = b; #define loadkeys(x0,x1,x2,x3,i) \ x0=k[i]; x1=k[i+1]; x2=k[i+2]; x3=k[i+3]; #define storekeys(x0,x1,x2,x3,i) \ k[i]=x0; k[i+1]=x1; k[i+2]=x2; k[i+3]=x3; #define K(x0,x1,x2,x3,i) \ x3 ^= k[4*(i)+3]; x2 ^= k[4*(i)+2]; \ x1 ^= k[4*(i)+1]; x0 ^= k[4*(i)+0]; #define LK(x0,x1,x2,x3,x4,i) \ x0=rol32(x0,13);\ x2=rol32(x2,3); x1 ^= x0; x4 = x0 << 3; \ x3 ^= x2; x1 ^= x2; \ x1=rol32(x1,1); x3 ^= x4; \ x3=rol32(x3,7); x4 = x1; \ x0 ^= x1; x4 <<= 7; x2 ^= x3; \ x0 ^= x3; x2 ^= x4; x3 ^= k[4*i+3]; \ x1 ^= k[4*i+1]; x0=rol32(x0,5); x2=rol32(x2,22);\ x0 ^= k[4*i+0]; x2 ^= k[4*i+2]; #define KL(x0,x1,x2,x3,x4,i) \ x0 ^= k[4*i+0]; x1 ^= k[4*i+1]; x2 ^= k[4*i+2]; \ x3 ^= k[4*i+3]; x0=ror32(x0,5); x2=ror32(x2,22);\ x4 = x1; x2 ^= x3; x0 ^= x3; \ x4 <<= 7; x0 ^= x1; x1=ror32(x1,1); \ x2 ^= x4; x3=ror32(x3,7); x4 = x0 << 3; \ x1 ^= x0; x3 ^= x4; x0=ror32(x0,13);\ x1 ^= x2; x3 ^= x2; x2=ror32(x2,3); #define S0(x0,x1,x2,x3,x4) \ x4 = x3; \ x3 |= x0; x0 ^= x4; x4 ^= x2; \ x4 =~ x4; x3 ^= x1; x1 &= x0; \ x1 ^= x4; x2 ^= x0; x0 ^= x3; \ x4 |= x0; x0 ^= x2; x2 &= x1; \ x3 ^= x2; x1 =~ x1; x2 ^= x4; \ x1 ^= x2; #define S1(x0,x1,x2,x3,x4) \ x4 = x1; \ x1 ^= x0; x0 ^= x3; x3 =~ x3; \ x4 &= x1; x0 |= x1; x3 ^= x2; \ x0 ^= x3; x1 ^= x3; x3 ^= x4; \ x1 |= x4; x4 ^= x2; x2 &= x0; \ x2 ^= x1; x1 |= x0; x0 =~ x0; \ x0 ^= x2; x4 ^= x1; #define S2(x0,x1,x2,x3,x4) \ x3 =~ x3; \ x1 ^= x0; x4 = x0; x0 &= x2; \ x0 ^= x3; x3 |= x4; x2 ^= x1; \ x3 ^= x1; x1 &= x0; x0 ^= x2; \ x2 &= x3; x3 |= x1; x0 =~ x0; \ x3 ^= x0; x4 ^= x0; x0 ^= x2; \ x1 |= x2; #define S3(x0,x1,x2,x3,x4) \ x4 = x1; \ x1 ^= x3; x3 |= x0; x4 &= x0; \ x0 ^= x2; x2 ^= x1; x1 &= x3; \ x2 ^= x3; x0 |= x4; x4 ^= x3; \ x1 ^= x0; x0 &= x3; x3 &= x4; \ x3 ^= x2; x4 |= x1; x2 &= x1; \ x4 ^= x3; x0 ^= x3; x3 ^= x2; #define S4(x0,x1,x2,x3,x4) \ x4 = x3; \ x3 &= x0; x0 ^= x4; \ x3 ^= x2; x2 |= x4; x0 ^= x1; \ x4 ^= x3; x2 |= x0; \ x2 ^= x1; x1 &= x0; \ x1 ^= x4; x4 &= x2; x2 ^= x3; \ x4 ^= x0; x3 |= x1; x1 =~ x1; \ x3 ^= x0; #define S5(x0,x1,x2,x3,x4) \ x4 = x1; x1 |= x0; \ x2 ^= x1; x3 =~ x3; x4 ^= x0; \ x0 ^= x2; x1 &= x4; x4 |= x3; \ x4 ^= x0; x0 &= x3; x1 ^= x3; \ x3 ^= x2; x0 ^= x1; x2 &= x4; \ x1 ^= x2; x2 &= x0; \ x3 ^= x2; #define S6(x0,x1,x2,x3,x4) \ x4 = x1; \ x3 ^= x0; x1 ^= x2; x2 ^= x0; \ x0 &= x3; x1 |= x3; x4 =~ x4; \ x0 ^= x1; x1 ^= x2; \ x3 ^= x4; x4 ^= x0; x2 &= x0; \ x4 ^= x1; x2 ^= x3; x3 &= x1; \ x3 ^= x0; x1 ^= x2; #define S7(x0,x1,x2,x3,x4) \ x1 =~ x1; \ x4 = x1; x0 =~ x0; x1 &= x2; \ x1 ^= x3; x3 |= x4; x4 ^= x2; \ x2 ^= x3; x3 ^= x0; x0 |= x1; \ x2 &= x0; x0 ^= x4; x4 ^= x3; \ x3 &= x0; x4 ^= x1; \ x2 ^= x4; x3 ^= x1; x4 |= x0; \ x4 ^= x1; #define SI0(x0,x1,x2,x3,x4) \ x4 = x3; x1 ^= x0; \ x3 |= x1; x4 ^= x1; x0 =~ x0; \ x2 ^= x3; x3 ^= x0; x0 &= x1; \ x0 ^= x2; x2 &= x3; x3 ^= x4; \ x2 ^= x3; x1 ^= x3; x3 &= x0; \ x1 ^= x0; x0 ^= x2; x4 ^= x3; #define SI1(x0,x1,x2,x3,x4) \ x1 ^= x3; x4 = x0; \ x0 ^= x2; x2 =~ x2; x4 |= x1; \ x4 ^= x3; x3 &= x1; x1 ^= x2; \ x2 &= x4; x4 ^= x1; x1 |= x3; \ x3 ^= x0; x2 ^= x0; x0 |= x4; \ x2 ^= x4; x1 ^= x0; \ x4 ^= x1; #define SI2(x0,x1,x2,x3,x4) \ x2 ^= x1; x4 = x3; x3 =~ x3; \ x3 |= x2; x2 ^= x4; x4 ^= x0; \ x3 ^= x1; x1 |= x2; x2 ^= x0; \ x1 ^= x4; x4 |= x3; x2 ^= x3; \ x4 ^= x2; x2 &= x1; \ x2 ^= x3; x3 ^= x4; x4 ^= x0; #define SI3(x0,x1,x2,x3,x4) \ x2 ^= x1; \ x4 = x1; x1 &= x2; \ x1 ^= x0; x0 |= x4; x4 ^= x3; \ x0 ^= x3; x3 |= x1; x1 ^= x2; \ x1 ^= x3; x0 ^= x2; x2 ^= x3; \ x3 &= x1; x1 ^= x0; x0 &= x2; \ x4 ^= x3; x3 ^= x0; x0 ^= x1; #define SI4(x0,x1,x2,x3,x4) \ x2 ^= x3; x4 = x0; x0 &= x1; \ x0 ^= x2; x2 |= x3; x4 =~ x4; \ x1 ^= x0; x0 ^= x2; x2 &= x4; \ x2 ^= x0; x0 |= x4; \ x0 ^= x3; x3 &= x2; \ x4 ^= x3; x3 ^= x1; x1 &= x0; \ x4 ^= x1; x0 ^= x3; #define SI5(x0,x1,x2,x3,x4) \ x4 = x1; x1 |= x2; \ x2 ^= x4; x1 ^= x3; x3 &= x4; \ x2 ^= x3; x3 |= x0; x0 =~ x0; \ x3 ^= x2; x2 |= x0; x4 ^= x1; \ x2 ^= x4; x4 &= x0; x0 ^= x1; \ x1 ^= x3; x0 &= x2; x2 ^= x3; \ x0 ^= x2; x2 ^= x4; x4 ^= x3; #define SI6(x0,x1,x2,x3,x4) \ x0 ^= x2; \ x4 = x0; x0 &= x3; x2 ^= x3; \ x0 ^= x2; x3 ^= x1; x2 |= x4; \ x2 ^= x3; x3 &= x0; x0 =~ x0; \ x3 ^= x1; x1 &= x2; x4 ^= x0; \ x3 ^= x4; x4 ^= x2; x0 ^= x1; \ x2 ^= x0; #define SI7(x0,x1,x2,x3,x4) \ x4 = x3; x3 &= x0; x0 ^= x2; \ x2 |= x4; x4 ^= x1; x0 =~ x0; \ x1 |= x3; x4 ^= x0; x0 &= x2; \ x0 ^= x1; x1 &= x2; x3 ^= x2; \ x4 ^= x3; x2 &= x3; x3 |= x0; \ x1 ^= x4; x3 ^= x4; x4 &= x0; \ x4 ^= x2; struct serpent_ctx { u32 expkey[SERPENT_EXPKEY_WORDS]; }; static int serpent_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { struct serpent_ctx *ctx = crypto_tfm_ctx(tfm); u32 *k = ctx->expkey; u8 *k8 = (u8 *)k; u32 r0,r1,r2,r3,r4; int i; /* Copy key, add padding */ for (i = 0; i < keylen; ++i) k8[i] = key[i]; if (i < SERPENT_MAX_KEY_SIZE) k8[i++] = 1; while (i < SERPENT_MAX_KEY_SIZE) k8[i++] = 0; /* Expand key using polynomial */ r0 = le32_to_cpu(k[3]); r1 = le32_to_cpu(k[4]); r2 = le32_to_cpu(k[5]); r3 = le32_to_cpu(k[6]); r4 = le32_to_cpu(k[7]); keyiter(le32_to_cpu(k[0]),r0,r4,r2,0,0); keyiter(le32_to_cpu(k[1]),r1,r0,r3,1,1); keyiter(le32_to_cpu(k[2]),r2,r1,r4,2,2); keyiter(le32_to_cpu(k[3]),r3,r2,r0,3,3); keyiter(le32_to_cpu(k[4]),r4,r3,r1,4,4); keyiter(le32_to_cpu(k[5]),r0,r4,r2,5,5); keyiter(le32_to_cpu(k[6]),r1,r0,r3,6,6); keyiter(le32_to_cpu(k[7]),r2,r1,r4,7,7); keyiter(k[ 0],r3,r2,r0, 8, 8); keyiter(k[ 1],r4,r3,r1, 9, 9); keyiter(k[ 2],r0,r4,r2, 10, 10); keyiter(k[ 3],r1,r0,r3, 11, 11); keyiter(k[ 4],r2,r1,r4, 12, 12); keyiter(k[ 5],r3,r2,r0, 13, 13); keyiter(k[ 6],r4,r3,r1, 14, 14); keyiter(k[ 7],r0,r4,r2, 15, 15); keyiter(k[ 8],r1,r0,r3, 16, 16); keyiter(k[ 9],r2,r1,r4, 17, 17); keyiter(k[ 10],r3,r2,r0, 18, 18); keyiter(k[ 11],r4,r3,r1, 19, 19); keyiter(k[ 12],r0,r4,r2, 20, 20); keyiter(k[ 13],r1,r0,r3, 21, 21); keyiter(k[ 14],r2,r1,r4, 22, 22); keyiter(k[ 15],r3,r2,r0, 23, 23); keyiter(k[ 16],r4,r3,r1, 24, 24); keyiter(k[ 17],r0,r4,r2, 25, 25); keyiter(k[ 18],r1,r0,r3, 26, 26); keyiter(k[ 19],r2,r1,r4, 27, 27); keyiter(k[ 20],r3,r2,r0, 28, 28); keyiter(k[ 21],r4,r3,r1, 29, 29); keyiter(k[ 22],r0,r4,r2, 30, 30); keyiter(k[ 23],r1,r0,r3, 31, 31); k += 50; keyiter(k[-26],r2,r1,r4, 32,-18); keyiter(k[-25],r3,r2,r0, 33,-17); keyiter(k[-24],r4,r3,r1, 34,-16); keyiter(k[-23],r0,r4,r2, 35,-15); keyiter(k[-22],r1,r0,r3, 36,-14); keyiter(k[-21],r2,r1,r4, 37,-13); keyiter(k[-20],r3,r2,r0, 38,-12); keyiter(k[-19],r4,r3,r1, 39,-11); keyiter(k[-18],r0,r4,r2, 40,-10); keyiter(k[-17],r1,r0,r3, 41, -9); keyiter(k[-16],r2,r1,r4, 42, -8); keyiter(k[-15],r3,r2,r0, 43, -7); keyiter(k[-14],r4,r3,r1, 44, -6); keyiter(k[-13],r0,r4,r2, 45, -5); keyiter(k[-12],r1,r0,r3, 46, -4); keyiter(k[-11],r2,r1,r4, 47, -3); keyiter(k[-10],r3,r2,r0, 48, -2); keyiter(k[ -9],r4,r3,r1, 49, -1); keyiter(k[ -8],r0,r4,r2, 50, 0); keyiter(k[ -7],r1,r0,r3, 51, 1); keyiter(k[ -6],r2,r1,r4, 52, 2); keyiter(k[ -5],r3,r2,r0, 53, 3); keyiter(k[ -4],r4,r3,r1, 54, 4); keyiter(k[ -3],r0,r4,r2, 55, 5); keyiter(k[ -2],r1,r0,r3, 56, 6); keyiter(k[ -1],r2,r1,r4, 57, 7); keyiter(k[ 0],r3,r2,r0, 58, 8); keyiter(k[ 1],r4,r3,r1, 59, 9); keyiter(k[ 2],r0,r4,r2, 60, 10); keyiter(k[ 3],r1,r0,r3, 61, 11); keyiter(k[ 4],r2,r1,r4, 62, 12); keyiter(k[ 5],r3,r2,r0, 63, 13); keyiter(k[ 6],r4,r3,r1, 64, 14); keyiter(k[ 7],r0,r4,r2, 65, 15); keyiter(k[ 8],r1,r0,r3, 66, 16); keyiter(k[ 9],r2,r1,r4, 67, 17); keyiter(k[ 10],r3,r2,r0, 68, 18); keyiter(k[ 11],r4,r3,r1, 69, 19); keyiter(k[ 12],r0,r4,r2, 70, 20); keyiter(k[ 13],r1,r0,r3, 71, 21); keyiter(k[ 14],r2,r1,r4, 72, 22); keyiter(k[ 15],r3,r2,r0, 73, 23); keyiter(k[ 16],r4,r3,r1, 74, 24); keyiter(k[ 17],r0,r4,r2, 75, 25); keyiter(k[ 18],r1,r0,r3, 76, 26); keyiter(k[ 19],r2,r1,r4, 77, 27); keyiter(k[ 20],r3,r2,r0, 78, 28); keyiter(k[ 21],r4,r3,r1, 79, 29); keyiter(k[ 22],r0,r4,r2, 80, 30); keyiter(k[ 23],r1,r0,r3, 81, 31); k += 50; keyiter(k[-26],r2,r1,r4, 82,-18); keyiter(k[-25],r3,r2,r0, 83,-17); keyiter(k[-24],r4,r3,r1, 84,-16); keyiter(k[-23],r0,r4,r2, 85,-15); keyiter(k[-22],r1,r0,r3, 86,-14); keyiter(k[-21],r2,r1,r4, 87,-13); keyiter(k[-20],r3,r2,r0, 88,-12); keyiter(k[-19],r4,r3,r1, 89,-11); keyiter(k[-18],r0,r4,r2, 90,-10); keyiter(k[-17],r1,r0,r3, 91, -9); keyiter(k[-16],r2,r1,r4, 92, -8); keyiter(k[-15],r3,r2,r0, 93, -7); keyiter(k[-14],r4,r3,r1, 94, -6); keyiter(k[-13],r0,r4,r2, 95, -5); keyiter(k[-12],r1,r0,r3, 96, -4); keyiter(k[-11],r2,r1,r4, 97, -3); keyiter(k[-10],r3,r2,r0, 98, -2); keyiter(k[ -9],r4,r3,r1, 99, -1); keyiter(k[ -8],r0,r4,r2,100, 0); keyiter(k[ -7],r1,r0,r3,101, 1); keyiter(k[ -6],r2,r1,r4,102, 2); keyiter(k[ -5],r3,r2,r0,103, 3); keyiter(k[ -4],r4,r3,r1,104, 4); keyiter(k[ -3],r0,r4,r2,105, 5); keyiter(k[ -2],r1,r0,r3,106, 6); keyiter(k[ -1],r2,r1,r4,107, 7); keyiter(k[ 0],r3,r2,r0,108, 8); keyiter(k[ 1],r4,r3,r1,109, 9); keyiter(k[ 2],r0,r4,r2,110, 10); keyiter(k[ 3],r1,r0,r3,111, 11); keyiter(k[ 4],r2,r1,r4,112, 12); keyiter(k[ 5],r3,r2,r0,113, 13); keyiter(k[ 6],r4,r3,r1,114, 14); keyiter(k[ 7],r0,r4,r2,115, 15); keyiter(k[ 8],r1,r0,r3,116, 16); keyiter(k[ 9],r2,r1,r4,117, 17); keyiter(k[ 10],r3,r2,r0,118, 18); keyiter(k[ 11],r4,r3,r1,119, 19); keyiter(k[ 12],r0,r4,r2,120, 20); keyiter(k[ 13],r1,r0,r3,121, 21); keyiter(k[ 14],r2,r1,r4,122, 22); keyiter(k[ 15],r3,r2,r0,123, 23); keyiter(k[ 16],r4,r3,r1,124, 24); keyiter(k[ 17],r0,r4,r2,125, 25); keyiter(k[ 18],r1,r0,r3,126, 26); keyiter(k[ 19],r2,r1,r4,127, 27); keyiter(k[ 20],r3,r2,r0,128, 28); keyiter(k[ 21],r4,r3,r1,129, 29); keyiter(k[ 22],r0,r4,r2,130, 30); keyiter(k[ 23],r1,r0,r3,131, 31); /* Apply S-boxes */ S3(r3,r4,r0,r1,r2); storekeys(r1,r2,r4,r3, 28); loadkeys(r1,r2,r4,r3, 24); S4(r1,r2,r4,r3,r0); storekeys(r2,r4,r3,r0, 24); loadkeys(r2,r4,r3,r0, 20); S5(r2,r4,r3,r0,r1); storekeys(r1,r2,r4,r0, 20); loadkeys(r1,r2,r4,r0, 16); S6(r1,r2,r4,r0,r3); storekeys(r4,r3,r2,r0, 16); loadkeys(r4,r3,r2,r0, 12); S7(r4,r3,r2,r0,r1); storekeys(r1,r2,r0,r4, 12); loadkeys(r1,r2,r0,r4, 8); S0(r1,r2,r0,r4,r3); storekeys(r0,r2,r4,r1, 8); loadkeys(r0,r2,r4,r1, 4); S1(r0,r2,r4,r1,r3); storekeys(r3,r4,r1,r0, 4); loadkeys(r3,r4,r1,r0, 0); S2(r3,r4,r1,r0,r2); storekeys(r2,r4,r3,r0, 0); loadkeys(r2,r4,r3,r0, -4); S3(r2,r4,r3,r0,r1); storekeys(r0,r1,r4,r2, -4); loadkeys(r0,r1,r4,r2, -8); S4(r0,r1,r4,r2,r3); storekeys(r1,r4,r2,r3, -8); loadkeys(r1,r4,r2,r3,-12); S5(r1,r4,r2,r3,r0); storekeys(r0,r1,r4,r3,-12); loadkeys(r0,r1,r4,r3,-16); S6(r0,r1,r4,r3,r2); storekeys(r4,r2,r1,r3,-16); loadkeys(r4,r2,r1,r3,-20); S7(r4,r2,r1,r3,r0); storekeys(r0,r1,r3,r4,-20); loadkeys(r0,r1,r3,r4,-24); S0(r0,r1,r3,r4,r2); storekeys(r3,r1,r4,r0,-24); loadkeys(r3,r1,r4,r0,-28); k -= 50; S1(r3,r1,r4,r0,r2); storekeys(r2,r4,r0,r3, 22); loadkeys(r2,r4,r0,r3, 18); S2(r2,r4,r0,r3,r1); storekeys(r1,r4,r2,r3, 18); loadkeys(r1,r4,r2,r3, 14); S3(r1,r4,r2,r3,r0); storekeys(r3,r0,r4,r1, 14); loadkeys(r3,r0,r4,r1, 10); S4(r3,r0,r4,r1,r2); storekeys(r0,r4,r1,r2, 10); loadkeys(r0,r4,r1,r2, 6); S5(r0,r4,r1,r2,r3); storekeys(r3,r0,r4,r2, 6); loadkeys(r3,r0,r4,r2, 2); S6(r3,r0,r4,r2,r1); storekeys(r4,r1,r0,r2, 2); loadkeys(r4,r1,r0,r2, -2); S7(r4,r1,r0,r2,r3); storekeys(r3,r0,r2,r4, -2); loadkeys(r3,r0,r2,r4, -6); S0(r3,r0,r2,r4,r1); storekeys(r2,r0,r4,r3, -6); loadkeys(r2,r0,r4,r3,-10); S1(r2,r0,r4,r3,r1); storekeys(r1,r4,r3,r2,-10); loadkeys(r1,r4,r3,r2,-14); S2(r1,r4,r3,r2,r0); storekeys(r0,r4,r1,r2,-14); loadkeys(r0,r4,r1,r2,-18); S3(r0,r4,r1,r2,r3); storekeys(r2,r3,r4,r0,-18); loadkeys(r2,r3,r4,r0,-22); k -= 50; S4(r2,r3,r4,r0,r1); storekeys(r3,r4,r0,r1, 28); loadkeys(r3,r4,r0,r1, 24); S5(r3,r4,r0,r1,r2); storekeys(r2,r3,r4,r1, 24); loadkeys(r2,r3,r4,r1, 20); S6(r2,r3,r4,r1,r0); storekeys(r4,r0,r3,r1, 20); loadkeys(r4,r0,r3,r1, 16); S7(r4,r0,r3,r1,r2); storekeys(r2,r3,r1,r4, 16); loadkeys(r2,r3,r1,r4, 12); S0(r2,r3,r1,r4,r0); storekeys(r1,r3,r4,r2, 12); loadkeys(r1,r3,r4,r2, 8); S1(r1,r3,r4,r2,r0); storekeys(r0,r4,r2,r1, 8); loadkeys(r0,r4,r2,r1, 4); S2(r0,r4,r2,r1,r3); storekeys(r3,r4,r0,r1, 4); loadkeys(r3,r4,r0,r1, 0); S3(r3,r4,r0,r1,r2); storekeys(r1,r2,r4,r3, 0); return 0; } static void serpent_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) { struct serpent_ctx *ctx = crypto_tfm_ctx(tfm); const u32 *k = ctx->expkey; const __le32 *s = (const __le32 *)src; __le32 *d = (__le32 *)dst; u32 r0, r1, r2, r3, r4; /* * Note: The conversions between u8* and u32* might cause trouble * on architectures with stricter alignment rules than x86 */ r0 = le32_to_cpu(s[0]); r1 = le32_to_cpu(s[1]); r2 = le32_to_cpu(s[2]); r3 = le32_to_cpu(s[3]); K(r0,r1,r2,r3,0); S0(r0,r1,r2,r3,r4); LK(r2,r1,r3,r0,r4,1); S1(r2,r1,r3,r0,r4); LK(r4,r3,r0,r2,r1,2); S2(r4,r3,r0,r2,r1); LK(r1,r3,r4,r2,r0,3); S3(r1,r3,r4,r2,r0); LK(r2,r0,r3,r1,r4,4); S4(r2,r0,r3,r1,r4); LK(r0,r3,r1,r4,r2,5); S5(r0,r3,r1,r4,r2); LK(r2,r0,r3,r4,r1,6); S6(r2,r0,r3,r4,r1); LK(r3,r1,r0,r4,r2,7); S7(r3,r1,r0,r4,r2); LK(r2,r0,r4,r3,r1,8); S0(r2,r0,r4,r3,r1); LK(r4,r0,r3,r2,r1,9); S1(r4,r0,r3,r2,r1); LK(r1,r3,r2,r4,r0,10); S2(r1,r3,r2,r4,r0); LK(r0,r3,r1,r4,r2,11); S3(r0,r3,r1,r4,r2); LK(r4,r2,r3,r0,r1,12); S4(r4,r2,r3,r0,r1); LK(r2,r3,r0,r1,r4,13); S5(r2,r3,r0,r1,r4); LK(r4,r2,r3,r1,r0,14); S6(r4,r2,r3,r1,r0); LK(r3,r0,r2,r1,r4,15); S7(r3,r0,r2,r1,r4); LK(r4,r2,r1,r3,r0,16); S0(r4,r2,r1,r3,r0); LK(r1,r2,r3,r4,r0,17); S1(r1,r2,r3,r4,r0); LK(r0,r3,r4,r1,r2,18); S2(r0,r3,r4,r1,r2); LK(r2,r3,r0,r1,r4,19); S3(r2,r3,r0,r1,r4); LK(r1,r4,r3,r2,r0,20); S4(r1,r4,r3,r2,r0); LK(r4,r3,r2,r0,r1,21); S5(r4,r3,r2,r0,r1); LK(r1,r4,r3,r0,r2,22); S6(r1,r4,r3,r0,r2); LK(r3,r2,r4,r0,r1,23); S7(r3,r2,r4,r0,r1); LK(r1,r4,r0,r3,r2,24); S0(r1,r4,r0,r3,r2); LK(r0,r4,r3,r1,r2,25); S1(r0,r4,r3,r1,r2); LK(r2,r3,r1,r0,r4,26); S2(r2,r3,r1,r0,r4); LK(r4,r3,r2,r0,r1,27); S3(r4,r3,r2,r0,r1); LK(r0,r1,r3,r4,r2,28); S4(r0,r1,r3,r4,r2); LK(r1,r3,r4,r2,r0,29); S5(r1,r3,r4,r2,r0); LK(r0,r1,r3,r2,r4,30); S6(r0,r1,r3,r2,r4); LK(r3,r4,r1,r2,r0,31); S7(r3,r4,r1,r2,r0); K(r0,r1,r2,r3,32); d[0] = cpu_to_le32(r0); d[1] = cpu_to_le32(r1); d[2] = cpu_to_le32(r2); d[3] = cpu_to_le32(r3); } static void serpent_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) { struct serpent_ctx *ctx = crypto_tfm_ctx(tfm); const u32 *k = ((struct serpent_ctx *)ctx)->expkey; const __le32 *s = (const __le32 *)src; __le32 *d = (__le32 *)dst; u32 r0, r1, r2, r3, r4; r0 = le32_to_cpu(s[0]); r1 = le32_to_cpu(s[1]); r2 = le32_to_cpu(s[2]); r3 = le32_to_cpu(s[3]); K(r0,r1,r2,r3,32); SI7(r0,r1,r2,r3,r4); KL(r1,r3,r0,r4,r2,31); SI6(r1,r3,r0,r4,r2); KL(r0,r2,r4,r1,r3,30); SI5(r0,r2,r4,r1,r3); KL(r2,r3,r0,r4,r1,29); SI4(r2,r3,r0,r4,r1); KL(r2,r0,r1,r4,r3,28); SI3(r2,r0,r1,r4,r3); KL(r1,r2,r3,r4,r0,27); SI2(r1,r2,r3,r4,r0); KL(r2,r0,r4,r3,r1,26); SI1(r2,r0,r4,r3,r1); KL(r1,r0,r4,r3,r2,25); SI0(r1,r0,r4,r3,r2); KL(r4,r2,r0,r1,r3,24); SI7(r4,r2,r0,r1,r3); KL(r2,r1,r4,r3,r0,23); SI6(r2,r1,r4,r3,r0); KL(r4,r0,r3,r2,r1,22); SI5(r4,r0,r3,r2,r1); KL(r0,r1,r4,r3,r2,21); SI4(r0,r1,r4,r3,r2); KL(r0,r4,r2,r3,r1,20); SI3(r0,r4,r2,r3,r1); KL(r2,r0,r1,r3,r4,19); SI2(r2,r0,r1,r3,r4); KL(r0,r4,r3,r1,r2,18); SI1(r0,r4,r3,r1,r2); KL(r2,r4,r3,r1,r0,17); SI0(r2,r4,r3,r1,r0); KL(r3,r0,r4,r2,r1,16); SI7(r3,r0,r4,r2,r1); KL(r0,r2,r3,r1,r4,15); SI6(r0,r2,r3,r1,r4); KL(r3,r4,r1,r0,r2,14); SI5(r3,r4,r1,r0,r2); KL(r4,r2,r3,r1,r0,13); SI4(r4,r2,r3,r1,r0); KL(r4,r3,r0,r1,r2,12); SI3(r4,r3,r0,r1,r2); KL(r0,r4,r2,r1,r3,11); SI2(r0,r4,r2,r1,r3); KL(r4,r3,r1,r2,r0,10); SI1(r4,r3,r1,r2,r0); KL(r0,r3,r1,r2,r4,9); SI0(r0,r3,r1,r2,r4); KL(r1,r4,r3,r0,r2,8); SI7(r1,r4,r3,r0,r2); KL(r4,r0,r1,r2,r3,7); SI6(r4,r0,r1,r2,r3); KL(r1,r3,r2,r4,r0,6); SI5(r1,r3,r2,r4,r0); KL(r3,r0,r1,r2,r4,5); SI4(r3,r0,r1,r2,r4); KL(r3,r1,r4,r2,r0,4); SI3(r3,r1,r4,r2,r0); KL(r4,r3,r0,r2,r1,3); SI2(r4,r3,r0,r2,r1); KL(r3,r1,r2,r0,r4,2); SI1(r3,r1,r2,r0,r4); KL(r4,r1,r2,r0,r3,1); SI0(r4,r1,r2,r0,r3); K(r2,r3,r1,r4,0); d[0] = cpu_to_le32(r2); d[1] = cpu_to_le32(r3); d[2] = cpu_to_le32(r1); d[3] = cpu_to_le32(r4); } static struct crypto_alg serpent_alg = { .cra_name = "serpent", .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = SERPENT_BLOCK_SIZE, .cra_ctxsize = sizeof(struct serpent_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(serpent_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = SERPENT_MIN_KEY_SIZE, .cia_max_keysize = SERPENT_MAX_KEY_SIZE, .cia_setkey = serpent_setkey, .cia_encrypt = serpent_encrypt, .cia_decrypt = serpent_decrypt } } }; static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { u8 rev_key[SERPENT_MAX_KEY_SIZE]; int i; for (i = 0; i < keylen; ++i) rev_key[keylen - i - 1] = key[i]; return serpent_setkey(tfm, rev_key, keylen); } static void tnepres_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) { const u32 * const s = (const u32 * const)src; u32 * const d = (u32 * const)dst; u32 rs[4], rd[4]; rs[0] = swab32(s[3]); rs[1] = swab32(s[2]); rs[2] = swab32(s[1]); rs[3] = swab32(s[0]); serpent_encrypt(tfm, (u8 *)rd, (u8 *)rs); d[0] = swab32(rd[3]); d[1] = swab32(rd[2]); d[2] = swab32(rd[1]); d[3] = swab32(rd[0]); } static void tnepres_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) { const u32 * const s = (const u32 * const)src; u32 * const d = (u32 * const)dst; u32 rs[4], rd[4]; rs[0] = swab32(s[3]); rs[1] = swab32(s[2]); rs[2] = swab32(s[1]); rs[3] = swab32(s[0]); serpent_decrypt(tfm, (u8 *)rd, (u8 *)rs); d[0] = swab32(rd[3]); d[1] = swab32(rd[2]); d[2] = swab32(rd[1]); d[3] = swab32(rd[0]); } static struct crypto_alg tnepres_alg = { .cra_name = "tnepres", .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = SERPENT_BLOCK_SIZE, .cra_ctxsize = sizeof(struct serpent_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(serpent_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = SERPENT_MIN_KEY_SIZE, .cia_max_keysize = SERPENT_MAX_KEY_SIZE, .cia_setkey = tnepres_setkey, .cia_encrypt = tnepres_encrypt, .cia_decrypt = tnepres_decrypt } } }; static int __init serpent_mod_init(void) { int ret = crypto_register_alg(&serpent_alg); if (ret) return ret; ret = crypto_register_alg(&tnepres_alg); if (ret) crypto_unregister_alg(&serpent_alg); return ret; } static void __exit serpent_mod_fini(void) { crypto_unregister_alg(&tnepres_alg); crypto_unregister_alg(&serpent_alg); } module_init(serpent_mod_init); module_exit(serpent_mod_fini); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Serpent and tnepres (kerneli compatible serpent reversed) Cipher Algorithm"); MODULE_AUTHOR("Dag Arne Osvik <osvik@ii.uib.no>"); MODULE_ALIAS("tnepres");
gpl-2.0
mordiford/saki-op2-kernel
arch/powerpc/sysdev/ppc4xx_cpm.c
7798
7793
/* * PowerPC 4xx Clock and Power Management * * Copyright (C) 2010, Applied Micro Circuits Corporation * Victor Gallardo (vgallardo@apm.com) * * Based on arch/powerpc/platforms/44x/idle.c: * Jerone Young <jyoung5@us.ibm.com> * Copyright 2008 IBM Corp. * * Based on arch/powerpc/sysdev/fsl_pmc.c: * Anton Vorontsov <avorontsov@ru.mvista.com> * Copyright 2009 MontaVista Software, Inc. * * See file CREDITS for list of people who contributed to this * project. * * 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/of_platform.h> #include <linux/sysfs.h> #include <linux/cpu.h> #include <linux/suspend.h> #include <asm/dcr.h> #include <asm/dcr-native.h> #include <asm/machdep.h> #define CPM_ER 0 #define CPM_FR 1 #define CPM_SR 2 #define CPM_IDLE_WAIT 0 #define CPM_IDLE_DOZE 1 struct cpm { dcr_host_t dcr_host; unsigned int dcr_offset[3]; unsigned int powersave_off; unsigned int unused; unsigned int idle_doze; unsigned int standby; unsigned int suspend; }; static struct cpm cpm; struct cpm_idle_mode { unsigned int enabled; const char *name; }; static struct cpm_idle_mode idle_mode[] = { [CPM_IDLE_WAIT] = { 1, "wait" }, /* default */ [CPM_IDLE_DOZE] = { 0, "doze" }, }; static unsigned int cpm_set(unsigned int cpm_reg, unsigned int mask) { unsigned int value; /* CPM controller supports 3 different types of sleep interface * known as class 1, 2 and 3. For class 1 units, they are * unconditionally put to sleep when the corresponding CPM bit is * set. For class 2 and 3 units this is not case; if they can be * put to to sleep, they will. Here we do not verify, we just * set them and expect them to eventually go off when they can. */ value = dcr_read(cpm.dcr_host, cpm.dcr_offset[cpm_reg]); dcr_write(cpm.dcr_host, cpm.dcr_offset[cpm_reg], value | mask); /* return old state, to restore later if needed */ return value; } static void cpm_idle_wait(void) { unsigned long msr_save; /* save off initial state */ msr_save = mfmsr(); /* sync required when CPM0_ER[CPU] is set */ mb(); /* set wait state MSR */ mtmsr(msr_save|MSR_WE|MSR_EE|MSR_CE|MSR_DE); isync(); /* return to initial state */ mtmsr(msr_save); isync(); } static void cpm_idle_sleep(unsigned int mask) { unsigned int er_save; /* update CPM_ER state */ er_save = cpm_set(CPM_ER, mask); /* go to wait state so that CPM0_ER[CPU] can take effect */ cpm_idle_wait(); /* restore CPM_ER state */ dcr_write(cpm.dcr_host, cpm.dcr_offset[CPM_ER], er_save); } static void cpm_idle_doze(void) { cpm_idle_sleep(cpm.idle_doze); } static void cpm_idle_config(int mode) { int i; if (idle_mode[mode].enabled) return; for (i = 0; i < ARRAY_SIZE(idle_mode); i++) idle_mode[i].enabled = 0; idle_mode[mode].enabled = 1; } static ssize_t cpm_idle_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { char *s = buf; int i; for (i = 0; i < ARRAY_SIZE(idle_mode); i++) { if (idle_mode[i].enabled) s += sprintf(s, "[%s] ", idle_mode[i].name); else s += sprintf(s, "%s ", idle_mode[i].name); } *(s-1) = '\n'; /* convert the last space to a newline */ return s - buf; } static ssize_t cpm_idle_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { int i; char *p; int len; p = memchr(buf, '\n', n); len = p ? p - buf : n; for (i = 0; i < ARRAY_SIZE(idle_mode); i++) { if (strncmp(buf, idle_mode[i].name, len) == 0) { cpm_idle_config(i); return n; } } return -EINVAL; } static struct kobj_attribute cpm_idle_attr = __ATTR(idle, 0644, cpm_idle_show, cpm_idle_store); static void cpm_idle_config_sysfs(void) { struct device *dev; unsigned long ret; dev = get_cpu_device(0); ret = sysfs_create_file(&dev->kobj, &cpm_idle_attr.attr); if (ret) printk(KERN_WARNING "cpm: failed to create idle sysfs entry\n"); } static void cpm_idle(void) { if (idle_mode[CPM_IDLE_DOZE].enabled) cpm_idle_doze(); else cpm_idle_wait(); } static int cpm_suspend_valid(suspend_state_t state) { switch (state) { case PM_SUSPEND_STANDBY: return !!cpm.standby; case PM_SUSPEND_MEM: return !!cpm.suspend; default: return 0; } } static void cpm_suspend_standby(unsigned int mask) { unsigned long tcr_save; /* disable decrement interrupt */ tcr_save = mfspr(SPRN_TCR); mtspr(SPRN_TCR, tcr_save & ~TCR_DIE); /* go to sleep state */ cpm_idle_sleep(mask); /* restore decrement interrupt */ mtspr(SPRN_TCR, tcr_save); } static int cpm_suspend_enter(suspend_state_t state) { switch (state) { case PM_SUSPEND_STANDBY: cpm_suspend_standby(cpm.standby); break; case PM_SUSPEND_MEM: cpm_suspend_standby(cpm.suspend); break; } return 0; } static struct platform_suspend_ops cpm_suspend_ops = { .valid = cpm_suspend_valid, .enter = cpm_suspend_enter, }; static int cpm_get_uint_property(struct device_node *np, const char *name) { int len; const unsigned int *prop = of_get_property(np, name, &len); if (prop == NULL || len < sizeof(u32)) return 0; return *prop; } static int __init cpm_init(void) { struct device_node *np; int dcr_base, dcr_len; int ret = 0; if (!cpm.powersave_off) { cpm_idle_config(CPM_IDLE_WAIT); ppc_md.power_save = &cpm_idle; } np = of_find_compatible_node(NULL, NULL, "ibm,cpm"); if (!np) { ret = -EINVAL; goto out; } dcr_base = dcr_resource_start(np, 0); dcr_len = dcr_resource_len(np, 0); if (dcr_base == 0 || dcr_len == 0) { printk(KERN_ERR "cpm: could not parse dcr property for %s\n", np->full_name); ret = -EINVAL; goto out; } cpm.dcr_host = dcr_map(np, dcr_base, dcr_len); if (!DCR_MAP_OK(cpm.dcr_host)) { printk(KERN_ERR "cpm: failed to map dcr property for %s\n", np->full_name); ret = -EINVAL; goto out; } /* All 4xx SoCs with a CPM controller have one of two * different order for the CPM registers. Some have the * CPM registers in the following order (ER,FR,SR). The * others have them in the following order (SR,ER,FR). */ if (cpm_get_uint_property(np, "er-offset") == 0) { cpm.dcr_offset[CPM_ER] = 0; cpm.dcr_offset[CPM_FR] = 1; cpm.dcr_offset[CPM_SR] = 2; } else { cpm.dcr_offset[CPM_ER] = 1; cpm.dcr_offset[CPM_FR] = 2; cpm.dcr_offset[CPM_SR] = 0; } /* Now let's see what IPs to turn off for the following modes */ cpm.unused = cpm_get_uint_property(np, "unused-units"); cpm.idle_doze = cpm_get_uint_property(np, "idle-doze"); cpm.standby = cpm_get_uint_property(np, "standby"); cpm.suspend = cpm_get_uint_property(np, "suspend"); /* If some IPs are unused let's turn them off now */ if (cpm.unused) { cpm_set(CPM_ER, cpm.unused); cpm_set(CPM_FR, cpm.unused); } /* Now let's export interfaces */ if (!cpm.powersave_off && cpm.idle_doze) cpm_idle_config_sysfs(); if (cpm.standby || cpm.suspend) suspend_set_ops(&cpm_suspend_ops); out: if (np) of_node_put(np); return ret; } late_initcall(cpm_init); static int __init cpm_powersave_off(char *arg) { cpm.powersave_off = 1; return 0; } __setup("powersave=off", cpm_powersave_off);
gpl-2.0
Racing1/android_kernel_htc_ruby_aosp
lib/lzo/lzo1x_compress.c
8310
4436
/* * LZO1X Compressor from MiniLZO * * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com> * * The full LZO package can be found at: * http://www.oberhumer.com/opensource/lzo/ * * Changed for kernel use by: * Nitin Gupta <nitingupta910@gmail.com> * Richard Purdie <rpurdie@openedhand.com> */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/lzo.h> #include <asm/unaligned.h> #include "lzodefs.h" static noinline size_t _lzo1x_1_do_compress(const unsigned char *in, size_t in_len, unsigned char *out, size_t *out_len, void *wrkmem) { const unsigned char * const in_end = in + in_len; const unsigned char * const ip_end = in + in_len - M2_MAX_LEN - 5; const unsigned char ** const dict = wrkmem; const unsigned char *ip = in, *ii = ip; const unsigned char *end, *m, *m_pos; size_t m_off, m_len, dindex; unsigned char *op = out; ip += 4; for (;;) { dindex = ((size_t)(0x21 * DX3(ip, 5, 5, 6)) >> 5) & D_MASK; m_pos = dict[dindex]; if (m_pos < in) goto literal; if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET)) goto literal; m_off = ip - m_pos; if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) goto try_match; dindex = (dindex & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f); m_pos = dict[dindex]; if (m_pos < in) goto literal; if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET)) goto literal; m_off = ip - m_pos; if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) goto try_match; goto literal; try_match: if (get_unaligned((const unsigned short *)m_pos) == get_unaligned((const unsigned short *)ip)) { if (likely(m_pos[2] == ip[2])) goto match; } literal: dict[dindex] = ip; ++ip; if (unlikely(ip >= ip_end)) break; continue; match: dict[dindex] = ip; if (ip != ii) { size_t t = ip - ii; if (t <= 3) { op[-2] |= t; } else if (t <= 18) { *op++ = (t - 3); } else { size_t tt = t - 18; *op++ = 0; while (tt > 255) { tt -= 255; *op++ = 0; } *op++ = tt; } do { *op++ = *ii++; } while (--t > 0); } ip += 3; if (m_pos[3] != *ip++ || m_pos[4] != *ip++ || m_pos[5] != *ip++ || m_pos[6] != *ip++ || m_pos[7] != *ip++ || m_pos[8] != *ip++) { --ip; m_len = ip - ii; if (m_off <= M2_MAX_OFFSET) { m_off -= 1; *op++ = (((m_len - 1) << 5) | ((m_off & 7) << 2)); *op++ = (m_off >> 3); } else if (m_off <= M3_MAX_OFFSET) { m_off -= 1; *op++ = (M3_MARKER | (m_len - 2)); goto m3_m4_offset; } else { m_off -= 0x4000; *op++ = (M4_MARKER | ((m_off & 0x4000) >> 11) | (m_len - 2)); goto m3_m4_offset; } } else { end = in_end; m = m_pos + M2_MAX_LEN + 1; while (ip < end && *m == *ip) { m++; ip++; } m_len = ip - ii; if (m_off <= M3_MAX_OFFSET) { m_off -= 1; if (m_len <= 33) { *op++ = (M3_MARKER | (m_len - 2)); } else { m_len -= 33; *op++ = M3_MARKER | 0; goto m3_m4_len; } } else { m_off -= 0x4000; if (m_len <= M4_MAX_LEN) { *op++ = (M4_MARKER | ((m_off & 0x4000) >> 11) | (m_len - 2)); } else { m_len -= M4_MAX_LEN; *op++ = (M4_MARKER | ((m_off & 0x4000) >> 11)); m3_m4_len: while (m_len > 255) { m_len -= 255; *op++ = 0; } *op++ = (m_len); } } m3_m4_offset: *op++ = ((m_off & 63) << 2); *op++ = (m_off >> 6); } ii = ip; if (unlikely(ip >= ip_end)) break; } *out_len = op - out; return in_end - ii; } int lzo1x_1_compress(const unsigned char *in, size_t in_len, unsigned char *out, size_t *out_len, void *wrkmem) { const unsigned char *ii; unsigned char *op = out; size_t t; if (unlikely(in_len <= M2_MAX_LEN + 5)) { t = in_len; } else { t = _lzo1x_1_do_compress(in, in_len, op, out_len, wrkmem); op += *out_len; } if (t > 0) { ii = in + in_len - t; if (op == out && t <= 238) { *op++ = (17 + t); } else if (t <= 3) { op[-2] |= t; } else if (t <= 18) { *op++ = (t - 3); } else { size_t tt = t - 18; *op++ = 0; while (tt > 255) { tt -= 255; *op++ = 0; } *op++ = tt; } do { *op++ = *ii++; } while (--t > 0); } *op++ = M4_MARKER | 1; *op++ = 0; *op++ = 0; *out_len = op - out; return LZO_E_OK; } EXPORT_SYMBOL_GPL(lzo1x_1_compress); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("LZO1X-1 Compressor");
gpl-2.0
hwlzc/3.4.50
drivers/dio/dio-driver.c
14198
3521
/* * DIO Driver Services * * Copyright (C) 2004 Jochen Friedrich * * Loosely based on drivers/pci/pci-driver.c and drivers/zorro/zorro-driver.c * * 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. */ #include <linux/init.h> #include <linux/module.h> #include <linux/dio.h> /** * dio_match_device - Tell if a DIO device structure has a matching DIO device id structure * @ids: array of DIO device id structures to search in * @d: the DIO device structure to match against * * Used by a driver to check whether a DIO device present in the * system is in its list of supported devices. Returns the matching * dio_device_id structure or %NULL if there is no match. */ const struct dio_device_id * dio_match_device(const struct dio_device_id *ids, const struct dio_dev *d) { while (ids->id) { if (ids->id == DIO_WILDCARD) return ids; if (DIO_NEEDSSECID(ids->id & 0xff)) { if (ids->id == d->id) return ids; } else { if ((ids->id & 0xff) == (d->id & 0xff)) return ids; } ids++; } return NULL; } static int dio_device_probe(struct device *dev) { int error = 0; struct dio_driver *drv = to_dio_driver(dev->driver); struct dio_dev *d = to_dio_dev(dev); if (!d->driver && drv->probe) { const struct dio_device_id *id; id = dio_match_device(drv->id_table, d); if (id) error = drv->probe(d, id); if (error >= 0) { d->driver = drv; error = 0; } } return error; } /** * dio_register_driver - register a new DIO driver * @drv: the driver structure to register * * Adds the driver structure to the list of registered drivers * Returns zero or a negative error value. */ int dio_register_driver(struct dio_driver *drv) { /* initialize common driver fields */ drv->driver.name = drv->name; drv->driver.bus = &dio_bus_type; /* register with core */ return driver_register(&drv->driver); } /** * dio_unregister_driver - unregister a DIO driver * @drv: the driver structure to unregister * * Deletes the driver structure from the list of registered DIO drivers, * gives it a chance to clean up by calling its remove() function for * each device it was responsible for, and marks those devices as * driverless. */ void dio_unregister_driver(struct dio_driver *drv) { driver_unregister(&drv->driver); } /** * dio_bus_match - Tell if a DIO device structure has a matching DIO device id structure * @dev: the DIO device structure to match against * @drv: the &device_driver that points to the array of DIO device id structures to search * * Used by a driver to check whether a DIO device present in the * system is in its list of supported devices. Returns the matching * dio_device_id structure or %NULL if there is no match. */ static int dio_bus_match(struct device *dev, struct device_driver *drv) { struct dio_dev *d = to_dio_dev(dev); struct dio_driver *dio_drv = to_dio_driver(drv); const struct dio_device_id *ids = dio_drv->id_table; if (!ids) return 0; return dio_match_device(ids, d) ? 1 : 0; } struct bus_type dio_bus_type = { .name = "dio", .match = dio_bus_match, .probe = dio_device_probe, }; static int __init dio_driver_init(void) { return bus_register(&dio_bus_type); } postcore_initcall(dio_driver_init); EXPORT_SYMBOL(dio_match_device); EXPORT_SYMBOL(dio_register_driver); EXPORT_SYMBOL(dio_unregister_driver); EXPORT_SYMBOL(dio_bus_type);
gpl-2.0
existz/htc-kernel-msm7x30
drivers/net/wireless/zd1211rw/zd_chip.c
887
37412
/* ZD1211 USB-WLAN driver for Linux * * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de> * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* This file implements all the hardware specific functions for the ZD1211 * and ZD1211B chips. Support for the ZD1211B was possible after Timothy * Legge sent me a ZD1211B device. Thank you Tim. -- Uli */ #include <linux/kernel.h> #include <linux/errno.h> #include <linux/slab.h> #include "zd_def.h" #include "zd_chip.h" #include "zd_mac.h" #include "zd_rf.h" void zd_chip_init(struct zd_chip *chip, struct ieee80211_hw *hw, struct usb_interface *intf) { memset(chip, 0, sizeof(*chip)); mutex_init(&chip->mutex); zd_usb_init(&chip->usb, hw, intf); zd_rf_init(&chip->rf); } void zd_chip_clear(struct zd_chip *chip) { ZD_ASSERT(!mutex_is_locked(&chip->mutex)); zd_usb_clear(&chip->usb); zd_rf_clear(&chip->rf); mutex_destroy(&chip->mutex); ZD_MEMCLEAR(chip, sizeof(*chip)); } static int scnprint_mac_oui(struct zd_chip *chip, char *buffer, size_t size) { u8 *addr = zd_mac_get_perm_addr(zd_chip_to_mac(chip)); return scnprintf(buffer, size, "%02x-%02x-%02x", addr[0], addr[1], addr[2]); } /* Prints an identifier line, which will support debugging. */ static int scnprint_id(struct zd_chip *chip, char *buffer, size_t size) { int i = 0; i = scnprintf(buffer, size, "zd1211%s chip ", zd_chip_is_zd1211b(chip) ? "b" : ""); i += zd_usb_scnprint_id(&chip->usb, buffer+i, size-i); i += scnprintf(buffer+i, size-i, " "); i += scnprint_mac_oui(chip, buffer+i, size-i); i += scnprintf(buffer+i, size-i, " "); i += zd_rf_scnprint_id(&chip->rf, buffer+i, size-i); i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c%c%c", chip->pa_type, chip->patch_cck_gain ? 'g' : '-', chip->patch_cr157 ? '7' : '-', chip->patch_6m_band_edge ? '6' : '-', chip->new_phy_layout ? 'N' : '-', chip->al2230s_bit ? 'S' : '-'); return i; } static void print_id(struct zd_chip *chip) { char buffer[80]; scnprint_id(chip, buffer, sizeof(buffer)); buffer[sizeof(buffer)-1] = 0; dev_info(zd_chip_dev(chip), "%s\n", buffer); } static zd_addr_t inc_addr(zd_addr_t addr) { u16 a = (u16)addr; /* Control registers use byte addressing, but everything else uses word * addressing. */ if ((a & 0xf000) == CR_START) a += 2; else a += 1; return (zd_addr_t)a; } /* Read a variable number of 32-bit values. Parameter count is not allowed to * exceed USB_MAX_IOREAD32_COUNT. */ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr, unsigned int count) { int r; int i; zd_addr_t *a16; u16 *v16; unsigned int count16; if (count > USB_MAX_IOREAD32_COUNT) return -EINVAL; /* Allocate a single memory block for values and addresses. */ count16 = 2*count; a16 = (zd_addr_t *) kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)), GFP_KERNEL); if (!a16) { dev_dbg_f(zd_chip_dev(chip), "error ENOMEM in allocation of a16\n"); r = -ENOMEM; goto out; } v16 = (u16 *)(a16 + count16); for (i = 0; i < count; i++) { int j = 2*i; /* We read the high word always first. */ a16[j] = inc_addr(addr[i]); a16[j+1] = addr[i]; } r = zd_ioread16v_locked(chip, v16, a16, count16); if (r) { dev_dbg_f(zd_chip_dev(chip), "error: zd_ioread16v_locked. Error number %d\n", r); goto out; } for (i = 0; i < count; i++) { int j = 2*i; values[i] = (v16[j] << 16) | v16[j+1]; } out: kfree((void *)a16); return r; } int _zd_iowrite32v_locked(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs, unsigned int count) { int i, j, r; struct zd_ioreq16 *ioreqs16; unsigned int count16; ZD_ASSERT(mutex_is_locked(&chip->mutex)); if (count == 0) return 0; if (count > USB_MAX_IOWRITE32_COUNT) return -EINVAL; /* Allocate a single memory block for values and addresses. */ count16 = 2*count; ioreqs16 = kmalloc(count16 * sizeof(struct zd_ioreq16), GFP_KERNEL); if (!ioreqs16) { r = -ENOMEM; dev_dbg_f(zd_chip_dev(chip), "error %d in ioreqs16 allocation\n", r); goto out; } for (i = 0; i < count; i++) { j = 2*i; /* We write the high word always first. */ ioreqs16[j].value = ioreqs[i].value >> 16; ioreqs16[j].addr = inc_addr(ioreqs[i].addr); ioreqs16[j+1].value = ioreqs[i].value; ioreqs16[j+1].addr = ioreqs[i].addr; } r = zd_usb_iowrite16v(&chip->usb, ioreqs16, count16); #ifdef DEBUG if (r) { dev_dbg_f(zd_chip_dev(chip), "error %d in zd_usb_write16v\n", r); } #endif /* DEBUG */ out: kfree(ioreqs16); return r; } int zd_iowrite16a_locked(struct zd_chip *chip, const struct zd_ioreq16 *ioreqs, unsigned int count) { int r; unsigned int i, j, t, max; ZD_ASSERT(mutex_is_locked(&chip->mutex)); for (i = 0; i < count; i += j + t) { t = 0; max = count-i; if (max > USB_MAX_IOWRITE16_COUNT) max = USB_MAX_IOWRITE16_COUNT; for (j = 0; j < max; j++) { if (!ioreqs[i+j].addr) { t = 1; break; } } r = zd_usb_iowrite16v(&chip->usb, &ioreqs[i], j); if (r) { dev_dbg_f(zd_chip_dev(chip), "error zd_usb_iowrite16v. Error number %d\n", r); return r; } } return 0; } /* Writes a variable number of 32 bit registers. The functions will split * that in several USB requests. A split can be forced by inserting an IO * request with an zero address field. */ int zd_iowrite32a_locked(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs, unsigned int count) { int r; unsigned int i, j, t, max; for (i = 0; i < count; i += j + t) { t = 0; max = count-i; if (max > USB_MAX_IOWRITE32_COUNT) max = USB_MAX_IOWRITE32_COUNT; for (j = 0; j < max; j++) { if (!ioreqs[i+j].addr) { t = 1; break; } } r = _zd_iowrite32v_locked(chip, &ioreqs[i], j); if (r) { dev_dbg_f(zd_chip_dev(chip), "error _zd_iowrite32v_locked." " Error number %d\n", r); return r; } } return 0; } int zd_ioread16(struct zd_chip *chip, zd_addr_t addr, u16 *value) { int r; mutex_lock(&chip->mutex); r = zd_ioread16_locked(chip, value, addr); mutex_unlock(&chip->mutex); return r; } int zd_ioread32(struct zd_chip *chip, zd_addr_t addr, u32 *value) { int r; mutex_lock(&chip->mutex); r = zd_ioread32_locked(chip, value, addr); mutex_unlock(&chip->mutex); return r; } int zd_iowrite16(struct zd_chip *chip, zd_addr_t addr, u16 value) { int r; mutex_lock(&chip->mutex); r = zd_iowrite16_locked(chip, value, addr); mutex_unlock(&chip->mutex); return r; } int zd_iowrite32(struct zd_chip *chip, zd_addr_t addr, u32 value) { int r; mutex_lock(&chip->mutex); r = zd_iowrite32_locked(chip, value, addr); mutex_unlock(&chip->mutex); return r; } int zd_ioread32v(struct zd_chip *chip, const zd_addr_t *addresses, u32 *values, unsigned int count) { int r; mutex_lock(&chip->mutex); r = zd_ioread32v_locked(chip, values, addresses, count); mutex_unlock(&chip->mutex); return r; } int zd_iowrite32a(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs, unsigned int count) { int r; mutex_lock(&chip->mutex); r = zd_iowrite32a_locked(chip, ioreqs, count); mutex_unlock(&chip->mutex); return r; } static int read_pod(struct zd_chip *chip, u8 *rf_type) { int r; u32 value; ZD_ASSERT(mutex_is_locked(&chip->mutex)); r = zd_ioread32_locked(chip, &value, E2P_POD); if (r) goto error; dev_dbg_f(zd_chip_dev(chip), "E2P_POD %#010x\n", value); /* FIXME: AL2230 handling (Bit 7 in POD) */ *rf_type = value & 0x0f; chip->pa_type = (value >> 16) & 0x0f; chip->patch_cck_gain = (value >> 8) & 0x1; chip->patch_cr157 = (value >> 13) & 0x1; chip->patch_6m_band_edge = (value >> 21) & 0x1; chip->new_phy_layout = (value >> 31) & 0x1; chip->al2230s_bit = (value >> 7) & 0x1; chip->link_led = ((value >> 4) & 1) ? LED1 : LED2; chip->supports_tx_led = 1; if (value & (1 << 24)) { /* LED scenario */ if (value & (1 << 29)) chip->supports_tx_led = 0; } dev_dbg_f(zd_chip_dev(chip), "RF %s %#01x PA type %#01x patch CCK %d patch CR157 %d " "patch 6M %d new PHY %d link LED%d tx led %d\n", zd_rf_name(*rf_type), *rf_type, chip->pa_type, chip->patch_cck_gain, chip->patch_cr157, chip->patch_6m_band_edge, chip->new_phy_layout, chip->link_led == LED1 ? 1 : 2, chip->supports_tx_led); return 0; error: *rf_type = 0; chip->pa_type = 0; chip->patch_cck_gain = 0; chip->patch_cr157 = 0; chip->patch_6m_band_edge = 0; chip->new_phy_layout = 0; return r; } /* MAC address: if custom mac addresses are to be used CR_MAC_ADDR_P1 and * CR_MAC_ADDR_P2 must be overwritten */ int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr) { int r; struct zd_ioreq32 reqs[2] = { [0] = { .addr = CR_MAC_ADDR_P1 }, [1] = { .addr = CR_MAC_ADDR_P2 }, }; if (mac_addr) { reqs[0].value = (mac_addr[3] << 24) | (mac_addr[2] << 16) | (mac_addr[1] << 8) | mac_addr[0]; reqs[1].value = (mac_addr[5] << 8) | mac_addr[4]; dev_dbg_f(zd_chip_dev(chip), "mac addr %pM\n", mac_addr); } else { dev_dbg_f(zd_chip_dev(chip), "set NULL mac\n"); } mutex_lock(&chip->mutex); r = zd_iowrite32a_locked(chip, reqs, ARRAY_SIZE(reqs)); mutex_unlock(&chip->mutex); return r; } int zd_read_regdomain(struct zd_chip *chip, u8 *regdomain) { int r; u32 value; mutex_lock(&chip->mutex); r = zd_ioread32_locked(chip, &value, E2P_SUBID); mutex_unlock(&chip->mutex); if (r) return r; *regdomain = value >> 16; dev_dbg_f(zd_chip_dev(chip), "regdomain: %#04x\n", *regdomain); return 0; } static int read_values(struct zd_chip *chip, u8 *values, size_t count, zd_addr_t e2p_addr, u32 guard) { int r; int i; u32 v; ZD_ASSERT(mutex_is_locked(&chip->mutex)); for (i = 0;;) { r = zd_ioread32_locked(chip, &v, (zd_addr_t)((u16)e2p_addr+i/2)); if (r) return r; v -= guard; if (i+4 < count) { values[i++] = v; values[i++] = v >> 8; values[i++] = v >> 16; values[i++] = v >> 24; continue; } for (;i < count; i++) values[i] = v >> (8*(i%3)); return 0; } } static int read_pwr_cal_values(struct zd_chip *chip) { return read_values(chip, chip->pwr_cal_values, E2P_CHANNEL_COUNT, E2P_PWR_CAL_VALUE1, 0); } static int read_pwr_int_values(struct zd_chip *chip) { return read_values(chip, chip->pwr_int_values, E2P_CHANNEL_COUNT, E2P_PWR_INT_VALUE1, E2P_PWR_INT_GUARD); } static int read_ofdm_cal_values(struct zd_chip *chip) { int r; int i; static const zd_addr_t addresses[] = { E2P_36M_CAL_VALUE1, E2P_48M_CAL_VALUE1, E2P_54M_CAL_VALUE1, }; for (i = 0; i < 3; i++) { r = read_values(chip, chip->ofdm_cal_values[i], E2P_CHANNEL_COUNT, addresses[i], 0); if (r) return r; } return 0; } static int read_cal_int_tables(struct zd_chip *chip) { int r; r = read_pwr_cal_values(chip); if (r) return r; r = read_pwr_int_values(chip); if (r) return r; r = read_ofdm_cal_values(chip); if (r) return r; return 0; } /* phy means physical registers */ int zd_chip_lock_phy_regs(struct zd_chip *chip) { int r; u32 tmp; ZD_ASSERT(mutex_is_locked(&chip->mutex)); r = zd_ioread32_locked(chip, &tmp, CR_REG1); if (r) { dev_err(zd_chip_dev(chip), "error ioread32(CR_REG1): %d\n", r); return r; } tmp &= ~UNLOCK_PHY_REGS; r = zd_iowrite32_locked(chip, tmp, CR_REG1); if (r) dev_err(zd_chip_dev(chip), "error iowrite32(CR_REG1): %d\n", r); return r; } int zd_chip_unlock_phy_regs(struct zd_chip *chip) { int r; u32 tmp; ZD_ASSERT(mutex_is_locked(&chip->mutex)); r = zd_ioread32_locked(chip, &tmp, CR_REG1); if (r) { dev_err(zd_chip_dev(chip), "error ioread32(CR_REG1): %d\n", r); return r; } tmp |= UNLOCK_PHY_REGS; r = zd_iowrite32_locked(chip, tmp, CR_REG1); if (r) dev_err(zd_chip_dev(chip), "error iowrite32(CR_REG1): %d\n", r); return r; } /* CR157 can be optionally patched by the EEPROM for original ZD1211 */ static int patch_cr157(struct zd_chip *chip) { int r; u16 value; if (!chip->patch_cr157) return 0; r = zd_ioread16_locked(chip, &value, E2P_PHY_REG); if (r) return r; dev_dbg_f(zd_chip_dev(chip), "patching value %x\n", value >> 8); return zd_iowrite32_locked(chip, value >> 8, CR157); } /* * 6M band edge can be optionally overwritten for certain RF's * Vendor driver says: for FCC regulation, enabled per HWFeature 6M band edge * bit (for AL2230, AL2230S) */ static int patch_6m_band_edge(struct zd_chip *chip, u8 channel) { ZD_ASSERT(mutex_is_locked(&chip->mutex)); if (!chip->patch_6m_band_edge) return 0; return zd_rf_patch_6m_band_edge(&chip->rf, channel); } /* Generic implementation of 6M band edge patching, used by most RFs via * zd_rf_generic_patch_6m() */ int zd_chip_generic_patch_6m_band(struct zd_chip *chip, int channel) { struct zd_ioreq16 ioreqs[] = { { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 }, { CR47, 0x1e }, }; /* FIXME: Channel 11 is not the edge for all regulatory domains. */ if (channel == 1 || channel == 11) ioreqs[0].value = 0x12; dev_dbg_f(zd_chip_dev(chip), "patching for channel %d\n", channel); return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); } static int zd1211_hw_reset_phy(struct zd_chip *chip) { static const struct zd_ioreq16 ioreqs[] = { { CR0, 0x0a }, { CR1, 0x06 }, { CR2, 0x26 }, { CR3, 0x38 }, { CR4, 0x80 }, { CR9, 0xa0 }, { CR10, 0x81 }, { CR11, 0x00 }, { CR12, 0x7f }, { CR13, 0x8c }, { CR14, 0x80 }, { CR15, 0x3d }, { CR16, 0x20 }, { CR17, 0x1e }, { CR18, 0x0a }, { CR19, 0x48 }, { CR20, 0x0c }, { CR21, 0x0c }, { CR22, 0x23 }, { CR23, 0x90 }, { CR24, 0x14 }, { CR25, 0x40 }, { CR26, 0x10 }, { CR27, 0x19 }, { CR28, 0x7f }, { CR29, 0x80 }, { CR30, 0x4b }, { CR31, 0x60 }, { CR32, 0x43 }, { CR33, 0x08 }, { CR34, 0x06 }, { CR35, 0x0a }, { CR36, 0x00 }, { CR37, 0x00 }, { CR38, 0x38 }, { CR39, 0x0c }, { CR40, 0x84 }, { CR41, 0x2a }, { CR42, 0x80 }, { CR43, 0x10 }, { CR44, 0x12 }, { CR46, 0xff }, { CR47, 0x1E }, { CR48, 0x26 }, { CR49, 0x5b }, { CR64, 0xd0 }, { CR65, 0x04 }, { CR66, 0x58 }, { CR67, 0xc9 }, { CR68, 0x88 }, { CR69, 0x41 }, { CR70, 0x23 }, { CR71, 0x10 }, { CR72, 0xff }, { CR73, 0x32 }, { CR74, 0x30 }, { CR75, 0x65 }, { CR76, 0x41 }, { CR77, 0x1b }, { CR78, 0x30 }, { CR79, 0x68 }, { CR80, 0x64 }, { CR81, 0x64 }, { CR82, 0x00 }, { CR83, 0x00 }, { CR84, 0x00 }, { CR85, 0x02 }, { CR86, 0x00 }, { CR87, 0x00 }, { CR88, 0xff }, { CR89, 0xfc }, { CR90, 0x00 }, { CR91, 0x00 }, { CR92, 0x00 }, { CR93, 0x08 }, { CR94, 0x00 }, { CR95, 0x00 }, { CR96, 0xff }, { CR97, 0xe7 }, { CR98, 0x00 }, { CR99, 0x00 }, { CR100, 0x00 }, { CR101, 0xae }, { CR102, 0x02 }, { CR103, 0x00 }, { CR104, 0x03 }, { CR105, 0x65 }, { CR106, 0x04 }, { CR107, 0x00 }, { CR108, 0x0a }, { CR109, 0xaa }, { CR110, 0xaa }, { CR111, 0x25 }, { CR112, 0x25 }, { CR113, 0x00 }, { CR119, 0x1e }, { CR125, 0x90 }, { CR126, 0x00 }, { CR127, 0x00 }, { }, { CR5, 0x00 }, { CR6, 0x00 }, { CR7, 0x00 }, { CR8, 0x00 }, { CR9, 0x20 }, { CR12, 0xf0 }, { CR20, 0x0e }, { CR21, 0x0e }, { CR27, 0x10 }, { CR44, 0x33 }, { CR47, 0x1E }, { CR83, 0x24 }, { CR84, 0x04 }, { CR85, 0x00 }, { CR86, 0x0C }, { CR87, 0x12 }, { CR88, 0x0C }, { CR89, 0x00 }, { CR90, 0x10 }, { CR91, 0x08 }, { CR93, 0x00 }, { CR94, 0x01 }, { CR95, 0x00 }, { CR96, 0x50 }, { CR97, 0x37 }, { CR98, 0x35 }, { CR101, 0x13 }, { CR102, 0x27 }, { CR103, 0x27 }, { CR104, 0x18 }, { CR105, 0x12 }, { CR109, 0x27 }, { CR110, 0x27 }, { CR111, 0x27 }, { CR112, 0x27 }, { CR113, 0x27 }, { CR114, 0x27 }, { CR115, 0x26 }, { CR116, 0x24 }, { CR117, 0xfc }, { CR118, 0xfa }, { CR120, 0x4f }, { CR125, 0xaa }, { CR127, 0x03 }, { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 }, { CR131, 0x0C }, { CR136, 0xdf }, { CR137, 0x40 }, { CR138, 0xa0 }, { CR139, 0xb0 }, { CR140, 0x99 }, { CR141, 0x82 }, { CR142, 0x54 }, { CR143, 0x1c }, { CR144, 0x6c }, { CR147, 0x07 }, { CR148, 0x4c }, { CR149, 0x50 }, { CR150, 0x0e }, { CR151, 0x18 }, { CR160, 0xfe }, { CR161, 0xee }, { CR162, 0xaa }, { CR163, 0xfa }, { CR164, 0xfa }, { CR165, 0xea }, { CR166, 0xbe }, { CR167, 0xbe }, { CR168, 0x6a }, { CR169, 0xba }, { CR170, 0xba }, { CR171, 0xba }, /* Note: CR204 must lead the CR203 */ { CR204, 0x7d }, { }, { CR203, 0x30 }, }; int r, t; dev_dbg_f(zd_chip_dev(chip), "\n"); r = zd_chip_lock_phy_regs(chip); if (r) goto out; r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); if (r) goto unlock; r = patch_cr157(chip); unlock: t = zd_chip_unlock_phy_regs(chip); if (t && !r) r = t; out: return r; } static int zd1211b_hw_reset_phy(struct zd_chip *chip) { static const struct zd_ioreq16 ioreqs[] = { { CR0, 0x14 }, { CR1, 0x06 }, { CR2, 0x26 }, { CR3, 0x38 }, { CR4, 0x80 }, { CR9, 0xe0 }, { CR10, 0x81 }, /* power control { { CR11, 1 << 6 }, */ { CR11, 0x00 }, { CR12, 0xf0 }, { CR13, 0x8c }, { CR14, 0x80 }, { CR15, 0x3d }, { CR16, 0x20 }, { CR17, 0x1e }, { CR18, 0x0a }, { CR19, 0x48 }, { CR20, 0x10 }, /* Org:0x0E, ComTrend:RalLink AP */ { CR21, 0x0e }, { CR22, 0x23 }, { CR23, 0x90 }, { CR24, 0x14 }, { CR25, 0x40 }, { CR26, 0x10 }, { CR27, 0x10 }, { CR28, 0x7f }, { CR29, 0x80 }, { CR30, 0x4b }, /* ASIC/FWT, no jointly decoder */ { CR31, 0x60 }, { CR32, 0x43 }, { CR33, 0x08 }, { CR34, 0x06 }, { CR35, 0x0a }, { CR36, 0x00 }, { CR37, 0x00 }, { CR38, 0x38 }, { CR39, 0x0c }, { CR40, 0x84 }, { CR41, 0x2a }, { CR42, 0x80 }, { CR43, 0x10 }, { CR44, 0x33 }, { CR46, 0xff }, { CR47, 0x1E }, { CR48, 0x26 }, { CR49, 0x5b }, { CR64, 0xd0 }, { CR65, 0x04 }, { CR66, 0x58 }, { CR67, 0xc9 }, { CR68, 0x88 }, { CR69, 0x41 }, { CR70, 0x23 }, { CR71, 0x10 }, { CR72, 0xff }, { CR73, 0x32 }, { CR74, 0x30 }, { CR75, 0x65 }, { CR76, 0x41 }, { CR77, 0x1b }, { CR78, 0x30 }, { CR79, 0xf0 }, { CR80, 0x64 }, { CR81, 0x64 }, { CR82, 0x00 }, { CR83, 0x24 }, { CR84, 0x04 }, { CR85, 0x00 }, { CR86, 0x0c }, { CR87, 0x12 }, { CR88, 0x0c }, { CR89, 0x00 }, { CR90, 0x58 }, { CR91, 0x04 }, { CR92, 0x00 }, { CR93, 0x00 }, { CR94, 0x01 }, { CR95, 0x20 }, /* ZD1211B */ { CR96, 0x50 }, { CR97, 0x37 }, { CR98, 0x35 }, { CR99, 0x00 }, { CR100, 0x01 }, { CR101, 0x13 }, { CR102, 0x27 }, { CR103, 0x27 }, { CR104, 0x18 }, { CR105, 0x12 }, { CR106, 0x04 }, { CR107, 0x00 }, { CR108, 0x0a }, { CR109, 0x27 }, { CR110, 0x27 }, { CR111, 0x27 }, { CR112, 0x27 }, { CR113, 0x27 }, { CR114, 0x27 }, { CR115, 0x26 }, { CR116, 0x24 }, { CR117, 0xfc }, { CR118, 0xfa }, { CR119, 0x1e }, { CR125, 0x90 }, { CR126, 0x00 }, { CR127, 0x00 }, { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 }, { CR131, 0x0c }, { CR136, 0xdf }, { CR137, 0xa0 }, { CR138, 0xa8 }, { CR139, 0xb4 }, { CR140, 0x98 }, { CR141, 0x82 }, { CR142, 0x53 }, { CR143, 0x1c }, { CR144, 0x6c }, { CR147, 0x07 }, { CR148, 0x40 }, { CR149, 0x40 }, /* Org:0x50 ComTrend:RalLink AP */ { CR150, 0x14 }, /* Org:0x0E ComTrend:RalLink AP */ { CR151, 0x18 }, { CR159, 0x70 }, { CR160, 0xfe }, { CR161, 0xee }, { CR162, 0xaa }, { CR163, 0xfa }, { CR164, 0xfa }, { CR165, 0xea }, { CR166, 0xbe }, { CR167, 0xbe }, { CR168, 0x6a }, { CR169, 0xba }, { CR170, 0xba }, { CR171, 0xba }, /* Note: CR204 must lead the CR203 */ { CR204, 0x7d }, {}, { CR203, 0x30 }, }; int r, t; dev_dbg_f(zd_chip_dev(chip), "\n"); r = zd_chip_lock_phy_regs(chip); if (r) goto out; r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); t = zd_chip_unlock_phy_regs(chip); if (t && !r) r = t; out: return r; } static int hw_reset_phy(struct zd_chip *chip) { return zd_chip_is_zd1211b(chip) ? zd1211b_hw_reset_phy(chip) : zd1211_hw_reset_phy(chip); } static int zd1211_hw_init_hmac(struct zd_chip *chip) { static const struct zd_ioreq32 ioreqs[] = { { CR_ZD1211_RETRY_MAX, ZD1211_RETRY_COUNT }, { CR_RX_THRESHOLD, 0x000c0640 }, }; dev_dbg_f(zd_chip_dev(chip), "\n"); ZD_ASSERT(mutex_is_locked(&chip->mutex)); return zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); } static int zd1211b_hw_init_hmac(struct zd_chip *chip) { static const struct zd_ioreq32 ioreqs[] = { { CR_ZD1211B_RETRY_MAX, ZD1211B_RETRY_COUNT }, { CR_ZD1211B_CWIN_MAX_MIN_AC0, 0x007f003f }, { CR_ZD1211B_CWIN_MAX_MIN_AC1, 0x007f003f }, { CR_ZD1211B_CWIN_MAX_MIN_AC2, 0x003f001f }, { CR_ZD1211B_CWIN_MAX_MIN_AC3, 0x001f000f }, { CR_ZD1211B_AIFS_CTL1, 0x00280028 }, { CR_ZD1211B_AIFS_CTL2, 0x008C003C }, { CR_ZD1211B_TXOP, 0x01800824 }, { CR_RX_THRESHOLD, 0x000c0eff, }, }; dev_dbg_f(zd_chip_dev(chip), "\n"); ZD_ASSERT(mutex_is_locked(&chip->mutex)); return zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); } static int hw_init_hmac(struct zd_chip *chip) { int r; static const struct zd_ioreq32 ioreqs[] = { { CR_ACK_TIMEOUT_EXT, 0x20 }, { CR_ADDA_MBIAS_WARMTIME, 0x30000808 }, { CR_SNIFFER_ON, 0 }, { CR_RX_FILTER, STA_RX_FILTER }, { CR_GROUP_HASH_P1, 0x00 }, { CR_GROUP_HASH_P2, 0x80000000 }, { CR_REG1, 0xa4 }, { CR_ADDA_PWR_DWN, 0x7f }, { CR_BCN_PLCP_CFG, 0x00f00401 }, { CR_PHY_DELAY, 0x00 }, { CR_ACK_TIMEOUT_EXT, 0x80 }, { CR_ADDA_PWR_DWN, 0x00 }, { CR_ACK_TIME_80211, 0x100 }, { CR_RX_PE_DELAY, 0x70 }, { CR_PS_CTRL, 0x10000000 }, { CR_RTS_CTS_RATE, 0x02030203 }, { CR_AFTER_PNP, 0x1 }, { CR_WEP_PROTECT, 0x114 }, { CR_IFS_VALUE, IFS_VALUE_DEFAULT }, { CR_CAM_MODE, MODE_AP_WDS}, }; ZD_ASSERT(mutex_is_locked(&chip->mutex)); r = zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); if (r) return r; return zd_chip_is_zd1211b(chip) ? zd1211b_hw_init_hmac(chip) : zd1211_hw_init_hmac(chip); } struct aw_pt_bi { u32 atim_wnd_period; u32 pre_tbtt; u32 beacon_interval; }; static int get_aw_pt_bi(struct zd_chip *chip, struct aw_pt_bi *s) { int r; static const zd_addr_t aw_pt_bi_addr[] = { CR_ATIM_WND_PERIOD, CR_PRE_TBTT, CR_BCN_INTERVAL }; u32 values[3]; r = zd_ioread32v_locked(chip, values, (const zd_addr_t *)aw_pt_bi_addr, ARRAY_SIZE(aw_pt_bi_addr)); if (r) { memset(s, 0, sizeof(*s)); return r; } s->atim_wnd_period = values[0]; s->pre_tbtt = values[1]; s->beacon_interval = values[2]; return 0; } static int set_aw_pt_bi(struct zd_chip *chip, struct aw_pt_bi *s) { struct zd_ioreq32 reqs[3]; if (s->beacon_interval <= 5) s->beacon_interval = 5; if (s->pre_tbtt < 4 || s->pre_tbtt >= s->beacon_interval) s->pre_tbtt = s->beacon_interval - 1; if (s->atim_wnd_period >= s->pre_tbtt) s->atim_wnd_period = s->pre_tbtt - 1; reqs[0].addr = CR_ATIM_WND_PERIOD; reqs[0].value = s->atim_wnd_period; reqs[1].addr = CR_PRE_TBTT; reqs[1].value = s->pre_tbtt; reqs[2].addr = CR_BCN_INTERVAL; reqs[2].value = s->beacon_interval; return zd_iowrite32a_locked(chip, reqs, ARRAY_SIZE(reqs)); } static int set_beacon_interval(struct zd_chip *chip, u32 interval) { int r; struct aw_pt_bi s; ZD_ASSERT(mutex_is_locked(&chip->mutex)); r = get_aw_pt_bi(chip, &s); if (r) return r; s.beacon_interval = interval; return set_aw_pt_bi(chip, &s); } int zd_set_beacon_interval(struct zd_chip *chip, u32 interval) { int r; mutex_lock(&chip->mutex); r = set_beacon_interval(chip, interval); mutex_unlock(&chip->mutex); return r; } static int hw_init(struct zd_chip *chip) { int r; dev_dbg_f(zd_chip_dev(chip), "\n"); ZD_ASSERT(mutex_is_locked(&chip->mutex)); r = hw_reset_phy(chip); if (r) return r; r = hw_init_hmac(chip); if (r) return r; return set_beacon_interval(chip, 100); } static zd_addr_t fw_reg_addr(struct zd_chip *chip, u16 offset) { return (zd_addr_t)((u16)chip->fw_regs_base + offset); } #ifdef DEBUG static int dump_cr(struct zd_chip *chip, const zd_addr_t addr, const char *addr_string) { int r; u32 value; r = zd_ioread32_locked(chip, &value, addr); if (r) { dev_dbg_f(zd_chip_dev(chip), "error reading %s. Error number %d\n", addr_string, r); return r; } dev_dbg_f(zd_chip_dev(chip), "%s %#010x\n", addr_string, (unsigned int)value); return 0; } static int test_init(struct zd_chip *chip) { int r; r = dump_cr(chip, CR_AFTER_PNP, "CR_AFTER_PNP"); if (r) return r; r = dump_cr(chip, CR_GPI_EN, "CR_GPI_EN"); if (r) return r; return dump_cr(chip, CR_INTERRUPT, "CR_INTERRUPT"); } static void dump_fw_registers(struct zd_chip *chip) { const zd_addr_t addr[4] = { fw_reg_addr(chip, FW_REG_FIRMWARE_VER), fw_reg_addr(chip, FW_REG_USB_SPEED), fw_reg_addr(chip, FW_REG_FIX_TX_RATE), fw_reg_addr(chip, FW_REG_LED_LINK_STATUS), }; int r; u16 values[4]; r = zd_ioread16v_locked(chip, values, (const zd_addr_t*)addr, ARRAY_SIZE(addr)); if (r) { dev_dbg_f(zd_chip_dev(chip), "error %d zd_ioread16v_locked\n", r); return; } dev_dbg_f(zd_chip_dev(chip), "FW_FIRMWARE_VER %#06hx\n", values[0]); dev_dbg_f(zd_chip_dev(chip), "FW_USB_SPEED %#06hx\n", values[1]); dev_dbg_f(zd_chip_dev(chip), "FW_FIX_TX_RATE %#06hx\n", values[2]); dev_dbg_f(zd_chip_dev(chip), "FW_LINK_STATUS %#06hx\n", values[3]); } #endif /* DEBUG */ static int print_fw_version(struct zd_chip *chip) { int r; u16 version; r = zd_ioread16_locked(chip, &version, fw_reg_addr(chip, FW_REG_FIRMWARE_VER)); if (r) return r; dev_info(zd_chip_dev(chip),"firmware version %04hx\n", version); return 0; } static int set_mandatory_rates(struct zd_chip *chip, int gmode) { u32 rates; ZD_ASSERT(mutex_is_locked(&chip->mutex)); /* This sets the mandatory rates, which only depend from the standard * that the device is supporting. Until further notice we should try * to support 802.11g also for full speed USB. */ if (!gmode) rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M; else rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M| CR_RATE_6M|CR_RATE_12M|CR_RATE_24M; return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL); } int zd_chip_set_rts_cts_rate_locked(struct zd_chip *chip, int preamble) { u32 value = 0; dev_dbg_f(zd_chip_dev(chip), "preamble=%x\n", preamble); value |= preamble << RTSCTS_SH_RTS_PMB_TYPE; value |= preamble << RTSCTS_SH_CTS_PMB_TYPE; /* We always send 11M RTS/self-CTS messages, like the vendor driver. */ value |= ZD_PURE_RATE(ZD_CCK_RATE_11M) << RTSCTS_SH_RTS_RATE; value |= ZD_RX_CCK << RTSCTS_SH_RTS_MOD_TYPE; value |= ZD_PURE_RATE(ZD_CCK_RATE_11M) << RTSCTS_SH_CTS_RATE; value |= ZD_RX_CCK << RTSCTS_SH_CTS_MOD_TYPE; return zd_iowrite32_locked(chip, value, CR_RTS_CTS_RATE); } int zd_chip_enable_hwint(struct zd_chip *chip) { int r; mutex_lock(&chip->mutex); r = zd_iowrite32_locked(chip, HWINT_ENABLED, CR_INTERRUPT); mutex_unlock(&chip->mutex); return r; } static int disable_hwint(struct zd_chip *chip) { return zd_iowrite32_locked(chip, HWINT_DISABLED, CR_INTERRUPT); } int zd_chip_disable_hwint(struct zd_chip *chip) { int r; mutex_lock(&chip->mutex); r = disable_hwint(chip); mutex_unlock(&chip->mutex); return r; } static int read_fw_regs_offset(struct zd_chip *chip) { int r; ZD_ASSERT(mutex_is_locked(&chip->mutex)); r = zd_ioread16_locked(chip, (u16*)&chip->fw_regs_base, FWRAW_REGS_ADDR); if (r) return r; dev_dbg_f(zd_chip_dev(chip), "fw_regs_base: %#06hx\n", (u16)chip->fw_regs_base); return 0; } /* Read mac address using pre-firmware interface */ int zd_chip_read_mac_addr_fw(struct zd_chip *chip, u8 *addr) { dev_dbg_f(zd_chip_dev(chip), "\n"); return zd_usb_read_fw(&chip->usb, E2P_MAC_ADDR_P1, addr, ETH_ALEN); } int zd_chip_init_hw(struct zd_chip *chip) { int r; u8 rf_type; dev_dbg_f(zd_chip_dev(chip), "\n"); mutex_lock(&chip->mutex); #ifdef DEBUG r = test_init(chip); if (r) goto out; #endif r = zd_iowrite32_locked(chip, 1, CR_AFTER_PNP); if (r) goto out; r = read_fw_regs_offset(chip); if (r) goto out; /* GPI is always disabled, also in the other driver. */ r = zd_iowrite32_locked(chip, 0, CR_GPI_EN); if (r) goto out; r = zd_iowrite32_locked(chip, CWIN_SIZE, CR_CWMIN_CWMAX); if (r) goto out; /* Currently we support IEEE 802.11g for full and high speed USB. * It might be discussed, whether we should suppport pure b mode for * full speed USB. */ r = set_mandatory_rates(chip, 1); if (r) goto out; /* Disabling interrupts is certainly a smart thing here. */ r = disable_hwint(chip); if (r) goto out; r = read_pod(chip, &rf_type); if (r) goto out; r = hw_init(chip); if (r) goto out; r = zd_rf_init_hw(&chip->rf, rf_type); if (r) goto out; r = print_fw_version(chip); if (r) goto out; #ifdef DEBUG dump_fw_registers(chip); r = test_init(chip); if (r) goto out; #endif /* DEBUG */ r = read_cal_int_tables(chip); if (r) goto out; print_id(chip); out: mutex_unlock(&chip->mutex); return r; } static int update_pwr_int(struct zd_chip *chip, u8 channel) { u8 value = chip->pwr_int_values[channel - 1]; return zd_iowrite16_locked(chip, value, CR31); } static int update_pwr_cal(struct zd_chip *chip, u8 channel) { u8 value = chip->pwr_cal_values[channel-1]; return zd_iowrite16_locked(chip, value, CR68); } static int update_ofdm_cal(struct zd_chip *chip, u8 channel) { struct zd_ioreq16 ioreqs[3]; ioreqs[0].addr = CR67; ioreqs[0].value = chip->ofdm_cal_values[OFDM_36M_INDEX][channel-1]; ioreqs[1].addr = CR66; ioreqs[1].value = chip->ofdm_cal_values[OFDM_48M_INDEX][channel-1]; ioreqs[2].addr = CR65; ioreqs[2].value = chip->ofdm_cal_values[OFDM_54M_INDEX][channel-1]; return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); } static int update_channel_integration_and_calibration(struct zd_chip *chip, u8 channel) { int r; if (!zd_rf_should_update_pwr_int(&chip->rf)) return 0; r = update_pwr_int(chip, channel); if (r) return r; if (zd_chip_is_zd1211b(chip)) { static const struct zd_ioreq16 ioreqs[] = { { CR69, 0x28 }, {}, { CR69, 0x2a }, }; r = update_ofdm_cal(chip, channel); if (r) return r; r = update_pwr_cal(chip, channel); if (r) return r; r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); if (r) return r; } return 0; } /* The CCK baseband gain can be optionally patched by the EEPROM */ static int patch_cck_gain(struct zd_chip *chip) { int r; u32 value; if (!chip->patch_cck_gain || !zd_rf_should_patch_cck_gain(&chip->rf)) return 0; ZD_ASSERT(mutex_is_locked(&chip->mutex)); r = zd_ioread32_locked(chip, &value, E2P_PHY_REG); if (r) return r; dev_dbg_f(zd_chip_dev(chip), "patching value %x\n", value & 0xff); return zd_iowrite16_locked(chip, value & 0xff, CR47); } int zd_chip_set_channel(struct zd_chip *chip, u8 channel) { int r, t; mutex_lock(&chip->mutex); r = zd_chip_lock_phy_regs(chip); if (r) goto out; r = zd_rf_set_channel(&chip->rf, channel); if (r) goto unlock; r = update_channel_integration_and_calibration(chip, channel); if (r) goto unlock; r = patch_cck_gain(chip); if (r) goto unlock; r = patch_6m_band_edge(chip, channel); if (r) goto unlock; r = zd_iowrite32_locked(chip, 0, CR_CONFIG_PHILIPS); unlock: t = zd_chip_unlock_phy_regs(chip); if (t && !r) r = t; out: mutex_unlock(&chip->mutex); return r; } u8 zd_chip_get_channel(struct zd_chip *chip) { u8 channel; mutex_lock(&chip->mutex); channel = chip->rf.channel; mutex_unlock(&chip->mutex); return channel; } int zd_chip_control_leds(struct zd_chip *chip, enum led_status status) { const zd_addr_t a[] = { fw_reg_addr(chip, FW_REG_LED_LINK_STATUS), CR_LED, }; int r; u16 v[ARRAY_SIZE(a)]; struct zd_ioreq16 ioreqs[ARRAY_SIZE(a)] = { [0] = { fw_reg_addr(chip, FW_REG_LED_LINK_STATUS) }, [1] = { CR_LED }, }; u16 other_led; mutex_lock(&chip->mutex); r = zd_ioread16v_locked(chip, v, (const zd_addr_t *)a, ARRAY_SIZE(a)); if (r) goto out; other_led = chip->link_led == LED1 ? LED2 : LED1; switch (status) { case ZD_LED_OFF: ioreqs[0].value = FW_LINK_OFF; ioreqs[1].value = v[1] & ~(LED1|LED2); break; case ZD_LED_SCANNING: ioreqs[0].value = FW_LINK_OFF; ioreqs[1].value = v[1] & ~other_led; if (get_seconds() % 3 == 0) { ioreqs[1].value &= ~chip->link_led; } else { ioreqs[1].value |= chip->link_led; } break; case ZD_LED_ASSOCIATED: ioreqs[0].value = FW_LINK_TX; ioreqs[1].value = v[1] & ~other_led; ioreqs[1].value |= chip->link_led; break; default: r = -EINVAL; goto out; } if (v[0] != ioreqs[0].value || v[1] != ioreqs[1].value) { r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); if (r) goto out; } r = 0; out: mutex_unlock(&chip->mutex); return r; } int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates) { int r; if (cr_rates & ~(CR_RATES_80211B|CR_RATES_80211G)) return -EINVAL; mutex_lock(&chip->mutex); r = zd_iowrite32_locked(chip, cr_rates, CR_BASIC_RATE_TBL); mutex_unlock(&chip->mutex); return r; } static inline u8 zd_rate_from_ofdm_plcp_header(const void *rx_frame) { return ZD_OFDM | zd_ofdm_plcp_header_rate(rx_frame); } /** * zd_rx_rate - report zd-rate * @rx_frame - received frame * @rx_status - rx_status as given by the device * * This function converts the rate as encoded in the received packet to the * zd-rate, we are using on other places in the driver. */ u8 zd_rx_rate(const void *rx_frame, const struct rx_status *status) { u8 zd_rate; if (status->frame_status & ZD_RX_OFDM) { zd_rate = zd_rate_from_ofdm_plcp_header(rx_frame); } else { switch (zd_cck_plcp_header_signal(rx_frame)) { case ZD_CCK_PLCP_SIGNAL_1M: zd_rate = ZD_CCK_RATE_1M; break; case ZD_CCK_PLCP_SIGNAL_2M: zd_rate = ZD_CCK_RATE_2M; break; case ZD_CCK_PLCP_SIGNAL_5M5: zd_rate = ZD_CCK_RATE_5_5M; break; case ZD_CCK_PLCP_SIGNAL_11M: zd_rate = ZD_CCK_RATE_11M; break; default: zd_rate = 0; } } return zd_rate; } int zd_chip_switch_radio_on(struct zd_chip *chip) { int r; mutex_lock(&chip->mutex); r = zd_switch_radio_on(&chip->rf); mutex_unlock(&chip->mutex); return r; } int zd_chip_switch_radio_off(struct zd_chip *chip) { int r; mutex_lock(&chip->mutex); r = zd_switch_radio_off(&chip->rf); mutex_unlock(&chip->mutex); return r; } int zd_chip_enable_int(struct zd_chip *chip) { int r; mutex_lock(&chip->mutex); r = zd_usb_enable_int(&chip->usb); mutex_unlock(&chip->mutex); return r; } void zd_chip_disable_int(struct zd_chip *chip) { mutex_lock(&chip->mutex); zd_usb_disable_int(&chip->usb); mutex_unlock(&chip->mutex); } int zd_chip_enable_rxtx(struct zd_chip *chip) { int r; mutex_lock(&chip->mutex); zd_usb_enable_tx(&chip->usb); r = zd_usb_enable_rx(&chip->usb); mutex_unlock(&chip->mutex); return r; } void zd_chip_disable_rxtx(struct zd_chip *chip) { mutex_lock(&chip->mutex); zd_usb_disable_rx(&chip->usb); zd_usb_disable_tx(&chip->usb); mutex_unlock(&chip->mutex); } int zd_rfwritev_locked(struct zd_chip *chip, const u32* values, unsigned int count, u8 bits) { int r; unsigned int i; for (i = 0; i < count; i++) { r = zd_rfwrite_locked(chip, values[i], bits); if (r) return r; } return 0; } /* * We can optionally program the RF directly through CR regs, if supported by * the hardware. This is much faster than the older method. */ int zd_rfwrite_cr_locked(struct zd_chip *chip, u32 value) { struct zd_ioreq16 ioreqs[] = { { CR244, (value >> 16) & 0xff }, { CR243, (value >> 8) & 0xff }, { CR242, value & 0xff }, }; ZD_ASSERT(mutex_is_locked(&chip->mutex)); return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); } int zd_rfwritev_cr_locked(struct zd_chip *chip, const u32 *values, unsigned int count) { int r; unsigned int i; for (i = 0; i < count; i++) { r = zd_rfwrite_cr_locked(chip, values[i]); if (r) return r; } return 0; } int zd_chip_set_multicast_hash(struct zd_chip *chip, struct zd_mc_hash *hash) { struct zd_ioreq32 ioreqs[] = { { CR_GROUP_HASH_P1, hash->low }, { CR_GROUP_HASH_P2, hash->high }, }; return zd_iowrite32a(chip, ioreqs, ARRAY_SIZE(ioreqs)); } u64 zd_chip_get_tsf(struct zd_chip *chip) { int r; static const zd_addr_t aw_pt_bi_addr[] = { CR_TSF_LOW_PART, CR_TSF_HIGH_PART }; u32 values[2]; u64 tsf; mutex_lock(&chip->mutex); r = zd_ioread32v_locked(chip, values, (const zd_addr_t *)aw_pt_bi_addr, ARRAY_SIZE(aw_pt_bi_addr)); mutex_unlock(&chip->mutex); if (r) return 0; tsf = values[1]; tsf = (tsf << 32) | values[0]; return tsf; }
gpl-2.0
pocketbook-free/kernel_613
arch/arm/mach-at91/board-ek.c
1655
5054
/* * linux/arch/arm/mach-at91/board-ek.c * * Copyright (C) 2005 SAN People * * Epson S1D framebuffer glue code is: * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org> * * 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/types.h> #include <linux/init.h> #include <linux/mm.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/spi/spi.h> #include <linux/mtd/physmap.h> #include <asm/setup.h> #include <asm/mach-types.h> #include <asm/irq.h> #include <asm/mach/arch.h> #include <asm/mach/map.h> #include <asm/mach/irq.h> #include <mach/hardware.h> #include <mach/board.h> #include <mach/gpio.h> #include <mach/at91rm9200_mc.h> #include "generic.h" static void __init ek_map_io(void) { /* Initialize processor: 18.432 MHz crystal */ at91rm9200_initialize(18432000, AT91RM9200_BGA); /* Setup the LEDs */ at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2); /* DBGU on ttyS0. (Rx & Tx only) */ at91_register_uart(0, 0, 0); /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD | ATMEL_UART_RI); /* set serial console to ttyS0 (ie, DBGU) */ at91_set_serial_console(0); } static void __init ek_init_irq(void) { at91rm9200_init_interrupts(NULL); } static struct at91_eth_data __initdata ek_eth_data = { .phy_irq_pin = AT91_PIN_PC4, .is_rmii = 1, }; static struct at91_usbh_data __initdata ek_usbh_data = { .ports = 2, }; static struct at91_udc_data __initdata ek_udc_data = { .vbus_pin = AT91_PIN_PD4, .pullup_pin = AT91_PIN_PD5, }; static struct at91_mmc_data __initdata ek_mmc_data = { .det_pin = AT91_PIN_PB27, .slot_b = 0, .wire4 = 1, .wp_pin = AT91_PIN_PA17, }; static struct spi_board_info ek_spi_devices[] = { { /* DataFlash chip */ .modalias = "mtd_dataflash", .chip_select = 0, .max_speed_hz = 15 * 1000 * 1000, }, #ifdef CONFIG_MTD_AT91_DATAFLASH_CARD { /* DataFlash card */ .modalias = "mtd_dataflash", .chip_select = 3, .max_speed_hz = 15 * 1000 * 1000, }, #endif }; static struct i2c_board_info __initdata ek_i2c_devices[] = { { I2C_BOARD_INFO("ics1523", 0x26), }, { I2C_BOARD_INFO("dac3550", 0x4d), } }; #define EK_FLASH_BASE AT91_CHIPSELECT_0 #define EK_FLASH_SIZE SZ_2M static struct physmap_flash_data ek_flash_data = { .width = 2, }; static struct resource ek_flash_resource = { .start = EK_FLASH_BASE, .end = EK_FLASH_BASE + EK_FLASH_SIZE - 1, .flags = IORESOURCE_MEM, }; static struct platform_device ek_flash = { .name = "physmap-flash", .id = 0, .dev = { .platform_data = &ek_flash_data, }, .resource = &ek_flash_resource, .num_resources = 1, }; static struct gpio_led ek_leds[] = { { /* "user led 1", DS2 */ .name = "green", .gpio = AT91_PIN_PB0, .active_low = 1, .default_trigger = "mmc0", }, { /* "user led 2", DS4 */ .name = "yellow", .gpio = AT91_PIN_PB1, .active_low = 1, .default_trigger = "heartbeat", }, { /* "user led 3", DS6 */ .name = "red", .gpio = AT91_PIN_PB2, .active_low = 1, } }; static void __init ek_board_init(void) { /* Serial */ at91_add_device_serial(); /* Ethernet */ at91_add_device_eth(&ek_eth_data); /* USB Host */ at91_add_device_usbh(&ek_usbh_data); /* USB Device */ at91_add_device_udc(&ek_udc_data); at91_set_multi_drive(ek_udc_data.pullup_pin, 1); /* pullup_pin is connected to reset */ /* I2C */ at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices)); /* SPI */ at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); #ifdef CONFIG_MTD_AT91_DATAFLASH_CARD /* DataFlash card */ at91_set_gpio_output(AT91_PIN_PB22, 0); #else /* MMC */ at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */ at91_add_device_mmc(0, &ek_mmc_data); #endif /* NOR Flash */ platform_device_register(&ek_flash); /* LEDs */ at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); /* VGA */ // ek_add_device_video(); } MACHINE_START(AT91RM9200EK, "Atmel AT91RM9200-EK") /* Maintainer: SAN People/Atmel */ .phys_io = AT91_BASE_SYS, .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc, .boot_params = AT91_SDRAM_BASE + 0x100, .timer = &at91rm9200_timer, .map_io = ek_map_io, .init_irq = ek_init_irq, .init_machine = ek_board_init, MACHINE_END
gpl-2.0
chase2534/gtab47.freekern
kernel/sched/idle_task.c
1911
2500
#include "sched.h" /* * idle-task scheduling class. * * (NOTE: these are not related to SCHED_IDLE tasks which are * handled in sched/fair.c) */ #ifdef CONFIG_SMP static int select_task_rq_idle(struct task_struct *p, int sd_flag, int flags) { return task_cpu(p); /* IDLE tasks as never migrated */ } static void pre_schedule_idle(struct rq *rq, struct task_struct *prev) { idle_exit_fair(rq); rq_last_tick_reset(rq); } static void post_schedule_idle(struct rq *rq) { idle_enter_fair(rq); } #endif /* CONFIG_SMP */ /* * Idle tasks are unconditionally rescheduled: */ static void check_preempt_curr_idle(struct rq *rq, struct task_struct *p, int flags) { resched_task(rq->idle); } static struct task_struct *pick_next_task_idle(struct rq *rq) { schedstat_inc(rq, sched_goidle); #ifdef CONFIG_SMP /* Trigger the post schedule to do an idle_enter for CFS */ rq->post_schedule = 1; #endif return rq->idle; } /* * It is not legal to sleep in the idle task - print a warning * message if some code attempts to do it: */ static void dequeue_task_idle(struct rq *rq, struct task_struct *p, int flags) { raw_spin_unlock_irq(&rq->lock); printk(KERN_ERR "bad: scheduling from the idle thread!\n"); dump_stack(); raw_spin_lock_irq(&rq->lock); } static void put_prev_task_idle(struct rq *rq, struct task_struct *prev) { } static void task_tick_idle(struct rq *rq, struct task_struct *curr, int queued) { } static void set_curr_task_idle(struct rq *rq) { } static void switched_to_idle(struct rq *rq, struct task_struct *p) { BUG(); } static void prio_changed_idle(struct rq *rq, struct task_struct *p, int oldprio) { BUG(); } static unsigned int get_rr_interval_idle(struct rq *rq, struct task_struct *task) { return 0; } /* * Simple, special scheduling class for the per-CPU idle tasks: */ const struct sched_class idle_sched_class = { /* .next is NULL */ /* no enqueue/yield_task for idle tasks */ /* dequeue is not valid, we print a debug message there: */ .dequeue_task = dequeue_task_idle, .check_preempt_curr = check_preempt_curr_idle, .pick_next_task = pick_next_task_idle, .put_prev_task = put_prev_task_idle, #ifdef CONFIG_SMP .select_task_rq = select_task_rq_idle, .pre_schedule = pre_schedule_idle, .post_schedule = post_schedule_idle, #endif .set_curr_task = set_curr_task_idle, .task_tick = task_tick_idle, .get_rr_interval = get_rr_interval_idle, .prio_changed = prio_changed_idle, .switched_to = switched_to_idle, };
gpl-2.0
CoolDevelopment/VSMC-i9105p
fs/xfs/linux-2.6/xfs_discard.c
1911
5957
/* * Copyright (C) 2010 Red Hat, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would 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 the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xfs.h" #include "xfs_sb.h" #include "xfs_inum.h" #include "xfs_log.h" #include "xfs_ag.h" #include "xfs_mount.h" #include "xfs_quota.h" #include "xfs_trans.h" #include "xfs_alloc_btree.h" #include "xfs_bmap_btree.h" #include "xfs_ialloc_btree.h" #include "xfs_btree.h" #include "xfs_inode.h" #include "xfs_alloc.h" #include "xfs_error.h" #include "xfs_discard.h" #include "xfs_trace.h" STATIC int xfs_trim_extents( struct xfs_mount *mp, xfs_agnumber_t agno, xfs_fsblock_t start, xfs_fsblock_t len, xfs_fsblock_t minlen, __uint64_t *blocks_trimmed) { struct block_device *bdev = mp->m_ddev_targp->bt_bdev; struct xfs_btree_cur *cur; struct xfs_buf *agbp; struct xfs_perag *pag; int error; int i; pag = xfs_perag_get(mp, agno); error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp); if (error || !agbp) goto out_put_perag; cur = xfs_allocbt_init_cursor(mp, NULL, agbp, agno, XFS_BTNUM_CNT); /* * Force out the log. This means any transactions that might have freed * space before we took the AGF buffer lock are now on disk, and the * volatile disk cache is flushed. */ xfs_log_force(mp, XFS_LOG_SYNC); /* * Look up the longest btree in the AGF and start with it. */ error = xfs_alloc_lookup_le(cur, 0, be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest), &i); if (error) goto out_del_cursor; /* * Loop until we are done with all extents that are large * enough to be worth discarding. */ while (i) { xfs_agblock_t fbno; xfs_extlen_t flen; error = xfs_alloc_get_rec(cur, &fbno, &flen, &i); if (error) goto out_del_cursor; XFS_WANT_CORRUPTED_GOTO(i == 1, out_del_cursor); ASSERT(flen <= be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest)); /* * Too small? Give up. */ if (flen < minlen) { trace_xfs_discard_toosmall(mp, agno, fbno, flen); goto out_del_cursor; } /* * If the extent is entirely outside of the range we are * supposed to discard skip it. Do not bother to trim * down partially overlapping ranges for now. */ if (XFS_AGB_TO_FSB(mp, agno, fbno) + flen < start || XFS_AGB_TO_FSB(mp, agno, fbno) >= start + len) { trace_xfs_discard_exclude(mp, agno, fbno, flen); goto next_extent; } /* * If any blocks in the range are still busy, skip the * discard and try again the next time. */ if (xfs_alloc_busy_search(mp, agno, fbno, flen)) { trace_xfs_discard_busy(mp, agno, fbno, flen); goto next_extent; } trace_xfs_discard_extent(mp, agno, fbno, flen); error = -blkdev_issue_discard(bdev, XFS_AGB_TO_DADDR(mp, agno, fbno), XFS_FSB_TO_BB(mp, flen), GFP_NOFS, 0); if (error) goto out_del_cursor; *blocks_trimmed += flen; next_extent: error = xfs_btree_decrement(cur, 0, &i); if (error) goto out_del_cursor; } out_del_cursor: xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR); xfs_buf_relse(agbp); out_put_perag: xfs_perag_put(pag); return error; } int xfs_ioc_trim( struct xfs_mount *mp, struct fstrim_range __user *urange) { struct request_queue *q = mp->m_ddev_targp->bt_bdev->bd_disk->queue; unsigned int granularity = q->limits.discard_granularity; struct fstrim_range range; xfs_fsblock_t start, len, minlen; xfs_agnumber_t start_agno, end_agno, agno; __uint64_t blocks_trimmed = 0; int error, last_error = 0; if (!capable(CAP_SYS_ADMIN)) return -XFS_ERROR(EPERM); if (!blk_queue_discard(q)) return -XFS_ERROR(EOPNOTSUPP); if (copy_from_user(&range, urange, sizeof(range))) return -XFS_ERROR(EFAULT); /* * Truncating down the len isn't actually quite correct, but using * XFS_B_TO_FSB would mean we trivially get overflows for values * of ULLONG_MAX or slightly lower. And ULLONG_MAX is the default * used by the fstrim application. In the end it really doesn't * matter as trimming blocks is an advisory interface. */ start = XFS_B_TO_FSBT(mp, range.start); len = XFS_B_TO_FSBT(mp, range.len); minlen = XFS_B_TO_FSB(mp, max_t(u64, granularity, range.minlen)); start_agno = XFS_FSB_TO_AGNO(mp, start); if (start_agno >= mp->m_sb.sb_agcount) return -XFS_ERROR(EINVAL); end_agno = XFS_FSB_TO_AGNO(mp, start + len); if (end_agno >= mp->m_sb.sb_agcount) end_agno = mp->m_sb.sb_agcount - 1; for (agno = start_agno; agno <= end_agno; agno++) { error = -xfs_trim_extents(mp, agno, start, len, minlen, &blocks_trimmed); if (error) last_error = error; } if (last_error) return last_error; range.len = XFS_FSB_TO_B(mp, blocks_trimmed); if (copy_to_user(urange, &range, sizeof(range))) return -XFS_ERROR(EFAULT); return 0; } int xfs_discard_extents( struct xfs_mount *mp, struct list_head *list) { struct xfs_busy_extent *busyp; int error = 0; list_for_each_entry(busyp, list, list) { trace_xfs_discard_extent(mp, busyp->agno, busyp->bno, busyp->length); error = -blkdev_issue_discard(mp->m_ddev_targp->bt_bdev, XFS_AGB_TO_DADDR(mp, busyp->agno, busyp->bno), XFS_FSB_TO_BB(mp, busyp->length), GFP_NOFS, 0); if (error && error != EOPNOTSUPP) { xfs_info(mp, "discard failed for extent [0x%llu,%u], error %d", (unsigned long long)busyp->bno, busyp->length, error); return error; } } return 0; }
gpl-2.0
HydraCompany/HydraKernel
fs/nls/nls_cp861.c
2935
17484
/* * linux/fs/nls/nls_cp861.c * * Charset cp861 translation tables. * Generated automatically from the Unicode and charset * tables from the Unicode Organization (www.unicode.org). * The Unicode to charset table has only exact mappings. */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/nls.h> #include <linux/errno.h> static const wchar_t charset2uni[256] = { /* 0x00*/ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, /* 0x10*/ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f, /* 0x20*/ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, /* 0x30*/ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, /* 0x40*/ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, /* 0x50*/ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, /* 0x60*/ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, /* 0x70*/ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f, /* 0x80*/ 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7, 0x00ea, 0x00eb, 0x00e8, 0x00d0, 0x00f0, 0x00de, 0x00c4, 0x00c5, /* 0x90*/ 0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00fe, 0x00fb, 0x00dd, 0x00fd, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8, 0x20a7, 0x0192, /* 0xa0*/ 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00c1, 0x00cd, 0x00d3, 0x00da, 0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb, /* 0xb0*/ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510, /* 0xc0*/ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567, /* 0xd0*/ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580, /* 0xe0*/ 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4, 0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229, /* 0xf0*/ 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248, 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0, }; static const unsigned char page00[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30-0x37 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40-0x47 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x48-0x4f */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50-0x57 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x58-0x5f */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60-0x67 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0x68-0x6f */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70-0x77 */ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0xff, 0xad, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0xae, 0xaa, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0xf8, 0xf1, 0xfd, 0x00, 0x00, 0xe6, 0x00, 0xfa, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0xaf, 0xac, 0xab, 0x00, 0xa8, /* 0xb8-0xbf */ 0x00, 0xa4, 0x00, 0x00, 0x8e, 0x8f, 0x92, 0x80, /* 0xc0-0xc7 */ 0x00, 0x90, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, /* 0xc8-0xcf */ 0x8b, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x99, 0x00, /* 0xd0-0xd7 */ 0x9d, 0x00, 0xa7, 0x00, 0x9a, 0x97, 0x8d, 0xe1, /* 0xd8-0xdf */ 0x85, 0xa0, 0x83, 0x00, 0x84, 0x86, 0x91, 0x87, /* 0xe0-0xe7 */ 0x8a, 0x82, 0x88, 0x89, 0x00, 0xa1, 0x00, 0x00, /* 0xe8-0xef */ 0x8c, 0x00, 0x00, 0xa2, 0x93, 0x00, 0x94, 0xf6, /* 0xf0-0xf7 */ 0x9b, 0x00, 0xa3, 0x96, 0x81, 0x98, 0x95, 0x00, /* 0xf8-0xff */ }; static const unsigned char page01[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ }; static const unsigned char page03[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0xe2, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0xe4, 0x00, 0x00, 0xe8, 0x00, /* 0xa0-0xa7 */ 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0xe0, 0x00, 0x00, 0xeb, 0xee, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0xe3, 0x00, 0x00, 0xe5, 0xe7, 0x00, 0xed, 0x00, /* 0xc0-0xc7 */ }; static const unsigned char page20[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, /* 0xa0-0xa7 */ }; static const unsigned char page22[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0xf9, 0xfb, 0x00, 0x00, 0x00, 0xec, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0xf0, 0x00, 0x00, 0xf3, 0xf2, 0x00, 0x00, /* 0x60-0x67 */ }; static const unsigned char page23[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0xa9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0xf4, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ }; static const unsigned char page25[256] = { 0xc4, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0xbf, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0xd9, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0xc5, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0xcd, 0xba, 0xd5, 0xd6, 0xc9, 0xb8, 0xb7, 0xbb, /* 0x50-0x57 */ 0xd4, 0xd3, 0xc8, 0xbe, 0xbd, 0xbc, 0xc6, 0xc7, /* 0x58-0x5f */ 0xcc, 0xb5, 0xb6, 0xb9, 0xd1, 0xd2, 0xcb, 0xcf, /* 0x60-0x67 */ 0xd0, 0xca, 0xd8, 0xd7, 0xce, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0xdf, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0xdb, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0xde, 0xb0, 0xb1, 0xb2, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; static const unsigned char *const page_uni2charset[256] = { page00, page01, NULL, page03, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, page20, NULL, page22, page23, NULL, page25, NULL, NULL, }; static const unsigned char charset2lower[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30-0x37 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x40-0x47 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0x48-0x4f */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x50-0x57 */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0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */ 0xed, 0x00, 0x00, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0-0xf7 */ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0xf8-0xff */ }; static const unsigned char charset2upper[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30-0x37 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40-0x47 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x48-0x4f */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50-0x57 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x58-0x5f */ 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x60-0x67 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x68-0x6f */ 0x50, 0x51, 0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, 0xfd, 0xfe, 0xff, /* 0xf8-0xff */ }; static int uni2char(wchar_t uni, unsigned char *out, int boundlen) { const unsigned char *uni2charset; unsigned char cl = uni & 0x00ff; unsigned char ch = (uni & 0xff00) >> 8; if (boundlen <= 0) return -ENAMETOOLONG; uni2charset = page_uni2charset[ch]; if (uni2charset && uni2charset[cl]) out[0] = uni2charset[cl]; else return -EINVAL; return 1; } static int char2uni(const unsigned char *rawstring, int boundlen, wchar_t *uni) { *uni = charset2uni[*rawstring]; if (*uni == 0x0000) return -EINVAL; return 1; } static struct nls_table table = { .charset = "cp861", .uni2char = uni2char, .char2uni = char2uni, .charset2lower = charset2lower, .charset2upper = charset2upper, }; static int __init init_nls_cp861(void) { return register_nls(&table); } static void __exit exit_nls_cp861(void) { unregister_nls(&table); } module_init(init_nls_cp861) module_exit(exit_nls_cp861) MODULE_LICENSE("Dual BSD/GPL");
gpl-2.0
googlehim/linux
fs/nls/nls_iso8859-6.c
2935
10444
/* * linux/fs/nls/nls_iso8859-6.c * * Charset iso8859-6 translation tables. * Generated automatically from the Unicode and charset * tables from the Unicode Organization (www.unicode.org). * The Unicode to charset table has only exact mappings. */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/nls.h> #include <linux/errno.h> static const wchar_t charset2uni[256] = { /* 0x00*/ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, /* 0x10*/ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f, /* 0x20*/ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, /* 0x30*/ 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, /* 0x40*/ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, /* 0x50*/ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, /* 0x60*/ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, /* 0x70*/ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f, /* 0x80*/ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, /* 0x90*/ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f, /* 0xa0*/ 0x00a0, 0x0000, 0x0000, 0x0000, 0x00a4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x060c, 0x00ad, 0x0000, 0x0000, /* 0xb0*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f, /* 0xc0*/ 0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f, /* 0xd0*/ 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0xe0*/ 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, /* 0xf0*/ 0x0650, 0x0651, 0x0652, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; static const unsigned char page00[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40-0x47 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x48-0x4f */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50-0x57 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x58-0x5f */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60-0x67 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0x68-0x6f */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70-0x77 */ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 0x78-0x7f */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x80-0x87 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, /* 0x88-0x8f */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x90-0x97 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, /* 0x98-0x9f */ 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, /* 0xa8-0xaf */ }; static const unsigned char page06[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0xbf, /* 0x18-0x1f */ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x20-0x27 */ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x28-0x2f */ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x30-0x37 */ 0xd8, 0xd9, 0xda, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x40-0x47 */ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x48-0x4f */ 0xf0, 0xf1, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x60-0x67 */ 0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ }; static const unsigned char *const page_uni2charset[256] = { page00, NULL, NULL, NULL, NULL, NULL, page06, NULL, }; static const unsigned char charset2lower[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30-0x37 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x40-0x47 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0x48-0x4f */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x50-0x57 */ 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x58-0x5f */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60-0x67 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0x68-0x6f */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70-0x77 */ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 0x78-0x7f */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x80-0x87 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, /* 0x88-0x8f */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x90-0x97 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, /* 0x98-0x9f */ 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0xac, 0xad, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0xbf, /* 0xb8-0xbf */ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0-0xc7 */ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0-0xd7 */ 0xd8, 0xd9, 0xda, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */ 0xf0, 0xf1, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; static const unsigned char charset2upper[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30-0x37 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40-0x47 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x48-0x4f */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50-0x57 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x58-0x5f */ 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x60-0x67 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x68-0x6f */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x70-0x77 */ 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 0x78-0x7f */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x80-0x87 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, /* 0x88-0x8f */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x90-0x97 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, /* 0x98-0x9f */ 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0xac, 0xad, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0xbf, /* 0xb8-0xbf */ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0-0xc7 */ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0-0xd7 */ 0xd8, 0xd9, 0xda, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */ 0xf0, 0xf1, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ }; static int uni2char(wchar_t uni, unsigned char *out, int boundlen) { const unsigned char *uni2charset; unsigned char cl = uni & 0x00ff; unsigned char ch = (uni & 0xff00) >> 8; if (boundlen <= 0) return -ENAMETOOLONG; uni2charset = page_uni2charset[ch]; if (uni2charset && uni2charset[cl]) out[0] = uni2charset[cl]; else return -EINVAL; return 1; } static int char2uni(const unsigned char *rawstring, int boundlen, wchar_t *uni) { *uni = charset2uni[*rawstring]; if (*uni == 0x0000) return -EINVAL; return 1; } static struct nls_table table = { .charset = "iso8859-6", .uni2char = uni2char, .char2uni = char2uni, .charset2lower = charset2lower, .charset2upper = charset2upper, }; static int __init init_nls_iso8859_6(void) { return register_nls(&table); } static void __exit exit_nls_iso8859_6(void) { unregister_nls(&table); } module_init(init_nls_iso8859_6) module_exit(exit_nls_iso8859_6) MODULE_LICENSE("Dual BSD/GPL");
gpl-2.0
arunthomas/linux
fs/nls/mac-roman.c
2935
33377
/* * linux/fs/nls/mac-roman.c * * Charset macroman translation tables. * Generated automatically from the Unicode and charset * tables from the Unicode Organization (www.unicode.org). * The Unicode to charset table has only exact mappings. */ /* * COPYRIGHT AND PERMISSION NOTICE * * Copyright 1991-2012 Unicode, Inc. All rights reserved. Distributed under * the Terms of Use in http://www.unicode.org/copyright.html. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of the Unicode data files and any associated documentation (the "Data * Files") or Unicode software and any associated documentation (the * "Software") to deal in the Data Files or Software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, and/or sell copies of the Data Files or Software, and * to permit persons to whom the Data Files or Software are furnished to do * so, provided that (a) the above copyright notice(s) and this permission * notice appear with all copies of the Data Files or Software, (b) both the * above copyright notice(s) and this permission notice appear in associated * documentation, and (c) there is clear notice in each modified Data File or * in the Software as well as in the documentation associated with the Data * File(s) or Software that the data or software has been modified. * * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THE DATA FILES OR SOFTWARE. * * Except as contained in this notice, the name of a copyright holder shall * not be used in advertising or otherwise to promote the sale, use or other * dealings in these Data Files or Software without prior written * authorization of the copyright holder. */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/nls.h> #include <linux/errno.h> static const wchar_t charset2uni[256] = { /* 0x00 */ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, /* 0x10 */ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f, /* 0x20 */ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, /* 0x30 */ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, /* 0x40 */ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, /* 0x50 */ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, /* 0x60 */ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, /* 0x70 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f, /* 0x80 */ 0x00c4, 0x00c5, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc, 0x00e1, 0x00e0, 0x00e2, 0x00e4, 0x00e3, 0x00e5, 0x00e7, 0x00e9, 0x00e8, /* 0x90 */ 0x00ea, 0x00eb, 0x00ed, 0x00ec, 0x00ee, 0x00ef, 0x00f1, 0x00f3, 0x00f2, 0x00f4, 0x00f6, 0x00f5, 0x00fa, 0x00f9, 0x00fb, 0x00fc, /* 0xa0 */ 0x2020, 0x00b0, 0x00a2, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x00df, 0x00ae, 0x00a9, 0x2122, 0x00b4, 0x00a8, 0x2260, 0x00c6, 0x00d8, /* 0xb0 */ 0x221e, 0x00b1, 0x2264, 0x2265, 0x00a5, 0x00b5, 0x2202, 0x2211, 0x220f, 0x03c0, 0x222b, 0x00aa, 0x00ba, 0x03a9, 0x00e6, 0x00f8, /* 0xc0 */ 0x00bf, 0x00a1, 0x00ac, 0x221a, 0x0192, 0x2248, 0x2206, 0x00ab, 0x00bb, 0x2026, 0x00a0, 0x00c0, 0x00c3, 0x00d5, 0x0152, 0x0153, /* 0xd0 */ 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x25ca, 0x00ff, 0x0178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02, /* 0xe0 */ 0x2021, 0x00b7, 0x201a, 0x201e, 0x2030, 0x00c2, 0x00ca, 0x00c1, 0x00cb, 0x00c8, 0x00cd, 0x00ce, 0x00cf, 0x00cc, 0x00d3, 0x00d4, /* 0xf0 */ 0xf8ff, 0x00d2, 0x00da, 0x00db, 0x00d9, 0x0131, 0x02c6, 0x02dc, 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7, }; static const unsigned char page00[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30-0x37 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40-0x47 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x48-0x4f */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50-0x57 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x58-0x5f */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60-0x67 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0x68-0x6f */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70-0x77 */ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0xca, 0xc1, 0xa2, 0xa3, 0x00, 0xb4, 0x00, 0xa4, /* 0xa0-0xa7 */ 0xac, 0xa9, 0xbb, 0xc7, 0xc2, 0x00, 0xa8, 0xf8, /* 0xa8-0xaf */ 0xa1, 0xb1, 0x00, 0x00, 0xab, 0xb5, 0xa6, 0xe1, /* 0xb0-0xb7 */ 0xfc, 0x00, 0xbc, 0xc8, 0x00, 0x00, 0x00, 0xc0, /* 0xb8-0xbf */ 0xcb, 0xe7, 0xe5, 0xcc, 0x80, 0x81, 0xae, 0x82, /* 0xc0-0xc7 */ 0xe9, 0x83, 0xe6, 0xe8, 0xed, 0xea, 0xeb, 0xec, /* 0xc8-0xcf */ 0x00, 0x84, 0xf1, 0xee, 0xef, 0xcd, 0x85, 0x00, /* 0xd0-0xd7 */ 0xaf, 0xf4, 0xf2, 0xf3, 0x86, 0x00, 0x00, 0xa7, /* 0xd8-0xdf */ 0x88, 0x87, 0x89, 0x8b, 0x8a, 0x8c, 0xbe, 0x8d, /* 0xe0-0xe7 */ 0x8f, 0x8e, 0x90, 0x91, 0x93, 0x92, 0x94, 0x95, /* 0xe8-0xef */ 0x00, 0x96, 0x98, 0x97, 0x99, 0x9b, 0x9a, 0xd6, /* 0xf0-0xf7 */ 0xbf, 0x9d, 0x9c, 0x9e, 0x9f, 0x00, 0x00, 0xd8, /* 0xf8-0xff */ }; static const unsigned char page01[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0xce, 0xcf, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0xd9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; static const unsigned char page02[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xff, /* 0xc0-0xc7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0xf9, 0xfa, 0xfb, 0xfe, 0xf7, 0xfd, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; static const unsigned char page03[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0xb9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; static const unsigned char page20[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0xd0, 0xd1, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0xd4, 0xd5, 0xe2, 0x00, 0xd2, 0xd3, 0xe3, 0x00, /* 0x18-0x1f */ 0xa0, 0xe0, 0xa5, 0x00, 0x00, 0x00, 0xc9, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0xe4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0xdc, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; static const unsigned char page21[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; static const unsigned char page22[256] = { 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, 0xc6, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, /* 0x08-0x0f */ 0x00, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xb0, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0xc5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0xad, 0x00, 0x00, 0x00, 0xb2, 0xb3, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; static const unsigned char page25[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; static const unsigned char pagef8[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, /* 0xf8-0xff */ }; static const unsigned char pagefb[256] = { 0x00, 0xde, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; static const unsigned char *const page_uni2charset[256] = { page00, page01, page02, page03, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, page20, page21, page22, NULL, NULL, page25, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, pagef8, NULL, NULL, pagefb, NULL, NULL, NULL, NULL, }; static const unsigned char charset2lower[256] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x00-0x07 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x08-0x0f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x10-0x17 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x18-0x1f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x20-0x27 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x28-0x2f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x30-0x37 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x38-0x3f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x40-0x47 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x48-0x4f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x50-0x57 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x58-0x5f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x60-0x67 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x68-0x6f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x70-0x77 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x78-0x7f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x80-0x87 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x88-0x8f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x90-0x97 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x98-0x9f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xa0-0xa7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xa8-0xaf */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xb0-0xb7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xb8-0xbf */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xc0-0xc7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xc8-0xcf */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xd0-0xd7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xd8-0xdf */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xe0-0xe7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xe8-0xef */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xf0-0xf7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xf8-0xff */ }; static const unsigned char charset2upper[256] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x00-0x07 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x08-0x0f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x10-0x17 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x18-0x1f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x20-0x27 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x28-0x2f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x30-0x37 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x38-0x3f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x40-0x47 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x48-0x4f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x50-0x57 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x58-0x5f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x60-0x67 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x68-0x6f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x70-0x77 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x78-0x7f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x80-0x87 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x88-0x8f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x90-0x97 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x98-0x9f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xa0-0xa7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xa8-0xaf */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xb0-0xb7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xb8-0xbf */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xc0-0xc7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xc8-0xcf */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xd0-0xd7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xd8-0xdf */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xe0-0xe7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xe8-0xef */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xf0-0xf7 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xf8-0xff */ }; static int uni2char(wchar_t uni, unsigned char *out, int boundlen) { const unsigned char *uni2charset; unsigned char cl = uni & 0x00ff; unsigned char ch = (uni & 0xff00) >> 8; if (boundlen <= 0) return -ENAMETOOLONG; uni2charset = page_uni2charset[ch]; if (uni2charset && uni2charset[cl]) out[0] = uni2charset[cl]; else return -EINVAL; return 1; } static int char2uni(const unsigned char *rawstring, int boundlen, wchar_t *uni) { *uni = charset2uni[*rawstring]; if (*uni == 0x0000) return -EINVAL; return 1; } static struct nls_table table = { .charset = "macroman", .uni2char = uni2char, .char2uni = char2uni, .charset2lower = charset2lower, .charset2upper = charset2upper, }; static int __init init_nls_macroman(void) { return register_nls(&table); } static void __exit exit_nls_macroman(void) { unregister_nls(&table); } module_init(init_nls_macroman) module_exit(exit_nls_macroman) MODULE_LICENSE("Dual BSD/GPL");
gpl-2.0
netico-solutions/linux_3.2.0_android_4.2.2
drivers/usb/host/u132-hcd.c
2935
92948
/* * Host Controller Driver for the Elan Digital Systems U132 adapter * * Copyright(C) 2006 Elan Digital Systems Limited * http://www.elandigitalsystems.com * * Author and Maintainer - Tony Olech - Elan Digital Systems * tony.olech@elandigitalsystems.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, version 2. * * * This driver was written by Tony Olech(tony.olech@elandigitalsystems.com) * based on various USB host drivers in the 2.6.15 linux kernel * with constant reference to the 3rd Edition of Linux Device Drivers * published by O'Reilly * * The U132 adapter is a USB to CardBus adapter specifically designed * for PC cards that contain an OHCI host controller. Typical PC cards * are the Orange Mobile 3G Option GlobeTrotter Fusion card. * * The U132 adapter will *NOT *work with PC cards that do not contain * an OHCI controller. A simple way to test whether a PC card has an * OHCI controller as an interface is to insert the PC card directly * into a laptop(or desktop) with a CardBus slot and if "lspci" shows * a new USB controller and "lsusb -v" shows a new OHCI Host Controller * then there is a good chance that the U132 adapter will support the * PC card.(you also need the specific client driver for the PC card) * * Please inform the Author and Maintainer about any PC cards that * contain OHCI Host Controller and work when directly connected to * an embedded CardBus slot but do not work when they are connected * via an ELAN U132 adapter. * */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/delay.h> #include <linux/ioport.h> #include <linux/pci_ids.h> #include <linux/sched.h> #include <linux/slab.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/timer.h> #include <linux/list.h> #include <linux/interrupt.h> #include <linux/usb.h> #include <linux/usb/hcd.h> #include <linux/workqueue.h> #include <linux/platform_device.h> #include <linux/mutex.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/system.h> #include <asm/byteorder.h> /* FIXME ohci.h is ONLY for internal use by the OHCI driver. * If you're going to try stuff like this, you need to split * out shareable stuff (register declarations?) into its own * file, maybe name <linux/usb/ohci.h> */ #include "ohci.h" #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR #define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ OHCI_INTR_WDH) MODULE_AUTHOR("Tony Olech - Elan Digital Systems Limited"); MODULE_DESCRIPTION("U132 USB Host Controller Driver"); MODULE_LICENSE("GPL"); #define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) INT_MODULE_PARM(testing, 0); /* Some boards misreport power switching/overcurrent*/ static int distrust_firmware = 1; module_param(distrust_firmware, bool, 0); MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" "t setup"); static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); /* * u132_module_lock exists to protect access to global variables * */ static struct mutex u132_module_lock; static int u132_exiting; static int u132_instances; static struct list_head u132_static_list; /* * end of the global variables protected by u132_module_lock */ static struct workqueue_struct *workqueue; #define MAX_U132_PORTS 7 #define MAX_U132_ADDRS 128 #define MAX_U132_UDEVS 4 #define MAX_U132_ENDPS 100 #define MAX_U132_RINGS 4 static const char *cc_to_text[16] = { "No Error ", "CRC Error ", "Bit Stuff ", "Data Togg ", "Stall ", "DevNotResp ", "PIDCheck ", "UnExpPID ", "DataOver ", "DataUnder ", "(for hw) ", "(for hw) ", "BufferOver ", "BuffUnder ", "(for HCD) ", "(for HCD) " }; struct u132_port { struct u132 *u132; int reset; int enable; int power; int Status; }; struct u132_addr { u8 address; }; struct u132_udev { struct kref kref; struct usb_device *usb_device; u8 enumeration; u8 udev_number; u8 usb_addr; u8 portnumber; u8 endp_number_in[16]; u8 endp_number_out[16]; }; #define ENDP_QUEUE_SHIFT 3 #define ENDP_QUEUE_SIZE (1<<ENDP_QUEUE_SHIFT) #define ENDP_QUEUE_MASK (ENDP_QUEUE_SIZE-1) struct u132_urbq { struct list_head urb_more; struct urb *urb; }; struct u132_spin { spinlock_t slock; }; struct u132_endp { struct kref kref; u8 udev_number; u8 endp_number; u8 usb_addr; u8 usb_endp; struct u132 *u132; struct list_head endp_ring; struct u132_ring *ring; unsigned toggle_bits:2; unsigned active:1; unsigned delayed:1; unsigned input:1; unsigned output:1; unsigned pipetype:2; unsigned dequeueing:1; unsigned edset_flush:1; unsigned spare_bits:14; unsigned long jiffies; struct usb_host_endpoint *hep; struct u132_spin queue_lock; u16 queue_size; u16 queue_last; u16 queue_next; struct urb *urb_list[ENDP_QUEUE_SIZE]; struct list_head urb_more; struct delayed_work scheduler; }; struct u132_ring { unsigned in_use:1; unsigned length:7; u8 number; struct u132 *u132; struct u132_endp *curr_endp; struct delayed_work scheduler; }; struct u132 { struct kref kref; struct list_head u132_list; struct mutex sw_lock; struct mutex scheduler_lock; struct u132_platform_data *board; struct platform_device *platform_dev; struct u132_ring ring[MAX_U132_RINGS]; int sequence_num; int going; int power; int reset; int num_ports; u32 hc_control; u32 hc_fminterval; u32 hc_roothub_status; u32 hc_roothub_a; u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; int flags; unsigned long next_statechange; struct delayed_work monitor; int num_endpoints; struct u132_addr addr[MAX_U132_ADDRS]; struct u132_udev udev[MAX_U132_UDEVS]; struct u132_port port[MAX_U132_PORTS]; struct u132_endp *endp[MAX_U132_ENDPS]; }; /* * these cannot be inlines because we need the structure offset!! * Does anyone have a better way????? */ #define ftdi_read_pcimem(pdev, member, data) usb_ftdi_elan_read_pcimem(pdev, \ offsetof(struct ohci_regs, member), 0, data); #define ftdi_write_pcimem(pdev, member, data) usb_ftdi_elan_write_pcimem(pdev, \ offsetof(struct ohci_regs, member), 0, data); #define u132_read_pcimem(u132, member, data) \ usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \ ohci_regs, member), 0, data); #define u132_write_pcimem(u132, member, data) \ usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \ ohci_regs, member), 0, data); static inline struct u132 *udev_to_u132(struct u132_udev *udev) { u8 udev_number = udev->udev_number; return container_of(udev, struct u132, udev[udev_number]); } static inline struct u132 *hcd_to_u132(struct usb_hcd *hcd) { return (struct u132 *)(hcd->hcd_priv); } static inline struct usb_hcd *u132_to_hcd(struct u132 *u132) { return container_of((void *)u132, struct usb_hcd, hcd_priv); } static inline void u132_disable(struct u132 *u132) { u132_to_hcd(u132)->state = HC_STATE_HALT; } #define kref_to_u132(d) container_of(d, struct u132, kref) #define kref_to_u132_endp(d) container_of(d, struct u132_endp, kref) #define kref_to_u132_udev(d) container_of(d, struct u132_udev, kref) #include "../misc/usb_u132.h" static const char hcd_name[] = "u132_hcd"; #define PORT_C_MASK ((USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | \ USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \ USB_PORT_STAT_C_RESET) << 16) static void u132_hcd_delete(struct kref *kref) { struct u132 *u132 = kref_to_u132(kref); struct platform_device *pdev = u132->platform_dev; struct usb_hcd *hcd = u132_to_hcd(u132); u132->going += 1; mutex_lock(&u132_module_lock); list_del_init(&u132->u132_list); u132_instances -= 1; mutex_unlock(&u132_module_lock); dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); usb_put_hcd(hcd); } static inline void u132_u132_put_kref(struct u132 *u132) { kref_put(&u132->kref, u132_hcd_delete); } static inline void u132_u132_init_kref(struct u132 *u132) { kref_init(&u132->kref); } static void u132_udev_delete(struct kref *kref) { struct u132_udev *udev = kref_to_u132_udev(kref); udev->udev_number = 0; udev->usb_device = NULL; udev->usb_addr = 0; udev->enumeration = 0; } static inline void u132_udev_put_kref(struct u132 *u132, struct u132_udev *udev) { kref_put(&udev->kref, u132_udev_delete); } static inline void u132_udev_get_kref(struct u132 *u132, struct u132_udev *udev) { kref_get(&udev->kref); } static inline void u132_udev_init_kref(struct u132 *u132, struct u132_udev *udev) { kref_init(&udev->kref); } static inline void u132_ring_put_kref(struct u132 *u132, struct u132_ring *ring) { kref_put(&u132->kref, u132_hcd_delete); } static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring, unsigned int delta) { if (delta > 0) { if (queue_delayed_work(workqueue, &ring->scheduler, delta)) return; } else if (queue_delayed_work(workqueue, &ring->scheduler, 0)) return; kref_put(&u132->kref, u132_hcd_delete); } static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring, unsigned int delta) { kref_get(&u132->kref); u132_ring_requeue_work(u132, ring, delta); } static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring) { if (cancel_delayed_work(&ring->scheduler)) kref_put(&u132->kref, u132_hcd_delete); } static void u132_endp_delete(struct kref *kref) { struct u132_endp *endp = kref_to_u132_endp(kref); struct u132 *u132 = endp->u132; u8 usb_addr = endp->usb_addr; u8 usb_endp = endp->usb_endp; u8 address = u132->addr[usb_addr].address; struct u132_udev *udev = &u132->udev[address]; u8 endp_number = endp->endp_number; struct usb_host_endpoint *hep = endp->hep; struct u132_ring *ring = endp->ring; struct list_head *head = &endp->endp_ring; ring->length -= 1; if (endp == ring->curr_endp) { if (list_empty(head)) { ring->curr_endp = NULL; list_del(head); } else { struct u132_endp *next_endp = list_entry(head->next, struct u132_endp, endp_ring); ring->curr_endp = next_endp; list_del(head); } } else list_del(head); if (endp->input) { udev->endp_number_in[usb_endp] = 0; u132_udev_put_kref(u132, udev); } if (endp->output) { udev->endp_number_out[usb_endp] = 0; u132_udev_put_kref(u132, udev); } u132->endp[endp_number - 1] = NULL; hep->hcpriv = NULL; kfree(endp); u132_u132_put_kref(u132); } static inline void u132_endp_put_kref(struct u132 *u132, struct u132_endp *endp) { kref_put(&endp->kref, u132_endp_delete); } static inline void u132_endp_get_kref(struct u132 *u132, struct u132_endp *endp) { kref_get(&endp->kref); } static inline void u132_endp_init_kref(struct u132 *u132, struct u132_endp *endp) { kref_init(&endp->kref); kref_get(&u132->kref); } static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, unsigned int delta) { if (queue_delayed_work(workqueue, &endp->scheduler, delta)) kref_get(&endp->kref); } static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) { if (cancel_delayed_work(&endp->scheduler)) kref_put(&endp->kref, u132_endp_delete); } static inline void u132_monitor_put_kref(struct u132 *u132) { kref_put(&u132->kref, u132_hcd_delete); } static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) { if (queue_delayed_work(workqueue, &u132->monitor, delta)) kref_get(&u132->kref); } static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta) { if (!queue_delayed_work(workqueue, &u132->monitor, delta)) kref_put(&u132->kref, u132_hcd_delete); } static void u132_monitor_cancel_work(struct u132 *u132) { if (cancel_delayed_work(&u132->monitor)) kref_put(&u132->kref, u132_hcd_delete); } static int read_roothub_info(struct u132 *u132) { u32 revision; int retval; retval = u132_read_pcimem(u132, revision, &revision); if (retval) { dev_err(&u132->platform_dev->dev, "error %d accessing device co" "ntrol\n", retval); return retval; } else if ((revision & 0xFF) == 0x10) { } else if ((revision & 0xFF) == 0x11) { } else { dev_err(&u132->platform_dev->dev, "device revision is not valid" " %08X\n", revision); return -ENODEV; } retval = u132_read_pcimem(u132, control, &u132->hc_control); if (retval) { dev_err(&u132->platform_dev->dev, "error %d accessing device co" "ntrol\n", retval); return retval; } retval = u132_read_pcimem(u132, roothub.status, &u132->hc_roothub_status); if (retval) { dev_err(&u132->platform_dev->dev, "error %d accessing device re" "g roothub.status\n", retval); return retval; } retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a); if (retval) { dev_err(&u132->platform_dev->dev, "error %d accessing device re" "g roothub.a\n", retval); return retval; } { int I = u132->num_ports; int i = 0; while (I-- > 0) { retval = u132_read_pcimem(u132, roothub.portstatus[i], &u132->hc_roothub_portstatus[i]); if (retval) { dev_err(&u132->platform_dev->dev, "error %d acc" "essing device roothub.portstatus[%d]\n" , retval, i); return retval; } else i += 1; } } return 0; } static void u132_hcd_monitor_work(struct work_struct *work) { struct u132 *u132 = container_of(work, struct u132, monitor.work); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); u132_monitor_put_kref(u132); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed\n"); u132_monitor_put_kref(u132); return; } else { int retval; mutex_lock(&u132->sw_lock); retval = read_roothub_info(u132); if (retval) { struct usb_hcd *hcd = u132_to_hcd(u132); u132_disable(u132); u132->going = 1; mutex_unlock(&u132->sw_lock); usb_hc_died(hcd); ftdi_elan_gone_away(u132->platform_dev); u132_monitor_put_kref(u132); return; } else { u132_monitor_requeue_work(u132, 500); mutex_unlock(&u132->sw_lock); return; } } } static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp, struct urb *urb, int status) { struct u132_ring *ring; unsigned long irqs; struct usb_hcd *hcd = u132_to_hcd(u132); urb->error_count = 0; spin_lock_irqsave(&endp->queue_lock.slock, irqs); usb_hcd_unlink_urb_from_ep(hcd, urb); endp->queue_next += 1; if (ENDP_QUEUE_SIZE > --endp->queue_size) { endp->active = 0; spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); } else { struct list_head *next = endp->urb_more.next; struct u132_urbq *urbq = list_entry(next, struct u132_urbq, urb_more); list_del(next); endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urbq->urb; endp->active = 0; spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); kfree(urbq); } mutex_lock(&u132->scheduler_lock); ring = endp->ring; ring->in_use = 0; u132_ring_cancel_work(u132, ring); u132_ring_queue_work(u132, ring, 0); mutex_unlock(&u132->scheduler_lock); u132_endp_put_kref(u132, endp); usb_hcd_giveback_urb(hcd, urb, status); } static void u132_hcd_forget_urb(struct u132 *u132, struct u132_endp *endp, struct urb *urb, int status) { u132_endp_put_kref(u132, endp); } static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp, struct urb *urb, int status) { unsigned long irqs; struct usb_hcd *hcd = u132_to_hcd(u132); urb->error_count = 0; spin_lock_irqsave(&endp->queue_lock.slock, irqs); usb_hcd_unlink_urb_from_ep(hcd, urb); endp->queue_next += 1; if (ENDP_QUEUE_SIZE > --endp->queue_size) { endp->active = 0; spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); } else { struct list_head *next = endp->urb_more.next; struct u132_urbq *urbq = list_entry(next, struct u132_urbq, urb_more); list_del(next); endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urbq->urb; endp->active = 0; spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); kfree(urbq); } usb_hcd_giveback_urb(hcd, urb, status); } static inline int edset_input(struct u132 *u132, struct u132_ring *ring, struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null)) { return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, urb, address, endp->usb_endp, toggle_bits, callback); } static inline int edset_setup(struct u132 *u132, struct u132_ring *ring, struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null)) { return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp, urb, address, endp->usb_endp, toggle_bits, callback); } static inline int edset_single(struct u132 *u132, struct u132_ring *ring, struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null)) { return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number, endp, urb, address, endp->usb_endp, toggle_bits, callback); } static inline int edset_output(struct u132 *u132, struct u132_ring *ring, struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null)) { return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number, endp, urb, address, endp->usb_endp, toggle_bits, callback); } /* * must not LOCK sw_lock * */ static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; u8 address = u132->addr[endp->usb_addr].address; struct u132_udev *udev = &u132->udev[address]; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { struct u132_ring *ring = endp->ring; u8 *u = urb->transfer_buffer + urb->actual_length; u8 *b = buf; int L = len; while (L-- > 0) *u++ = *b++; urb->actual_length += len; if ((condition_code == TD_CC_NOERROR) && (urb->transfer_buffer_length > urb->actual_length)) { endp->toggle_bits = toggle_bits; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 1 & toggle_bits); if (urb->actual_length > 0) { int retval; mutex_unlock(&u132->scheduler_lock); retval = edset_single(u132, ring, endp, urb, address, endp->toggle_bits, u132_hcd_interrupt_recv); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); } else { ring->in_use = 0; endp->active = 0; endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); u132_ring_cancel_work(u132, ring); u132_ring_queue_work(u132, ring, 0); mutex_unlock(&u132->scheduler_lock); u132_endp_put_kref(u132, endp); } return; } else if ((condition_code == TD_DATAUNDERRUN) && ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { endp->toggle_bits = toggle_bits; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 1 & toggle_bits); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } else { if (condition_code == TD_CC_NOERROR) { endp->toggle_bits = toggle_bits; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 1 & toggle_bits); } else if (condition_code == TD_CC_STALL) { endp->toggle_bits = 0x2; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); } else { endp->toggle_bits = 0x2; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); dev_err(&u132->platform_dev->dev, "urb=%p givin" "g back INTERRUPT %s\n", urb, cc_to_text[condition_code]); } mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, cc_to_error[condition_code]); return; } } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; u8 address = u132->addr[endp->usb_addr].address; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { struct u132_ring *ring = endp->ring; urb->actual_length += len; endp->toggle_bits = toggle_bits; if (urb->transfer_buffer_length > urb->actual_length) { int retval; mutex_unlock(&u132->scheduler_lock); retval = edset_output(u132, ring, endp, urb, address, endp->toggle_bits, u132_hcd_bulk_output_sent); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } else { mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; u8 address = u132->addr[endp->usb_addr].address; struct u132_udev *udev = &u132->udev[address]; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { struct u132_ring *ring = endp->ring; u8 *u = urb->transfer_buffer + urb->actual_length; u8 *b = buf; int L = len; while (L-- > 0) *u++ = *b++; urb->actual_length += len; if ((condition_code == TD_CC_NOERROR) && (urb->transfer_buffer_length > urb->actual_length)) { int retval; endp->toggle_bits = toggle_bits; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 1 & toggle_bits); mutex_unlock(&u132->scheduler_lock); retval = usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, urb, address, endp->usb_endp, endp->toggle_bits, u132_hcd_bulk_input_recv); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } else if (condition_code == TD_CC_NOERROR) { endp->toggle_bits = toggle_bits; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 1 & toggle_bits); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, cc_to_error[condition_code]); return; } else if ((condition_code == TD_DATAUNDERRUN) && ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { endp->toggle_bits = toggle_bits; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 1 & toggle_bits); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } else if (condition_code == TD_DATAUNDERRUN) { endp->toggle_bits = toggle_bits; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 1 & toggle_bits); dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK" ") giving back BULK IN %s\n", urb, cc_to_text[condition_code]); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } else if (condition_code == TD_CC_STALL) { endp->toggle_bits = 0x2; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, cc_to_error[condition_code]); return; } else { endp->toggle_bits = 0x2; usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); dev_err(&u132->platform_dev->dev, "urb=%p giving back B" "ULK IN code=%d %s\n", urb, condition_code, cc_to_text[condition_code]); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, cc_to_error[condition_code]); return; } } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; u8 address = u132->addr[endp->usb_addr].address; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { struct u132_ring *ring = endp->ring; u8 *u = urb->transfer_buffer; u8 *b = buf; int L = len; while (L-- > 0) *u++ = *b++; urb->actual_length = len; if ((condition_code == TD_CC_NOERROR) || ((condition_code == TD_DATAUNDERRUN) && ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0))) { int retval; mutex_unlock(&u132->scheduler_lock); retval = usb_ftdi_elan_edset_empty(u132->platform_dev, ring->number, endp, urb, address, endp->usb_endp, 0x3, u132_hcd_configure_empty_sent); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } else if (condition_code == TD_CC_STALL) { mutex_unlock(&u132->scheduler_lock); dev_warn(&u132->platform_dev->dev, "giving back SETUP I" "NPUT STALL urb %p\n", urb); u132_hcd_giveback_urb(u132, endp, urb, cc_to_error[condition_code]); return; } else { mutex_unlock(&u132->scheduler_lock); dev_err(&u132->platform_dev->dev, "giving back SETUP IN" "PUT %s urb %p\n", cc_to_text[condition_code], urb); u132_hcd_giveback_urb(u132, endp, urb, cc_to_error[condition_code]); return; } } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; u8 address = u132->addr[endp->usb_addr].address; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { if (usb_pipein(urb->pipe)) { int retval; struct u132_ring *ring = endp->ring; mutex_unlock(&u132->scheduler_lock); retval = usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, urb, address, endp->usb_endp, 0, u132_hcd_configure_input_recv); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } else { int retval; struct u132_ring *ring = endp->ring; mutex_unlock(&u132->scheduler_lock); retval = usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, urb, address, endp->usb_endp, 0, u132_hcd_configure_empty_recv); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; u8 address = u132->addr[endp->usb_addr].address; struct u132_udev *udev = &u132->udev[address]; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { u132->addr[0].address = 0; endp->usb_addr = udev->usb_addr; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { int retval; struct u132_ring *ring = endp->ring; mutex_unlock(&u132->scheduler_lock); retval = usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, urb, 0, endp->usb_endp, 0, u132_hcd_enumeration_empty_recv); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; u8 address = u132->addr[endp->usb_addr].address; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { int retval; struct u132_ring *ring = endp->ring; u8 *u = urb->transfer_buffer; u8 *b = buf; int L = len; while (L-- > 0) *u++ = *b++; urb->actual_length = len; mutex_unlock(&u132->scheduler_lock); retval = usb_ftdi_elan_edset_empty(u132->platform_dev, ring->number, endp, urb, address, endp->usb_endp, 0x3, u132_hcd_initial_empty_sent); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, int len, int toggle_bits, int error_count, int condition_code, int repeat_number, int halted, int skipped, int actual, int non_null) { struct u132_endp *endp = data; struct u132 *u132 = endp->u132; u8 address = u132->addr[endp->usb_addr].address; mutex_lock(&u132->scheduler_lock); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); mutex_unlock(&u132->scheduler_lock); u132_hcd_forget_urb(u132, endp, urb, -ENODEV); return; } else if (endp->dequeueing) { endp->dequeueing = 0; mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -EINTR); return; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); return; } else if (!urb->unlinked) { int retval; struct u132_ring *ring = endp->ring; mutex_unlock(&u132->scheduler_lock); retval = usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, urb, address, endp->usb_endp, 0, u132_hcd_initial_input_recv); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } else { dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p " "unlinked=%d\n", urb, urb->unlinked); mutex_unlock(&u132->scheduler_lock); u132_hcd_giveback_urb(u132, endp, urb, 0); return; } } /* * this work function is only executed from the work queue * */ static void u132_hcd_ring_work_scheduler(struct work_struct *work) { struct u132_ring *ring = container_of(work, struct u132_ring, scheduler.work); struct u132 *u132 = ring->u132; mutex_lock(&u132->scheduler_lock); if (ring->in_use) { mutex_unlock(&u132->scheduler_lock); u132_ring_put_kref(u132, ring); return; } else if (ring->curr_endp) { struct u132_endp *last_endp = ring->curr_endp; struct list_head *scan; struct list_head *head = &last_endp->endp_ring; unsigned long wakeup = 0; list_for_each(scan, head) { struct u132_endp *endp = list_entry(scan, struct u132_endp, endp_ring); if (endp->queue_next == endp->queue_last) { } else if ((endp->delayed == 0) || time_after_eq(jiffies, endp->jiffies)) { ring->curr_endp = endp; u132_endp_cancel_work(u132, last_endp); u132_endp_queue_work(u132, last_endp, 0); mutex_unlock(&u132->scheduler_lock); u132_ring_put_kref(u132, ring); return; } else { unsigned long delta = endp->jiffies - jiffies; if (delta > wakeup) wakeup = delta; } } if (last_endp->queue_next == last_endp->queue_last) { } else if ((last_endp->delayed == 0) || time_after_eq(jiffies, last_endp->jiffies)) { u132_endp_cancel_work(u132, last_endp); u132_endp_queue_work(u132, last_endp, 0); mutex_unlock(&u132->scheduler_lock); u132_ring_put_kref(u132, ring); return; } else { unsigned long delta = last_endp->jiffies - jiffies; if (delta > wakeup) wakeup = delta; } if (wakeup > 0) { u132_ring_requeue_work(u132, ring, wakeup); mutex_unlock(&u132->scheduler_lock); return; } else { mutex_unlock(&u132->scheduler_lock); u132_ring_put_kref(u132, ring); return; } } else { mutex_unlock(&u132->scheduler_lock); u132_ring_put_kref(u132, ring); return; } } static void u132_hcd_endp_work_scheduler(struct work_struct *work) { struct u132_ring *ring; struct u132_endp *endp = container_of(work, struct u132_endp, scheduler.work); struct u132 *u132 = endp->u132; mutex_lock(&u132->scheduler_lock); ring = endp->ring; if (endp->edset_flush) { endp->edset_flush = 0; if (endp->dequeueing) usb_ftdi_elan_edset_flush(u132->platform_dev, ring->number, endp); mutex_unlock(&u132->scheduler_lock); u132_endp_put_kref(u132, endp); return; } else if (endp->active) { mutex_unlock(&u132->scheduler_lock); u132_endp_put_kref(u132, endp); return; } else if (ring->in_use) { mutex_unlock(&u132->scheduler_lock); u132_endp_put_kref(u132, endp); return; } else if (endp->queue_next == endp->queue_last) { mutex_unlock(&u132->scheduler_lock); u132_endp_put_kref(u132, endp); return; } else if (endp->pipetype == PIPE_INTERRUPT) { u8 address = u132->addr[endp->usb_addr].address; if (ring->in_use) { mutex_unlock(&u132->scheduler_lock); u132_endp_put_kref(u132, endp); return; } else { int retval; struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]; endp->active = 1; ring->curr_endp = endp; ring->in_use = 1; mutex_unlock(&u132->scheduler_lock); retval = edset_single(u132, ring, endp, urb, address, endp->toggle_bits, u132_hcd_interrupt_recv); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } } else if (endp->pipetype == PIPE_CONTROL) { u8 address = u132->addr[endp->usb_addr].address; if (ring->in_use) { mutex_unlock(&u132->scheduler_lock); u132_endp_put_kref(u132, endp); return; } else if (address == 0) { int retval; struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]; endp->active = 1; ring->curr_endp = endp; ring->in_use = 1; mutex_unlock(&u132->scheduler_lock); retval = edset_setup(u132, ring, endp, urb, address, 0x2, u132_hcd_initial_setup_sent); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } else if (endp->usb_addr == 0) { int retval; struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]; endp->active = 1; ring->curr_endp = endp; ring->in_use = 1; mutex_unlock(&u132->scheduler_lock); retval = edset_setup(u132, ring, endp, urb, 0, 0x2, u132_hcd_enumeration_address_sent); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } else { int retval; struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]; address = u132->addr[endp->usb_addr].address; endp->active = 1; ring->curr_endp = endp; ring->in_use = 1; mutex_unlock(&u132->scheduler_lock); retval = edset_setup(u132, ring, endp, urb, address, 0x2, u132_hcd_configure_setup_sent); if (retval != 0) u132_hcd_giveback_urb(u132, endp, urb, retval); return; } } else { if (endp->input) { u8 address = u132->addr[endp->usb_addr].address; if (ring->in_use) { mutex_unlock(&u132->scheduler_lock); u132_endp_put_kref(u132, endp); return; } else { int retval; struct urb *urb = endp->urb_list[ ENDP_QUEUE_MASK & endp->queue_next]; endp->active = 1; ring->curr_endp = endp; ring->in_use = 1; mutex_unlock(&u132->scheduler_lock); retval = edset_input(u132, ring, endp, urb, address, endp->toggle_bits, u132_hcd_bulk_input_recv); if (retval == 0) { } else u132_hcd_giveback_urb(u132, endp, urb, retval); return; } } else { /* output pipe */ u8 address = u132->addr[endp->usb_addr].address; if (ring->in_use) { mutex_unlock(&u132->scheduler_lock); u132_endp_put_kref(u132, endp); return; } else { int retval; struct urb *urb = endp->urb_list[ ENDP_QUEUE_MASK & endp->queue_next]; endp->active = 1; ring->curr_endp = endp; ring->in_use = 1; mutex_unlock(&u132->scheduler_lock); retval = edset_output(u132, ring, endp, urb, address, endp->toggle_bits, u132_hcd_bulk_output_sent); if (retval == 0) { } else u132_hcd_giveback_urb(u132, endp, urb, retval); return; } } } } #ifdef CONFIG_PM static void port_power(struct u132 *u132, int pn, int is_on) { u132->port[pn].power = is_on; } #endif static void u132_power(struct u132 *u132, int is_on) { struct usb_hcd *hcd = u132_to_hcd(u132) ; /* hub is inactive unless the port is powered */ if (is_on) { if (u132->power) return; u132->power = 1; } else { u132->power = 0; hcd->state = HC_STATE_HALT; } } static int u132_periodic_reinit(struct u132 *u132) { int retval; u32 fi = u132->hc_fminterval & 0x03fff; u32 fit; u32 fminterval; retval = u132_read_pcimem(u132, fminterval, &fminterval); if (retval) return retval; fit = fminterval & FIT; retval = u132_write_pcimem(u132, fminterval, (fit ^ FIT) | u132->hc_fminterval); if (retval) return retval; retval = u132_write_pcimem(u132, periodicstart, ((9 * fi) / 10) & 0x3fff); if (retval) return retval; return 0; } static char *hcfs2string(int state) { switch (state) { case OHCI_USB_RESET: return "reset"; case OHCI_USB_RESUME: return "resume"; case OHCI_USB_OPER: return "operational"; case OHCI_USB_SUSPEND: return "suspend"; } return "?"; } static int u132_init(struct u132 *u132) { int retval; u32 control; u132_disable(u132); u132->next_statechange = jiffies; retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE); if (retval) return retval; retval = u132_read_pcimem(u132, control, &control); if (retval) return retval; if (u132->num_ports == 0) { u32 rh_a = -1; retval = u132_read_pcimem(u132, roothub.a, &rh_a); if (retval) return retval; u132->num_ports = rh_a & RH_A_NDP; retval = read_roothub_info(u132); if (retval) return retval; } if (u132->num_ports > MAX_U132_PORTS) return -EINVAL; return 0; } /* Start an OHCI controller, set the BUS operational * resets USB and controller * enable interrupts */ static int u132_run(struct u132 *u132) { int retval; u32 control; u32 status; u32 fminterval; u32 periodicstart; u32 cmdstatus; u32 roothub_a; int mask = OHCI_INTR_INIT; int first = u132->hc_fminterval == 0; int sleep_time = 0; int reset_timeout = 30; /* ... allow extra time */ u132_disable(u132); if (first) { u32 temp; retval = u132_read_pcimem(u132, fminterval, &temp); if (retval) return retval; u132->hc_fminterval = temp & 0x3fff; u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16; } retval = u132_read_pcimem(u132, control, &u132->hc_control); if (retval) return retval; dev_info(&u132->platform_dev->dev, "resetting from state '%s', control " "= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS), u132->hc_control); switch (u132->hc_control & OHCI_CTRL_HCFS) { case OHCI_USB_OPER: sleep_time = 0; break; case OHCI_USB_SUSPEND: case OHCI_USB_RESUME: u132->hc_control &= OHCI_CTRL_RWC; u132->hc_control |= OHCI_USB_RESUME; sleep_time = 10; break; default: u132->hc_control &= OHCI_CTRL_RWC; u132->hc_control |= OHCI_USB_RESET; sleep_time = 50; break; } retval = u132_write_pcimem(u132, control, u132->hc_control); if (retval) return retval; retval = u132_read_pcimem(u132, control, &control); if (retval) return retval; msleep(sleep_time); retval = u132_read_pcimem(u132, roothub.a, &roothub_a); if (retval) return retval; if (!(roothub_a & RH_A_NPS)) { int temp; /* power down each port */ for (temp = 0; temp < u132->num_ports; temp++) { retval = u132_write_pcimem(u132, roothub.portstatus[temp], RH_PS_LSDA); if (retval) return retval; } } retval = u132_read_pcimem(u132, control, &control); if (retval) return retval; retry: retval = u132_read_pcimem(u132, cmdstatus, &status); if (retval) return retval; retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR); if (retval) return retval; extra: { retval = u132_read_pcimem(u132, cmdstatus, &status); if (retval) return retval; if (0 != (status & OHCI_HCR)) { if (--reset_timeout == 0) { dev_err(&u132->platform_dev->dev, "USB HC reset" " timed out!\n"); return -ENODEV; } else { msleep(5); goto extra; } } } if (u132->flags & OHCI_QUIRK_INITRESET) { retval = u132_write_pcimem(u132, control, u132->hc_control); if (retval) return retval; retval = u132_read_pcimem(u132, control, &control); if (retval) return retval; } retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000); if (retval) return retval; retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000); if (retval) return retval; retval = u132_write_pcimem(u132, hcca, 0x00000000); if (retval) return retval; retval = u132_periodic_reinit(u132); if (retval) return retval; retval = u132_read_pcimem(u132, fminterval, &fminterval); if (retval) return retval; retval = u132_read_pcimem(u132, periodicstart, &periodicstart); if (retval) return retval; if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) { if (!(u132->flags & OHCI_QUIRK_INITRESET)) { u132->flags |= OHCI_QUIRK_INITRESET; goto retry; } else dev_err(&u132->platform_dev->dev, "init err(%08x %04x)" "\n", fminterval, periodicstart); } /* start controller operations */ u132->hc_control &= OHCI_CTRL_RWC; u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER; retval = u132_write_pcimem(u132, control, u132->hc_control); if (retval) return retval; retval = u132_write_pcimem(u132, cmdstatus, OHCI_BLF); if (retval) return retval; retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus); if (retval) return retval; retval = u132_read_pcimem(u132, control, &control); if (retval) return retval; u132_to_hcd(u132)->state = HC_STATE_RUNNING; retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE); if (retval) return retval; retval = u132_write_pcimem(u132, intrstatus, mask); if (retval) return retval; retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO | OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH | OHCI_INTR_SO); if (retval) return retval; /* handle root hub init quirks ... */ retval = u132_read_pcimem(u132, roothub.a, &roothub_a); if (retval) return retval; roothub_a &= ~(RH_A_PSM | RH_A_OCPM); if (u132->flags & OHCI_QUIRK_SUPERIO) { roothub_a |= RH_A_NOCP; roothub_a &= ~(RH_A_POTPGT | RH_A_NPS); retval = u132_write_pcimem(u132, roothub.a, roothub_a); if (retval) return retval; } else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) { roothub_a |= RH_A_NPS; retval = u132_write_pcimem(u132, roothub.a, roothub_a); if (retval) return retval; } retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC); if (retval) return retval; retval = u132_write_pcimem(u132, roothub.b, (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM); if (retval) return retval; retval = u132_read_pcimem(u132, control, &control); if (retval) return retval; mdelay((roothub_a >> 23) & 0x1fe); u132_to_hcd(u132)->state = HC_STATE_RUNNING; return 0; } static void u132_hcd_stop(struct usb_hcd *hcd) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p) has b" "een removed %d\n", u132, hcd, u132->going); } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" "ed\n", hcd); } else { mutex_lock(&u132->sw_lock); msleep(100); u132_power(u132, 0); mutex_unlock(&u132->sw_lock); } } static int u132_hcd_start(struct usb_hcd *hcd) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed\n"); return -ESHUTDOWN; } else if (hcd->self.controller) { int retval; struct platform_device *pdev = to_platform_device(hcd->self.controller); u16 vendor = ((struct u132_platform_data *) (pdev->dev.platform_data))->vendor; u16 device = ((struct u132_platform_data *) (pdev->dev.platform_data))->device; mutex_lock(&u132->sw_lock); msleep(10); if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) { u132->flags = OHCI_QUIRK_AMD756; } else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) { dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar" "ounds unavailable\n"); } else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8) u132->flags |= OHCI_QUIRK_ZFMICRO; retval = u132_run(u132); if (retval) { u132_disable(u132); u132->going = 1; } msleep(100); mutex_unlock(&u132->sw_lock); return retval; } else { dev_err(&u132->platform_dev->dev, "platform_device missing\n"); return -ENODEV; } } static int u132_hcd_reset(struct usb_hcd *hcd) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed\n"); return -ESHUTDOWN; } else { int retval; mutex_lock(&u132->sw_lock); retval = u132_init(u132); if (retval) { u132_disable(u132); u132->going = 1; } mutex_unlock(&u132->sw_lock); return retval; } } static int create_endpoint_and_queue_int(struct u132 *u132, struct u132_udev *udev, struct urb *urb, struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, gfp_t mem_flags) { struct u132_ring *ring; unsigned long irqs; int rc; u8 endp_number; struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); if (!endp) return -ENOMEM; spin_lock_init(&endp->queue_lock.slock); spin_lock_irqsave(&endp->queue_lock.slock, irqs); rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb); if (rc) { spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); kfree(endp); return rc; } endp_number = ++u132->num_endpoints; urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); INIT_LIST_HEAD(&endp->urb_more); ring = endp->ring = &u132->ring[0]; if (ring->curr_endp) { list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); } else { INIT_LIST_HEAD(&endp->endp_ring); ring->curr_endp = endp; } ring->length += 1; endp->dequeueing = 0; endp->edset_flush = 0; endp->active = 0; endp->delayed = 0; endp->endp_number = endp_number; endp->u132 = u132; endp->hep = urb->ep; endp->pipetype = usb_pipetype(urb->pipe); u132_endp_init_kref(u132, endp); if (usb_pipein(urb->pipe)) { endp->toggle_bits = 0x2; usb_settoggle(udev->usb_device, usb_endp, 0, 0); endp->input = 1; endp->output = 0; udev->endp_number_in[usb_endp] = endp_number; u132_udev_get_kref(u132, udev); } else { endp->toggle_bits = 0x2; usb_settoggle(udev->usb_device, usb_endp, 1, 0); endp->input = 0; endp->output = 1; udev->endp_number_out[usb_endp] = endp_number; u132_udev_get_kref(u132, udev); } urb->hcpriv = u132; endp->delayed = 1; endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); endp->udev_number = address; endp->usb_addr = usb_addr; endp->usb_endp = usb_endp; endp->queue_size = 1; endp->queue_last = 0; endp->queue_next = 0; endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval)); return 0; } static int queue_int_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, struct urb *urb, struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, u8 usb_endp, u8 address) { urb->hcpriv = u132; endp->delayed = 1; endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); if (endp->queue_size++ < ENDP_QUEUE_SIZE) { endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; } else { struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); if (urbq == NULL) { endp->queue_size -= 1; return -ENOMEM; } else { list_add_tail(&urbq->urb_more, &endp->urb_more); urbq->urb = urb; } } return 0; } static int create_endpoint_and_queue_bulk(struct u132 *u132, struct u132_udev *udev, struct urb *urb, struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, gfp_t mem_flags) { int ring_number; struct u132_ring *ring; unsigned long irqs; int rc; u8 endp_number; struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); if (!endp) return -ENOMEM; spin_lock_init(&endp->queue_lock.slock); spin_lock_irqsave(&endp->queue_lock.slock, irqs); rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb); if (rc) { spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); kfree(endp); return rc; } endp_number = ++u132->num_endpoints; urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); INIT_LIST_HEAD(&endp->urb_more); endp->dequeueing = 0; endp->edset_flush = 0; endp->active = 0; endp->delayed = 0; endp->endp_number = endp_number; endp->u132 = u132; endp->hep = urb->ep; endp->pipetype = usb_pipetype(urb->pipe); u132_endp_init_kref(u132, endp); if (usb_pipein(urb->pipe)) { endp->toggle_bits = 0x2; usb_settoggle(udev->usb_device, usb_endp, 0, 0); ring_number = 3; endp->input = 1; endp->output = 0; udev->endp_number_in[usb_endp] = endp_number; u132_udev_get_kref(u132, udev); } else { endp->toggle_bits = 0x2; usb_settoggle(udev->usb_device, usb_endp, 1, 0); ring_number = 2; endp->input = 0; endp->output = 1; udev->endp_number_out[usb_endp] = endp_number; u132_udev_get_kref(u132, udev); } ring = endp->ring = &u132->ring[ring_number - 1]; if (ring->curr_endp) { list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); } else { INIT_LIST_HEAD(&endp->endp_ring); ring->curr_endp = endp; } ring->length += 1; urb->hcpriv = u132; endp->udev_number = address; endp->usb_addr = usb_addr; endp->usb_endp = usb_endp; endp->queue_size = 1; endp->queue_last = 0; endp->queue_next = 0; endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); u132_endp_queue_work(u132, endp, 0); return 0; } static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, struct urb *urb, struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, u8 usb_endp, u8 address) { urb->hcpriv = u132; if (endp->queue_size++ < ENDP_QUEUE_SIZE) { endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; } else { struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); if (urbq == NULL) { endp->queue_size -= 1; return -ENOMEM; } else { list_add_tail(&urbq->urb_more, &endp->urb_more); urbq->urb = urb; } } return 0; } static int create_endpoint_and_queue_control(struct u132 *u132, struct urb *urb, struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, gfp_t mem_flags) { struct u132_ring *ring; unsigned long irqs; int rc; u8 endp_number; struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags); if (!endp) return -ENOMEM; spin_lock_init(&endp->queue_lock.slock); spin_lock_irqsave(&endp->queue_lock.slock, irqs); rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb); if (rc) { spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); kfree(endp); return rc; } endp_number = ++u132->num_endpoints; urb->ep->hcpriv = u132->endp[endp_number - 1] = endp; INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler); INIT_LIST_HEAD(&endp->urb_more); ring = endp->ring = &u132->ring[0]; if (ring->curr_endp) { list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); } else { INIT_LIST_HEAD(&endp->endp_ring); ring->curr_endp = endp; } ring->length += 1; endp->dequeueing = 0; endp->edset_flush = 0; endp->active = 0; endp->delayed = 0; endp->endp_number = endp_number; endp->u132 = u132; endp->hep = urb->ep; u132_endp_init_kref(u132, endp); u132_endp_get_kref(u132, endp); if (usb_addr == 0) { u8 address = u132->addr[usb_addr].address; struct u132_udev *udev = &u132->udev[address]; endp->udev_number = address; endp->usb_addr = usb_addr; endp->usb_endp = usb_endp; endp->input = 1; endp->output = 1; endp->pipetype = usb_pipetype(urb->pipe); u132_udev_init_kref(u132, udev); u132_udev_get_kref(u132, udev); udev->endp_number_in[usb_endp] = endp_number; udev->endp_number_out[usb_endp] = endp_number; urb->hcpriv = u132; endp->queue_size = 1; endp->queue_last = 0; endp->queue_next = 0; endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); u132_endp_queue_work(u132, endp, 0); return 0; } else { /*(usb_addr > 0) */ u8 address = u132->addr[usb_addr].address; struct u132_udev *udev = &u132->udev[address]; endp->udev_number = address; endp->usb_addr = usb_addr; endp->usb_endp = usb_endp; endp->input = 1; endp->output = 1; endp->pipetype = usb_pipetype(urb->pipe); u132_udev_get_kref(u132, udev); udev->enumeration = 2; udev->endp_number_in[usb_endp] = endp_number; udev->endp_number_out[usb_endp] = endp_number; urb->hcpriv = u132; endp->queue_size = 1; endp->queue_last = 0; endp->queue_next = 0; endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); u132_endp_queue_work(u132, endp, 0); return 0; } } static int queue_control_on_old_endpoint(struct u132 *u132, struct urb *urb, struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, u8 usb_endp) { if (usb_addr == 0) { if (usb_pipein(urb->pipe)) { urb->hcpriv = u132; if (endp->queue_size++ < ENDP_QUEUE_SIZE) { endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; } else { struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); if (urbq == NULL) { endp->queue_size -= 1; return -ENOMEM; } else { list_add_tail(&urbq->urb_more, &endp->urb_more); urbq->urb = urb; } } return 0; } else { /* usb_pipeout(urb->pipe) */ struct u132_addr *addr = &u132->addr[usb_dev->devnum]; int I = MAX_U132_UDEVS; int i = 0; while (--I > 0) { struct u132_udev *udev = &u132->udev[++i]; if (udev->usb_device) { continue; } else { udev->enumeration = 1; u132->addr[0].address = i; endp->udev_number = i; udev->udev_number = i; udev->usb_addr = usb_dev->devnum; u132_udev_init_kref(u132, udev); udev->endp_number_in[usb_endp] = endp->endp_number; u132_udev_get_kref(u132, udev); udev->endp_number_out[usb_endp] = endp->endp_number; udev->usb_device = usb_dev; ((u8 *) (urb->setup_packet))[2] = addr->address = i; u132_udev_get_kref(u132, udev); break; } } if (I == 0) { dev_err(&u132->platform_dev->dev, "run out of d" "evice space\n"); return -EINVAL; } urb->hcpriv = u132; if (endp->queue_size++ < ENDP_QUEUE_SIZE) { endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; } else { struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); if (urbq == NULL) { endp->queue_size -= 1; return -ENOMEM; } else { list_add_tail(&urbq->urb_more, &endp->urb_more); urbq->urb = urb; } } return 0; } } else { /*(usb_addr > 0) */ u8 address = u132->addr[usb_addr].address; struct u132_udev *udev = &u132->udev[address]; urb->hcpriv = u132; if (udev->enumeration != 2) udev->enumeration = 2; if (endp->queue_size++ < ENDP_QUEUE_SIZE) { endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; } else { struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); if (urbq == NULL) { endp->queue_size -= 1; return -ENOMEM; } else { list_add_tail(&urbq->urb_more, &endp->urb_more); urbq->urb = urb; } } return 0; } } static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) { struct u132 *u132 = hcd_to_u132(hcd); if (irqs_disabled()) { if (__GFP_WAIT & mem_flags) { printk(KERN_ERR "invalid context for function that migh" "t sleep\n"); return -EINVAL; } } if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed " "urb=%p\n", urb); return -ESHUTDOWN; } else { u8 usb_addr = usb_pipedevice(urb->pipe); u8 usb_endp = usb_pipeendpoint(urb->pipe); struct usb_device *usb_dev = urb->dev; if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { u8 address = u132->addr[usb_addr].address; struct u132_udev *udev = &u132->udev[address]; struct u132_endp *endp = urb->ep->hcpriv; urb->actual_length = 0; if (endp) { unsigned long irqs; int retval; spin_lock_irqsave(&endp->queue_lock.slock, irqs); retval = usb_hcd_link_urb_to_ep(hcd, urb); if (retval == 0) { retval = queue_int_on_old_endpoint( u132, udev, urb, usb_dev, endp, usb_addr, usb_endp, address); if (retval) usb_hcd_unlink_urb_from_ep( hcd, urb); } spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); if (retval) { return retval; } else { u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval)) ; return 0; } } else if (u132->num_endpoints == MAX_U132_ENDPS) { return -EINVAL; } else { /*(endp == NULL) */ return create_endpoint_and_queue_int(u132, udev, urb, usb_dev, usb_addr, usb_endp, address, mem_flags); } } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { dev_err(&u132->platform_dev->dev, "the hardware does no" "t support PIPE_ISOCHRONOUS\n"); return -EINVAL; } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { u8 address = u132->addr[usb_addr].address; struct u132_udev *udev = &u132->udev[address]; struct u132_endp *endp = urb->ep->hcpriv; urb->actual_length = 0; if (endp) { unsigned long irqs; int retval; spin_lock_irqsave(&endp->queue_lock.slock, irqs); retval = usb_hcd_link_urb_to_ep(hcd, urb); if (retval == 0) { retval = queue_bulk_on_old_endpoint( u132, udev, urb, usb_dev, endp, usb_addr, usb_endp, address); if (retval) usb_hcd_unlink_urb_from_ep( hcd, urb); } spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); if (retval) { return retval; } else { u132_endp_queue_work(u132, endp, 0); return 0; } } else if (u132->num_endpoints == MAX_U132_ENDPS) { return -EINVAL; } else return create_endpoint_and_queue_bulk(u132, udev, urb, usb_dev, usb_addr, usb_endp, address, mem_flags); } else { struct u132_endp *endp = urb->ep->hcpriv; u16 urb_size = 8; u8 *b = urb->setup_packet; int i = 0; char data[30 * 3 + 4]; char *d = data; int m = (sizeof(data) - 1) / 3; int l = 0; data[0] = 0; while (urb_size-- > 0) { if (i > m) { } else if (i++ < m) { int w = sprintf(d, " %02X", *b++); d += w; l += w; } else d += sprintf(d, " .."); } if (endp) { unsigned long irqs; int retval; spin_lock_irqsave(&endp->queue_lock.slock, irqs); retval = usb_hcd_link_urb_to_ep(hcd, urb); if (retval == 0) { retval = queue_control_on_old_endpoint( u132, urb, usb_dev, endp, usb_addr, usb_endp); if (retval) usb_hcd_unlink_urb_from_ep( hcd, urb); } spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); if (retval) { return retval; } else { u132_endp_queue_work(u132, endp, 0); return 0; } } else if (u132->num_endpoints == MAX_U132_ENDPS) { return -EINVAL; } else return create_endpoint_and_queue_control(u132, urb, usb_dev, usb_addr, usb_endp, mem_flags); } } } static int dequeue_from_overflow_chain(struct u132 *u132, struct u132_endp *endp, struct urb *urb) { struct list_head *scan; struct list_head *head = &endp->urb_more; list_for_each(scan, head) { struct u132_urbq *urbq = list_entry(scan, struct u132_urbq, urb_more); if (urbq->urb == urb) { struct usb_hcd *hcd = u132_to_hcd(u132); list_del(scan); endp->queue_size -= 1; urb->error_count = 0; usb_hcd_giveback_urb(hcd, urb, 0); return 0; } else continue; } dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring" "[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X" "\n", urb, endp->endp_number, endp, endp->ring->number, endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', endp->usb_endp, endp->usb_addr, endp->queue_size, endp->queue_next, endp->queue_last); return -EINVAL; } static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, struct urb *urb, int status) { unsigned long irqs; int rc; spin_lock_irqsave(&endp->queue_lock.slock, irqs); rc = usb_hcd_check_unlink_urb(u132_to_hcd(u132), urb, status); if (rc) { spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); return rc; } if (endp->queue_size == 0) { dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]" "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb, endp->endp_number, endp, endp->ring->number, endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', endp->usb_endp, endp->usb_addr); spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); return -EINVAL; } if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) { if (endp->active) { endp->dequeueing = 1; endp->edset_flush = 1; u132_endp_queue_work(u132, endp, 0); spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); return 0; } else { spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); u132_hcd_abandon_urb(u132, endp, urb, status); return 0; } } else { u16 queue_list = 0; u16 queue_size = endp->queue_size; u16 queue_scan = endp->queue_next; struct urb **urb_slot = NULL; while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { if (urb == endp->urb_list[ENDP_QUEUE_MASK & ++queue_scan]) { urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & queue_scan]; break; } else continue; } while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { *urb_slot = endp->urb_list[ENDP_QUEUE_MASK & ++queue_scan]; urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & queue_scan]; } if (urb_slot) { struct usb_hcd *hcd = u132_to_hcd(u132); usb_hcd_unlink_urb_from_ep(hcd, urb); endp->queue_size -= 1; if (list_empty(&endp->urb_more)) { spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); } else { struct list_head *next = endp->urb_more.next; struct u132_urbq *urbq = list_entry(next, struct u132_urbq, urb_more); list_del(next); *urb_slot = urbq->urb; spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); kfree(urbq); } urb->error_count = 0; usb_hcd_giveback_urb(hcd, urb, status); return 0; } else if (list_empty(&endp->urb_more)) { dev_err(&u132->platform_dev->dev, "urb=%p not found in " "endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr" "=%d size=%d next=%04X last=%04X\n", urb, endp->endp_number, endp, endp->ring->number, endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', endp->usb_endp, endp->usb_addr, endp->queue_size, endp->queue_next, endp->queue_last); spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); return -EINVAL; } else { int retval; usb_hcd_unlink_urb_from_ep(u132_to_hcd(u132), urb); retval = dequeue_from_overflow_chain(u132, endp, urb); spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); return retval; } } } static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 2) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else { u8 usb_addr = usb_pipedevice(urb->pipe); u8 usb_endp = usb_pipeendpoint(urb->pipe); u8 address = u132->addr[usb_addr].address; struct u132_udev *udev = &u132->udev[address]; if (usb_pipein(urb->pipe)) { u8 endp_number = udev->endp_number_in[usb_endp]; struct u132_endp *endp = u132->endp[endp_number - 1]; return u132_endp_urb_dequeue(u132, endp, urb, status); } else { u8 endp_number = udev->endp_number_out[usb_endp]; struct u132_endp *endp = u132->endp[endp_number - 1]; return u132_endp_urb_dequeue(u132, endp, urb, status); } } } static void u132_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 2) { dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p hep=%p" ") has been removed %d\n", u132, hcd, hep, u132->going); } else { struct u132_endp *endp = hep->hcpriv; if (endp) u132_endp_put_kref(u132, endp); } } static int u132_get_frame(struct usb_hcd *hcd) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed\n"); return -ESHUTDOWN; } else { int frame = 0; dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); msleep(100); return frame; } } static int u132_roothub_descriptor(struct u132 *u132, struct usb_hub_descriptor *desc) { int retval; u16 temp; u32 rh_a = -1; u32 rh_b = -1; retval = u132_read_pcimem(u132, roothub.a, &rh_a); if (retval) return retval; desc->bDescriptorType = 0x29; desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24; desc->bHubContrCurrent = 0; desc->bNbrPorts = u132->num_ports; temp = 1 + (u132->num_ports / 8); desc->bDescLength = 7 + 2 * temp; temp = 0; if (rh_a & RH_A_NPS) temp |= 0x0002; if (rh_a & RH_A_PSM) temp |= 0x0001; if (rh_a & RH_A_NOCP) temp |= 0x0010; else if (rh_a & RH_A_OCPM) temp |= 0x0008; desc->wHubCharacteristics = cpu_to_le16(temp); retval = u132_read_pcimem(u132, roothub.b, &rh_b); if (retval) return retval; memset(desc->u.hs.DeviceRemovable, 0xff, sizeof(desc->u.hs.DeviceRemovable)); desc->u.hs.DeviceRemovable[0] = rh_b & RH_B_DR; if (u132->num_ports > 7) { desc->u.hs.DeviceRemovable[1] = (rh_b & RH_B_DR) >> 8; desc->u.hs.DeviceRemovable[2] = 0xff; } else desc->u.hs.DeviceRemovable[1] = 0xff; return 0; } static int u132_roothub_status(struct u132 *u132, __le32 *desc) { u32 rh_status = -1; int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status); *desc = cpu_to_le32(rh_status); return ret_status; } static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex) { if (wIndex == 0 || wIndex > u132->num_ports) { return -EINVAL; } else { int port = wIndex - 1; u32 rh_portstatus = -1; int ret_portstatus = u132_read_pcimem(u132, roothub.portstatus[port], &rh_portstatus); *desc = cpu_to_le32(rh_portstatus); if (*(u16 *) (desc + 2)) { dev_info(&u132->platform_dev->dev, "Port %d Status Chan" "ge = %08X\n", port, *desc); } return ret_portstatus; } } /* this timer value might be vendor-specific ... */ #define PORT_RESET_HW_MSEC 10 #define PORT_RESET_MSEC 10 /* wrap-aware logic morphed from <linux/jiffies.h> */ #define tick_before(t1, t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0) static int u132_roothub_portreset(struct u132 *u132, int port_index) { int retval; u32 fmnumber; u16 now; u16 reset_done; retval = u132_read_pcimem(u132, fmnumber, &fmnumber); if (retval) return retval; now = fmnumber; reset_done = now + PORT_RESET_MSEC; do { u32 portstat; do { retval = u132_read_pcimem(u132, roothub.portstatus[port_index], &portstat); if (retval) return retval; if (RH_PS_PRS & portstat) continue; else break; } while (tick_before(now, reset_done)); if (RH_PS_PRS & portstat) return -ENODEV; if (RH_PS_CCS & portstat) { if (RH_PS_PRSC & portstat) { retval = u132_write_pcimem(u132, roothub.portstatus[port_index], RH_PS_PRSC); if (retval) return retval; } } else break; /* start the next reset, sleep till it's probably done */ retval = u132_write_pcimem(u132, roothub.portstatus[port_index], RH_PS_PRS); if (retval) return retval; msleep(PORT_RESET_HW_MSEC); retval = u132_read_pcimem(u132, fmnumber, &fmnumber); if (retval) return retval; now = fmnumber; } while (tick_before(now, reset_done)); return 0; } static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue, u16 wIndex) { if (wIndex == 0 || wIndex > u132->num_ports) { return -EINVAL; } else { int retval; int port_index = wIndex - 1; struct u132_port *port = &u132->port[port_index]; port->Status &= ~(1 << wValue); switch (wValue) { case USB_PORT_FEAT_SUSPEND: retval = u132_write_pcimem(u132, roothub.portstatus[port_index], RH_PS_PSS); if (retval) return retval; return 0; case USB_PORT_FEAT_POWER: retval = u132_write_pcimem(u132, roothub.portstatus[port_index], RH_PS_PPS); if (retval) return retval; return 0; case USB_PORT_FEAT_RESET: retval = u132_roothub_portreset(u132, port_index); if (retval) return retval; return 0; default: return -EPIPE; } } } static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue, u16 wIndex) { if (wIndex == 0 || wIndex > u132->num_ports) { return -EINVAL; } else { int port_index = wIndex - 1; u32 temp; int retval; struct u132_port *port = &u132->port[port_index]; port->Status &= ~(1 << wValue); switch (wValue) { case USB_PORT_FEAT_ENABLE: temp = RH_PS_CCS; break; case USB_PORT_FEAT_C_ENABLE: temp = RH_PS_PESC; break; case USB_PORT_FEAT_SUSPEND: temp = RH_PS_POCI; if ((u132->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER) { dev_err(&u132->platform_dev->dev, "TODO resume_" "root_hub\n"); } break; case USB_PORT_FEAT_C_SUSPEND: temp = RH_PS_PSSC; break; case USB_PORT_FEAT_POWER: temp = RH_PS_LSDA; break; case USB_PORT_FEAT_C_CONNECTION: temp = RH_PS_CSC; break; case USB_PORT_FEAT_C_OVER_CURRENT: temp = RH_PS_OCIC; break; case USB_PORT_FEAT_C_RESET: temp = RH_PS_PRSC; break; default: return -EPIPE; } retval = u132_write_pcimem(u132, roothub.portstatus[port_index], temp); if (retval) return retval; return 0; } } /* the virtual root hub timer IRQ checks for hub status*/ static int u132_hub_status_data(struct usb_hcd *hcd, char *buf) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov" "ed %d\n", hcd, u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" "ed\n", hcd); return -ESHUTDOWN; } else { int i, changed = 0, length = 1; if (u132->flags & OHCI_QUIRK_AMD756) { if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) { dev_err(&u132->platform_dev->dev, "bogus NDP, r" "ereads as NDP=%d\n", u132->hc_roothub_a & RH_A_NDP); goto done; } } if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC)) buf[0] = changed = 1; else buf[0] = 0; if (u132->num_ports > 7) { buf[1] = 0; length++; } for (i = 0; i < u132->num_ports; i++) { if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC | RH_PS_PRSC)) { changed = 1; if (i < 7) buf[0] |= 1 << (i + 1); else buf[1] |= 1 << (i - 7); continue; } if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS)) continue; if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS)) continue; } done: return changed ? length : 0; } } static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed\n"); return -ESHUTDOWN; } else { int retval = 0; mutex_lock(&u132->sw_lock); switch (typeReq) { case ClearHubFeature: switch (wValue) { case C_HUB_OVER_CURRENT: case C_HUB_LOCAL_POWER: break; default: goto stall; } break; case SetHubFeature: switch (wValue) { case C_HUB_OVER_CURRENT: case C_HUB_LOCAL_POWER: break; default: goto stall; } break; case ClearPortFeature:{ retval = u132_roothub_clearportfeature(u132, wValue, wIndex); if (retval) goto error; break; } case GetHubDescriptor:{ retval = u132_roothub_descriptor(u132, (struct usb_hub_descriptor *)buf); if (retval) goto error; break; } case GetHubStatus:{ retval = u132_roothub_status(u132, (__le32 *) buf); if (retval) goto error; break; } case GetPortStatus:{ retval = u132_roothub_portstatus(u132, (__le32 *) buf, wIndex); if (retval) goto error; break; } case SetPortFeature:{ retval = u132_roothub_setportfeature(u132, wValue, wIndex); if (retval) goto error; break; } default: goto stall; error: u132_disable(u132); u132->going = 1; break; stall: retval = -EPIPE; break; } mutex_unlock(&u132->sw_lock); return retval; } } static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed\n"); return -ESHUTDOWN; } else return 0; } #ifdef CONFIG_PM static int u132_bus_suspend(struct usb_hcd *hcd) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed\n"); return -ESHUTDOWN; } else return 0; } static int u132_bus_resume(struct usb_hcd *hcd) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed\n"); return -ESHUTDOWN; } else return 0; } #else #define u132_bus_suspend NULL #define u132_bus_resume NULL #endif static struct hc_driver u132_hc_driver = { .description = hcd_name, .hcd_priv_size = sizeof(struct u132), .irq = NULL, .flags = HCD_USB11 | HCD_MEMORY, .reset = u132_hcd_reset, .start = u132_hcd_start, .stop = u132_hcd_stop, .urb_enqueue = u132_urb_enqueue, .urb_dequeue = u132_urb_dequeue, .endpoint_disable = u132_endpoint_disable, .get_frame_number = u132_get_frame, .hub_status_data = u132_hub_status_data, .hub_control = u132_hub_control, .bus_suspend = u132_bus_suspend, .bus_resume = u132_bus_resume, .start_port_reset = u132_start_port_reset, }; /* * This function may be called by the USB core whilst the "usb_all_devices_rwsem" * is held for writing, thus this module must not call usb_remove_hcd() * synchronously - but instead should immediately stop activity to the * device and asynchronously call usb_remove_hcd() */ static int __devexit u132_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); if (hcd) { struct u132 *u132 = hcd_to_u132(hcd); if (u132->going++ > 1) { dev_err(&u132->platform_dev->dev, "already being remove" "d\n"); return -ENODEV; } else { int rings = MAX_U132_RINGS; int endps = MAX_U132_ENDPS; dev_err(&u132->platform_dev->dev, "removing device u132" ".%d\n", u132->sequence_num); msleep(100); mutex_lock(&u132->sw_lock); u132_monitor_cancel_work(u132); while (rings-- > 0) { struct u132_ring *ring = &u132->ring[rings]; u132_ring_cancel_work(u132, ring); } while (endps-- > 0) { struct u132_endp *endp = u132->endp[endps]; if (endp) u132_endp_cancel_work(u132, endp); } u132->going += 1; printk(KERN_INFO "removing device u132.%d\n", u132->sequence_num); mutex_unlock(&u132->sw_lock); usb_remove_hcd(hcd); u132_u132_put_kref(u132); return 0; } } else return 0; } static void u132_initialise(struct u132 *u132, struct platform_device *pdev) { int rings = MAX_U132_RINGS; int ports = MAX_U132_PORTS; int addrs = MAX_U132_ADDRS; int udevs = MAX_U132_UDEVS; int endps = MAX_U132_ENDPS; u132->board = pdev->dev.platform_data; u132->platform_dev = pdev; u132->power = 0; u132->reset = 0; mutex_init(&u132->sw_lock); mutex_init(&u132->scheduler_lock); while (rings-- > 0) { struct u132_ring *ring = &u132->ring[rings]; ring->u132 = u132; ring->number = rings + 1; ring->length = 0; ring->curr_endp = NULL; INIT_DELAYED_WORK(&ring->scheduler, u132_hcd_ring_work_scheduler); } mutex_lock(&u132->sw_lock); INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work); while (ports-- > 0) { struct u132_port *port = &u132->port[ports]; port->u132 = u132; port->reset = 0; port->enable = 0; port->power = 0; port->Status = 0; } while (addrs-- > 0) { struct u132_addr *addr = &u132->addr[addrs]; addr->address = 0; } while (udevs-- > 0) { struct u132_udev *udev = &u132->udev[udevs]; int i = ARRAY_SIZE(udev->endp_number_in); int o = ARRAY_SIZE(udev->endp_number_out); udev->usb_device = NULL; udev->udev_number = 0; udev->usb_addr = 0; udev->portnumber = 0; while (i-- > 0) udev->endp_number_in[i] = 0; while (o-- > 0) udev->endp_number_out[o] = 0; } while (endps-- > 0) u132->endp[endps] = NULL; mutex_unlock(&u132->sw_lock); } static int __devinit u132_probe(struct platform_device *pdev) { struct usb_hcd *hcd; int retval; u32 control; u32 rh_a = -1; u32 num_ports; msleep(100); if (u132_exiting > 0) return -ENODEV; retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE); if (retval) return retval; retval = ftdi_read_pcimem(pdev, control, &control); if (retval) return retval; retval = ftdi_read_pcimem(pdev, roothub.a, &rh_a); if (retval) return retval; num_ports = rh_a & RH_A_NDP; /* refuse to confuse usbcore */ if (pdev->dev.dma_mask) return -EINVAL; hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { printk(KERN_ERR "failed to create the usb hcd struct for U132\n" ); ftdi_elan_gone_away(pdev); return -ENOMEM; } else { struct u132 *u132 = hcd_to_u132(hcd); retval = 0; hcd->rsrc_start = 0; mutex_lock(&u132_module_lock); list_add_tail(&u132->u132_list, &u132_static_list); u132->sequence_num = ++u132_instances; mutex_unlock(&u132_module_lock); u132_u132_init_kref(u132); u132_initialise(u132, pdev); hcd->product_desc = "ELAN U132 Host Controller"; retval = usb_add_hcd(hcd, 0, 0); if (retval != 0) { dev_err(&u132->platform_dev->dev, "init error %d\n", retval); u132_u132_put_kref(u132); return retval; } else { u132_monitor_queue_work(u132, 100); return 0; } } } #ifdef CONFIG_PM /* for this device there's no useful distinction between the controller * and its root hub, except that the root hub only gets direct PM calls * when CONFIG_USB_SUSPEND is enabled. */ static int u132_suspend(struct platform_device *pdev, pm_message_t state) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed\n"); return -ESHUTDOWN; } else { int retval = 0, ports; switch (state.event) { case PM_EVENT_FREEZE: retval = u132_bus_suspend(hcd); break; case PM_EVENT_SUSPEND: case PM_EVENT_HIBERNATE: ports = MAX_U132_PORTS; while (ports-- > 0) { port_power(u132, ports, 0); } break; } return retval; } } static int u132_resume(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct u132 *u132 = hcd_to_u132(hcd); if (u132->going > 1) { dev_err(&u132->platform_dev->dev, "device has been removed %d\n" , u132->going); return -ENODEV; } else if (u132->going > 0) { dev_err(&u132->platform_dev->dev, "device is being removed\n"); return -ESHUTDOWN; } else { int retval = 0; if (!u132->port[0].power) { int ports = MAX_U132_PORTS; while (ports-- > 0) { port_power(u132, ports, 1); } retval = 0; } else { retval = u132_bus_resume(hcd); } return retval; } } #else #define u132_suspend NULL #define u132_resume NULL #endif /* * this driver is loaded explicitly by ftdi_u132 * * the platform_driver struct is static because it is per type of module */ static struct platform_driver u132_platform_driver = { .probe = u132_probe, .remove = __devexit_p(u132_remove), .suspend = u132_suspend, .resume = u132_resume, .driver = { .name = (char *)hcd_name, .owner = THIS_MODULE, }, }; static int __init u132_hcd_init(void) { int retval; INIT_LIST_HEAD(&u132_static_list); u132_instances = 0; u132_exiting = 0; mutex_init(&u132_module_lock); if (usb_disabled()) return -ENODEV; printk(KERN_INFO "driver %s\n", hcd_name); workqueue = create_singlethread_workqueue("u132"); retval = platform_driver_register(&u132_platform_driver); return retval; } module_init(u132_hcd_init); static void __exit u132_hcd_exit(void) { struct u132 *u132; struct u132 *temp; mutex_lock(&u132_module_lock); u132_exiting += 1; mutex_unlock(&u132_module_lock); list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) { platform_device_unregister(u132->platform_dev); } platform_driver_unregister(&u132_platform_driver); printk(KERN_INFO "u132-hcd driver deregistered\n"); wait_event(u132_hcd_wait, u132_instances == 0); flush_workqueue(workqueue); destroy_workqueue(workqueue); } module_exit(u132_hcd_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:u132_hcd");
gpl-2.0
gdetal/kernel_omap
net/xfrm/xfrm_output.c
3191
4362
/* * xfrm_output.c - Common IPsec encapsulation code. * * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au> * * 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. */ #include <linux/errno.h> #include <linux/module.h> #include <linux/netdevice.h> #include <linux/netfilter.h> #include <linux/skbuff.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <net/dst.h> #include <net/xfrm.h> static int xfrm_output2(struct sk_buff *skb); static int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb) { struct dst_entry *dst = skb_dst(skb); int nhead = dst->header_len + LL_RESERVED_SPACE(dst->dev) - skb_headroom(skb); int ntail = dst->dev->needed_tailroom - skb_tailroom(skb); if (nhead <= 0) { if (ntail <= 0) return 0; nhead = 0; } else if (ntail < 0) ntail = 0; return pskb_expand_head(skb, nhead, ntail, GFP_ATOMIC); } static int xfrm_output_one(struct sk_buff *skb, int err) { struct dst_entry *dst = skb_dst(skb); struct xfrm_state *x = dst->xfrm; struct net *net = xs_net(x); if (err <= 0) goto resume; do { err = xfrm_state_check_space(x, skb); if (err) { XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR); goto error_nolock; } err = x->outer_mode->output(x, skb); if (err) { XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEMODEERROR); goto error_nolock; } spin_lock_bh(&x->lock); err = xfrm_state_check_expire(x); if (err) { XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEEXPIRED); goto error; } err = x->repl->overflow(x, skb); if (err) { XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATESEQERROR); goto error; } x->curlft.bytes += skb->len; x->curlft.packets++; spin_unlock_bh(&x->lock); skb_dst_force(skb); err = x->type->output(x, skb); if (err == -EINPROGRESS) goto out_exit; resume: if (err) { XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEPROTOERROR); goto error_nolock; } dst = skb_dst_pop(skb); if (!dst) { XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR); err = -EHOSTUNREACH; goto error_nolock; } skb_dst_set(skb, dst); x = dst->xfrm; } while (x && !(x->outer_mode->flags & XFRM_MODE_FLAG_TUNNEL)); err = 0; out_exit: return err; error: spin_unlock_bh(&x->lock); error_nolock: kfree_skb(skb); goto out_exit; } int xfrm_output_resume(struct sk_buff *skb, int err) { while (likely((err = xfrm_output_one(skb, err)) == 0)) { nf_reset(skb); err = skb_dst(skb)->ops->local_out(skb); if (unlikely(err != 1)) goto out; if (!skb_dst(skb)->xfrm) return dst_output(skb); err = nf_hook(skb_dst(skb)->ops->family, NF_INET_POST_ROUTING, skb, NULL, skb_dst(skb)->dev, xfrm_output2); if (unlikely(err != 1)) goto out; } if (err == -EINPROGRESS) err = 0; out: return err; } EXPORT_SYMBOL_GPL(xfrm_output_resume); static int xfrm_output2(struct sk_buff *skb) { return xfrm_output_resume(skb, 1); } static int xfrm_output_gso(struct sk_buff *skb) { struct sk_buff *segs; segs = skb_gso_segment(skb, 0); kfree_skb(skb); if (IS_ERR(segs)) return PTR_ERR(segs); do { struct sk_buff *nskb = segs->next; int err; segs->next = NULL; err = xfrm_output2(segs); if (unlikely(err)) { while ((segs = nskb)) { nskb = segs->next; segs->next = NULL; kfree_skb(segs); } return err; } segs = nskb; } while (segs); return 0; } int xfrm_output(struct sk_buff *skb) { struct net *net = dev_net(skb_dst(skb)->dev); int err; if (skb_is_gso(skb)) return xfrm_output_gso(skb); if (skb->ip_summed == CHECKSUM_PARTIAL) { err = skb_checksum_help(skb); if (err) { XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR); kfree_skb(skb); return err; } } return xfrm_output2(skb); } int xfrm_inner_extract_output(struct xfrm_state *x, struct sk_buff *skb) { struct xfrm_mode *inner_mode; if (x->sel.family == AF_UNSPEC) inner_mode = xfrm_ip2inner_mode(x, xfrm_af2proto(skb_dst(skb)->ops->family)); else inner_mode = x->inner_mode; if (inner_mode == NULL) return -EAFNOSUPPORT; return inner_mode->afinfo->extract_output(x, skb); } EXPORT_SYMBOL_GPL(xfrm_output); EXPORT_SYMBOL_GPL(xfrm_inner_extract_output);
gpl-2.0
daemon32/android_kernel_lge_fx3t
drivers/spi/spi.c
3447
41514
/* * SPI init/core code * * Copyright (C) 2005 David Brownell * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <linux/kernel.h> #include <linux/device.h> #include <linux/init.h> #include <linux/cache.h> #include <linux/mutex.h> #include <linux/of_device.h> #include <linux/slab.h> #include <linux/mod_devicetable.h> #include <linux/spi/spi.h> #include <linux/of_spi.h> #include <linux/pm_runtime.h> #include <linux/export.h> #include <linux/sched.h> #include <linux/delay.h> #include <linux/kthread.h> static void spidev_release(struct device *dev) { struct spi_device *spi = to_spi_device(dev); /* spi masters may cleanup for released devices */ if (spi->master->cleanup) spi->master->cleanup(spi); spi_master_put(spi->master); kfree(spi); } static ssize_t modalias_show(struct device *dev, struct device_attribute *a, char *buf) { const struct spi_device *spi = to_spi_device(dev); return sprintf(buf, "%s\n", spi->modalias); } static struct device_attribute spi_dev_attrs[] = { __ATTR_RO(modalias), __ATTR_NULL, }; /* modalias support makes "modprobe $MODALIAS" new-style hotplug work, * and the sysfs version makes coldplug work too. */ static const struct spi_device_id *spi_match_id(const struct spi_device_id *id, const struct spi_device *sdev) { while (id->name[0]) { if (!strcmp(sdev->modalias, id->name)) return id; id++; } return NULL; } const struct spi_device_id *spi_get_device_id(const struct spi_device *sdev) { const struct spi_driver *sdrv = to_spi_driver(sdev->dev.driver); return spi_match_id(sdrv->id_table, sdev); } EXPORT_SYMBOL_GPL(spi_get_device_id); static int spi_match_device(struct device *dev, struct device_driver *drv) { const struct spi_device *spi = to_spi_device(dev); const struct spi_driver *sdrv = to_spi_driver(drv); /* Attempt an OF style match */ if (of_driver_match_device(dev, drv)) return 1; if (sdrv->id_table) return !!spi_match_id(sdrv->id_table, spi); return strcmp(spi->modalias, drv->name) == 0; } static int spi_uevent(struct device *dev, struct kobj_uevent_env *env) { const struct spi_device *spi = to_spi_device(dev); add_uevent_var(env, "MODALIAS=%s%s", SPI_MODULE_PREFIX, spi->modalias); return 0; } #ifdef CONFIG_PM_SLEEP static int spi_legacy_suspend(struct device *dev, pm_message_t message) { int value = 0; struct spi_driver *drv = to_spi_driver(dev->driver); /* suspend will stop irqs and dma; no more i/o */ if (drv) { if (drv->suspend) value = drv->suspend(to_spi_device(dev), message); else dev_dbg(dev, "... can't suspend\n"); } return value; } static int spi_legacy_resume(struct device *dev) { int value = 0; struct spi_driver *drv = to_spi_driver(dev->driver); /* resume may restart the i/o queue */ if (drv) { if (drv->resume) value = drv->resume(to_spi_device(dev)); else dev_dbg(dev, "... can't resume\n"); } return value; } static int spi_pm_suspend(struct device *dev) { const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; if (pm) return pm_generic_suspend(dev); else return spi_legacy_suspend(dev, PMSG_SUSPEND); } static int spi_pm_resume(struct device *dev) { const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; if (pm) return pm_generic_resume(dev); else return spi_legacy_resume(dev); } static int spi_pm_freeze(struct device *dev) { const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; if (pm) return pm_generic_freeze(dev); else return spi_legacy_suspend(dev, PMSG_FREEZE); } static int spi_pm_thaw(struct device *dev) { const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; if (pm) return pm_generic_thaw(dev); else return spi_legacy_resume(dev); } static int spi_pm_poweroff(struct device *dev) { const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; if (pm) return pm_generic_poweroff(dev); else return spi_legacy_suspend(dev, PMSG_HIBERNATE); } static int spi_pm_restore(struct device *dev) { const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; if (pm) return pm_generic_restore(dev); else return spi_legacy_resume(dev); } #else #define spi_pm_suspend NULL #define spi_pm_resume NULL #define spi_pm_freeze NULL #define spi_pm_thaw NULL #define spi_pm_poweroff NULL #define spi_pm_restore NULL #endif static const struct dev_pm_ops spi_pm = { .suspend = spi_pm_suspend, .resume = spi_pm_resume, .freeze = spi_pm_freeze, .thaw = spi_pm_thaw, .poweroff = spi_pm_poweroff, .restore = spi_pm_restore, SET_RUNTIME_PM_OPS( pm_generic_runtime_suspend, pm_generic_runtime_resume, pm_generic_runtime_idle ) }; struct bus_type spi_bus_type = { .name = "spi", .dev_attrs = spi_dev_attrs, .match = spi_match_device, .uevent = spi_uevent, .pm = &spi_pm, }; EXPORT_SYMBOL_GPL(spi_bus_type); static int spi_drv_probe(struct device *dev) { const struct spi_driver *sdrv = to_spi_driver(dev->driver); return sdrv->probe(to_spi_device(dev)); } static int spi_drv_remove(struct device *dev) { const struct spi_driver *sdrv = to_spi_driver(dev->driver); return sdrv->remove(to_spi_device(dev)); } static void spi_drv_shutdown(struct device *dev) { const struct spi_driver *sdrv = to_spi_driver(dev->driver); sdrv->shutdown(to_spi_device(dev)); } /** * spi_register_driver - register a SPI driver * @sdrv: the driver to register * Context: can sleep */ int spi_register_driver(struct spi_driver *sdrv) { sdrv->driver.bus = &spi_bus_type; if (sdrv->probe) sdrv->driver.probe = spi_drv_probe; if (sdrv->remove) sdrv->driver.remove = spi_drv_remove; if (sdrv->shutdown) sdrv->driver.shutdown = spi_drv_shutdown; return driver_register(&sdrv->driver); } EXPORT_SYMBOL_GPL(spi_register_driver); /*-------------------------------------------------------------------------*/ /* SPI devices should normally not be created by SPI device drivers; that * would make them board-specific. Similarly with SPI master drivers. * Device registration normally goes into like arch/.../mach.../board-YYY.c * with other readonly (flashable) information about mainboard devices. */ struct boardinfo { struct list_head list; struct spi_board_info board_info; }; static LIST_HEAD(board_list); static LIST_HEAD(spi_master_list); /* * Used to protect add/del opertion for board_info list and * spi_master list, and their matching process */ static DEFINE_MUTEX(board_lock); /** * spi_alloc_device - Allocate a new SPI device * @master: Controller to which device is connected * Context: can sleep * * Allows a driver to allocate and initialize a spi_device without * registering it immediately. This allows a driver to directly * fill the spi_device with device parameters before calling * spi_add_device() on it. * * Caller is responsible to call spi_add_device() on the returned * spi_device structure to add it to the SPI master. If the caller * needs to discard the spi_device without adding it, then it should * call spi_dev_put() on it. * * Returns a pointer to the new device, or NULL. */ struct spi_device *spi_alloc_device(struct spi_master *master) { struct spi_device *spi; struct device *dev = master->dev.parent; if (!spi_master_get(master)) return NULL; spi = kzalloc(sizeof *spi, GFP_KERNEL); if (!spi) { dev_err(dev, "cannot alloc spi_device\n"); spi_master_put(master); return NULL; } spi->master = master; spi->dev.parent = &master->dev; spi->dev.bus = &spi_bus_type; spi->dev.release = spidev_release; device_initialize(&spi->dev); return spi; } EXPORT_SYMBOL_GPL(spi_alloc_device); /** * spi_add_device - Add spi_device allocated with spi_alloc_device * @spi: spi_device to register * * Companion function to spi_alloc_device. Devices allocated with * spi_alloc_device can be added onto the spi bus with this function. * * Returns 0 on success; negative errno on failure */ int spi_add_device(struct spi_device *spi) { static DEFINE_MUTEX(spi_add_lock); struct device *dev = spi->master->dev.parent; struct device *d; int status; /* Chipselects are numbered 0..max; validate. */ if (spi->chip_select >= spi->master->num_chipselect) { dev_err(dev, "cs%d >= max %d\n", spi->chip_select, spi->master->num_chipselect); return -EINVAL; } /* Set the bus ID string */ dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->master->dev), spi->chip_select); /* We need to make sure there's no other device with this * chipselect **BEFORE** we call setup(), else we'll trash * its configuration. Lock against concurrent add() calls. */ mutex_lock(&spi_add_lock); d = bus_find_device_by_name(&spi_bus_type, NULL, dev_name(&spi->dev)); if (d != NULL) { dev_err(dev, "chipselect %d already in use\n", spi->chip_select); put_device(d); status = -EBUSY; goto done; } /* Drivers may modify this initial i/o setup, but will * normally rely on the device being setup. Devices * using SPI_CS_HIGH can't coexist well otherwise... */ status = spi_setup(spi); if (status < 0) { dev_err(dev, "can't setup %s, status %d\n", dev_name(&spi->dev), status); goto done; } /* Device may be bound to an active driver when this returns */ status = device_add(&spi->dev); if (status < 0) dev_err(dev, "can't add %s, status %d\n", dev_name(&spi->dev), status); else dev_dbg(dev, "registered child %s\n", dev_name(&spi->dev)); done: mutex_unlock(&spi_add_lock); return status; } EXPORT_SYMBOL_GPL(spi_add_device); /** * spi_new_device - instantiate one new SPI device * @master: Controller to which device is connected * @chip: Describes the SPI device * Context: can sleep * * On typical mainboards, this is purely internal; and it's not needed * after board init creates the hard-wired devices. Some development * platforms may not be able to use spi_register_board_info though, and * this is exported so that for example a USB or parport based adapter * driver could add devices (which it would learn about out-of-band). * * Returns the new device, or NULL. */ struct spi_device *spi_new_device(struct spi_master *master, struct spi_board_info *chip) { struct spi_device *proxy; int status; /* NOTE: caller did any chip->bus_num checks necessary. * * Also, unless we change the return value convention to use * error-or-pointer (not NULL-or-pointer), troubleshootability * suggests syslogged diagnostics are best here (ugh). */ proxy = spi_alloc_device(master); if (!proxy) return NULL; WARN_ON(strlen(chip->modalias) >= sizeof(proxy->modalias)); proxy->chip_select = chip->chip_select; proxy->max_speed_hz = chip->max_speed_hz; proxy->mode = chip->mode; proxy->irq = chip->irq; strlcpy(proxy->modalias, chip->modalias, sizeof(proxy->modalias)); proxy->dev.platform_data = (void *) chip->platform_data; proxy->controller_data = chip->controller_data; proxy->controller_state = NULL; status = spi_add_device(proxy); if (status < 0) { spi_dev_put(proxy); return NULL; } return proxy; } EXPORT_SYMBOL_GPL(spi_new_device); static void spi_match_master_to_boardinfo(struct spi_master *master, struct spi_board_info *bi) { struct spi_device *dev; if (master->bus_num != bi->bus_num) return; dev = spi_new_device(master, bi); if (!dev) dev_err(master->dev.parent, "can't create new device for %s\n", bi->modalias); } /** * spi_register_board_info - register SPI devices for a given board * @info: array of chip descriptors * @n: how many descriptors are provided * Context: can sleep * * Board-specific early init code calls this (probably during arch_initcall) * with segments of the SPI device table. Any device nodes are created later, * after the relevant parent SPI controller (bus_num) is defined. We keep * this table of devices forever, so that reloading a controller driver will * not make Linux forget about these hard-wired devices. * * Other code can also call this, e.g. a particular add-on board might provide * SPI devices through its expansion connector, so code initializing that board * would naturally declare its SPI devices. * * The board info passed can safely be __initdata ... but be careful of * any embedded pointers (platform_data, etc), they're copied as-is. */ int __devinit spi_register_board_info(struct spi_board_info const *info, unsigned n) { struct boardinfo *bi; int i; bi = kzalloc(n * sizeof(*bi), GFP_KERNEL); if (!bi) return -ENOMEM; for (i = 0; i < n; i++, bi++, info++) { struct spi_master *master; memcpy(&bi->board_info, info, sizeof(*info)); mutex_lock(&board_lock); list_add_tail(&bi->list, &board_list); list_for_each_entry(master, &spi_master_list, list) spi_match_master_to_boardinfo(master, &bi->board_info); mutex_unlock(&board_lock); } return 0; } /*-------------------------------------------------------------------------*/ /** * spi_pump_messages - kthread work function which processes spi message queue * @work: pointer to kthread work struct contained in the master struct * * This function checks if there is any spi message in the queue that * needs processing and if so call out to the driver to initialize hardware * and transfer each message. * */ static void spi_pump_messages(struct kthread_work *work) { struct spi_master *master = container_of(work, struct spi_master, pump_messages); unsigned long flags; bool was_busy = false; int ret; /* Lock queue and check for queue work */ spin_lock_irqsave(&master->queue_lock, flags); if (list_empty(&master->queue) || !master->running) { if (master->busy) { ret = master->unprepare_transfer_hardware(master); if (ret) { spin_unlock_irqrestore(&master->queue_lock, flags); dev_err(&master->dev, "failed to unprepare transfer hardware\n"); return; } } master->busy = false; spin_unlock_irqrestore(&master->queue_lock, flags); return; } /* Make sure we are not already running a message */ if (master->cur_msg) { spin_unlock_irqrestore(&master->queue_lock, flags); return; } /* Extract head of queue */ master->cur_msg = list_entry(master->queue.next, struct spi_message, queue); list_del_init(&master->cur_msg->queue); if (master->busy) was_busy = true; else master->busy = true; spin_unlock_irqrestore(&master->queue_lock, flags); if (!was_busy) { ret = master->prepare_transfer_hardware(master); if (ret) { dev_err(&master->dev, "failed to prepare transfer hardware\n"); return; } } ret = master->transfer_one_message(master, master->cur_msg); if (ret) { dev_err(&master->dev, "failed to transfer one message from queue\n"); return; } } static int spi_init_queue(struct spi_master *master) { struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 }; INIT_LIST_HEAD(&master->queue); spin_lock_init(&master->queue_lock); master->running = false; master->busy = false; init_kthread_worker(&master->kworker); master->kworker_task = kthread_run(kthread_worker_fn, &master->kworker, dev_name(&master->dev)); if (IS_ERR(master->kworker_task)) { dev_err(&master->dev, "failed to create message pump task\n"); return -ENOMEM; } init_kthread_work(&master->pump_messages, spi_pump_messages); /* * Master config will indicate if this controller should run the * message pump with high (realtime) priority to reduce the transfer * latency on the bus by minimising the delay between a transfer * request and the scheduling of the message pump thread. Without this * setting the message pump thread will remain at default priority. */ if (master->rt) { dev_info(&master->dev, "will run message pump with realtime priority\n"); sched_setscheduler(master->kworker_task, SCHED_FIFO, &param); } return 0; } /** * spi_get_next_queued_message() - called by driver to check for queued * messages * @master: the master to check for queued messages * * If there are more messages in the queue, the next message is returned from * this call. */ struct spi_message *spi_get_next_queued_message(struct spi_master *master) { struct spi_message *next; unsigned long flags; /* get a pointer to the next message, if any */ spin_lock_irqsave(&master->queue_lock, flags); if (list_empty(&master->queue)) next = NULL; else next = list_entry(master->queue.next, struct spi_message, queue); spin_unlock_irqrestore(&master->queue_lock, flags); return next; } EXPORT_SYMBOL_GPL(spi_get_next_queued_message); /** * spi_finalize_current_message() - the current message is complete * @master: the master to return the message to * * Called by the driver to notify the core that the message in the front of the * queue is complete and can be removed from the queue. */ void spi_finalize_current_message(struct spi_master *master) { struct spi_message *mesg; unsigned long flags; spin_lock_irqsave(&master->queue_lock, flags); mesg = master->cur_msg; master->cur_msg = NULL; queue_kthread_work(&master->kworker, &master->pump_messages); spin_unlock_irqrestore(&master->queue_lock, flags); mesg->state = NULL; if (mesg->complete) mesg->complete(mesg->context); } EXPORT_SYMBOL_GPL(spi_finalize_current_message); static int spi_start_queue(struct spi_master *master) { unsigned long flags; spin_lock_irqsave(&master->queue_lock, flags); if (master->running || master->busy) { spin_unlock_irqrestore(&master->queue_lock, flags); return -EBUSY; } master->running = true; master->cur_msg = NULL; spin_unlock_irqrestore(&master->queue_lock, flags); queue_kthread_work(&master->kworker, &master->pump_messages); return 0; } static int spi_stop_queue(struct spi_master *master) { unsigned long flags; unsigned limit = 500; int ret = 0; spin_lock_irqsave(&master->queue_lock, flags); /* * This is a bit lame, but is optimized for the common execution path. * A wait_queue on the master->busy could be used, but then the common * execution path (pump_messages) would be required to call wake_up or * friends on every SPI message. Do this instead. */ while ((!list_empty(&master->queue) || master->busy) && limit--) { spin_unlock_irqrestore(&master->queue_lock, flags); msleep(10); spin_lock_irqsave(&master->queue_lock, flags); } if (!list_empty(&master->queue) || master->busy) ret = -EBUSY; else master->running = false; spin_unlock_irqrestore(&master->queue_lock, flags); if (ret) { dev_warn(&master->dev, "could not stop message queue\n"); return ret; } return ret; } static int spi_destroy_queue(struct spi_master *master) { int ret; ret = spi_stop_queue(master); /* * flush_kthread_worker will block until all work is done. * If the reason that stop_queue timed out is that the work will never * finish, then it does no good to call flush/stop thread, so * return anyway. */ if (ret) { dev_err(&master->dev, "problem destroying queue\n"); return ret; } flush_kthread_worker(&master->kworker); kthread_stop(master->kworker_task); return 0; } /** * spi_queued_transfer - transfer function for queued transfers * @spi: spi device which is requesting transfer * @msg: spi message which is to handled is queued to driver queue */ static int spi_queued_transfer(struct spi_device *spi, struct spi_message *msg) { struct spi_master *master = spi->master; unsigned long flags; spin_lock_irqsave(&master->queue_lock, flags); if (!master->running) { spin_unlock_irqrestore(&master->queue_lock, flags); return -ESHUTDOWN; } msg->actual_length = 0; msg->status = -EINPROGRESS; list_add_tail(&msg->queue, &master->queue); if (master->running && !master->busy) queue_kthread_work(&master->kworker, &master->pump_messages); spin_unlock_irqrestore(&master->queue_lock, flags); return 0; } static int spi_master_initialize_queue(struct spi_master *master) { int ret; master->queued = true; master->transfer = spi_queued_transfer; /* Initialize and start queue */ ret = spi_init_queue(master); if (ret) { dev_err(&master->dev, "problem initializing queue\n"); goto err_init_queue; } ret = spi_start_queue(master); if (ret) { dev_err(&master->dev, "problem starting queue\n"); goto err_start_queue; } return 0; err_start_queue: err_init_queue: spi_destroy_queue(master); return ret; } /*-------------------------------------------------------------------------*/ static void spi_master_release(struct device *dev) { struct spi_master *master; master = container_of(dev, struct spi_master, dev); kfree(master); } static struct class spi_master_class = { .name = "spi_master", .owner = THIS_MODULE, .dev_release = spi_master_release, }; /** * spi_alloc_master - allocate SPI master controller * @dev: the controller, possibly using the platform_bus * @size: how much zeroed driver-private data to allocate; the pointer to this * memory is in the driver_data field of the returned device, * accessible with spi_master_get_devdata(). * Context: can sleep * * This call is used only by SPI master controller drivers, which are the * only ones directly touching chip registers. It's how they allocate * an spi_master structure, prior to calling spi_register_master(). * * This must be called from context that can sleep. It returns the SPI * master structure on success, else NULL. * * The caller is responsible for assigning the bus number and initializing * the master's methods before calling spi_register_master(); and (after errors * adding the device) calling spi_master_put() and kfree() to prevent a memory * leak. */ struct spi_master *spi_alloc_master(struct device *dev, unsigned size) { struct spi_master *master; if (!dev) return NULL; master = kzalloc(size + sizeof *master, GFP_KERNEL); if (!master) return NULL; device_initialize(&master->dev); master->dev.class = &spi_master_class; master->dev.parent = get_device(dev); spi_master_set_devdata(master, &master[1]); return master; } EXPORT_SYMBOL_GPL(spi_alloc_master); /** * spi_register_master - register SPI master controller * @master: initialized master, originally from spi_alloc_master() * Context: can sleep * * SPI master controllers connect to their drivers using some non-SPI bus, * such as the platform bus. The final stage of probe() in that code * includes calling spi_register_master() to hook up to this SPI bus glue. * * SPI controllers use board specific (often SOC specific) bus numbers, * and board-specific addressing for SPI devices combines those numbers * with chip select numbers. Since SPI does not directly support dynamic * device identification, boards need configuration tables telling which * chip is at which address. * * This must be called from context that can sleep. It returns zero on * success, else a negative error code (dropping the master's refcount). * After a successful return, the caller is responsible for calling * spi_unregister_master(). */ int spi_register_master(struct spi_master *master) { static atomic_t dyn_bus_id = ATOMIC_INIT((1<<15) - 1); struct device *dev = master->dev.parent; struct boardinfo *bi; int status = -ENODEV; int dynamic = 0; if (!dev) return -ENODEV; /* even if it's just one always-selected device, there must * be at least one chipselect */ if (master->num_chipselect == 0) return -EINVAL; /* convention: dynamically assigned bus IDs count down from the max */ if (master->bus_num < 0) { /* FIXME switch to an IDR based scheme, something like * I2C now uses, so we can't run out of "dynamic" IDs */ master->bus_num = atomic_dec_return(&dyn_bus_id); dynamic = 1; } spin_lock_init(&master->bus_lock_spinlock); mutex_init(&master->bus_lock_mutex); master->bus_lock_flag = 0; /* register the device, then userspace will see it. * registration fails if the bus ID is in use. */ dev_set_name(&master->dev, "spi%u", master->bus_num); status = device_add(&master->dev); if (status < 0) goto done; dev_dbg(dev, "registered master %s%s\n", dev_name(&master->dev), dynamic ? " (dynamic)" : ""); /* If we're using a queued driver, start the queue */ if (master->transfer) dev_info(dev, "master is unqueued, this is deprecated\n"); else { status = spi_master_initialize_queue(master); if (status) { device_unregister(&master->dev); goto done; } } mutex_lock(&board_lock); list_add_tail(&master->list, &spi_master_list); list_for_each_entry(bi, &board_list, list) spi_match_master_to_boardinfo(master, &bi->board_info); mutex_unlock(&board_lock); /* Register devices from the device tree */ of_register_spi_devices(master); done: return status; } EXPORT_SYMBOL_GPL(spi_register_master); static int __unregister(struct device *dev, void *null) { spi_unregister_device(to_spi_device(dev)); return 0; } /** * spi_unregister_master - unregister SPI master controller * @master: the master being unregistered * Context: can sleep * * This call is used only by SPI master controller drivers, which are the * only ones directly touching chip registers. * * This must be called from context that can sleep. */ void spi_unregister_master(struct spi_master *master) { int dummy; if (master->queued) { if (spi_destroy_queue(master)) dev_err(&master->dev, "queue remove failed\n"); } mutex_lock(&board_lock); list_del(&master->list); mutex_unlock(&board_lock); dummy = device_for_each_child(&master->dev, NULL, __unregister); device_unregister(&master->dev); } EXPORT_SYMBOL_GPL(spi_unregister_master); int spi_master_suspend(struct spi_master *master) { int ret; /* Basically no-ops for non-queued masters */ if (!master->queued) return 0; ret = spi_stop_queue(master); if (ret) dev_err(&master->dev, "queue stop failed\n"); return ret; } EXPORT_SYMBOL_GPL(spi_master_suspend); int spi_master_resume(struct spi_master *master) { int ret; if (!master->queued) return 0; ret = spi_start_queue(master); if (ret) dev_err(&master->dev, "queue restart failed\n"); return ret; } EXPORT_SYMBOL_GPL(spi_master_resume); static int __spi_master_match(struct device *dev, void *data) { struct spi_master *m; u16 *bus_num = data; m = container_of(dev, struct spi_master, dev); return m->bus_num == *bus_num; } /** * spi_busnum_to_master - look up master associated with bus_num * @bus_num: the master's bus number * Context: can sleep * * This call may be used with devices that are registered after * arch init time. It returns a refcounted pointer to the relevant * spi_master (which the caller must release), or NULL if there is * no such master registered. */ struct spi_master *spi_busnum_to_master(u16 bus_num) { struct device *dev; struct spi_master *master = NULL; dev = class_find_device(&spi_master_class, NULL, &bus_num, __spi_master_match); if (dev) master = container_of(dev, struct spi_master, dev); /* reference got in class_find_device */ return master; } EXPORT_SYMBOL_GPL(spi_busnum_to_master); /*-------------------------------------------------------------------------*/ /* Core methods for SPI master protocol drivers. Some of the * other core methods are currently defined as inline functions. */ /** * spi_setup - setup SPI mode and clock rate * @spi: the device whose settings are being modified * Context: can sleep, and no requests are queued to the device * * SPI protocol drivers may need to update the transfer mode if the * device doesn't work with its default. They may likewise need * to update clock rates or word sizes from initial values. This function * changes those settings, and must be called from a context that can sleep. * Except for SPI_CS_HIGH, which takes effect immediately, the changes take * effect the next time the device is selected and data is transferred to * or from it. When this function returns, the spi device is deselected. * * Note that this call will fail if the protocol driver specifies an option * that the underlying controller or its driver does not support. For * example, not all hardware supports wire transfers using nine bit words, * LSB-first wire encoding, or active-high chipselects. */ int spi_setup(struct spi_device *spi) { unsigned bad_bits; int status; /* help drivers fail *cleanly* when they need options * that aren't supported with their current master */ bad_bits = spi->mode & ~spi->master->mode_bits; if (bad_bits) { dev_err(&spi->dev, "setup: unsupported mode bits %x\n", bad_bits); return -EINVAL; } if (!spi->bits_per_word) spi->bits_per_word = 8; status = spi->master->setup(spi); dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s" "%u bits/w, %u Hz max --> %d\n", (int) (spi->mode & (SPI_CPOL | SPI_CPHA)), (spi->mode & SPI_CS_HIGH) ? "cs_high, " : "", (spi->mode & SPI_LSB_FIRST) ? "lsb, " : "", (spi->mode & SPI_3WIRE) ? "3wire, " : "", (spi->mode & SPI_LOOP) ? "loopback, " : "", spi->bits_per_word, spi->max_speed_hz, status); return status; } EXPORT_SYMBOL_GPL(spi_setup); static int __spi_async(struct spi_device *spi, struct spi_message *message) { struct spi_master *master = spi->master; /* Half-duplex links include original MicroWire, and ones with * only one data pin like SPI_3WIRE (switches direction) or where * either MOSI or MISO is missing. They can also be caused by * software limitations. */ if ((master->flags & SPI_MASTER_HALF_DUPLEX) || (spi->mode & SPI_3WIRE)) { struct spi_transfer *xfer; unsigned flags = master->flags; list_for_each_entry(xfer, &message->transfers, transfer_list) { if (xfer->rx_buf && xfer->tx_buf) return -EINVAL; if ((flags & SPI_MASTER_NO_TX) && xfer->tx_buf) return -EINVAL; if ((flags & SPI_MASTER_NO_RX) && xfer->rx_buf) return -EINVAL; } } message->spi = spi; message->status = -EINPROGRESS; return master->transfer(spi, message); } /** * spi_async - asynchronous SPI transfer * @spi: device with which data will be exchanged * @message: describes the data transfers, including completion callback * Context: any (irqs may be blocked, etc) * * This call may be used in_irq and other contexts which can't sleep, * as well as from task contexts which can sleep. * * The completion callback is invoked in a context which can't sleep. * Before that invocation, the value of message->status is undefined. * When the callback is issued, message->status holds either zero (to * indicate complete success) or a negative error code. After that * callback returns, the driver which issued the transfer request may * deallocate the associated memory; it's no longer in use by any SPI * core or controller driver code. * * Note that although all messages to a spi_device are handled in * FIFO order, messages may go to different devices in other orders. * Some device might be higher priority, or have various "hard" access * time requirements, for example. * * On detection of any fault during the transfer, processing of * the entire message is aborted, and the device is deselected. * Until returning from the associated message completion callback, * no other spi_message queued to that device will be processed. * (This rule applies equally to all the synchronous transfer calls, * which are wrappers around this core asynchronous primitive.) */ int spi_async(struct spi_device *spi, struct spi_message *message) { struct spi_master *master = spi->master; int ret; unsigned long flags; spin_lock_irqsave(&master->bus_lock_spinlock, flags); if (master->bus_lock_flag) ret = -EBUSY; else ret = __spi_async(spi, message); spin_unlock_irqrestore(&master->bus_lock_spinlock, flags); return ret; } EXPORT_SYMBOL_GPL(spi_async); /** * spi_async_locked - version of spi_async with exclusive bus usage * @spi: device with which data will be exchanged * @message: describes the data transfers, including completion callback * Context: any (irqs may be blocked, etc) * * This call may be used in_irq and other contexts which can't sleep, * as well as from task contexts which can sleep. * * The completion callback is invoked in a context which can't sleep. * Before that invocation, the value of message->status is undefined. * When the callback is issued, message->status holds either zero (to * indicate complete success) or a negative error code. After that * callback returns, the driver which issued the transfer request may * deallocate the associated memory; it's no longer in use by any SPI * core or controller driver code. * * Note that although all messages to a spi_device are handled in * FIFO order, messages may go to different devices in other orders. * Some device might be higher priority, or have various "hard" access * time requirements, for example. * * On detection of any fault during the transfer, processing of * the entire message is aborted, and the device is deselected. * Until returning from the associated message completion callback, * no other spi_message queued to that device will be processed. * (This rule applies equally to all the synchronous transfer calls, * which are wrappers around this core asynchronous primitive.) */ int spi_async_locked(struct spi_device *spi, struct spi_message *message) { struct spi_master *master = spi->master; int ret; unsigned long flags; spin_lock_irqsave(&master->bus_lock_spinlock, flags); ret = __spi_async(spi, message); spin_unlock_irqrestore(&master->bus_lock_spinlock, flags); return ret; } EXPORT_SYMBOL_GPL(spi_async_locked); /*-------------------------------------------------------------------------*/ /* Utility methods for SPI master protocol drivers, layered on * top of the core. Some other utility methods are defined as * inline functions. */ static void spi_complete(void *arg) { complete(arg); } static int __spi_sync(struct spi_device *spi, struct spi_message *message, int bus_locked) { DECLARE_COMPLETION_ONSTACK(done); int status; struct spi_master *master = spi->master; message->complete = spi_complete; message->context = &done; if (!bus_locked) mutex_lock(&master->bus_lock_mutex); status = spi_async_locked(spi, message); if (!bus_locked) mutex_unlock(&master->bus_lock_mutex); if (status == 0) { wait_for_completion(&done); status = message->status; } message->context = NULL; return status; } /** * spi_sync - blocking/synchronous SPI data transfers * @spi: device with which data will be exchanged * @message: describes the data transfers * Context: can sleep * * This call may only be used from a context that may sleep. The sleep * is non-interruptible, and has no timeout. Low-overhead controller * drivers may DMA directly into and out of the message buffers. * * Note that the SPI device's chip select is active during the message, * and then is normally disabled between messages. Drivers for some * frequently-used devices may want to minimize costs of selecting a chip, * by leaving it selected in anticipation that the next message will go * to the same chip. (That may increase power usage.) * * Also, the caller is guaranteeing that the memory associated with the * message will not be freed before this call returns. * * It returns zero on success, else a negative error code. */ int spi_sync(struct spi_device *spi, struct spi_message *message) { return __spi_sync(spi, message, 0); } EXPORT_SYMBOL_GPL(spi_sync); /** * spi_sync_locked - version of spi_sync with exclusive bus usage * @spi: device with which data will be exchanged * @message: describes the data transfers * Context: can sleep * * This call may only be used from a context that may sleep. The sleep * is non-interruptible, and has no timeout. Low-overhead controller * drivers may DMA directly into and out of the message buffers. * * This call should be used by drivers that require exclusive access to the * SPI bus. It has to be preceded by a spi_bus_lock call. The SPI bus must * be released by a spi_bus_unlock call when the exclusive access is over. * * It returns zero on success, else a negative error code. */ int spi_sync_locked(struct spi_device *spi, struct spi_message *message) { return __spi_sync(spi, message, 1); } EXPORT_SYMBOL_GPL(spi_sync_locked); /** * spi_bus_lock - obtain a lock for exclusive SPI bus usage * @master: SPI bus master that should be locked for exclusive bus access * Context: can sleep * * This call may only be used from a context that may sleep. The sleep * is non-interruptible, and has no timeout. * * This call should be used by drivers that require exclusive access to the * SPI bus. The SPI bus must be released by a spi_bus_unlock call when the * exclusive access is over. Data transfer must be done by spi_sync_locked * and spi_async_locked calls when the SPI bus lock is held. * * It returns zero on success, else a negative error code. */ int spi_bus_lock(struct spi_master *master) { unsigned long flags; mutex_lock(&master->bus_lock_mutex); spin_lock_irqsave(&master->bus_lock_spinlock, flags); master->bus_lock_flag = 1; spin_unlock_irqrestore(&master->bus_lock_spinlock, flags); /* mutex remains locked until spi_bus_unlock is called */ return 0; } EXPORT_SYMBOL_GPL(spi_bus_lock); /** * spi_bus_unlock - release the lock for exclusive SPI bus usage * @master: SPI bus master that was locked for exclusive bus access * Context: can sleep * * This call may only be used from a context that may sleep. The sleep * is non-interruptible, and has no timeout. * * This call releases an SPI bus lock previously obtained by an spi_bus_lock * call. * * It returns zero on success, else a negative error code. */ int spi_bus_unlock(struct spi_master *master) { master->bus_lock_flag = 0; mutex_unlock(&master->bus_lock_mutex); return 0; } EXPORT_SYMBOL_GPL(spi_bus_unlock); /* portable code must never pass more than 32 bytes */ #define SPI_BUFSIZ max(32,SMP_CACHE_BYTES) static u8 *buf; /** * spi_write_then_read - SPI synchronous write followed by read * @spi: device with which data will be exchanged * @txbuf: data to be written (need not be dma-safe) * @n_tx: size of txbuf, in bytes * @rxbuf: buffer into which data will be read (need not be dma-safe) * @n_rx: size of rxbuf, in bytes * Context: can sleep * * This performs a half duplex MicroWire style transaction with the * device, sending txbuf and then reading rxbuf. The return value * is zero for success, else a negative errno status code. * This call may only be used from a context that may sleep. * * Parameters to this routine are always copied using a small buffer; * portable code should never use this for more than 32 bytes. * Performance-sensitive or bulk transfer code should instead use * spi_{async,sync}() calls with dma-safe buffers. */ int spi_write_then_read(struct spi_device *spi, const void *txbuf, unsigned n_tx, void *rxbuf, unsigned n_rx) { static DEFINE_MUTEX(lock); int status; struct spi_message message; struct spi_transfer x[2]; u8 *local_buf; /* Use preallocated DMA-safe buffer. We can't avoid copying here, * (as a pure convenience thing), but we can keep heap costs * out of the hot path ... */ if ((n_tx + n_rx) > SPI_BUFSIZ) return -EINVAL; spi_message_init(&message); memset(x, 0, sizeof x); if (n_tx) { x[0].len = n_tx; spi_message_add_tail(&x[0], &message); } if (n_rx) { x[1].len = n_rx; spi_message_add_tail(&x[1], &message); } /* ... unless someone else is using the pre-allocated buffer */ if (!mutex_trylock(&lock)) { local_buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL); if (!local_buf) return -ENOMEM; } else local_buf = buf; memcpy(local_buf, txbuf, n_tx); x[0].tx_buf = local_buf; x[1].rx_buf = local_buf + n_tx; /* do the i/o */ status = spi_sync(spi, &message); if (status == 0) memcpy(rxbuf, x[1].rx_buf, n_rx); if (x[0].tx_buf == buf) mutex_unlock(&lock); else kfree(local_buf); return status; } EXPORT_SYMBOL_GPL(spi_write_then_read); /*-------------------------------------------------------------------------*/ static int __init spi_init(void) { int status; buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL); if (!buf) { status = -ENOMEM; goto err0; } status = bus_register(&spi_bus_type); if (status < 0) goto err1; status = class_register(&spi_master_class); if (status < 0) goto err2; return 0; err2: bus_unregister(&spi_bus_type); err1: kfree(buf); buf = NULL; err0: return status; } /* board_info is normally registered in arch_initcall(), * but even essential drivers wait till later * * REVISIT only boardinfo really needs static linking. the rest (device and * driver registration) _could_ be dynamically linked (modular) ... costs * include needing to have boardinfo data structures be much more public. */ postcore_initcall(spi_init);
gpl-2.0
mlachwani/Android-4.4.2-Manta-Kernel
sound/soc/imx/imx-ssi.c
3959
16986
/* * imx-ssi.c -- ALSA Soc Audio Layer * * Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de> * * This code is based on code copyrighted by Freescale, * Liam Girdwood, Javier Martin and probably others. * * 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. * * * The i.MX SSI core has some nasty limitations in AC97 mode. While most * sane processor vendors have a FIFO per AC97 slot, the i.MX has only * one FIFO which combines all valid receive slots. We cannot even select * which slots we want to receive. The WM9712 with which this driver * was developed with always sends GPIO status data in slot 12 which * we receive in our (PCM-) data stream. The only chance we have is to * manually skip this data in the FIQ handler. With sampling rates different * from 48000Hz not every frame has valid receive data, so the ratio * between pcm data and GPIO status data changes. Our FIQ handler is not * able to handle this, hence this driver only works with 48000Hz sampling * rate. * Reading and writing AC97 registers is another challenge. The core * provides us status bits when the read register is updated with *another* * value. When we read the same register two times (and the register still * contains the same value) these status bits are not set. We work * around this by not polling these bits but only wait a fixed delay. * */ #include <linux/clk.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/dma-mapping.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <sound/core.h> #include <sound/initval.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> #include <mach/ssi.h> #include <mach/hardware.h> #include "imx-ssi.h" #define SSI_SACNT_DEFAULT (SSI_SACNT_AC97EN | SSI_SACNT_FV) /* * SSI Network Mode or TDM slots configuration. * Should only be called when port is inactive (i.e. SSIEN = 0). */ static int imx_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { struct imx_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai); u32 sccr; sccr = readl(ssi->base + SSI_STCCR); sccr &= ~SSI_STCCR_DC_MASK; sccr |= SSI_STCCR_DC(slots - 1); writel(sccr, ssi->base + SSI_STCCR); sccr = readl(ssi->base + SSI_SRCCR); sccr &= ~SSI_STCCR_DC_MASK; sccr |= SSI_STCCR_DC(slots - 1); writel(sccr, ssi->base + SSI_SRCCR); writel(tx_mask, ssi->base + SSI_STMSK); writel(rx_mask, ssi->base + SSI_SRMSK); return 0; } /* * SSI DAI format configuration. * Should only be called when port is inactive (i.e. SSIEN = 0). */ static int imx_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { struct imx_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai); u32 strcr = 0, scr; scr = readl(ssi->base + SSI_SCR) & ~(SSI_SCR_SYN | SSI_SCR_NET); /* DAI mode */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: /* data on rising edge of bclk, frame low 1clk before data */ strcr |= SSI_STCR_TFSI | SSI_STCR_TEFS | SSI_STCR_TXBIT0; scr |= SSI_SCR_NET; if (ssi->flags & IMX_SSI_USE_I2S_SLAVE) { scr &= ~SSI_I2S_MODE_MASK; scr |= SSI_SCR_I2S_MODE_SLAVE; } break; case SND_SOC_DAIFMT_LEFT_J: /* data on rising edge of bclk, frame high with data */ strcr |= SSI_STCR_TXBIT0; break; case SND_SOC_DAIFMT_DSP_B: /* data on rising edge of bclk, frame high with data */ strcr |= SSI_STCR_TFSL | SSI_STCR_TXBIT0; break; case SND_SOC_DAIFMT_DSP_A: /* data on rising edge of bclk, frame high 1clk before data */ strcr |= SSI_STCR_TFSL | SSI_STCR_TXBIT0 | SSI_STCR_TEFS; break; } /* DAI clock inversion */ switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_IB_IF: strcr |= SSI_STCR_TFSI; strcr &= ~SSI_STCR_TSCKP; break; case SND_SOC_DAIFMT_IB_NF: strcr &= ~(SSI_STCR_TSCKP | SSI_STCR_TFSI); break; case SND_SOC_DAIFMT_NB_IF: strcr |= SSI_STCR_TFSI | SSI_STCR_TSCKP; break; case SND_SOC_DAIFMT_NB_NF: strcr &= ~SSI_STCR_TFSI; strcr |= SSI_STCR_TSCKP; break; } /* DAI clock master masks */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: break; default: /* Master mode not implemented, needs handling of clocks. */ return -EINVAL; } strcr |= SSI_STCR_TFEN0; if (ssi->flags & IMX_SSI_NET) scr |= SSI_SCR_NET; if (ssi->flags & IMX_SSI_SYN) scr |= SSI_SCR_SYN; writel(strcr, ssi->base + SSI_STCR); writel(strcr, ssi->base + SSI_SRCR); writel(scr, ssi->base + SSI_SCR); return 0; } /* * SSI system clock configuration. * Should only be called when port is inactive (i.e. SSIEN = 0). */ static int imx_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int dir) { struct imx_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai); u32 scr; scr = readl(ssi->base + SSI_SCR); switch (clk_id) { case IMX_SSP_SYS_CLK: if (dir == SND_SOC_CLOCK_OUT) scr |= SSI_SCR_SYS_CLK_EN; else scr &= ~SSI_SCR_SYS_CLK_EN; break; default: return -EINVAL; } writel(scr, ssi->base + SSI_SCR); return 0; } /* * SSI Clock dividers * Should only be called when port is inactive (i.e. SSIEN = 0). */ static int imx_ssi_set_dai_clkdiv(struct snd_soc_dai *cpu_dai, int div_id, int div) { struct imx_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai); u32 stccr, srccr; stccr = readl(ssi->base + SSI_STCCR); srccr = readl(ssi->base + SSI_SRCCR); switch (div_id) { case IMX_SSI_TX_DIV_2: stccr &= ~SSI_STCCR_DIV2; stccr |= div; break; case IMX_SSI_TX_DIV_PSR: stccr &= ~SSI_STCCR_PSR; stccr |= div; break; case IMX_SSI_TX_DIV_PM: stccr &= ~0xff; stccr |= SSI_STCCR_PM(div); break; case IMX_SSI_RX_DIV_2: stccr &= ~SSI_STCCR_DIV2; stccr |= div; break; case IMX_SSI_RX_DIV_PSR: stccr &= ~SSI_STCCR_PSR; stccr |= div; break; case IMX_SSI_RX_DIV_PM: stccr &= ~0xff; stccr |= SSI_STCCR_PM(div); break; default: return -EINVAL; } writel(stccr, ssi->base + SSI_STCCR); writel(srccr, ssi->base + SSI_SRCCR); return 0; } static int imx_ssi_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct imx_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai); struct imx_pcm_dma_params *dma_data; /* Tx/Rx config */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) dma_data = &ssi->dma_params_tx; else dma_data = &ssi->dma_params_rx; snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data); return 0; } /* * Should only be called when port is inactive (i.e. SSIEN = 0), * although can be called multiple times by upper layers. */ static int imx_ssi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *cpu_dai) { struct imx_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai); u32 reg, sccr; /* Tx/Rx config */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) reg = SSI_STCCR; else reg = SSI_SRCCR; if (ssi->flags & IMX_SSI_SYN) reg = SSI_STCCR; sccr = readl(ssi->base + reg) & ~SSI_STCCR_WL_MASK; /* DAI data (word) size */ switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: sccr |= SSI_SRCCR_WL(16); break; case SNDRV_PCM_FORMAT_S20_3LE: sccr |= SSI_SRCCR_WL(20); break; case SNDRV_PCM_FORMAT_S24_LE: sccr |= SSI_SRCCR_WL(24); break; } writel(sccr, ssi->base + reg); return 0; } static int imx_ssi_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct imx_ssi *ssi = snd_soc_dai_get_drvdata(dai); unsigned int sier_bits, sier; unsigned int scr; scr = readl(ssi->base + SSI_SCR); sier = readl(ssi->base + SSI_SIER); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (ssi->flags & IMX_SSI_DMA) sier_bits = SSI_SIER_TDMAE; else sier_bits = SSI_SIER_TIE | SSI_SIER_TFE0_EN; } else { if (ssi->flags & IMX_SSI_DMA) sier_bits = SSI_SIER_RDMAE; else sier_bits = SSI_SIER_RIE | SSI_SIER_RFF0_EN; } switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) scr |= SSI_SCR_TE; else scr |= SSI_SCR_RE; sier |= sier_bits; if (++ssi->enabled == 1) scr |= SSI_SCR_SSIEN; break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) scr &= ~SSI_SCR_TE; else scr &= ~SSI_SCR_RE; sier &= ~sier_bits; if (--ssi->enabled == 0) scr &= ~SSI_SCR_SSIEN; break; default: return -EINVAL; } if (!(ssi->flags & IMX_SSI_USE_AC97)) /* rx/tx are always enabled to access ac97 registers */ writel(scr, ssi->base + SSI_SCR); writel(sier, ssi->base + SSI_SIER); return 0; } static const struct snd_soc_dai_ops imx_ssi_pcm_dai_ops = { .startup = imx_ssi_startup, .hw_params = imx_ssi_hw_params, .set_fmt = imx_ssi_set_dai_fmt, .set_clkdiv = imx_ssi_set_dai_clkdiv, .set_sysclk = imx_ssi_set_dai_sysclk, .set_tdm_slot = imx_ssi_set_dai_tdm_slot, .trigger = imx_ssi_trigger, }; static int imx_ssi_dai_probe(struct snd_soc_dai *dai) { struct imx_ssi *ssi = dev_get_drvdata(dai->dev); uint32_t val; snd_soc_dai_set_drvdata(dai, ssi); val = SSI_SFCSR_TFWM0(ssi->dma_params_tx.burstsize) | SSI_SFCSR_RFWM0(ssi->dma_params_rx.burstsize); writel(val, ssi->base + SSI_SFCSR); return 0; } static struct snd_soc_dai_driver imx_ssi_dai = { .probe = imx_ssi_dai_probe, .playback = { .channels_min = 1, .channels_max = 2, .rates = SNDRV_PCM_RATE_8000_96000, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .capture = { .channels_min = 1, .channels_max = 2, .rates = SNDRV_PCM_RATE_8000_96000, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &imx_ssi_pcm_dai_ops, }; static struct snd_soc_dai_driver imx_ac97_dai = { .probe = imx_ssi_dai_probe, .ac97_control = 1, .playback = { .stream_name = "AC97 Playback", .channels_min = 2, .channels_max = 2, .rates = SNDRV_PCM_RATE_48000, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .capture = { .stream_name = "AC97 Capture", .channels_min = 2, .channels_max = 2, .rates = SNDRV_PCM_RATE_48000, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &imx_ssi_pcm_dai_ops, }; static void setup_channel_to_ac97(struct imx_ssi *imx_ssi) { void __iomem *base = imx_ssi->base; writel(0x0, base + SSI_SCR); writel(0x0, base + SSI_STCR); writel(0x0, base + SSI_SRCR); writel(SSI_SCR_SYN | SSI_SCR_NET, base + SSI_SCR); writel(SSI_SFCSR_RFWM0(8) | SSI_SFCSR_TFWM0(8) | SSI_SFCSR_RFWM1(8) | SSI_SFCSR_TFWM1(8), base + SSI_SFCSR); writel(SSI_STCCR_WL(16) | SSI_STCCR_DC(12), base + SSI_STCCR); writel(SSI_STCCR_WL(16) | SSI_STCCR_DC(12), base + SSI_SRCCR); writel(SSI_SCR_SYN | SSI_SCR_NET | SSI_SCR_SSIEN, base + SSI_SCR); writel(SSI_SOR_WAIT(3), base + SSI_SOR); writel(SSI_SCR_SYN | SSI_SCR_NET | SSI_SCR_SSIEN | SSI_SCR_TE | SSI_SCR_RE, base + SSI_SCR); writel(SSI_SACNT_DEFAULT, base + SSI_SACNT); writel(0xff, base + SSI_SACCDIS); writel(0x300, base + SSI_SACCEN); } static struct imx_ssi *ac97_ssi; static void imx_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { struct imx_ssi *imx_ssi = ac97_ssi; void __iomem *base = imx_ssi->base; unsigned int lreg; unsigned int lval; if (reg > 0x7f) return; pr_debug("%s: 0x%02x 0x%04x\n", __func__, reg, val); lreg = reg << 12; writel(lreg, base + SSI_SACADD); lval = val << 4; writel(lval , base + SSI_SACDAT); writel(SSI_SACNT_DEFAULT | SSI_SACNT_WR, base + SSI_SACNT); udelay(100); } static unsigned short imx_ssi_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { struct imx_ssi *imx_ssi = ac97_ssi; void __iomem *base = imx_ssi->base; unsigned short val = -1; unsigned int lreg; lreg = (reg & 0x7f) << 12 ; writel(lreg, base + SSI_SACADD); writel(SSI_SACNT_DEFAULT | SSI_SACNT_RD, base + SSI_SACNT); udelay(100); val = (readl(base + SSI_SACDAT) >> 4) & 0xffff; pr_debug("%s: 0x%02x 0x%04x\n", __func__, reg, val); return val; } static void imx_ssi_ac97_reset(struct snd_ac97 *ac97) { struct imx_ssi *imx_ssi = ac97_ssi; if (imx_ssi->ac97_reset) imx_ssi->ac97_reset(ac97); } static void imx_ssi_ac97_warm_reset(struct snd_ac97 *ac97) { struct imx_ssi *imx_ssi = ac97_ssi; if (imx_ssi->ac97_warm_reset) imx_ssi->ac97_warm_reset(ac97); } struct snd_ac97_bus_ops soc_ac97_ops = { .read = imx_ssi_ac97_read, .write = imx_ssi_ac97_write, .reset = imx_ssi_ac97_reset, .warm_reset = imx_ssi_ac97_warm_reset }; EXPORT_SYMBOL_GPL(soc_ac97_ops); static int imx_ssi_probe(struct platform_device *pdev) { struct resource *res; struct imx_ssi *ssi; struct imx_ssi_platform_data *pdata = pdev->dev.platform_data; int ret = 0; struct snd_soc_dai_driver *dai; ssi = kzalloc(sizeof(*ssi), GFP_KERNEL); if (!ssi) return -ENOMEM; dev_set_drvdata(&pdev->dev, ssi); if (pdata) { ssi->ac97_reset = pdata->ac97_reset; ssi->ac97_warm_reset = pdata->ac97_warm_reset; ssi->flags = pdata->flags; } ssi->irq = platform_get_irq(pdev, 0); ssi->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(ssi->clk)) { ret = PTR_ERR(ssi->clk); dev_err(&pdev->dev, "Cannot get the clock: %d\n", ret); goto failed_clk; } clk_enable(ssi->clk); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { ret = -ENODEV; goto failed_get_resource; } if (!request_mem_region(res->start, resource_size(res), DRV_NAME)) { dev_err(&pdev->dev, "request_mem_region failed\n"); ret = -EBUSY; goto failed_get_resource; } ssi->base = ioremap(res->start, resource_size(res)); if (!ssi->base) { dev_err(&pdev->dev, "ioremap failed\n"); ret = -ENODEV; goto failed_ioremap; } if (ssi->flags & IMX_SSI_USE_AC97) { if (ac97_ssi) { ret = -EBUSY; goto failed_ac97; } ac97_ssi = ssi; setup_channel_to_ac97(ssi); dai = &imx_ac97_dai; } else dai = &imx_ssi_dai; writel(0x0, ssi->base + SSI_SIER); ssi->dma_params_rx.dma_addr = res->start + SSI_SRX0; ssi->dma_params_tx.dma_addr = res->start + SSI_STX0; ssi->dma_params_tx.burstsize = 6; ssi->dma_params_rx.burstsize = 4; res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0"); if (res) ssi->dma_params_tx.dma = res->start; res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0"); if (res) ssi->dma_params_rx.dma = res->start; platform_set_drvdata(pdev, ssi); ret = snd_soc_register_dai(&pdev->dev, dai); if (ret) { dev_err(&pdev->dev, "register DAI failed\n"); goto failed_register; } ssi->soc_platform_pdev_fiq = platform_device_alloc("imx-fiq-pcm-audio", pdev->id); if (!ssi->soc_platform_pdev_fiq) { ret = -ENOMEM; goto failed_pdev_fiq_alloc; } platform_set_drvdata(ssi->soc_platform_pdev_fiq, ssi); ret = platform_device_add(ssi->soc_platform_pdev_fiq); if (ret) { dev_err(&pdev->dev, "failed to add platform device\n"); goto failed_pdev_fiq_add; } ssi->soc_platform_pdev = platform_device_alloc("imx-pcm-audio", pdev->id); if (!ssi->soc_platform_pdev) { ret = -ENOMEM; goto failed_pdev_alloc; } platform_set_drvdata(ssi->soc_platform_pdev, ssi); ret = platform_device_add(ssi->soc_platform_pdev); if (ret) { dev_err(&pdev->dev, "failed to add platform device\n"); goto failed_pdev_add; } return 0; failed_pdev_add: platform_device_put(ssi->soc_platform_pdev); failed_pdev_alloc: platform_device_del(ssi->soc_platform_pdev_fiq); failed_pdev_fiq_add: platform_device_put(ssi->soc_platform_pdev_fiq); failed_pdev_fiq_alloc: snd_soc_unregister_dai(&pdev->dev); failed_register: failed_ac97: iounmap(ssi->base); failed_ioremap: release_mem_region(res->start, resource_size(res)); failed_get_resource: clk_disable(ssi->clk); clk_put(ssi->clk); failed_clk: kfree(ssi); return ret; } static int __devexit imx_ssi_remove(struct platform_device *pdev) { struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct imx_ssi *ssi = platform_get_drvdata(pdev); platform_device_unregister(ssi->soc_platform_pdev); platform_device_unregister(ssi->soc_platform_pdev_fiq); snd_soc_unregister_dai(&pdev->dev); if (ssi->flags & IMX_SSI_USE_AC97) ac97_ssi = NULL; iounmap(ssi->base); release_mem_region(res->start, resource_size(res)); clk_disable(ssi->clk); clk_put(ssi->clk); kfree(ssi); return 0; } static struct platform_driver imx_ssi_driver = { .probe = imx_ssi_probe, .remove = __devexit_p(imx_ssi_remove), .driver = { .name = "imx-ssi", .owner = THIS_MODULE, }, }; module_platform_driver(imx_ssi_driver); /* Module information */ MODULE_AUTHOR("Sascha Hauer, <s.hauer@pengutronix.de>"); MODULE_DESCRIPTION("i.MX I2S/ac97 SoC Interface"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:imx-ssi");
gpl-2.0
wow73611/smdk6410-linux-3.18.14
tools/power/cpupower/utils/helpers/cpuid.c
4471
4504
#include <stdio.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <stdlib.h> #include "helpers/helpers.h" static const char *cpu_vendor_table[X86_VENDOR_MAX] = { "Unknown", "GenuineIntel", "AuthenticAMD", }; #if defined(__i386__) || defined(__x86_64__) /* from gcc */ #include <cpuid.h> /* * CPUID functions returning a single datum * * Define unsigned int cpuid_e[abcd]x(unsigned int op) */ #define cpuid_func(reg) \ unsigned int cpuid_##reg(unsigned int op) \ { \ unsigned int eax, ebx, ecx, edx; \ __cpuid(op, eax, ebx, ecx, edx); \ return reg; \ } cpuid_func(eax); cpuid_func(ebx); cpuid_func(ecx); cpuid_func(edx); #endif /* defined(__i386__) || defined(__x86_64__) */ /* get_cpu_info * * Extract CPU vendor, family, model, stepping info from /proc/cpuinfo * * Returns 0 on success or a negativ error code * * TBD: Should there be a cpuid alternative for this if /proc is not mounted? */ int get_cpu_info(unsigned int cpu, struct cpupower_cpu_info *cpu_info) { FILE *fp; char value[64]; unsigned int proc, x; unsigned int unknown = 0xffffff; unsigned int cpuid_level, ext_cpuid_level; int ret = -EINVAL; cpu_info->vendor = X86_VENDOR_UNKNOWN; cpu_info->family = unknown; cpu_info->model = unknown; cpu_info->stepping = unknown; cpu_info->caps = 0; fp = fopen("/proc/cpuinfo", "r"); if (!fp) return -EIO; while (!feof(fp)) { if (!fgets(value, 64, fp)) continue; value[63 - 1] = '\0'; if (!strncmp(value, "processor\t: ", 12)) sscanf(value, "processor\t: %u", &proc); if (proc != cpu) continue; /* Get CPU vendor */ if (!strncmp(value, "vendor_id", 9)) { for (x = 1; x < X86_VENDOR_MAX; x++) { if (strstr(value, cpu_vendor_table[x])) cpu_info->vendor = x; } /* Get CPU family, etc. */ } else if (!strncmp(value, "cpu family\t: ", 13)) { sscanf(value, "cpu family\t: %u", &cpu_info->family); } else if (!strncmp(value, "model\t\t: ", 9)) { sscanf(value, "model\t\t: %u", &cpu_info->model); } else if (!strncmp(value, "stepping\t: ", 10)) { sscanf(value, "stepping\t: %u", &cpu_info->stepping); /* Exit -> all values must have been set */ if (cpu_info->vendor == X86_VENDOR_UNKNOWN || cpu_info->family == unknown || cpu_info->model == unknown || cpu_info->stepping == unknown) { ret = -EINVAL; goto out; } ret = 0; goto out; } } ret = -ENODEV; out: fclose(fp); /* Get some useful CPU capabilities from cpuid */ if (cpu_info->vendor != X86_VENDOR_AMD && cpu_info->vendor != X86_VENDOR_INTEL) return ret; cpuid_level = cpuid_eax(0); ext_cpuid_level = cpuid_eax(0x80000000); /* Invariant TSC */ if (ext_cpuid_level >= 0x80000007 && (cpuid_edx(0x80000007) & (1 << 8))) cpu_info->caps |= CPUPOWER_CAP_INV_TSC; /* Aperf/Mperf registers support */ if (cpuid_level >= 6 && (cpuid_ecx(6) & 0x1)) cpu_info->caps |= CPUPOWER_CAP_APERF; /* AMD Boost state enable/disable register */ if (cpu_info->vendor == X86_VENDOR_AMD) { if (ext_cpuid_level >= 0x80000007 && (cpuid_edx(0x80000007) & (1 << 9))) cpu_info->caps |= CPUPOWER_CAP_AMD_CBP; } if (cpu_info->vendor == X86_VENDOR_INTEL) { if (cpuid_level >= 6 && (cpuid_eax(6) & (1 << 1))) cpu_info->caps |= CPUPOWER_CAP_INTEL_IDA; } if (cpu_info->vendor == X86_VENDOR_INTEL) { /* Intel's perf-bias MSR support */ if (cpuid_level >= 6 && (cpuid_ecx(6) & (1 << 3))) cpu_info->caps |= CPUPOWER_CAP_PERF_BIAS; /* Intel's Turbo Ratio Limit support */ if (cpu_info->family == 6) { switch (cpu_info->model) { case 0x1A: /* Core i7, Xeon 5500 series * Bloomfield, Gainstown NHM-EP */ case 0x1E: /* Core i7 and i5 Processor * Clarksfield, Lynnfield, Jasper Forest */ case 0x1F: /* Core i7 and i5 Processor - Nehalem */ case 0x25: /* Westmere Client * Clarkdale, Arrandale */ case 0x2C: /* Westmere EP - Gulftown */ cpu_info->caps |= CPUPOWER_CAP_HAS_TURBO_RATIO; case 0x2A: /* SNB */ case 0x2D: /* SNB Xeon */ case 0x3A: /* IVB */ case 0x3E: /* IVB Xeon */ cpu_info->caps |= CPUPOWER_CAP_HAS_TURBO_RATIO; cpu_info->caps |= CPUPOWER_CAP_IS_SNB; break; case 0x2E: /* Nehalem-EX Xeon - Beckton */ case 0x2F: /* Westmere-EX Xeon - Eagleton */ default: break; } } } /* printf("ID: %u - Extid: 0x%x - Caps: 0x%llx\n", cpuid_level, ext_cpuid_level, cpu_info->caps); */ return ret; }
gpl-2.0
scto/android_kernel_jide_sk1wg
arch/arm/mach-spear6xx/spear6xx.c
4727
3057
/* * arch/arm/mach-spear6xx/spear6xx.c * * SPEAr6XX machines common source file * * Copyright (C) 2009 ST Microelectronics * Rajeev Kumar<rajeev-dlh.kumar@st.com> * * Copyright 2012 Stefan Roese <sr@denx.de> * * This file is licensed under the terms of the GNU General Public * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/of_platform.h> #include <asm/hardware/vic.h> #include <asm/mach/arch.h> #include <mach/generic.h> #include <mach/hardware.h> /* Following will create static virtual/physical mappings */ static struct map_desc spear6xx_io_desc[] __initdata = { { .virtual = VA_SPEAR6XX_ICM1_UART0_BASE, .pfn = __phys_to_pfn(SPEAR6XX_ICM1_UART0_BASE), .length = SZ_4K, .type = MT_DEVICE }, { .virtual = VA_SPEAR6XX_CPU_VIC_PRI_BASE, .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_PRI_BASE), .length = SZ_4K, .type = MT_DEVICE }, { .virtual = VA_SPEAR6XX_CPU_VIC_SEC_BASE, .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_SEC_BASE), .length = SZ_4K, .type = MT_DEVICE }, { .virtual = VA_SPEAR6XX_ICM3_SYS_CTRL_BASE, .pfn = __phys_to_pfn(SPEAR6XX_ICM3_SYS_CTRL_BASE), .length = SZ_4K, .type = MT_DEVICE }, { .virtual = VA_SPEAR6XX_ICM3_MISC_REG_BASE, .pfn = __phys_to_pfn(SPEAR6XX_ICM3_MISC_REG_BASE), .length = SZ_4K, .type = MT_DEVICE }, }; /* This will create static memory mapping for selected devices */ void __init spear6xx_map_io(void) { iotable_init(spear6xx_io_desc, ARRAY_SIZE(spear6xx_io_desc)); /* This will initialize clock framework */ spear6xx_clk_init(); } static void __init spear6xx_timer_init(void) { char pclk_name[] = "pll3_48m_clk"; struct clk *gpt_clk, *pclk; /* get the system timer clock */ gpt_clk = clk_get_sys("gpt0", NULL); if (IS_ERR(gpt_clk)) { pr_err("%s:couldn't get clk for gpt\n", __func__); BUG(); } /* get the suitable parent clock for timer*/ pclk = clk_get(NULL, pclk_name); if (IS_ERR(pclk)) { pr_err("%s:couldn't get %s as parent for gpt\n", __func__, pclk_name); BUG(); } clk_set_parent(gpt_clk, pclk); clk_put(gpt_clk); clk_put(pclk); spear_setup_timer(); } struct sys_timer spear6xx_timer = { .init = spear6xx_timer_init, }; static void __init spear600_dt_init(void) { of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); } static const char *spear600_dt_board_compat[] = { "st,spear600", NULL }; static const struct of_device_id vic_of_match[] __initconst = { { .compatible = "arm,pl190-vic", .data = vic_of_init, }, { /* Sentinel */ } }; static void __init spear6xx_dt_init_irq(void) { of_irq_init(vic_of_match); } DT_MACHINE_START(SPEAR600_DT, "ST SPEAr600 (Flattened Device Tree)") .map_io = spear6xx_map_io, .init_irq = spear6xx_dt_init_irq, .handle_irq = vic_handle_irq, .timer = &spear6xx_timer, .init_machine = spear600_dt_init, .restart = spear_restart, .dt_compat = spear600_dt_board_compat, MACHINE_END
gpl-2.0
Vegaviet-DevTeam/kernel-stock-4.4.2-ef63slk
arch/powerpc/mm/slice.c
4727
20490
/* * address space "slices" (meta-segments) support * * Copyright (C) 2007 Benjamin Herrenschmidt, IBM Corporation. * * Based on hugetlb implementation * * Copyright (C) 2003 David Gibson, IBM Corporation. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #undef DEBUG #include <linux/kernel.h> #include <linux/mm.h> #include <linux/pagemap.h> #include <linux/err.h> #include <linux/spinlock.h> #include <linux/export.h> #include <asm/mman.h> #include <asm/mmu.h> #include <asm/spu.h> static DEFINE_SPINLOCK(slice_convert_lock); #ifdef DEBUG int _slice_debug = 1; static void slice_print_mask(const char *label, struct slice_mask mask) { char *p, buf[16 + 3 + 16 + 1]; int i; if (!_slice_debug) return; p = buf; for (i = 0; i < SLICE_NUM_LOW; i++) *(p++) = (mask.low_slices & (1 << i)) ? '1' : '0'; *(p++) = ' '; *(p++) = '-'; *(p++) = ' '; for (i = 0; i < SLICE_NUM_HIGH; i++) *(p++) = (mask.high_slices & (1 << i)) ? '1' : '0'; *(p++) = 0; printk(KERN_DEBUG "%s:%s\n", label, buf); } #define slice_dbg(fmt...) do { if (_slice_debug) pr_debug(fmt); } while(0) #else static void slice_print_mask(const char *label, struct slice_mask mask) {} #define slice_dbg(fmt...) #endif static struct slice_mask slice_range_to_mask(unsigned long start, unsigned long len) { unsigned long end = start + len - 1; struct slice_mask ret = { 0, 0 }; if (start < SLICE_LOW_TOP) { unsigned long mend = min(end, SLICE_LOW_TOP); unsigned long mstart = min(start, SLICE_LOW_TOP); ret.low_slices = (1u << (GET_LOW_SLICE_INDEX(mend) + 1)) - (1u << GET_LOW_SLICE_INDEX(mstart)); } if ((start + len) > SLICE_LOW_TOP) ret.high_slices = (1u << (GET_HIGH_SLICE_INDEX(end) + 1)) - (1u << GET_HIGH_SLICE_INDEX(start)); return ret; } static int slice_area_is_free(struct mm_struct *mm, unsigned long addr, unsigned long len) { struct vm_area_struct *vma; if ((mm->task_size - len) < addr) return 0; vma = find_vma(mm, addr); return (!vma || (addr + len) <= vma->vm_start); } static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice) { return !slice_area_is_free(mm, slice << SLICE_LOW_SHIFT, 1ul << SLICE_LOW_SHIFT); } static int slice_high_has_vma(struct mm_struct *mm, unsigned long slice) { unsigned long start = slice << SLICE_HIGH_SHIFT; unsigned long end = start + (1ul << SLICE_HIGH_SHIFT); /* Hack, so that each addresses is controlled by exactly one * of the high or low area bitmaps, the first high area starts * at 4GB, not 0 */ if (start == 0) start = SLICE_LOW_TOP; return !slice_area_is_free(mm, start, end - start); } static struct slice_mask slice_mask_for_free(struct mm_struct *mm) { struct slice_mask ret = { 0, 0 }; unsigned long i; for (i = 0; i < SLICE_NUM_LOW; i++) if (!slice_low_has_vma(mm, i)) ret.low_slices |= 1u << i; if (mm->task_size <= SLICE_LOW_TOP) return ret; for (i = 0; i < SLICE_NUM_HIGH; i++) if (!slice_high_has_vma(mm, i)) ret.high_slices |= 1u << i; return ret; } static struct slice_mask slice_mask_for_size(struct mm_struct *mm, int psize) { struct slice_mask ret = { 0, 0 }; unsigned long i; u64 psizes; psizes = mm->context.low_slices_psize; for (i = 0; i < SLICE_NUM_LOW; i++) if (((psizes >> (i * 4)) & 0xf) == psize) ret.low_slices |= 1u << i; psizes = mm->context.high_slices_psize; for (i = 0; i < SLICE_NUM_HIGH; i++) if (((psizes >> (i * 4)) & 0xf) == psize) ret.high_slices |= 1u << i; return ret; } static int slice_check_fit(struct slice_mask mask, struct slice_mask available) { return (mask.low_slices & available.low_slices) == mask.low_slices && (mask.high_slices & available.high_slices) == mask.high_slices; } static void slice_flush_segments(void *parm) { struct mm_struct *mm = parm; unsigned long flags; if (mm != current->active_mm) return; /* update the paca copy of the context struct */ get_paca()->context = current->active_mm->context; local_irq_save(flags); slb_flush_and_rebolt(); local_irq_restore(flags); } static void slice_convert(struct mm_struct *mm, struct slice_mask mask, int psize) { /* Write the new slice psize bits */ u64 lpsizes, hpsizes; unsigned long i, flags; slice_dbg("slice_convert(mm=%p, psize=%d)\n", mm, psize); slice_print_mask(" mask", mask); /* We need to use a spinlock here to protect against * concurrent 64k -> 4k demotion ... */ spin_lock_irqsave(&slice_convert_lock, flags); lpsizes = mm->context.low_slices_psize; for (i = 0; i < SLICE_NUM_LOW; i++) if (mask.low_slices & (1u << i)) lpsizes = (lpsizes & ~(0xful << (i * 4))) | (((unsigned long)psize) << (i * 4)); hpsizes = mm->context.high_slices_psize; for (i = 0; i < SLICE_NUM_HIGH; i++) if (mask.high_slices & (1u << i)) hpsizes = (hpsizes & ~(0xful << (i * 4))) | (((unsigned long)psize) << (i * 4)); mm->context.low_slices_psize = lpsizes; mm->context.high_slices_psize = hpsizes; slice_dbg(" lsps=%lx, hsps=%lx\n", mm->context.low_slices_psize, mm->context.high_slices_psize); spin_unlock_irqrestore(&slice_convert_lock, flags); #ifdef CONFIG_SPU_BASE spu_flush_all_slbs(mm); #endif } static unsigned long slice_find_area_bottomup(struct mm_struct *mm, unsigned long len, struct slice_mask available, int psize, int use_cache) { struct vm_area_struct *vma; unsigned long start_addr, addr; struct slice_mask mask; int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT); if (use_cache) { if (len <= mm->cached_hole_size) { start_addr = addr = TASK_UNMAPPED_BASE; mm->cached_hole_size = 0; } else start_addr = addr = mm->free_area_cache; } else start_addr = addr = TASK_UNMAPPED_BASE; full_search: for (;;) { addr = _ALIGN_UP(addr, 1ul << pshift); if ((TASK_SIZE - len) < addr) break; vma = find_vma(mm, addr); BUG_ON(vma && (addr >= vma->vm_end)); mask = slice_range_to_mask(addr, len); if (!slice_check_fit(mask, available)) { if (addr < SLICE_LOW_TOP) addr = _ALIGN_UP(addr + 1, 1ul << SLICE_LOW_SHIFT); else addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT); continue; } if (!vma || addr + len <= vma->vm_start) { /* * Remember the place where we stopped the search: */ if (use_cache) mm->free_area_cache = addr + len; return addr; } if (use_cache && (addr + mm->cached_hole_size) < vma->vm_start) mm->cached_hole_size = vma->vm_start - addr; addr = vma->vm_end; } /* Make sure we didn't miss any holes */ if (use_cache && start_addr != TASK_UNMAPPED_BASE) { start_addr = addr = TASK_UNMAPPED_BASE; mm->cached_hole_size = 0; goto full_search; } return -ENOMEM; } static unsigned long slice_find_area_topdown(struct mm_struct *mm, unsigned long len, struct slice_mask available, int psize, int use_cache) { struct vm_area_struct *vma; unsigned long addr; struct slice_mask mask; int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT); /* check if free_area_cache is useful for us */ if (use_cache) { if (len <= mm->cached_hole_size) { mm->cached_hole_size = 0; mm->free_area_cache = mm->mmap_base; } /* either no address requested or can't fit in requested * address hole */ addr = mm->free_area_cache; /* make sure it can fit in the remaining address space */ if (addr > len) { addr = _ALIGN_DOWN(addr - len, 1ul << pshift); mask = slice_range_to_mask(addr, len); if (slice_check_fit(mask, available) && slice_area_is_free(mm, addr, len)) /* remember the address as a hint for * next time */ return (mm->free_area_cache = addr); } } addr = mm->mmap_base; while (addr > len) { /* Go down by chunk size */ addr = _ALIGN_DOWN(addr - len, 1ul << pshift); /* Check for hit with different page size */ mask = slice_range_to_mask(addr, len); if (!slice_check_fit(mask, available)) { if (addr < SLICE_LOW_TOP) addr = _ALIGN_DOWN(addr, 1ul << SLICE_LOW_SHIFT); else if (addr < (1ul << SLICE_HIGH_SHIFT)) addr = SLICE_LOW_TOP; else addr = _ALIGN_DOWN(addr, 1ul << SLICE_HIGH_SHIFT); continue; } /* * Lookup failure means no vma is above this address, * else if new region fits below vma->vm_start, * return with success: */ vma = find_vma(mm, addr); if (!vma || (addr + len) <= vma->vm_start) { /* remember the address as a hint for next time */ if (use_cache) mm->free_area_cache = addr; return addr; } /* remember the largest hole we saw so far */ if (use_cache && (addr + mm->cached_hole_size) < vma->vm_start) mm->cached_hole_size = vma->vm_start - addr; /* try just below the current vma->vm_start */ addr = vma->vm_start; } /* * A failed mmap() very likely causes application failure, * so fall back to the bottom-up function here. This scenario * can happen with large stack limits and large mmap() * allocations. */ addr = slice_find_area_bottomup(mm, len, available, psize, 0); /* * Restore the topdown base: */ if (use_cache) { mm->free_area_cache = mm->mmap_base; mm->cached_hole_size = ~0UL; } return addr; } static unsigned long slice_find_area(struct mm_struct *mm, unsigned long len, struct slice_mask mask, int psize, int topdown, int use_cache) { if (topdown) return slice_find_area_topdown(mm, len, mask, psize, use_cache); else return slice_find_area_bottomup(mm, len, mask, psize, use_cache); } #define or_mask(dst, src) do { \ (dst).low_slices |= (src).low_slices; \ (dst).high_slices |= (src).high_slices; \ } while (0) #define andnot_mask(dst, src) do { \ (dst).low_slices &= ~(src).low_slices; \ (dst).high_slices &= ~(src).high_slices; \ } while (0) #ifdef CONFIG_PPC_64K_PAGES #define MMU_PAGE_BASE MMU_PAGE_64K #else #define MMU_PAGE_BASE MMU_PAGE_4K #endif unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, unsigned long flags, unsigned int psize, int topdown, int use_cache) { struct slice_mask mask = {0, 0}; struct slice_mask good_mask; struct slice_mask potential_mask = {0,0} /* silence stupid warning */; struct slice_mask compat_mask = {0, 0}; int fixed = (flags & MAP_FIXED); int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT); struct mm_struct *mm = current->mm; unsigned long newaddr; /* Sanity checks */ BUG_ON(mm->task_size == 0); slice_dbg("slice_get_unmapped_area(mm=%p, psize=%d...\n", mm, psize); slice_dbg(" addr=%lx, len=%lx, flags=%lx, topdown=%d, use_cache=%d\n", addr, len, flags, topdown, use_cache); if (len > mm->task_size) return -ENOMEM; if (len & ((1ul << pshift) - 1)) return -EINVAL; if (fixed && (addr & ((1ul << pshift) - 1))) return -EINVAL; if (fixed && addr > (mm->task_size - len)) return -EINVAL; /* If hint, make sure it matches our alignment restrictions */ if (!fixed && addr) { addr = _ALIGN_UP(addr, 1ul << pshift); slice_dbg(" aligned addr=%lx\n", addr); /* Ignore hint if it's too large or overlaps a VMA */ if (addr > mm->task_size - len || !slice_area_is_free(mm, addr, len)) addr = 0; } /* First make up a "good" mask of slices that have the right size * already */ good_mask = slice_mask_for_size(mm, psize); slice_print_mask(" good_mask", good_mask); /* * Here "good" means slices that are already the right page size, * "compat" means slices that have a compatible page size (i.e. * 4k in a 64k pagesize kernel), and "free" means slices without * any VMAs. * * If MAP_FIXED: * check if fits in good | compat => OK * check if fits in good | compat | free => convert free * else bad * If have hint: * check if hint fits in good => OK * check if hint fits in good | free => convert free * Otherwise: * search in good, found => OK * search in good | free, found => convert free * search in good | compat | free, found => convert free. */ #ifdef CONFIG_PPC_64K_PAGES /* If we support combo pages, we can allow 64k pages in 4k slices */ if (psize == MMU_PAGE_64K) { compat_mask = slice_mask_for_size(mm, MMU_PAGE_4K); if (fixed) or_mask(good_mask, compat_mask); } #endif /* First check hint if it's valid or if we have MAP_FIXED */ if (addr != 0 || fixed) { /* Build a mask for the requested range */ mask = slice_range_to_mask(addr, len); slice_print_mask(" mask", mask); /* Check if we fit in the good mask. If we do, we just return, * nothing else to do */ if (slice_check_fit(mask, good_mask)) { slice_dbg(" fits good !\n"); return addr; } } else { /* Now let's see if we can find something in the existing * slices for that size */ newaddr = slice_find_area(mm, len, good_mask, psize, topdown, use_cache); if (newaddr != -ENOMEM) { /* Found within the good mask, we don't have to setup, * we thus return directly */ slice_dbg(" found area at 0x%lx\n", newaddr); return newaddr; } } /* We don't fit in the good mask, check what other slices are * empty and thus can be converted */ potential_mask = slice_mask_for_free(mm); or_mask(potential_mask, good_mask); slice_print_mask(" potential", potential_mask); if ((addr != 0 || fixed) && slice_check_fit(mask, potential_mask)) { slice_dbg(" fits potential !\n"); goto convert; } /* If we have MAP_FIXED and failed the above steps, then error out */ if (fixed) return -EBUSY; slice_dbg(" search...\n"); /* If we had a hint that didn't work out, see if we can fit * anywhere in the good area. */ if (addr) { addr = slice_find_area(mm, len, good_mask, psize, topdown, use_cache); if (addr != -ENOMEM) { slice_dbg(" found area at 0x%lx\n", addr); return addr; } } /* Now let's see if we can find something in the existing slices * for that size plus free slices */ addr = slice_find_area(mm, len, potential_mask, psize, topdown, use_cache); #ifdef CONFIG_PPC_64K_PAGES if (addr == -ENOMEM && psize == MMU_PAGE_64K) { /* retry the search with 4k-page slices included */ or_mask(potential_mask, compat_mask); addr = slice_find_area(mm, len, potential_mask, psize, topdown, use_cache); } #endif if (addr == -ENOMEM) return -ENOMEM; mask = slice_range_to_mask(addr, len); slice_dbg(" found potential area at 0x%lx\n", addr); slice_print_mask(" mask", mask); convert: andnot_mask(mask, good_mask); andnot_mask(mask, compat_mask); if (mask.low_slices || mask.high_slices) { slice_convert(mm, mask, psize); if (psize > MMU_PAGE_BASE) on_each_cpu(slice_flush_segments, mm, 1); } return addr; } EXPORT_SYMBOL_GPL(slice_get_unmapped_area); unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { return slice_get_unmapped_area(addr, len, flags, current->mm->context.user_psize, 0, 1); } unsigned long arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, const unsigned long len, const unsigned long pgoff, const unsigned long flags) { return slice_get_unmapped_area(addr0, len, flags, current->mm->context.user_psize, 1, 1); } unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr) { u64 psizes; int index; if (addr < SLICE_LOW_TOP) { psizes = mm->context.low_slices_psize; index = GET_LOW_SLICE_INDEX(addr); } else { psizes = mm->context.high_slices_psize; index = GET_HIGH_SLICE_INDEX(addr); } return (psizes >> (index * 4)) & 0xf; } EXPORT_SYMBOL_GPL(get_slice_psize); /* * This is called by hash_page when it needs to do a lazy conversion of * an address space from real 64K pages to combo 4K pages (typically * when hitting a non cacheable mapping on a processor or hypervisor * that won't allow them for 64K pages). * * This is also called in init_new_context() to change back the user * psize from whatever the parent context had it set to * N.B. This may be called before mm->context.id has been set. * * This function will only change the content of the {low,high)_slice_psize * masks, it will not flush SLBs as this shall be handled lazily by the * caller. */ void slice_set_user_psize(struct mm_struct *mm, unsigned int psize) { unsigned long flags, lpsizes, hpsizes; unsigned int old_psize; int i; slice_dbg("slice_set_user_psize(mm=%p, psize=%d)\n", mm, psize); spin_lock_irqsave(&slice_convert_lock, flags); old_psize = mm->context.user_psize; slice_dbg(" old_psize=%d\n", old_psize); if (old_psize == psize) goto bail; mm->context.user_psize = psize; wmb(); lpsizes = mm->context.low_slices_psize; for (i = 0; i < SLICE_NUM_LOW; i++) if (((lpsizes >> (i * 4)) & 0xf) == old_psize) lpsizes = (lpsizes & ~(0xful << (i * 4))) | (((unsigned long)psize) << (i * 4)); hpsizes = mm->context.high_slices_psize; for (i = 0; i < SLICE_NUM_HIGH; i++) if (((hpsizes >> (i * 4)) & 0xf) == old_psize) hpsizes = (hpsizes & ~(0xful << (i * 4))) | (((unsigned long)psize) << (i * 4)); mm->context.low_slices_psize = lpsizes; mm->context.high_slices_psize = hpsizes; slice_dbg(" lsps=%lx, hsps=%lx\n", mm->context.low_slices_psize, mm->context.high_slices_psize); bail: spin_unlock_irqrestore(&slice_convert_lock, flags); } void slice_set_psize(struct mm_struct *mm, unsigned long address, unsigned int psize) { unsigned long i, flags; u64 *p; spin_lock_irqsave(&slice_convert_lock, flags); if (address < SLICE_LOW_TOP) { i = GET_LOW_SLICE_INDEX(address); p = &mm->context.low_slices_psize; } else { i = GET_HIGH_SLICE_INDEX(address); p = &mm->context.high_slices_psize; } *p = (*p & ~(0xful << (i * 4))) | ((unsigned long) psize << (i * 4)); spin_unlock_irqrestore(&slice_convert_lock, flags); #ifdef CONFIG_SPU_BASE spu_flush_all_slbs(mm); #endif } void slice_set_range_psize(struct mm_struct *mm, unsigned long start, unsigned long len, unsigned int psize) { struct slice_mask mask = slice_range_to_mask(start, len); slice_convert(mm, mask, psize); } /* * is_hugepage_only_range() is used by generic code to verify wether * a normal mmap mapping (non hugetlbfs) is valid on a given area. * * until the generic code provides a more generic hook and/or starts * calling arch get_unmapped_area for MAP_FIXED (which our implementation * here knows how to deal with), we hijack it to keep standard mappings * away from us. * * because of that generic code limitation, MAP_FIXED mapping cannot * "convert" back a slice with no VMAs to the standard page size, only * get_unmapped_area() can. It would be possible to fix it here but I * prefer working on fixing the generic code instead. * * WARNING: This will not work if hugetlbfs isn't enabled since the * generic code will redefine that function as 0 in that. This is ok * for now as we only use slices with hugetlbfs enabled. This should * be fixed as the generic code gets fixed. */ int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, unsigned long len) { struct slice_mask mask, available; unsigned int psize = mm->context.user_psize; mask = slice_range_to_mask(addr, len); available = slice_mask_for_size(mm, psize); #ifdef CONFIG_PPC_64K_PAGES /* We need to account for 4k slices too */ if (psize == MMU_PAGE_64K) { struct slice_mask compat_mask; compat_mask = slice_mask_for_size(mm, MMU_PAGE_4K); or_mask(available, compat_mask); } #endif #if 0 /* too verbose */ slice_dbg("is_hugepage_only_range(mm=%p, addr=%lx, len=%lx)\n", mm, addr, len); slice_print_mask(" mask", mask); slice_print_mask(" available", available); #endif return !slice_check_fit(mask, available); }
gpl-2.0
MSM8226-Samsung/android_kernel_samsung_ms01lte
arch/arm/mach-spear6xx/clock.c
4727
16852
/* * arch/arm/mach-spear6xx/clock.c * * SPEAr6xx machines clock framework source file * * Copyright (C) 2009 ST Microelectronics * Viresh Kumar<viresh.kumar@st.com> * * This file is licensed under the terms of the GNU General Public * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ #include <linux/init.h> #include <linux/io.h> #include <linux/kernel.h> #include <plat/clock.h> #include <mach/misc_regs.h> /* root clks */ /* 32 KHz oscillator clock */ static struct clk osc_32k_clk = { .flags = ALWAYS_ENABLED, .rate = 32000, }; /* 30 MHz oscillator clock */ static struct clk osc_30m_clk = { .flags = ALWAYS_ENABLED, .rate = 30000000, }; /* clock derived from 32 KHz osc clk */ /* rtc clock */ static struct clk rtc_clk = { .pclk = &osc_32k_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = RTC_CLK_ENB, .recalc = &follow_parent, }; /* clock derived from 30 MHz osc clk */ /* pll masks structure */ static struct pll_clk_masks pll1_masks = { .mode_mask = PLL_MODE_MASK, .mode_shift = PLL_MODE_SHIFT, .norm_fdbk_m_mask = PLL_NORM_FDBK_M_MASK, .norm_fdbk_m_shift = PLL_NORM_FDBK_M_SHIFT, .dith_fdbk_m_mask = PLL_DITH_FDBK_M_MASK, .dith_fdbk_m_shift = PLL_DITH_FDBK_M_SHIFT, .div_p_mask = PLL_DIV_P_MASK, .div_p_shift = PLL_DIV_P_SHIFT, .div_n_mask = PLL_DIV_N_MASK, .div_n_shift = PLL_DIV_N_SHIFT, }; /* pll1 configuration structure */ static struct pll_clk_config pll1_config = { .mode_reg = PLL1_CTR, .cfg_reg = PLL1_FRQ, .masks = &pll1_masks, }; /* pll rate configuration table, in ascending order of rates */ struct pll_rate_tbl pll_rtbl[] = { {.mode = 0, .m = 0x85, .n = 0x0C, .p = 0x1}, /* 266 MHz */ {.mode = 0, .m = 0xA6, .n = 0x0C, .p = 0x1}, /* 332 MHz */ }; /* PLL1 clock */ static struct clk pll1_clk = { .flags = ENABLED_ON_INIT, .pclk = &osc_30m_clk, .en_reg = PLL1_CTR, .en_reg_bit = PLL_ENABLE, .calc_rate = &pll_calc_rate, .recalc = &pll_clk_recalc, .set_rate = &pll_clk_set_rate, .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1}, .private_data = &pll1_config, }; /* PLL3 48 MHz clock */ static struct clk pll3_48m_clk = { .flags = ALWAYS_ENABLED, .pclk = &osc_30m_clk, .rate = 48000000, }; /* watch dog timer clock */ static struct clk wdt_clk = { .flags = ALWAYS_ENABLED, .pclk = &osc_30m_clk, .recalc = &follow_parent, }; /* clock derived from pll1 clk */ /* cpu clock */ static struct clk cpu_clk = { .flags = ALWAYS_ENABLED, .pclk = &pll1_clk, .recalc = &follow_parent, }; /* ahb masks structure */ static struct bus_clk_masks ahb_masks = { .mask = PLL_HCLK_RATIO_MASK, .shift = PLL_HCLK_RATIO_SHIFT, }; /* ahb configuration structure */ static struct bus_clk_config ahb_config = { .reg = CORE_CLK_CFG, .masks = &ahb_masks, }; /* ahb rate configuration table, in ascending order of rates */ struct bus_rate_tbl bus_rtbl[] = { {.div = 3}, /* == parent divided by 4 */ {.div = 2}, /* == parent divided by 3 */ {.div = 1}, /* == parent divided by 2 */ {.div = 0}, /* == parent divided by 1 */ }; /* ahb clock */ static struct clk ahb_clk = { .flags = ALWAYS_ENABLED, .pclk = &pll1_clk, .calc_rate = &bus_calc_rate, .recalc = &bus_clk_recalc, .set_rate = &bus_clk_set_rate, .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2}, .private_data = &ahb_config, }; /* auxiliary synthesizers masks */ static struct aux_clk_masks aux_masks = { .eq_sel_mask = AUX_EQ_SEL_MASK, .eq_sel_shift = AUX_EQ_SEL_SHIFT, .eq1_mask = AUX_EQ1_SEL, .eq2_mask = AUX_EQ2_SEL, .xscale_sel_mask = AUX_XSCALE_MASK, .xscale_sel_shift = AUX_XSCALE_SHIFT, .yscale_sel_mask = AUX_YSCALE_MASK, .yscale_sel_shift = AUX_YSCALE_SHIFT, }; /* uart configurations */ static struct aux_clk_config uart_synth_config = { .synth_reg = UART_CLK_SYNT, .masks = &aux_masks, }; /* aux rate configuration table, in ascending order of rates */ struct aux_rate_tbl aux_rtbl[] = { /* For PLL1 = 332 MHz */ {.xscale = 1, .yscale = 8, .eq = 1}, /* 41.5 MHz */ {.xscale = 1, .yscale = 4, .eq = 1}, /* 83 MHz */ {.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */ }; /* uart synth clock */ static struct clk uart_synth_clk = { .en_reg = UART_CLK_SYNT, .en_reg_bit = AUX_SYNT_ENB, .pclk = &pll1_clk, .calc_rate = &aux_calc_rate, .recalc = &aux_clk_recalc, .set_rate = &aux_clk_set_rate, .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, .private_data = &uart_synth_config, }; /* uart parents */ static struct pclk_info uart_pclk_info[] = { { .pclk = &uart_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* uart parent select structure */ static struct pclk_sel uart_pclk_sel = { .pclk_info = uart_pclk_info, .pclk_count = ARRAY_SIZE(uart_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = UART_CLK_MASK, }; /* uart0 clock */ static struct clk uart0_clk = { .en_reg = PERIP1_CLK_ENB, .en_reg_bit = UART0_CLK_ENB, .pclk_sel = &uart_pclk_sel, .pclk_sel_shift = UART_CLK_SHIFT, .recalc = &follow_parent, }; /* uart1 clock */ static struct clk uart1_clk = { .en_reg = PERIP1_CLK_ENB, .en_reg_bit = UART1_CLK_ENB, .pclk_sel = &uart_pclk_sel, .pclk_sel_shift = UART_CLK_SHIFT, .recalc = &follow_parent, }; /* firda configurations */ static struct aux_clk_config firda_synth_config = { .synth_reg = FIRDA_CLK_SYNT, .masks = &aux_masks, }; /* firda synth clock */ static struct clk firda_synth_clk = { .en_reg = FIRDA_CLK_SYNT, .en_reg_bit = AUX_SYNT_ENB, .pclk = &pll1_clk, .calc_rate = &aux_calc_rate, .recalc = &aux_clk_recalc, .set_rate = &aux_clk_set_rate, .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, .private_data = &firda_synth_config, }; /* firda parents */ static struct pclk_info firda_pclk_info[] = { { .pclk = &firda_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* firda parent select structure */ static struct pclk_sel firda_pclk_sel = { .pclk_info = firda_pclk_info, .pclk_count = ARRAY_SIZE(firda_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = FIRDA_CLK_MASK, }; /* firda clock */ static struct clk firda_clk = { .en_reg = PERIP1_CLK_ENB, .en_reg_bit = FIRDA_CLK_ENB, .pclk_sel = &firda_pclk_sel, .pclk_sel_shift = FIRDA_CLK_SHIFT, .recalc = &follow_parent, }; /* clcd configurations */ static struct aux_clk_config clcd_synth_config = { .synth_reg = CLCD_CLK_SYNT, .masks = &aux_masks, }; /* firda synth clock */ static struct clk clcd_synth_clk = { .en_reg = CLCD_CLK_SYNT, .en_reg_bit = AUX_SYNT_ENB, .pclk = &pll1_clk, .calc_rate = &aux_calc_rate, .recalc = &aux_clk_recalc, .set_rate = &aux_clk_set_rate, .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, .private_data = &clcd_synth_config, }; /* clcd parents */ static struct pclk_info clcd_pclk_info[] = { { .pclk = &clcd_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* clcd parent select structure */ static struct pclk_sel clcd_pclk_sel = { .pclk_info = clcd_pclk_info, .pclk_count = ARRAY_SIZE(clcd_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = CLCD_CLK_MASK, }; /* clcd clock */ static struct clk clcd_clk = { .en_reg = PERIP1_CLK_ENB, .en_reg_bit = CLCD_CLK_ENB, .pclk_sel = &clcd_pclk_sel, .pclk_sel_shift = CLCD_CLK_SHIFT, .recalc = &follow_parent, }; /* gpt synthesizer masks */ static struct gpt_clk_masks gpt_masks = { .mscale_sel_mask = GPT_MSCALE_MASK, .mscale_sel_shift = GPT_MSCALE_SHIFT, .nscale_sel_mask = GPT_NSCALE_MASK, .nscale_sel_shift = GPT_NSCALE_SHIFT, }; /* gpt rate configuration table, in ascending order of rates */ struct gpt_rate_tbl gpt_rtbl[] = { /* For pll1 = 332 MHz */ {.mscale = 4, .nscale = 0}, /* 41.5 MHz */ {.mscale = 2, .nscale = 0}, /* 55.3 MHz */ {.mscale = 1, .nscale = 0}, /* 83 MHz */ }; /* gpt0 synth clk config*/ static struct gpt_clk_config gpt0_synth_config = { .synth_reg = PRSC1_CLK_CFG, .masks = &gpt_masks, }; /* gpt synth clock */ static struct clk gpt0_synth_clk = { .flags = ALWAYS_ENABLED, .pclk = &pll1_clk, .calc_rate = &gpt_calc_rate, .recalc = &gpt_clk_recalc, .set_rate = &gpt_clk_set_rate, .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, .private_data = &gpt0_synth_config, }; /* gpt parents */ static struct pclk_info gpt0_pclk_info[] = { { .pclk = &gpt0_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* gpt parent select structure */ static struct pclk_sel gpt0_pclk_sel = { .pclk_info = gpt0_pclk_info, .pclk_count = ARRAY_SIZE(gpt0_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = GPT_CLK_MASK, }; /* gpt0 ARM1 subsystem timer clock */ static struct clk gpt0_clk = { .flags = ALWAYS_ENABLED, .pclk_sel = &gpt0_pclk_sel, .pclk_sel_shift = GPT0_CLK_SHIFT, .recalc = &follow_parent, }; /* Note: gpt0 and gpt1 share same parent clocks */ /* gpt parent select structure */ static struct pclk_sel gpt1_pclk_sel = { .pclk_info = gpt0_pclk_info, .pclk_count = ARRAY_SIZE(gpt0_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = GPT_CLK_MASK, }; /* gpt1 timer clock */ static struct clk gpt1_clk = { .flags = ALWAYS_ENABLED, .pclk_sel = &gpt1_pclk_sel, .pclk_sel_shift = GPT1_CLK_SHIFT, .recalc = &follow_parent, }; /* gpt2 synth clk config*/ static struct gpt_clk_config gpt2_synth_config = { .synth_reg = PRSC2_CLK_CFG, .masks = &gpt_masks, }; /* gpt synth clock */ static struct clk gpt2_synth_clk = { .flags = ALWAYS_ENABLED, .pclk = &pll1_clk, .calc_rate = &gpt_calc_rate, .recalc = &gpt_clk_recalc, .set_rate = &gpt_clk_set_rate, .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, .private_data = &gpt2_synth_config, }; /* gpt parents */ static struct pclk_info gpt2_pclk_info[] = { { .pclk = &gpt2_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* gpt parent select structure */ static struct pclk_sel gpt2_pclk_sel = { .pclk_info = gpt2_pclk_info, .pclk_count = ARRAY_SIZE(gpt2_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = GPT_CLK_MASK, }; /* gpt2 timer clock */ static struct clk gpt2_clk = { .flags = ALWAYS_ENABLED, .pclk_sel = &gpt2_pclk_sel, .pclk_sel_shift = GPT2_CLK_SHIFT, .recalc = &follow_parent, }; /* gpt3 synth clk config*/ static struct gpt_clk_config gpt3_synth_config = { .synth_reg = PRSC3_CLK_CFG, .masks = &gpt_masks, }; /* gpt synth clock */ static struct clk gpt3_synth_clk = { .flags = ALWAYS_ENABLED, .pclk = &pll1_clk, .calc_rate = &gpt_calc_rate, .recalc = &gpt_clk_recalc, .set_rate = &gpt_clk_set_rate, .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, .private_data = &gpt3_synth_config, }; /* gpt parents */ static struct pclk_info gpt3_pclk_info[] = { { .pclk = &gpt3_synth_clk, .pclk_val = AUX_CLK_PLL1_VAL, }, { .pclk = &pll3_48m_clk, .pclk_val = AUX_CLK_PLL3_VAL, }, }; /* gpt parent select structure */ static struct pclk_sel gpt3_pclk_sel = { .pclk_info = gpt3_pclk_info, .pclk_count = ARRAY_SIZE(gpt3_pclk_info), .pclk_sel_reg = PERIP_CLK_CFG, .pclk_sel_mask = GPT_CLK_MASK, }; /* gpt3 timer clock */ static struct clk gpt3_clk = { .flags = ALWAYS_ENABLED, .pclk_sel = &gpt3_pclk_sel, .pclk_sel_shift = GPT3_CLK_SHIFT, .recalc = &follow_parent, }; /* clock derived from pll3 clk */ /* usbh0 clock */ static struct clk usbh0_clk = { .pclk = &pll3_48m_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = USBH0_CLK_ENB, .recalc = &follow_parent, }; /* usbh1 clock */ static struct clk usbh1_clk = { .pclk = &pll3_48m_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = USBH1_CLK_ENB, .recalc = &follow_parent, }; /* usbd clock */ static struct clk usbd_clk = { .pclk = &pll3_48m_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = USBD_CLK_ENB, .recalc = &follow_parent, }; /* clock derived from ahb clk */ /* apb masks structure */ static struct bus_clk_masks apb_masks = { .mask = HCLK_PCLK_RATIO_MASK, .shift = HCLK_PCLK_RATIO_SHIFT, }; /* apb configuration structure */ static struct bus_clk_config apb_config = { .reg = CORE_CLK_CFG, .masks = &apb_masks, }; /* apb clock */ static struct clk apb_clk = { .flags = ALWAYS_ENABLED, .pclk = &ahb_clk, .calc_rate = &bus_calc_rate, .recalc = &bus_clk_recalc, .set_rate = &bus_clk_set_rate, .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2}, .private_data = &apb_config, }; /* i2c clock */ static struct clk i2c_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = I2C_CLK_ENB, .recalc = &follow_parent, }; /* dma clock */ static struct clk dma_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = DMA_CLK_ENB, .recalc = &follow_parent, }; /* jpeg clock */ static struct clk jpeg_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = JPEG_CLK_ENB, .recalc = &follow_parent, }; /* gmac clock */ static struct clk gmac_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = GMAC_CLK_ENB, .recalc = &follow_parent, }; /* smi clock */ static struct clk smi_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = SMI_CLK_ENB, .recalc = &follow_parent, }; /* fsmc clock */ static struct clk fsmc_clk = { .pclk = &ahb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = FSMC_CLK_ENB, .recalc = &follow_parent, }; /* clock derived from apb clk */ /* adc clock */ static struct clk adc_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = ADC_CLK_ENB, .recalc = &follow_parent, }; /* ssp0 clock */ static struct clk ssp0_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = SSP0_CLK_ENB, .recalc = &follow_parent, }; /* ssp1 clock */ static struct clk ssp1_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = SSP1_CLK_ENB, .recalc = &follow_parent, }; /* ssp2 clock */ static struct clk ssp2_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = SSP2_CLK_ENB, .recalc = &follow_parent, }; /* gpio0 ARM subsystem clock */ static struct clk gpio0_clk = { .flags = ALWAYS_ENABLED, .pclk = &apb_clk, .recalc = &follow_parent, }; /* gpio1 clock */ static struct clk gpio1_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = GPIO1_CLK_ENB, .recalc = &follow_parent, }; /* gpio2 clock */ static struct clk gpio2_clk = { .pclk = &apb_clk, .en_reg = PERIP1_CLK_ENB, .en_reg_bit = GPIO2_CLK_ENB, .recalc = &follow_parent, }; static struct clk dummy_apb_pclk; /* array of all spear 6xx clock lookups */ static struct clk_lookup spear_clk_lookups[] = { { .con_id = "apb_pclk", .clk = &dummy_apb_pclk}, /* root clks */ { .con_id = "osc_32k_clk", .clk = &osc_32k_clk}, { .con_id = "osc_30m_clk", .clk = &osc_30m_clk}, /* clock derived from 32 KHz os clk */ { .dev_id = "rtc-spear", .clk = &rtc_clk}, /* clock derived from 30 MHz os clk */ { .con_id = "pll1_clk", .clk = &pll1_clk}, { .con_id = "pll3_48m_clk", .clk = &pll3_48m_clk}, { .dev_id = "wdt", .clk = &wdt_clk}, /* clock derived from pll1 clk */ { .con_id = "cpu_clk", .clk = &cpu_clk}, { .con_id = "ahb_clk", .clk = &ahb_clk}, { .con_id = "uart_synth_clk", .clk = &uart_synth_clk}, { .con_id = "firda_synth_clk", .clk = &firda_synth_clk}, { .con_id = "clcd_synth_clk", .clk = &clcd_synth_clk}, { .con_id = "gpt0_synth_clk", .clk = &gpt0_synth_clk}, { .con_id = "gpt2_synth_clk", .clk = &gpt2_synth_clk}, { .con_id = "gpt3_synth_clk", .clk = &gpt3_synth_clk}, { .dev_id = "d0000000.serial", .clk = &uart0_clk}, { .dev_id = "d0080000.serial", .clk = &uart1_clk}, { .dev_id = "firda", .clk = &firda_clk}, { .dev_id = "clcd", .clk = &clcd_clk}, { .dev_id = "gpt0", .clk = &gpt0_clk}, { .dev_id = "gpt1", .clk = &gpt1_clk}, { .dev_id = "gpt2", .clk = &gpt2_clk}, { .dev_id = "gpt3", .clk = &gpt3_clk}, /* clock derived from pll3 clk */ { .dev_id = "designware_udc", .clk = &usbd_clk}, { .con_id = "usbh.0_clk", .clk = &usbh0_clk}, { .con_id = "usbh.1_clk", .clk = &usbh1_clk}, /* clock derived from ahb clk */ { .con_id = "apb_clk", .clk = &apb_clk}, { .dev_id = "d0200000.i2c", .clk = &i2c_clk}, { .dev_id = "dma", .clk = &dma_clk}, { .dev_id = "jpeg", .clk = &jpeg_clk}, { .dev_id = "gmac", .clk = &gmac_clk}, { .dev_id = "smi", .clk = &smi_clk}, { .dev_id = "fsmc-nand", .clk = &fsmc_clk}, /* clock derived from apb clk */ { .dev_id = "adc", .clk = &adc_clk}, { .dev_id = "ssp-pl022.0", .clk = &ssp0_clk}, { .dev_id = "ssp-pl022.1", .clk = &ssp1_clk}, { .dev_id = "ssp-pl022.2", .clk = &ssp2_clk}, { .dev_id = "f0100000.gpio", .clk = &gpio0_clk}, { .dev_id = "fc980000.gpio", .clk = &gpio1_clk}, { .dev_id = "d8100000.gpio", .clk = &gpio2_clk}, }; void __init spear6xx_clk_init(void) { int i; for (i = 0; i < ARRAY_SIZE(spear_clk_lookups); i++) clk_register(&spear_clk_lookups[i]); clk_init(); }
gpl-2.0
arasilinux/arasievm-kernel
scripts/basic/fixdep.c
4983
10782
/* * "Optimize" a list of dependencies as spit out by gcc -MD * for the kernel build * =========================================================================== * * Author Kai Germaschewski * Copyright 2002 by Kai Germaschewski <kai.germaschewski@gmx.de> * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * * * Introduction: * * gcc produces a very nice and correct list of dependencies which * tells make when to remake a file. * * To use this list as-is however has the drawback that virtually * every file in the kernel includes autoconf.h. * * If the user re-runs make *config, autoconf.h will be * regenerated. make notices that and will rebuild every file which * includes autoconf.h, i.e. basically all files. This is extremely * annoying if the user just changed CONFIG_HIS_DRIVER from n to m. * * So we play the same trick that "mkdep" played before. We replace * the dependency on autoconf.h by a dependency on every config * option which is mentioned in any of the listed prequisites. * * kconfig populates a tree in include/config/ with an empty file * for each config symbol and when the configuration is updated * the files representing changed config options are touched * which then let make pick up the changes and the files that use * the config symbols are rebuilt. * * So if the user changes his CONFIG_HIS_DRIVER option, only the objects * which depend on "include/linux/config/his/driver.h" will be rebuilt, * so most likely only his driver ;-) * * The idea above dates, by the way, back to Michael E Chastain, AFAIK. * * So to get dependencies right, there are two issues: * o if any of the files the compiler read changed, we need to rebuild * o if the command line given to the compile the file changed, we * better rebuild as well. * * The former is handled by using the -MD output, the later by saving * the command line used to compile the old object and comparing it * to the one we would now use. * * Again, also this idea is pretty old and has been discussed on * kbuild-devel a long time ago. I don't have a sensibly working * internet connection right now, so I rather don't mention names * without double checking. * * This code here has been based partially based on mkdep.c, which * says the following about its history: * * Copyright abandoned, Michael Chastain, <mailto:mec@shout.net>. * This is a C version of syncdep.pl by Werner Almesberger. * * * It is invoked as * * fixdep <depfile> <target> <cmdline> * * and will read the dependency file <depfile> * * The transformed dependency snipped is written to stdout. * * It first generates a line * * cmd_<target> = <cmdline> * * and then basically copies the .<target>.d file to stdout, in the * process filtering out the dependency on autoconf.h and adding * dependencies on include/config/my/option.h for every * CONFIG_MY_OPTION encountered in any of the prequisites. * * It will also filter out all the dependencies on *.ver. We need * to make sure that the generated version checksum are globally up * to date before even starting the recursive build, so it's too late * at this point anyway. * * The algorithm to grep for "CONFIG_..." is bit unusual, but should * be fast ;-) We don't even try to really parse the header files, but * merely grep, i.e. if CONFIG_FOO is mentioned in a comment, it will * be picked up as well. It's not a problem with respect to * correctness, since that can only give too many dependencies, thus * we cannot miss a rebuild. Since people tend to not mention totally * unrelated CONFIG_ options all over the place, it's not an * efficiency problem either. * * (Note: it'd be easy to port over the complete mkdep state machine, * but I don't think the added complexity is worth it) */ /* * Note 2: if somebody writes HELLO_CONFIG_BOOM in a file, it will depend onto * CONFIG_BOOM. This could seem a bug (not too hard to fix), but please do not * fix it! Some UserModeLinux files (look at arch/um/) call CONFIG_BOOM as * UML_CONFIG_BOOM, to avoid conflicts with /usr/include/linux/autoconf.h, * through arch/um/include/uml-config.h; this fixdep "bug" makes sure that * those files will have correct dependencies. */ #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <limits.h> #include <ctype.h> #include <arpa/inet.h> #define INT_CONF ntohl(0x434f4e46) #define INT_ONFI ntohl(0x4f4e4649) #define INT_NFIG ntohl(0x4e464947) #define INT_FIG_ ntohl(0x4649475f) char *target; char *depfile; char *cmdline; static void usage(void) { fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n"); exit(1); } /* * Print out the commandline prefixed with cmd_<target filename> := */ static void print_cmdline(void) { printf("cmd_%s := %s\n\n", target, cmdline); } struct item { struct item *next; unsigned int len; unsigned int hash; char name[0]; }; #define HASHSZ 256 static struct item *hashtab[HASHSZ]; static unsigned int strhash(const char *str, unsigned int sz) { /* fnv32 hash */ unsigned int i, hash = 2166136261U; for (i = 0; i < sz; i++) hash = (hash ^ str[i]) * 0x01000193; return hash; } /* * Lookup a value in the configuration string. */ static int is_defined_config(const char *name, int len, unsigned int hash) { struct item *aux; for (aux = hashtab[hash % HASHSZ]; aux; aux = aux->next) { if (aux->hash == hash && aux->len == len && memcmp(aux->name, name, len) == 0) return 1; } return 0; } /* * Add a new value to the configuration string. */ static void define_config(const char *name, int len, unsigned int hash) { struct item *aux = malloc(sizeof(*aux) + len); if (!aux) { perror("fixdep:malloc"); exit(1); } memcpy(aux->name, name, len); aux->len = len; aux->hash = hash; aux->next = hashtab[hash % HASHSZ]; hashtab[hash % HASHSZ] = aux; } /* * Clear the set of configuration strings. */ static void clear_config(void) { struct item *aux, *next; unsigned int i; for (i = 0; i < HASHSZ; i++) { for (aux = hashtab[i]; aux; aux = next) { next = aux->next; free(aux); } hashtab[i] = NULL; } } /* * Record the use of a CONFIG_* word. */ static void use_config(const char *m, int slen) { unsigned int hash = strhash(m, slen); int c, i; if (is_defined_config(m, slen, hash)) return; define_config(m, slen, hash); printf(" $(wildcard include/config/"); for (i = 0; i < slen; i++) { c = m[i]; if (c == '_') c = '/'; else c = tolower(c); putchar(c); } printf(".h) \\\n"); } static void parse_config_file(const char *map, size_t len) { const int *end = (const int *) (map + len); /* start at +1, so that p can never be < map */ const int *m = (const int *) map + 1; const char *p, *q; for (; m < end; m++) { if (*m == INT_CONF) { p = (char *) m ; goto conf; } if (*m == INT_ONFI) { p = (char *) m-1; goto conf; } if (*m == INT_NFIG) { p = (char *) m-2; goto conf; } if (*m == INT_FIG_) { p = (char *) m-3; goto conf; } continue; conf: if (p > map + len - 7) continue; if (memcmp(p, "CONFIG_", 7)) continue; for (q = p + 7; q < map + len; q++) { if (!(isalnum(*q) || *q == '_')) goto found; } continue; found: if (!memcmp(q - 7, "_MODULE", 7)) q -= 7; if( (q-p-7) < 0 ) continue; use_config(p+7, q-p-7); } } /* test is s ends in sub */ static int strrcmp(char *s, char *sub) { int slen = strlen(s); int sublen = strlen(sub); if (sublen > slen) return 1; return memcmp(s + slen - sublen, sub, sublen); } static void do_config_file(const char *filename) { struct stat st; int fd; void *map; fd = open(filename, O_RDONLY); if (fd < 0) { fprintf(stderr, "fixdep: error opening config file: "); perror(filename); exit(2); } fstat(fd, &st); if (st.st_size == 0) { close(fd); return; } map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if ((long) map == -1) { perror("fixdep: mmap"); close(fd); return; } parse_config_file(map, st.st_size); munmap(map, st.st_size); close(fd); } /* * Important: The below generated source_foo.o and deps_foo.o variable * assignments are parsed not only by make, but also by the rather simple * parser in scripts/mod/sumversion.c. */ static void parse_dep_file(void *map, size_t len) { char *m = map; char *end = m + len; char *p; char s[PATH_MAX]; int first; p = strchr(m, ':'); if (!p) { fprintf(stderr, "fixdep: parse error\n"); exit(1); } memcpy(s, m, p-m); s[p-m] = 0; m = p+1; clear_config(); first = 1; while (m < end) { while (m < end && (*m == ' ' || *m == '\\' || *m == '\n')) m++; p = m; while (p < end && *p != ' ') p++; if (p == end) { do p--; while (!isalnum(*p)); p++; } memcpy(s, m, p-m); s[p-m] = 0; if (strrcmp(s, "include/generated/autoconf.h") && strrcmp(s, "arch/um/include/uml-config.h") && strrcmp(s, "include/linux/kconfig.h") && strrcmp(s, ".ver")) { /* * Do not list the source file as dependency, so that * kbuild is not confused if a .c file is rewritten * into .S or vice versa. Storing it in source_* is * needed for modpost to compute srcversions. */ if (first) { printf("source_%s := %s\n\n", target, s); printf("deps_%s := \\\n", target); } else printf(" %s \\\n", s); do_config_file(s); } first = 0; m = p + 1; } printf("\n%s: $(deps_%s)\n\n", target, target); printf("$(deps_%s):\n", target); } static void print_deps(void) { struct stat st; int fd; void *map; fd = open(depfile, O_RDONLY); if (fd < 0) { fprintf(stderr, "fixdep: error opening depfile: "); perror(depfile); exit(2); } if (fstat(fd, &st) < 0) { fprintf(stderr, "fixdep: error fstat'ing depfile: "); perror(depfile); exit(2); } if (st.st_size == 0) { fprintf(stderr,"fixdep: %s is empty\n",depfile); close(fd); return; } map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if ((long) map == -1) { perror("fixdep: mmap"); close(fd); return; } parse_dep_file(map, st.st_size); munmap(map, st.st_size); close(fd); } static void traps(void) { static char test[] __attribute__((aligned(sizeof(int)))) = "CONF"; int *p = (int *)test; if (*p != INT_CONF) { fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n", *p); exit(2); } } int main(int argc, char *argv[]) { traps(); if (argc != 4) usage(); depfile = argv[1]; target = argv[2]; cmdline = argv[3]; print_cmdline(); print_deps(); return 0; }
gpl-2.0
fhasovic/furnace_lg
drivers/video/backlight/vgg2432a4.c
4983
6383
/* drivers/video/backlight/vgg2432a4.c * * VGG2432A4 (ILI9320) LCD controller driver. * * Copyright 2007 Simtec Electronics * http://armlinux.simtec.co.uk/ * Ben Dooks <ben@simtec.co.uk> * * 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/delay.h> #include <linux/err.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/lcd.h> #include <linux/module.h> #include <linux/spi/spi.h> #include <video/ili9320.h> #include "ili9320.h" /* Device initialisation sequences */ static struct ili9320_reg vgg_init1[] = { { .address = ILI9320_POWER1, .value = ILI9320_POWER1_AP(0) | ILI9320_POWER1_BT(0), }, { .address = ILI9320_POWER2, .value = (ILI9320_POWER2_VC(7) | ILI9320_POWER2_DC0(0) | ILI9320_POWER2_DC1(0)), }, { .address = ILI9320_POWER3, .value = ILI9320_POWER3_VRH(0), }, { .address = ILI9320_POWER4, .value = ILI9320_POWER4_VREOUT(0), }, }; static struct ili9320_reg vgg_init2[] = { { .address = ILI9320_POWER1, .value = (ILI9320_POWER1_AP(3) | ILI9320_POWER1_APE | ILI9320_POWER1_BT(7) | ILI9320_POWER1_SAP), }, { .address = ILI9320_POWER2, .value = ILI9320_POWER2_VC(7) | ILI9320_POWER2_DC0(3), } }; static struct ili9320_reg vgg_gamma[] = { { .address = ILI9320_GAMMA1, .value = 0x0000, }, { .address = ILI9320_GAMMA2, .value = 0x0505, }, { .address = ILI9320_GAMMA3, .value = 0x0004, }, { .address = ILI9320_GAMMA4, .value = 0x0006, }, { .address = ILI9320_GAMMA5, .value = 0x0707, }, { .address = ILI9320_GAMMA6, .value = 0x0105, }, { .address = ILI9320_GAMMA7, .value = 0x0002, }, { .address = ILI9320_GAMMA8, .value = 0x0707, }, { .address = ILI9320_GAMMA9, .value = 0x0704, }, { .address = ILI9320_GAMMA10, .value = 0x807, } }; static struct ili9320_reg vgg_init0[] = { [0] = { /* set direction and scan mode gate */ .address = ILI9320_DRIVER, .value = ILI9320_DRIVER_SS, }, { .address = ILI9320_DRIVEWAVE, .value = (ILI9320_DRIVEWAVE_MUSTSET | ILI9320_DRIVEWAVE_EOR | ILI9320_DRIVEWAVE_BC), }, { .address = ILI9320_ENTRYMODE, .value = ILI9320_ENTRYMODE_ID(3) | ILI9320_ENTRYMODE_BGR, }, { .address = ILI9320_RESIZING, .value = 0x0, }, }; static int vgg2432a4_lcd_init(struct ili9320 *lcd, struct ili9320_platdata *cfg) { unsigned int addr; int ret; /* Set VCore before anything else (VGG243237-6UFLWA) */ ret = ili9320_write(lcd, 0x00e5, 0x8000); if (ret) goto err_initial; /* Start the oscillator up before we can do anything else. */ ret = ili9320_write(lcd, ILI9320_OSCILATION, ILI9320_OSCILATION_OSC); if (ret) goto err_initial; /* must wait at-lesat 10ms after starting */ mdelay(15); ret = ili9320_write_regs(lcd, vgg_init0, ARRAY_SIZE(vgg_init0)); if (ret != 0) goto err_initial; ili9320_write(lcd, ILI9320_DISPLAY2, cfg->display2); ili9320_write(lcd, ILI9320_DISPLAY3, cfg->display3); ili9320_write(lcd, ILI9320_DISPLAY4, cfg->display4); ili9320_write(lcd, ILI9320_RGB_IF1, cfg->rgb_if1); ili9320_write(lcd, ILI9320_FRAMEMAKER, 0x0); ili9320_write(lcd, ILI9320_RGB_IF2, cfg->rgb_if2); ret = ili9320_write_regs(lcd, vgg_init1, ARRAY_SIZE(vgg_init1)); if (ret != 0) goto err_vgg; mdelay(300); ret = ili9320_write_regs(lcd, vgg_init2, ARRAY_SIZE(vgg_init2)); if (ret != 0) goto err_vgg2; mdelay(100); ili9320_write(lcd, ILI9320_POWER3, 0x13c); mdelay(100); ili9320_write(lcd, ILI9320_POWER4, 0x1c00); ili9320_write(lcd, ILI9320_POWER7, 0x000e); mdelay(100); ili9320_write(lcd, ILI9320_GRAM_HORIZ_ADDR, 0x00); ili9320_write(lcd, ILI9320_GRAM_VERT_ADD, 0x00); ret = ili9320_write_regs(lcd, vgg_gamma, ARRAY_SIZE(vgg_gamma)); if (ret != 0) goto err_vgg3; ili9320_write(lcd, ILI9320_HORIZ_START, 0x0); ili9320_write(lcd, ILI9320_HORIZ_END, cfg->hsize - 1); ili9320_write(lcd, ILI9320_VERT_START, 0x0); ili9320_write(lcd, ILI9320_VERT_END, cfg->vsize - 1); ili9320_write(lcd, ILI9320_DRIVER2, ILI9320_DRIVER2_NL(((cfg->vsize - 240) / 8) + 0x1D)); ili9320_write(lcd, ILI9320_BASE_IMAGE, 0x1); ili9320_write(lcd, ILI9320_VERT_SCROLL, 0x00); for (addr = ILI9320_PARTIAL1_POSITION; addr <= ILI9320_PARTIAL2_END; addr++) { ili9320_write(lcd, addr, 0x0); } ili9320_write(lcd, ILI9320_INTERFACE1, 0x10); ili9320_write(lcd, ILI9320_INTERFACE2, cfg->interface2); ili9320_write(lcd, ILI9320_INTERFACE3, cfg->interface3); ili9320_write(lcd, ILI9320_INTERFACE4, cfg->interface4); ili9320_write(lcd, ILI9320_INTERFACE5, cfg->interface5); ili9320_write(lcd, ILI9320_INTERFACE6, cfg->interface6); lcd->display1 = (ILI9320_DISPLAY1_D(3) | ILI9320_DISPLAY1_DTE | ILI9320_DISPLAY1_GON | ILI9320_DISPLAY1_BASEE | 0x40); ili9320_write(lcd, ILI9320_DISPLAY1, lcd->display1); return 0; err_vgg3: err_vgg2: err_vgg: err_initial: return ret; } #ifdef CONFIG_PM static int vgg2432a4_suspend(struct spi_device *spi, pm_message_t state) { return ili9320_suspend(dev_get_drvdata(&spi->dev), state); } static int vgg2432a4_resume(struct spi_device *spi) { return ili9320_resume(dev_get_drvdata(&spi->dev)); } #else #define vgg2432a4_suspend NULL #define vgg2432a4_resume NULL #endif static struct ili9320_client vgg2432a4_client = { .name = "VGG2432A4", .init = vgg2432a4_lcd_init, }; /* Device probe */ static int __devinit vgg2432a4_probe(struct spi_device *spi) { int ret; ret = ili9320_probe_spi(spi, &vgg2432a4_client); if (ret != 0) { dev_err(&spi->dev, "failed to initialise ili9320\n"); return ret; } return 0; } static int __devexit vgg2432a4_remove(struct spi_device *spi) { return ili9320_remove(dev_get_drvdata(&spi->dev)); } static void vgg2432a4_shutdown(struct spi_device *spi) { ili9320_shutdown(dev_get_drvdata(&spi->dev)); } static struct spi_driver vgg2432a4_driver = { .driver = { .name = "VGG2432A4", .owner = THIS_MODULE, }, .probe = vgg2432a4_probe, .remove = __devexit_p(vgg2432a4_remove), .shutdown = vgg2432a4_shutdown, .suspend = vgg2432a4_suspend, .resume = vgg2432a4_resume, }; module_spi_driver(vgg2432a4_driver); MODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>"); MODULE_DESCRIPTION("VGG2432A4 LCD Driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("spi:VGG2432A4");
gpl-2.0
SlimDevs/kernel_lge_hammerhead
drivers/scsi/ips.c
4983
241346
/*****************************************************************************/ /* ips.c -- driver for the Adaptec / IBM ServeRAID controller */ /* */ /* Written By: Keith Mitchell, IBM Corporation */ /* Jack Hammer, Adaptec, Inc. */ /* David Jeffery, Adaptec, Inc. */ /* */ /* Copyright (C) 2000 IBM Corporation */ /* Copyright (C) 2002,2003 Adaptec, Inc. */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* NO WARRANTY */ /* THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR */ /* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT */ /* LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, */ /* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is */ /* solely responsible for determining the appropriateness of using and */ /* distributing the Program and assumes all risks associated with its */ /* exercise of rights under this Agreement, including but not limited to */ /* the risks and costs of program errors, damage to or loss of data, */ /* programs or equipment, and unavailability or interruption of operations. */ /* */ /* DISCLAIMER OF LIABILITY */ /* NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY */ /* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL */ /* DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), 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 OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED */ /* HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES */ /* */ /* 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 */ /* */ /* Bugs/Comments/Suggestions about this driver should be mailed to: */ /* ipslinux@adaptec.com */ /* */ /* For system support issues, contact your local IBM Customer support. */ /* Directions to find IBM Customer Support for each country can be found at: */ /* http://www.ibm.com/planetwide/ */ /* */ /*****************************************************************************/ /*****************************************************************************/ /* Change Log */ /* */ /* 0.99.02 - Breakup commands that are bigger than 8 * the stripe size */ /* 0.99.03 - Make interrupt routine handle all completed request on the */ /* adapter not just the first one */ /* - Make sure passthru commands get woken up if we run out of */ /* SCBs */ /* - Send all of the commands on the queue at once rather than */ /* one at a time since the card will support it. */ /* 0.99.04 - Fix race condition in the passthru mechanism -- this required */ /* the interface to the utilities to change */ /* - Fix error recovery code */ /* 0.99.05 - Fix an oops when we get certain passthru commands */ /* 1.00.00 - Initial Public Release */ /* Functionally equivalent to 0.99.05 */ /* 3.60.00 - Bump max commands to 128 for use with firmware 3.60 */ /* - Change version to 3.60 to coincide with release numbering. */ /* 3.60.01 - Remove bogus error check in passthru routine */ /* 3.60.02 - Make DCDB direction based on lookup table */ /* - Only allow one DCDB command to a SCSI ID at a time */ /* 4.00.00 - Add support for ServeRAID 4 */ /* 4.00.01 - Add support for First Failure Data Capture */ /* 4.00.02 - Fix problem with PT DCDB with no buffer */ /* 4.00.03 - Add alternative passthru interface */ /* - Add ability to flash BIOS */ /* 4.00.04 - Rename structures/constants to be prefixed with IPS_ */ /* 4.00.05 - Remove wish_block from init routine */ /* - Use linux/spinlock.h instead of asm/spinlock.h for kernels */ /* 2.3.18 and later */ /* - Sync with other changes from the 2.3 kernels */ /* 4.00.06 - Fix timeout with initial FFDC command */ /* 4.00.06a - Port to 2.4 (trivial) -- Christoph Hellwig <hch@infradead.org> */ /* 4.10.00 - Add support for ServeRAID 4M/4L */ /* 4.10.13 - Fix for dynamic unload and proc file system */ /* 4.20.03 - Rename version to coincide with new release schedules */ /* Performance fixes */ /* Fix truncation of /proc files with cat */ /* Merge in changes through kernel 2.4.0test1ac21 */ /* 4.20.13 - Fix some failure cases / reset code */ /* - Hook into the reboot_notifier to flush the controller cache */ /* 4.50.01 - Fix problem when there is a hole in logical drive numbering */ /* 4.70.09 - Use a Common ( Large Buffer ) for Flashing from the JCRM CD */ /* - Add IPSSEND Flash Support */ /* - Set Sense Data for Unknown SCSI Command */ /* - Use Slot Number from NVRAM Page 5 */ /* - Restore caller's DCDB Structure */ /* 4.70.12 - Corrective actions for bad controller ( during initialization )*/ /* 4.70.13 - Don't Send CDB's if we already know the device is not present */ /* - Don't release HA Lock in ips_next() until SC taken off queue */ /* - Unregister SCSI device in ips_release() */ /* 4.70.15 - Fix Breakup for very large ( non-SG ) requests in ips_done() */ /* 4.71.00 - Change all memory allocations to not use GFP_DMA flag */ /* Code Clean-Up for 2.4.x kernel */ /* 4.72.00 - Allow for a Scatter-Gather Element to exceed MAX_XFER Size */ /* 4.72.01 - I/O Mapped Memory release ( so "insmod ips" does not Fail ) */ /* - Don't Issue Internal FFDC Command if there are Active Commands */ /* - Close Window for getting too many IOCTL's active */ /* 4.80.00 - Make ia64 Safe */ /* 4.80.04 - Eliminate calls to strtok() if 2.4.x or greater */ /* - Adjustments to Device Queue Depth */ /* 4.80.14 - Take all semaphores off stack */ /* - Clean Up New_IOCTL path */ /* 4.80.20 - Set max_sectors in Scsi_Host structure ( if >= 2.4.7 kernel ) */ /* - 5 second delay needed after resetting an i960 adapter */ /* 4.80.26 - Clean up potential code problems ( Arjan's recommendations ) */ /* 4.90.01 - Version Matching for FirmWare, BIOS, and Driver */ /* 4.90.05 - Use New PCI Architecture to facilitate Hot Plug Development */ /* 4.90.08 - Increase Delays in Flashing ( Trombone Only - 4H ) */ /* 4.90.08 - Data Corruption if First Scatter Gather Element is > 64K */ /* 4.90.11 - Don't actually RESET unless it's physically required */ /* - Remove unused compile options */ /* 5.00.01 - Sarasota ( 5i ) adapters must always be scanned first */ /* - Get rid on IOCTL_NEW_COMMAND code */ /* - Add Extended DCDB Commands for Tape Support in 5I */ /* 5.10.12 - use pci_dma interfaces, update for 2.5 kernel changes */ /* 5.10.15 - remove unused code (sem, macros, etc.) */ /* 5.30.00 - use __devexit_p() */ /* 6.00.00 - Add 6x Adapters and Battery Flash */ /* 6.10.00 - Remove 1G Addressing Limitations */ /* 6.11.xx - Get VersionInfo buffer off the stack ! DDTS 60401 */ /* 6.11.xx - Make Logical Drive Info structure safe for DMA DDTS 60639 */ /* 7.10.18 - Add highmem_io flag in SCSI Templete for 2.4 kernels */ /* - Fix path/name for scsi_hosts.h include for 2.6 kernels */ /* - Fix sort order of 7k */ /* - Remove 3 unused "inline" functions */ /* 7.12.xx - Use STATIC functions wherever possible */ /* - Clean up deprecated MODULE_PARM calls */ /* 7.12.05 - Remove Version Matching per IBM request */ /*****************************************************************************/ /* * Conditional Compilation directives for this driver: * * IPS_DEBUG - Turn on debugging info * * Parameters: * * debug:<number> - Set debug level to <number> * NOTE: only works when IPS_DEBUG compile directive is used. * 1 - Normal debug messages * 2 - Verbose debug messages * 11 - Method trace (non interrupt) * 12 - Method trace (includes interrupt) * * noi2o - Don't use I2O Queues (ServeRAID 4 only) * nommap - Don't use memory mapped I/O * ioctlsize - Initial size of the IOCTL buffer */ #include <asm/io.h> #include <asm/byteorder.h> #include <asm/page.h> #include <linux/stddef.h> #include <linux/string.h> #include <linux/errno.h> #include <linux/kernel.h> #include <linux/ioport.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/pci.h> #include <linux/proc_fs.h> #include <linux/reboot.h> #include <linux/interrupt.h> #include <linux/blkdev.h> #include <linux/types.h> #include <linux/dma-mapping.h> #include <scsi/sg.h> #include "scsi.h" #include <scsi/scsi_host.h> #include "ips.h" #include <linux/module.h> #include <linux/stat.h> #include <linux/spinlock.h> #include <linux/init.h> #include <linux/smp.h> #ifdef MODULE static char *ips = NULL; module_param(ips, charp, 0); #endif /* * DRIVER_VER */ #define IPS_VERSION_HIGH IPS_VER_MAJOR_STRING "." IPS_VER_MINOR_STRING #define IPS_VERSION_LOW "." IPS_VER_BUILD_STRING " " #if !defined(__i386__) && !defined(__ia64__) && !defined(__x86_64__) #warning "This driver has only been tested on the x86/ia64/x86_64 platforms" #endif #define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \ DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \ PCI_DMA_BIDIRECTIONAL : \ scb->scsi_cmd->sc_data_direction) #ifdef IPS_DEBUG #define METHOD_TRACE(s, i) if (ips_debug >= (i+10)) printk(KERN_NOTICE s "\n"); #define DEBUG(i, s) if (ips_debug >= i) printk(KERN_NOTICE s "\n"); #define DEBUG_VAR(i, s, v...) if (ips_debug >= i) printk(KERN_NOTICE s "\n", v); #else #define METHOD_TRACE(s, i) #define DEBUG(i, s) #define DEBUG_VAR(i, s, v...) #endif /* * Function prototypes */ static int ips_detect(struct scsi_host_template *); static int ips_release(struct Scsi_Host *); static int ips_eh_abort(struct scsi_cmnd *); static int ips_eh_reset(struct scsi_cmnd *); static int ips_queue(struct Scsi_Host *, struct scsi_cmnd *); static const char *ips_info(struct Scsi_Host *); static irqreturn_t do_ipsintr(int, void *); static int ips_hainit(ips_ha_t *); static int ips_map_status(ips_ha_t *, ips_scb_t *, ips_stat_t *); static int ips_send_wait(ips_ha_t *, ips_scb_t *, int, int); static int ips_send_cmd(ips_ha_t *, ips_scb_t *); static int ips_online(ips_ha_t *, ips_scb_t *); static int ips_inquiry(ips_ha_t *, ips_scb_t *); static int ips_rdcap(ips_ha_t *, ips_scb_t *); static int ips_msense(ips_ha_t *, ips_scb_t *); static int ips_reqsen(ips_ha_t *, ips_scb_t *); static int ips_deallocatescbs(ips_ha_t *, int); static int ips_allocatescbs(ips_ha_t *); static int ips_reset_copperhead(ips_ha_t *); static int ips_reset_copperhead_memio(ips_ha_t *); static int ips_reset_morpheus(ips_ha_t *); static int ips_issue_copperhead(ips_ha_t *, ips_scb_t *); static int ips_issue_copperhead_memio(ips_ha_t *, ips_scb_t *); static int ips_issue_i2o(ips_ha_t *, ips_scb_t *); static int ips_issue_i2o_memio(ips_ha_t *, ips_scb_t *); static int ips_isintr_copperhead(ips_ha_t *); static int ips_isintr_copperhead_memio(ips_ha_t *); static int ips_isintr_morpheus(ips_ha_t *); static int ips_wait(ips_ha_t *, int, int); static int ips_write_driver_status(ips_ha_t *, int); static int ips_read_adapter_status(ips_ha_t *, int); static int ips_read_subsystem_parameters(ips_ha_t *, int); static int ips_read_config(ips_ha_t *, int); static int ips_clear_adapter(ips_ha_t *, int); static int ips_readwrite_page5(ips_ha_t *, int, int); static int ips_init_copperhead(ips_ha_t *); static int ips_init_copperhead_memio(ips_ha_t *); static int ips_init_morpheus(ips_ha_t *); static int ips_isinit_copperhead(ips_ha_t *); static int ips_isinit_copperhead_memio(ips_ha_t *); static int ips_isinit_morpheus(ips_ha_t *); static int ips_erase_bios(ips_ha_t *); static int ips_program_bios(ips_ha_t *, char *, uint32_t, uint32_t); static int ips_verify_bios(ips_ha_t *, char *, uint32_t, uint32_t); static int ips_erase_bios_memio(ips_ha_t *); static int ips_program_bios_memio(ips_ha_t *, char *, uint32_t, uint32_t); static int ips_verify_bios_memio(ips_ha_t *, char *, uint32_t, uint32_t); static int ips_flash_copperhead(ips_ha_t *, ips_passthru_t *, ips_scb_t *); static int ips_flash_bios(ips_ha_t *, ips_passthru_t *, ips_scb_t *); static int ips_flash_firmware(ips_ha_t *, ips_passthru_t *, ips_scb_t *); static void ips_free_flash_copperhead(ips_ha_t * ha); static void ips_get_bios_version(ips_ha_t *, int); static void ips_identify_controller(ips_ha_t *); static void ips_chkstatus(ips_ha_t *, IPS_STATUS *); static void ips_enable_int_copperhead(ips_ha_t *); static void ips_enable_int_copperhead_memio(ips_ha_t *); static void ips_enable_int_morpheus(ips_ha_t *); static int ips_intr_copperhead(ips_ha_t *); static int ips_intr_morpheus(ips_ha_t *); static void ips_next(ips_ha_t *, int); static void ipsintr_blocking(ips_ha_t *, struct ips_scb *); static void ipsintr_done(ips_ha_t *, struct ips_scb *); static void ips_done(ips_ha_t *, ips_scb_t *); static void ips_free(ips_ha_t *); static void ips_init_scb(ips_ha_t *, ips_scb_t *); static void ips_freescb(ips_ha_t *, ips_scb_t *); static void ips_setup_funclist(ips_ha_t *); static void ips_statinit(ips_ha_t *); static void ips_statinit_memio(ips_ha_t *); static void ips_fix_ffdc_time(ips_ha_t *, ips_scb_t *, time_t); static void ips_ffdc_reset(ips_ha_t *, int); static void ips_ffdc_time(ips_ha_t *); static uint32_t ips_statupd_copperhead(ips_ha_t *); static uint32_t ips_statupd_copperhead_memio(ips_ha_t *); static uint32_t ips_statupd_morpheus(ips_ha_t *); static ips_scb_t *ips_getscb(ips_ha_t *); static void ips_putq_scb_head(ips_scb_queue_t *, ips_scb_t *); static void ips_putq_wait_tail(ips_wait_queue_t *, struct scsi_cmnd *); static void ips_putq_copp_tail(ips_copp_queue_t *, ips_copp_wait_item_t *); static ips_scb_t *ips_removeq_scb_head(ips_scb_queue_t *); static ips_scb_t *ips_removeq_scb(ips_scb_queue_t *, ips_scb_t *); static struct scsi_cmnd *ips_removeq_wait_head(ips_wait_queue_t *); static struct scsi_cmnd *ips_removeq_wait(ips_wait_queue_t *, struct scsi_cmnd *); static ips_copp_wait_item_t *ips_removeq_copp(ips_copp_queue_t *, ips_copp_wait_item_t *); static ips_copp_wait_item_t *ips_removeq_copp_head(ips_copp_queue_t *); static int ips_is_passthru(struct scsi_cmnd *); static int ips_make_passthru(ips_ha_t *, struct scsi_cmnd *, ips_scb_t *, int); static int ips_usrcmd(ips_ha_t *, ips_passthru_t *, ips_scb_t *); static void ips_cleanup_passthru(ips_ha_t *, ips_scb_t *); static void ips_scmd_buf_write(struct scsi_cmnd * scmd, void *data, unsigned int count); static void ips_scmd_buf_read(struct scsi_cmnd * scmd, void *data, unsigned int count); static int ips_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int); static int ips_host_info(ips_ha_t *, char *, off_t, int); static void copy_mem_info(IPS_INFOSTR *, char *, int); static int copy_info(IPS_INFOSTR *, char *, ...); static int ips_abort_init(ips_ha_t * ha, int index); static int ips_init_phase2(int index); static int ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr); static int ips_register_scsi(int index); static int ips_poll_for_flush_complete(ips_ha_t * ha); static void ips_flush_and_reset(ips_ha_t *ha); /* * global variables */ static const char ips_name[] = "ips"; static struct Scsi_Host *ips_sh[IPS_MAX_ADAPTERS]; /* Array of host controller structures */ static ips_ha_t *ips_ha[IPS_MAX_ADAPTERS]; /* Array of HA structures */ static unsigned int ips_next_controller; static unsigned int ips_num_controllers; static unsigned int ips_released_controllers; static int ips_hotplug; static int ips_cmd_timeout = 60; static int ips_reset_timeout = 60 * 5; static int ips_force_memio = 1; /* Always use Memory Mapped I/O */ static int ips_force_i2o = 1; /* Always use I2O command delivery */ static int ips_ioctlsize = IPS_IOCTL_SIZE; /* Size of the ioctl buffer */ static int ips_cd_boot; /* Booting from Manager CD */ static char *ips_FlashData = NULL; /* CD Boot - Flash Data Buffer */ static dma_addr_t ips_flashbusaddr; static long ips_FlashDataInUse; /* CD Boot - Flash Data In Use Flag */ static uint32_t MaxLiteCmds = 32; /* Max Active Cmds for a Lite Adapter */ static struct scsi_host_template ips_driver_template = { .detect = ips_detect, .release = ips_release, .info = ips_info, .queuecommand = ips_queue, .eh_abort_handler = ips_eh_abort, .eh_host_reset_handler = ips_eh_reset, .proc_name = "ips", .proc_info = ips_proc_info, .slave_configure = ips_slave_configure, .bios_param = ips_biosparam, .this_id = -1, .sg_tablesize = IPS_MAX_SG, .cmd_per_lun = 3, .use_clustering = ENABLE_CLUSTERING, }; /* This table describes all ServeRAID Adapters */ static struct pci_device_id ips_pci_table[] = { { 0x1014, 0x002E, PCI_ANY_ID, PCI_ANY_ID, 0, 0 }, { 0x1014, 0x01BD, PCI_ANY_ID, PCI_ANY_ID, 0, 0 }, { 0x9005, 0x0250, PCI_ANY_ID, PCI_ANY_ID, 0, 0 }, { 0, } }; MODULE_DEVICE_TABLE( pci, ips_pci_table ); static char ips_hot_plug_name[] = "ips"; static int __devinit ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent); static void __devexit ips_remove_device(struct pci_dev *pci_dev); static struct pci_driver ips_pci_driver = { .name = ips_hot_plug_name, .id_table = ips_pci_table, .probe = ips_insert_device, .remove = __devexit_p(ips_remove_device), }; /* * Necessary forward function protoypes */ static int ips_halt(struct notifier_block *nb, ulong event, void *buf); #define MAX_ADAPTER_NAME 15 static char ips_adapter_name[][30] = { "ServeRAID", "ServeRAID II", "ServeRAID on motherboard", "ServeRAID on motherboard", "ServeRAID 3H", "ServeRAID 3L", "ServeRAID 4H", "ServeRAID 4M", "ServeRAID 4L", "ServeRAID 4Mx", "ServeRAID 4Lx", "ServeRAID 5i", "ServeRAID 5i", "ServeRAID 6M", "ServeRAID 6i", "ServeRAID 7t", "ServeRAID 7k", "ServeRAID 7M" }; static struct notifier_block ips_notifier = { ips_halt, NULL, 0 }; /* * Direction table */ static char ips_command_direction[] = { IPS_DATA_NONE, IPS_DATA_NONE, IPS_DATA_IN, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_IN, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_IN, IPS_DATA_UNK, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_IN, IPS_DATA_NONE, IPS_DATA_NONE, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_NONE, IPS_DATA_NONE, IPS_DATA_OUT, IPS_DATA_NONE, IPS_DATA_IN, IPS_DATA_NONE, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_NONE, IPS_DATA_UNK, IPS_DATA_IN, IPS_DATA_UNK, IPS_DATA_IN, IPS_DATA_UNK, IPS_DATA_OUT, IPS_DATA_IN, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_IN, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_NONE, IPS_DATA_UNK, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_NONE, IPS_DATA_IN, IPS_DATA_NONE, IPS_DATA_NONE, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_IN, IPS_DATA_IN, IPS_DATA_IN, IPS_DATA_NONE, IPS_DATA_UNK, IPS_DATA_NONE, IPS_DATA_NONE, IPS_DATA_NONE, IPS_DATA_UNK, IPS_DATA_NONE, IPS_DATA_OUT, IPS_DATA_IN, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_OUT, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_IN, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_NONE, IPS_DATA_NONE, IPS_DATA_UNK, IPS_DATA_IN, IPS_DATA_NONE, IPS_DATA_OUT, IPS_DATA_UNK, IPS_DATA_NONE, IPS_DATA_UNK, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_OUT, IPS_DATA_NONE, IPS_DATA_UNK, IPS_DATA_IN, IPS_DATA_OUT, IPS_DATA_IN, IPS_DATA_IN, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_OUT, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK, IPS_DATA_UNK }; /****************************************************************************/ /* */ /* Routine Name: ips_setup */ /* */ /* Routine Description: */ /* */ /* setup parameters to the driver */ /* */ /****************************************************************************/ static int ips_setup(char *ips_str) { int i; char *key; char *value; IPS_OPTION options[] = { {"noi2o", &ips_force_i2o, 0}, {"nommap", &ips_force_memio, 0}, {"ioctlsize", &ips_ioctlsize, IPS_IOCTL_SIZE}, {"cdboot", &ips_cd_boot, 0}, {"maxcmds", &MaxLiteCmds, 32}, }; /* Don't use strtok() anymore ( if 2.4 Kernel or beyond ) */ /* Search for value */ while ((key = strsep(&ips_str, ",."))) { if (!*key) continue; value = strchr(key, ':'); if (value) *value++ = '\0'; /* * We now have key/value pairs. * Update the variables */ for (i = 0; i < ARRAY_SIZE(options); i++) { if (strnicmp (key, options[i].option_name, strlen(options[i].option_name)) == 0) { if (value) *options[i].option_flag = simple_strtoul(value, NULL, 0); else *options[i].option_flag = options[i].option_value; break; } } } return (1); } __setup("ips=", ips_setup); /****************************************************************************/ /* */ /* Routine Name: ips_detect */ /* */ /* Routine Description: */ /* */ /* Detect and initialize the driver */ /* */ /* NOTE: this routine is called under the io_request_lock spinlock */ /* */ /****************************************************************************/ static int ips_detect(struct scsi_host_template * SHT) { int i; METHOD_TRACE("ips_detect", 1); #ifdef MODULE if (ips) ips_setup(ips); #endif for (i = 0; i < ips_num_controllers; i++) { if (ips_register_scsi(i)) ips_free(ips_ha[i]); ips_released_controllers++; } ips_hotplug = 1; return (ips_num_controllers); } /****************************************************************************/ /* configure the function pointers to use the functions that will work */ /* with the found version of the adapter */ /****************************************************************************/ static void ips_setup_funclist(ips_ha_t * ha) { /* * Setup Functions */ if (IPS_IS_MORPHEUS(ha) || IPS_IS_MARCO(ha)) { /* morpheus / marco / sebring */ ha->func.isintr = ips_isintr_morpheus; ha->func.isinit = ips_isinit_morpheus; ha->func.issue = ips_issue_i2o_memio; ha->func.init = ips_init_morpheus; ha->func.statupd = ips_statupd_morpheus; ha->func.reset = ips_reset_morpheus; ha->func.intr = ips_intr_morpheus; ha->func.enableint = ips_enable_int_morpheus; } else if (IPS_USE_MEMIO(ha)) { /* copperhead w/MEMIO */ ha->func.isintr = ips_isintr_copperhead_memio; ha->func.isinit = ips_isinit_copperhead_memio; ha->func.init = ips_init_copperhead_memio; ha->func.statupd = ips_statupd_copperhead_memio; ha->func.statinit = ips_statinit_memio; ha->func.reset = ips_reset_copperhead_memio; ha->func.intr = ips_intr_copperhead; ha->func.erasebios = ips_erase_bios_memio; ha->func.programbios = ips_program_bios_memio; ha->func.verifybios = ips_verify_bios_memio; ha->func.enableint = ips_enable_int_copperhead_memio; if (IPS_USE_I2O_DELIVER(ha)) ha->func.issue = ips_issue_i2o_memio; else ha->func.issue = ips_issue_copperhead_memio; } else { /* copperhead */ ha->func.isintr = ips_isintr_copperhead; ha->func.isinit = ips_isinit_copperhead; ha->func.init = ips_init_copperhead; ha->func.statupd = ips_statupd_copperhead; ha->func.statinit = ips_statinit; ha->func.reset = ips_reset_copperhead; ha->func.intr = ips_intr_copperhead; ha->func.erasebios = ips_erase_bios; ha->func.programbios = ips_program_bios; ha->func.verifybios = ips_verify_bios; ha->func.enableint = ips_enable_int_copperhead; if (IPS_USE_I2O_DELIVER(ha)) ha->func.issue = ips_issue_i2o; else ha->func.issue = ips_issue_copperhead; } } /****************************************************************************/ /* */ /* Routine Name: ips_release */ /* */ /* Routine Description: */ /* */ /* Remove a driver */ /* */ /****************************************************************************/ static int ips_release(struct Scsi_Host *sh) { ips_scb_t *scb; ips_ha_t *ha; int i; METHOD_TRACE("ips_release", 1); scsi_remove_host(sh); for (i = 0; i < IPS_MAX_ADAPTERS && ips_sh[i] != sh; i++) ; if (i == IPS_MAX_ADAPTERS) { printk(KERN_WARNING "(%s) release, invalid Scsi_Host pointer.\n", ips_name); BUG(); return (FALSE); } ha = IPS_HA(sh); if (!ha) return (FALSE); /* flush the cache on the controller */ scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_FLUSH; scb->cmd.flush_cache.op_code = IPS_CMD_FLUSH; scb->cmd.flush_cache.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.flush_cache.state = IPS_NORM_STATE; scb->cmd.flush_cache.reserved = 0; scb->cmd.flush_cache.reserved2 = 0; scb->cmd.flush_cache.reserved3 = 0; scb->cmd.flush_cache.reserved4 = 0; IPS_PRINTK(KERN_WARNING, ha->pcidev, "Flushing Cache.\n"); /* send command */ if (ips_send_wait(ha, scb, ips_cmd_timeout, IPS_INTR_ON) == IPS_FAILURE) IPS_PRINTK(KERN_WARNING, ha->pcidev, "Incomplete Flush.\n"); IPS_PRINTK(KERN_WARNING, ha->pcidev, "Flushing Complete.\n"); ips_sh[i] = NULL; ips_ha[i] = NULL; /* free extra memory */ ips_free(ha); /* free IRQ */ free_irq(ha->pcidev->irq, ha); scsi_host_put(sh); ips_released_controllers++; return (FALSE); } /****************************************************************************/ /* */ /* Routine Name: ips_halt */ /* */ /* Routine Description: */ /* */ /* Perform cleanup when the system reboots */ /* */ /****************************************************************************/ static int ips_halt(struct notifier_block *nb, ulong event, void *buf) { ips_scb_t *scb; ips_ha_t *ha; int i; if ((event != SYS_RESTART) && (event != SYS_HALT) && (event != SYS_POWER_OFF)) return (NOTIFY_DONE); for (i = 0; i < ips_next_controller; i++) { ha = (ips_ha_t *) ips_ha[i]; if (!ha) continue; if (!ha->active) continue; /* flush the cache on the controller */ scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_FLUSH; scb->cmd.flush_cache.op_code = IPS_CMD_FLUSH; scb->cmd.flush_cache.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.flush_cache.state = IPS_NORM_STATE; scb->cmd.flush_cache.reserved = 0; scb->cmd.flush_cache.reserved2 = 0; scb->cmd.flush_cache.reserved3 = 0; scb->cmd.flush_cache.reserved4 = 0; IPS_PRINTK(KERN_WARNING, ha->pcidev, "Flushing Cache.\n"); /* send command */ if (ips_send_wait(ha, scb, ips_cmd_timeout, IPS_INTR_ON) == IPS_FAILURE) IPS_PRINTK(KERN_WARNING, ha->pcidev, "Incomplete Flush.\n"); else IPS_PRINTK(KERN_WARNING, ha->pcidev, "Flushing Complete.\n"); } return (NOTIFY_OK); } /****************************************************************************/ /* */ /* Routine Name: ips_eh_abort */ /* */ /* Routine Description: */ /* */ /* Abort a command (using the new error code stuff) */ /* Note: this routine is called under the io_request_lock */ /****************************************************************************/ int ips_eh_abort(struct scsi_cmnd *SC) { ips_ha_t *ha; ips_copp_wait_item_t *item; int ret; struct Scsi_Host *host; METHOD_TRACE("ips_eh_abort", 1); if (!SC) return (FAILED); host = SC->device->host; ha = (ips_ha_t *) SC->device->host->hostdata; if (!ha) return (FAILED); if (!ha->active) return (FAILED); spin_lock(host->host_lock); /* See if the command is on the copp queue */ item = ha->copp_waitlist.head; while ((item) && (item->scsi_cmd != SC)) item = item->next; if (item) { /* Found it */ ips_removeq_copp(&ha->copp_waitlist, item); ret = (SUCCESS); /* See if the command is on the wait queue */ } else if (ips_removeq_wait(&ha->scb_waitlist, SC)) { /* command not sent yet */ ret = (SUCCESS); } else { /* command must have already been sent */ ret = (FAILED); } spin_unlock(host->host_lock); return ret; } /****************************************************************************/ /* */ /* Routine Name: ips_eh_reset */ /* */ /* Routine Description: */ /* */ /* Reset the controller (with new eh error code) */ /* */ /* NOTE: this routine is called under the io_request_lock spinlock */ /* */ /****************************************************************************/ static int __ips_eh_reset(struct scsi_cmnd *SC) { int ret; int i; ips_ha_t *ha; ips_scb_t *scb; ips_copp_wait_item_t *item; METHOD_TRACE("ips_eh_reset", 1); #ifdef NO_IPS_RESET return (FAILED); #else if (!SC) { DEBUG(1, "Reset called with NULL scsi command"); return (FAILED); } ha = (ips_ha_t *) SC->device->host->hostdata; if (!ha) { DEBUG(1, "Reset called with NULL ha struct"); return (FAILED); } if (!ha->active) return (FAILED); /* See if the command is on the copp queue */ item = ha->copp_waitlist.head; while ((item) && (item->scsi_cmd != SC)) item = item->next; if (item) { /* Found it */ ips_removeq_copp(&ha->copp_waitlist, item); return (SUCCESS); } /* See if the command is on the wait queue */ if (ips_removeq_wait(&ha->scb_waitlist, SC)) { /* command not sent yet */ return (SUCCESS); } /* An explanation for the casual observer: */ /* Part of the function of a RAID controller is automatic error */ /* detection and recovery. As such, the only problem that physically */ /* resetting an adapter will ever fix is when, for some reason, */ /* the driver is not successfully communicating with the adapter. */ /* Therefore, we will attempt to flush this adapter. If that succeeds, */ /* then there's no real purpose in a physical reset. This will complete */ /* much faster and avoids any problems that might be caused by a */ /* physical reset ( such as having to fail all the outstanding I/O's ). */ if (ha->ioctl_reset == 0) { /* IF Not an IOCTL Requested Reset */ scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_FLUSH; scb->cmd.flush_cache.op_code = IPS_CMD_FLUSH; scb->cmd.flush_cache.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.flush_cache.state = IPS_NORM_STATE; scb->cmd.flush_cache.reserved = 0; scb->cmd.flush_cache.reserved2 = 0; scb->cmd.flush_cache.reserved3 = 0; scb->cmd.flush_cache.reserved4 = 0; /* Attempt the flush command */ ret = ips_send_wait(ha, scb, ips_cmd_timeout, IPS_INTR_IORL); if (ret == IPS_SUCCESS) { IPS_PRINTK(KERN_NOTICE, ha->pcidev, "Reset Request - Flushed Cache\n"); return (SUCCESS); } } /* Either we can't communicate with the adapter or it's an IOCTL request */ /* from a utility. A physical reset is needed at this point. */ ha->ioctl_reset = 0; /* Reset the IOCTL Requested Reset Flag */ /* * command must have already been sent * reset the controller */ IPS_PRINTK(KERN_NOTICE, ha->pcidev, "Resetting controller.\n"); ret = (*ha->func.reset) (ha); if (!ret) { struct scsi_cmnd *scsi_cmd; IPS_PRINTK(KERN_NOTICE, ha->pcidev, "Controller reset failed - controller now offline.\n"); /* Now fail all of the active commands */ DEBUG_VAR(1, "(%s%d) Failing active commands", ips_name, ha->host_num); while ((scb = ips_removeq_scb_head(&ha->scb_activelist))) { scb->scsi_cmd->result = DID_ERROR << 16; scb->scsi_cmd->scsi_done(scb->scsi_cmd); ips_freescb(ha, scb); } /* Now fail all of the pending commands */ DEBUG_VAR(1, "(%s%d) Failing pending commands", ips_name, ha->host_num); while ((scsi_cmd = ips_removeq_wait_head(&ha->scb_waitlist))) { scsi_cmd->result = DID_ERROR; scsi_cmd->scsi_done(scsi_cmd); } ha->active = FALSE; return (FAILED); } if (!ips_clear_adapter(ha, IPS_INTR_IORL)) { struct scsi_cmnd *scsi_cmd; IPS_PRINTK(KERN_NOTICE, ha->pcidev, "Controller reset failed - controller now offline.\n"); /* Now fail all of the active commands */ DEBUG_VAR(1, "(%s%d) Failing active commands", ips_name, ha->host_num); while ((scb = ips_removeq_scb_head(&ha->scb_activelist))) { scb->scsi_cmd->result = DID_ERROR << 16; scb->scsi_cmd->scsi_done(scb->scsi_cmd); ips_freescb(ha, scb); } /* Now fail all of the pending commands */ DEBUG_VAR(1, "(%s%d) Failing pending commands", ips_name, ha->host_num); while ((scsi_cmd = ips_removeq_wait_head(&ha->scb_waitlist))) { scsi_cmd->result = DID_ERROR << 16; scsi_cmd->scsi_done(scsi_cmd); } ha->active = FALSE; return (FAILED); } /* FFDC */ if (le32_to_cpu(ha->subsys->param[3]) & 0x300000) { struct timeval tv; do_gettimeofday(&tv); ha->last_ffdc = tv.tv_sec; ha->reset_count++; ips_ffdc_reset(ha, IPS_INTR_IORL); } /* Now fail all of the active commands */ DEBUG_VAR(1, "(%s%d) Failing active commands", ips_name, ha->host_num); while ((scb = ips_removeq_scb_head(&ha->scb_activelist))) { scb->scsi_cmd->result = DID_RESET << 16; scb->scsi_cmd->scsi_done(scb->scsi_cmd); ips_freescb(ha, scb); } /* Reset DCDB active command bits */ for (i = 1; i < ha->nbus; i++) ha->dcdb_active[i - 1] = 0; /* Reset the number of active IOCTLs */ ha->num_ioctl = 0; ips_next(ha, IPS_INTR_IORL); return (SUCCESS); #endif /* NO_IPS_RESET */ } static int ips_eh_reset(struct scsi_cmnd *SC) { int rc; spin_lock_irq(SC->device->host->host_lock); rc = __ips_eh_reset(SC); spin_unlock_irq(SC->device->host->host_lock); return rc; } /****************************************************************************/ /* */ /* Routine Name: ips_queue */ /* */ /* Routine Description: */ /* */ /* Send a command to the controller */ /* */ /* NOTE: */ /* Linux obtains io_request_lock before calling this function */ /* */ /****************************************************************************/ static int ips_queue_lck(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *)) { ips_ha_t *ha; ips_passthru_t *pt; METHOD_TRACE("ips_queue", 1); ha = (ips_ha_t *) SC->device->host->hostdata; if (!ha) return (1); if (!ha->active) return (DID_ERROR); if (ips_is_passthru(SC)) { if (ha->copp_waitlist.count == IPS_MAX_IOCTL_QUEUE) { SC->result = DID_BUS_BUSY << 16; done(SC); return (0); } } else if (ha->scb_waitlist.count == IPS_MAX_QUEUE) { SC->result = DID_BUS_BUSY << 16; done(SC); return (0); } SC->scsi_done = done; DEBUG_VAR(2, "(%s%d): ips_queue: cmd 0x%X (%d %d %d)", ips_name, ha->host_num, SC->cmnd[0], SC->device->channel, SC->device->id, SC->device->lun); /* Check for command to initiator IDs */ if ((scmd_channel(SC) > 0) && (scmd_id(SC) == ha->ha_id[scmd_channel(SC)])) { SC->result = DID_NO_CONNECT << 16; done(SC); return (0); } if (ips_is_passthru(SC)) { ips_copp_wait_item_t *scratch; /* A Reset IOCTL is only sent by the boot CD in extreme cases. */ /* There can never be any system activity ( network or disk ), but check */ /* anyway just as a good practice. */ pt = (ips_passthru_t *) scsi_sglist(SC); if ((pt->CoppCP.cmd.reset.op_code == IPS_CMD_RESET_CHANNEL) && (pt->CoppCP.cmd.reset.adapter_flag == 1)) { if (ha->scb_activelist.count != 0) { SC->result = DID_BUS_BUSY << 16; done(SC); return (0); } ha->ioctl_reset = 1; /* This reset request is from an IOCTL */ __ips_eh_reset(SC); SC->result = DID_OK << 16; SC->scsi_done(SC); return (0); } /* allocate space for the scribble */ scratch = kmalloc(sizeof (ips_copp_wait_item_t), GFP_ATOMIC); if (!scratch) { SC->result = DID_ERROR << 16; done(SC); return (0); } scratch->scsi_cmd = SC; scratch->next = NULL; ips_putq_copp_tail(&ha->copp_waitlist, scratch); } else { ips_putq_wait_tail(&ha->scb_waitlist, SC); } ips_next(ha, IPS_INTR_IORL); return (0); } static DEF_SCSI_QCMD(ips_queue) /****************************************************************************/ /* */ /* Routine Name: ips_biosparam */ /* */ /* Routine Description: */ /* */ /* Set bios geometry for the controller */ /* */ /****************************************************************************/ static int ips_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int geom[]) { ips_ha_t *ha = (ips_ha_t *) sdev->host->hostdata; int heads; int sectors; int cylinders; METHOD_TRACE("ips_biosparam", 1); if (!ha) /* ?!?! host adater info invalid */ return (0); if (!ha->active) return (0); if (!ips_read_adapter_status(ha, IPS_INTR_ON)) /* ?!?! Enquiry command failed */ return (0); if ((capacity > 0x400000) && ((ha->enq->ucMiscFlag & 0x8) == 0)) { heads = IPS_NORM_HEADS; sectors = IPS_NORM_SECTORS; } else { heads = IPS_COMP_HEADS; sectors = IPS_COMP_SECTORS; } cylinders = (unsigned long) capacity / (heads * sectors); DEBUG_VAR(2, "Geometry: heads: %d, sectors: %d, cylinders: %d", heads, sectors, cylinders); geom[0] = heads; geom[1] = sectors; geom[2] = cylinders; return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_slave_configure */ /* */ /* Routine Description: */ /* */ /* Set queue depths on devices once scan is complete */ /* */ /****************************************************************************/ static int ips_slave_configure(struct scsi_device * SDptr) { ips_ha_t *ha; int min; ha = IPS_HA(SDptr->host); if (SDptr->tagged_supported && SDptr->type == TYPE_DISK) { min = ha->max_cmds / 2; if (ha->enq->ucLogDriveCount <= 2) min = ha->max_cmds - 1; scsi_adjust_queue_depth(SDptr, MSG_ORDERED_TAG, min); } SDptr->skip_ms_page_8 = 1; SDptr->skip_ms_page_3f = 1; return 0; } /****************************************************************************/ /* */ /* Routine Name: do_ipsintr */ /* */ /* Routine Description: */ /* */ /* Wrapper for the interrupt handler */ /* */ /****************************************************************************/ static irqreturn_t do_ipsintr(int irq, void *dev_id) { ips_ha_t *ha; struct Scsi_Host *host; int irqstatus; METHOD_TRACE("do_ipsintr", 2); ha = (ips_ha_t *) dev_id; if (!ha) return IRQ_NONE; host = ips_sh[ha->host_num]; /* interrupt during initialization */ if (!host) { (*ha->func.intr) (ha); return IRQ_HANDLED; } spin_lock(host->host_lock); if (!ha->active) { spin_unlock(host->host_lock); return IRQ_HANDLED; } irqstatus = (*ha->func.intr) (ha); spin_unlock(host->host_lock); /* start the next command */ ips_next(ha, IPS_INTR_ON); return IRQ_RETVAL(irqstatus); } /****************************************************************************/ /* */ /* Routine Name: ips_intr_copperhead */ /* */ /* Routine Description: */ /* */ /* Polling interrupt handler */ /* */ /* ASSUMES interrupts are disabled */ /* */ /****************************************************************************/ int ips_intr_copperhead(ips_ha_t * ha) { ips_stat_t *sp; ips_scb_t *scb; IPS_STATUS cstatus; int intrstatus; METHOD_TRACE("ips_intr", 2); if (!ha) return 0; if (!ha->active) return 0; intrstatus = (*ha->func.isintr) (ha); if (!intrstatus) { /* * Unexpected/Shared interrupt */ return 0; } while (TRUE) { sp = &ha->sp; intrstatus = (*ha->func.isintr) (ha); if (!intrstatus) break; else cstatus.value = (*ha->func.statupd) (ha); if (cstatus.fields.command_id > (IPS_MAX_CMDS - 1)) { /* Spurious Interrupt ? */ continue; } ips_chkstatus(ha, &cstatus); scb = (ips_scb_t *) sp->scb_addr; /* * use the callback function to finish things up * NOTE: interrupts are OFF for this */ (*scb->callback) (ha, scb); } /* end while */ return 1; } /****************************************************************************/ /* */ /* Routine Name: ips_intr_morpheus */ /* */ /* Routine Description: */ /* */ /* Polling interrupt handler */ /* */ /* ASSUMES interrupts are disabled */ /* */ /****************************************************************************/ int ips_intr_morpheus(ips_ha_t * ha) { ips_stat_t *sp; ips_scb_t *scb; IPS_STATUS cstatus; int intrstatus; METHOD_TRACE("ips_intr_morpheus", 2); if (!ha) return 0; if (!ha->active) return 0; intrstatus = (*ha->func.isintr) (ha); if (!intrstatus) { /* * Unexpected/Shared interrupt */ return 0; } while (TRUE) { sp = &ha->sp; intrstatus = (*ha->func.isintr) (ha); if (!intrstatus) break; else cstatus.value = (*ha->func.statupd) (ha); if (cstatus.value == 0xffffffff) /* No more to process */ break; if (cstatus.fields.command_id > (IPS_MAX_CMDS - 1)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "Spurious interrupt; no ccb.\n"); continue; } ips_chkstatus(ha, &cstatus); scb = (ips_scb_t *) sp->scb_addr; /* * use the callback function to finish things up * NOTE: interrupts are OFF for this */ (*scb->callback) (ha, scb); } /* end while */ return 1; } /****************************************************************************/ /* */ /* Routine Name: ips_info */ /* */ /* Routine Description: */ /* */ /* Return info about the driver */ /* */ /****************************************************************************/ static const char * ips_info(struct Scsi_Host *SH) { static char buffer[256]; char *bp; ips_ha_t *ha; METHOD_TRACE("ips_info", 1); ha = IPS_HA(SH); if (!ha) return (NULL); bp = &buffer[0]; memset(bp, 0, sizeof (buffer)); sprintf(bp, "%s%s%s Build %d", "IBM PCI ServeRAID ", IPS_VERSION_HIGH, IPS_VERSION_LOW, IPS_BUILD_IDENT); if (ha->ad_type > 0 && ha->ad_type <= MAX_ADAPTER_NAME) { strcat(bp, " <"); strcat(bp, ips_adapter_name[ha->ad_type - 1]); strcat(bp, ">"); } return (bp); } /****************************************************************************/ /* */ /* Routine Name: ips_proc_info */ /* */ /* Routine Description: */ /* */ /* The passthru interface for the driver */ /* */ /****************************************************************************/ static int ips_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func) { int i; int ret; ips_ha_t *ha = NULL; METHOD_TRACE("ips_proc_info", 1); /* Find our host structure */ for (i = 0; i < ips_next_controller; i++) { if (ips_sh[i]) { if (ips_sh[i] == host) { ha = (ips_ha_t *) ips_sh[i]->hostdata; break; } } } if (!ha) return (-EINVAL); if (func) { /* write */ return (0); } else { /* read */ if (start) *start = buffer; ret = ips_host_info(ha, buffer, offset, length); return (ret); } } /*--------------------------------------------------------------------------*/ /* Helper Functions */ /*--------------------------------------------------------------------------*/ /****************************************************************************/ /* */ /* Routine Name: ips_is_passthru */ /* */ /* Routine Description: */ /* */ /* Determine if the specified SCSI command is really a passthru command */ /* */ /****************************************************************************/ static int ips_is_passthru(struct scsi_cmnd *SC) { unsigned long flags; METHOD_TRACE("ips_is_passthru", 1); if (!SC) return (0); if ((SC->cmnd[0] == IPS_IOCTL_COMMAND) && (SC->device->channel == 0) && (SC->device->id == IPS_ADAPTER_ID) && (SC->device->lun == 0) && scsi_sglist(SC)) { struct scatterlist *sg = scsi_sglist(SC); char *buffer; /* kmap_atomic() ensures addressability of the user buffer.*/ /* local_irq_save() protects the KM_IRQ0 address slot. */ local_irq_save(flags); buffer = kmap_atomic(sg_page(sg)) + sg->offset; if (buffer && buffer[0] == 'C' && buffer[1] == 'O' && buffer[2] == 'P' && buffer[3] == 'P') { kunmap_atomic(buffer - sg->offset); local_irq_restore(flags); return 1; } kunmap_atomic(buffer - sg->offset); local_irq_restore(flags); } return 0; } /****************************************************************************/ /* */ /* Routine Name: ips_alloc_passthru_buffer */ /* */ /* Routine Description: */ /* allocate a buffer large enough for the ioctl data if the ioctl buffer */ /* is too small or doesn't exist */ /****************************************************************************/ static int ips_alloc_passthru_buffer(ips_ha_t * ha, int length) { void *bigger_buf; dma_addr_t dma_busaddr; if (ha->ioctl_data && length <= ha->ioctl_len) return 0; /* there is no buffer or it's not big enough, allocate a new one */ bigger_buf = pci_alloc_consistent(ha->pcidev, length, &dma_busaddr); if (bigger_buf) { /* free the old memory */ pci_free_consistent(ha->pcidev, ha->ioctl_len, ha->ioctl_data, ha->ioctl_busaddr); /* use the new memory */ ha->ioctl_data = (char *) bigger_buf; ha->ioctl_len = length; ha->ioctl_busaddr = dma_busaddr; } else { return -1; } return 0; } /****************************************************************************/ /* */ /* Routine Name: ips_make_passthru */ /* */ /* Routine Description: */ /* */ /* Make a passthru command out of the info in the Scsi block */ /* */ /****************************************************************************/ static int ips_make_passthru(ips_ha_t *ha, struct scsi_cmnd *SC, ips_scb_t *scb, int intr) { ips_passthru_t *pt; int length = 0; int i, ret; struct scatterlist *sg = scsi_sglist(SC); METHOD_TRACE("ips_make_passthru", 1); scsi_for_each_sg(SC, sg, scsi_sg_count(SC), i) length += sg->length; if (length < sizeof (ips_passthru_t)) { /* wrong size */ DEBUG_VAR(1, "(%s%d) Passthru structure wrong size", ips_name, ha->host_num); return (IPS_FAILURE); } if (ips_alloc_passthru_buffer(ha, length)) { /* allocation failure! If ha->ioctl_data exists, use it to return some error codes. Return a failed command to the scsi layer. */ if (ha->ioctl_data) { pt = (ips_passthru_t *) ha->ioctl_data; ips_scmd_buf_read(SC, pt, sizeof (ips_passthru_t)); pt->BasicStatus = 0x0B; pt->ExtendedStatus = 0x00; ips_scmd_buf_write(SC, pt, sizeof (ips_passthru_t)); } return IPS_FAILURE; } ha->ioctl_datasize = length; ips_scmd_buf_read(SC, ha->ioctl_data, ha->ioctl_datasize); pt = (ips_passthru_t *) ha->ioctl_data; /* * Some notes about the passthru interface used * * IF the scsi op_code == 0x0d then we assume * that the data came along with/goes with the * packet we received from the sg driver. In this * case the CmdBSize field of the pt structure is * used for the size of the buffer. */ switch (pt->CoppCmd) { case IPS_NUMCTRLS: memcpy(ha->ioctl_data + sizeof (ips_passthru_t), &ips_num_controllers, sizeof (int)); ips_scmd_buf_write(SC, ha->ioctl_data, sizeof (ips_passthru_t) + sizeof (int)); SC->result = DID_OK << 16; return (IPS_SUCCESS_IMM); case IPS_COPPUSRCMD: case IPS_COPPIOCCMD: if (SC->cmnd[0] == IPS_IOCTL_COMMAND) { if (length < (sizeof (ips_passthru_t) + pt->CmdBSize)) { /* wrong size */ DEBUG_VAR(1, "(%s%d) Passthru structure wrong size", ips_name, ha->host_num); return (IPS_FAILURE); } if (ha->pcidev->device == IPS_DEVICEID_COPPERHEAD && pt->CoppCP.cmd.flashfw.op_code == IPS_CMD_RW_BIOSFW) { ret = ips_flash_copperhead(ha, pt, scb); ips_scmd_buf_write(SC, ha->ioctl_data, sizeof (ips_passthru_t)); return ret; } if (ips_usrcmd(ha, pt, scb)) return (IPS_SUCCESS); else return (IPS_FAILURE); } break; } /* end switch */ return (IPS_FAILURE); } /****************************************************************************/ /* Routine Name: ips_flash_copperhead */ /* Routine Description: */ /* Flash the BIOS/FW on a Copperhead style controller */ /****************************************************************************/ static int ips_flash_copperhead(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) { int datasize; /* Trombone is the only copperhead that can do packet flash, but only * for firmware. No one said it had to make sense. */ if (IPS_IS_TROMBONE(ha) && pt->CoppCP.cmd.flashfw.type == IPS_FW_IMAGE) { if (ips_usrcmd(ha, pt, scb)) return IPS_SUCCESS; else return IPS_FAILURE; } pt->BasicStatus = 0x0B; pt->ExtendedStatus = 0; scb->scsi_cmd->result = DID_OK << 16; /* IF it's OK to Use the "CD BOOT" Flash Buffer, then you can */ /* avoid allocating a huge buffer per adapter ( which can fail ). */ if (pt->CoppCP.cmd.flashfw.type == IPS_BIOS_IMAGE && pt->CoppCP.cmd.flashfw.direction == IPS_ERASE_BIOS) { pt->BasicStatus = 0; return ips_flash_bios(ha, pt, scb); } else if (pt->CoppCP.cmd.flashfw.packet_num == 0) { if (ips_FlashData && !test_and_set_bit(0, &ips_FlashDataInUse)){ ha->flash_data = ips_FlashData; ha->flash_busaddr = ips_flashbusaddr; ha->flash_len = PAGE_SIZE << 7; ha->flash_datasize = 0; } else if (!ha->flash_data) { datasize = pt->CoppCP.cmd.flashfw.total_packets * pt->CoppCP.cmd.flashfw.count; ha->flash_data = pci_alloc_consistent(ha->pcidev, datasize, &ha->flash_busaddr); if (!ha->flash_data){ printk(KERN_WARNING "Unable to allocate a flash buffer\n"); return IPS_FAILURE; } ha->flash_datasize = 0; ha->flash_len = datasize; } else return IPS_FAILURE; } else { if (pt->CoppCP.cmd.flashfw.count + ha->flash_datasize > ha->flash_len) { ips_free_flash_copperhead(ha); IPS_PRINTK(KERN_WARNING, ha->pcidev, "failed size sanity check\n"); return IPS_FAILURE; } } if (!ha->flash_data) return IPS_FAILURE; pt->BasicStatus = 0; memcpy(&ha->flash_data[ha->flash_datasize], pt + 1, pt->CoppCP.cmd.flashfw.count); ha->flash_datasize += pt->CoppCP.cmd.flashfw.count; if (pt->CoppCP.cmd.flashfw.packet_num == pt->CoppCP.cmd.flashfw.total_packets - 1) { if (pt->CoppCP.cmd.flashfw.type == IPS_BIOS_IMAGE) return ips_flash_bios(ha, pt, scb); else if (pt->CoppCP.cmd.flashfw.type == IPS_FW_IMAGE) return ips_flash_firmware(ha, pt, scb); } return IPS_SUCCESS_IMM; } /****************************************************************************/ /* Routine Name: ips_flash_bios */ /* Routine Description: */ /* flashes the bios of a copperhead adapter */ /****************************************************************************/ static int ips_flash_bios(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) { if (pt->CoppCP.cmd.flashfw.type == IPS_BIOS_IMAGE && pt->CoppCP.cmd.flashfw.direction == IPS_WRITE_BIOS) { if ((!ha->func.programbios) || (!ha->func.erasebios) || (!ha->func.verifybios)) goto error; if ((*ha->func.erasebios) (ha)) { DEBUG_VAR(1, "(%s%d) flash bios failed - unable to erase flash", ips_name, ha->host_num); goto error; } else if ((*ha->func.programbios) (ha, ha->flash_data + IPS_BIOS_HEADER, ha->flash_datasize - IPS_BIOS_HEADER, 0)) { DEBUG_VAR(1, "(%s%d) flash bios failed - unable to flash", ips_name, ha->host_num); goto error; } else if ((*ha->func.verifybios) (ha, ha->flash_data + IPS_BIOS_HEADER, ha->flash_datasize - IPS_BIOS_HEADER, 0)) { DEBUG_VAR(1, "(%s%d) flash bios failed - unable to verify flash", ips_name, ha->host_num); goto error; } ips_free_flash_copperhead(ha); return IPS_SUCCESS_IMM; } else if (pt->CoppCP.cmd.flashfw.type == IPS_BIOS_IMAGE && pt->CoppCP.cmd.flashfw.direction == IPS_ERASE_BIOS) { if (!ha->func.erasebios) goto error; if ((*ha->func.erasebios) (ha)) { DEBUG_VAR(1, "(%s%d) flash bios failed - unable to erase flash", ips_name, ha->host_num); goto error; } return IPS_SUCCESS_IMM; } error: pt->BasicStatus = 0x0B; pt->ExtendedStatus = 0x00; ips_free_flash_copperhead(ha); return IPS_FAILURE; } /****************************************************************************/ /* */ /* Routine Name: ips_fill_scb_sg_single */ /* */ /* Routine Description: */ /* Fill in a single scb sg_list element from an address */ /* return a -1 if a breakup occurred */ /****************************************************************************/ static int ips_fill_scb_sg_single(ips_ha_t * ha, dma_addr_t busaddr, ips_scb_t * scb, int indx, unsigned int e_len) { int ret_val = 0; if ((scb->data_len + e_len) > ha->max_xfer) { e_len = ha->max_xfer - scb->data_len; scb->breakup = indx; ++scb->sg_break; ret_val = -1; } else { scb->breakup = 0; scb->sg_break = 0; } if (IPS_USE_ENH_SGLIST(ha)) { scb->sg_list.enh_list[indx].address_lo = cpu_to_le32(pci_dma_lo32(busaddr)); scb->sg_list.enh_list[indx].address_hi = cpu_to_le32(pci_dma_hi32(busaddr)); scb->sg_list.enh_list[indx].length = cpu_to_le32(e_len); } else { scb->sg_list.std_list[indx].address = cpu_to_le32(pci_dma_lo32(busaddr)); scb->sg_list.std_list[indx].length = cpu_to_le32(e_len); } ++scb->sg_len; scb->data_len += e_len; return ret_val; } /****************************************************************************/ /* Routine Name: ips_flash_firmware */ /* Routine Description: */ /* flashes the firmware of a copperhead adapter */ /****************************************************************************/ static int ips_flash_firmware(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) { IPS_SG_LIST sg_list; uint32_t cmd_busaddr; if (pt->CoppCP.cmd.flashfw.type == IPS_FW_IMAGE && pt->CoppCP.cmd.flashfw.direction == IPS_WRITE_FW) { memset(&pt->CoppCP.cmd, 0, sizeof (IPS_HOST_COMMAND)); pt->CoppCP.cmd.flashfw.op_code = IPS_CMD_DOWNLOAD; pt->CoppCP.cmd.flashfw.count = cpu_to_le32(ha->flash_datasize); } else { pt->BasicStatus = 0x0B; pt->ExtendedStatus = 0x00; ips_free_flash_copperhead(ha); return IPS_FAILURE; } /* Save the S/G list pointer so it doesn't get clobbered */ sg_list.list = scb->sg_list.list; cmd_busaddr = scb->scb_busaddr; /* copy in the CP */ memcpy(&scb->cmd, &pt->CoppCP.cmd, sizeof (IPS_IOCTL_CMD)); /* FIX stuff that might be wrong */ scb->sg_list.list = sg_list.list; scb->scb_busaddr = cmd_busaddr; scb->bus = scb->scsi_cmd->device->channel; scb->target_id = scb->scsi_cmd->device->id; scb->lun = scb->scsi_cmd->device->lun; scb->sg_len = 0; scb->data_len = 0; scb->flags = 0; scb->op_code = 0; scb->callback = ipsintr_done; scb->timeout = ips_cmd_timeout; scb->data_len = ha->flash_datasize; scb->data_busaddr = pci_map_single(ha->pcidev, ha->flash_data, scb->data_len, IPS_DMA_DIR(scb)); scb->flags |= IPS_SCB_MAP_SINGLE; scb->cmd.flashfw.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.flashfw.buffer_addr = cpu_to_le32(scb->data_busaddr); if (pt->TimeOut) scb->timeout = pt->TimeOut; scb->scsi_cmd->result = DID_OK << 16; return IPS_SUCCESS; } /****************************************************************************/ /* Routine Name: ips_free_flash_copperhead */ /* Routine Description: */ /* release the memory resources used to hold the flash image */ /****************************************************************************/ static void ips_free_flash_copperhead(ips_ha_t * ha) { if (ha->flash_data == ips_FlashData) test_and_clear_bit(0, &ips_FlashDataInUse); else if (ha->flash_data) pci_free_consistent(ha->pcidev, ha->flash_len, ha->flash_data, ha->flash_busaddr); ha->flash_data = NULL; } /****************************************************************************/ /* */ /* Routine Name: ips_usrcmd */ /* */ /* Routine Description: */ /* */ /* Process a user command and make it ready to send */ /* */ /****************************************************************************/ static int ips_usrcmd(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) { IPS_SG_LIST sg_list; uint32_t cmd_busaddr; METHOD_TRACE("ips_usrcmd", 1); if ((!scb) || (!pt) || (!ha)) return (0); /* Save the S/G list pointer so it doesn't get clobbered */ sg_list.list = scb->sg_list.list; cmd_busaddr = scb->scb_busaddr; /* copy in the CP */ memcpy(&scb->cmd, &pt->CoppCP.cmd, sizeof (IPS_IOCTL_CMD)); memcpy(&scb->dcdb, &pt->CoppCP.dcdb, sizeof (IPS_DCDB_TABLE)); /* FIX stuff that might be wrong */ scb->sg_list.list = sg_list.list; scb->scb_busaddr = cmd_busaddr; scb->bus = scb->scsi_cmd->device->channel; scb->target_id = scb->scsi_cmd->device->id; scb->lun = scb->scsi_cmd->device->lun; scb->sg_len = 0; scb->data_len = 0; scb->flags = 0; scb->op_code = 0; scb->callback = ipsintr_done; scb->timeout = ips_cmd_timeout; scb->cmd.basic_io.command_id = IPS_COMMAND_ID(ha, scb); /* we don't support DCDB/READ/WRITE Scatter Gather */ if ((scb->cmd.basic_io.op_code == IPS_CMD_READ_SG) || (scb->cmd.basic_io.op_code == IPS_CMD_WRITE_SG) || (scb->cmd.basic_io.op_code == IPS_CMD_DCDB_SG)) return (0); if (pt->CmdBSize) { scb->data_len = pt->CmdBSize; scb->data_busaddr = ha->ioctl_busaddr + sizeof (ips_passthru_t); } else { scb->data_busaddr = 0L; } if (scb->cmd.dcdb.op_code == IPS_CMD_DCDB) scb->cmd.dcdb.dcdb_address = cpu_to_le32(scb->scb_busaddr + (unsigned long) &scb-> dcdb - (unsigned long) scb); if (pt->CmdBSize) { if (scb->cmd.dcdb.op_code == IPS_CMD_DCDB) scb->dcdb.buffer_pointer = cpu_to_le32(scb->data_busaddr); else scb->cmd.basic_io.sg_addr = cpu_to_le32(scb->data_busaddr); } /* set timeouts */ if (pt->TimeOut) { scb->timeout = pt->TimeOut; if (pt->TimeOut <= 10) scb->dcdb.cmd_attribute |= IPS_TIMEOUT10; else if (pt->TimeOut <= 60) scb->dcdb.cmd_attribute |= IPS_TIMEOUT60; else scb->dcdb.cmd_attribute |= IPS_TIMEOUT20M; } /* assume success */ scb->scsi_cmd->result = DID_OK << 16; /* success */ return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_cleanup_passthru */ /* */ /* Routine Description: */ /* */ /* Cleanup after a passthru command */ /* */ /****************************************************************************/ static void ips_cleanup_passthru(ips_ha_t * ha, ips_scb_t * scb) { ips_passthru_t *pt; METHOD_TRACE("ips_cleanup_passthru", 1); if ((!scb) || (!scb->scsi_cmd) || (!scsi_sglist(scb->scsi_cmd))) { DEBUG_VAR(1, "(%s%d) couldn't cleanup after passthru", ips_name, ha->host_num); return; } pt = (ips_passthru_t *) ha->ioctl_data; /* Copy data back to the user */ if (scb->cmd.dcdb.op_code == IPS_CMD_DCDB) /* Copy DCDB Back to Caller's Area */ memcpy(&pt->CoppCP.dcdb, &scb->dcdb, sizeof (IPS_DCDB_TABLE)); pt->BasicStatus = scb->basic_status; pt->ExtendedStatus = scb->extended_status; pt->AdapterType = ha->ad_type; if (ha->pcidev->device == IPS_DEVICEID_COPPERHEAD && (scb->cmd.flashfw.op_code == IPS_CMD_DOWNLOAD || scb->cmd.flashfw.op_code == IPS_CMD_RW_BIOSFW)) ips_free_flash_copperhead(ha); ips_scmd_buf_write(scb->scsi_cmd, ha->ioctl_data, ha->ioctl_datasize); } /****************************************************************************/ /* */ /* Routine Name: ips_host_info */ /* */ /* Routine Description: */ /* */ /* The passthru interface for the driver */ /* */ /****************************************************************************/ static int ips_host_info(ips_ha_t * ha, char *ptr, off_t offset, int len) { IPS_INFOSTR info; METHOD_TRACE("ips_host_info", 1); info.buffer = ptr; info.length = len; info.offset = offset; info.pos = 0; info.localpos = 0; copy_info(&info, "\nIBM ServeRAID General Information:\n\n"); if ((le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) && (le16_to_cpu(ha->nvram->adapter_type) != 0)) copy_info(&info, "\tController Type : %s\n", ips_adapter_name[ha->ad_type - 1]); else copy_info(&info, "\tController Type : Unknown\n"); if (ha->io_addr) copy_info(&info, "\tIO region : 0x%lx (%d bytes)\n", ha->io_addr, ha->io_len); if (ha->mem_addr) { copy_info(&info, "\tMemory region : 0x%lx (%d bytes)\n", ha->mem_addr, ha->mem_len); copy_info(&info, "\tShared memory address : 0x%lx\n", ha->mem_ptr); } copy_info(&info, "\tIRQ number : %d\n", ha->pcidev->irq); /* For the Next 3 lines Check for Binary 0 at the end and don't include it if it's there. */ /* That keeps everything happy for "text" operations on the proc file. */ if (le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) { if (ha->nvram->bios_low[3] == 0) { copy_info(&info, "\tBIOS Version : %c%c%c%c%c%c%c\n", ha->nvram->bios_high[0], ha->nvram->bios_high[1], ha->nvram->bios_high[2], ha->nvram->bios_high[3], ha->nvram->bios_low[0], ha->nvram->bios_low[1], ha->nvram->bios_low[2]); } else { copy_info(&info, "\tBIOS Version : %c%c%c%c%c%c%c%c\n", ha->nvram->bios_high[0], ha->nvram->bios_high[1], ha->nvram->bios_high[2], ha->nvram->bios_high[3], ha->nvram->bios_low[0], ha->nvram->bios_low[1], ha->nvram->bios_low[2], ha->nvram->bios_low[3]); } } if (ha->enq->CodeBlkVersion[7] == 0) { copy_info(&info, "\tFirmware Version : %c%c%c%c%c%c%c\n", ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1], ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3], ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5], ha->enq->CodeBlkVersion[6]); } else { copy_info(&info, "\tFirmware Version : %c%c%c%c%c%c%c%c\n", ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1], ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3], ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5], ha->enq->CodeBlkVersion[6], ha->enq->CodeBlkVersion[7]); } if (ha->enq->BootBlkVersion[7] == 0) { copy_info(&info, "\tBoot Block Version : %c%c%c%c%c%c%c\n", ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1], ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3], ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5], ha->enq->BootBlkVersion[6]); } else { copy_info(&info, "\tBoot Block Version : %c%c%c%c%c%c%c%c\n", ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1], ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3], ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5], ha->enq->BootBlkVersion[6], ha->enq->BootBlkVersion[7]); } copy_info(&info, "\tDriver Version : %s%s\n", IPS_VERSION_HIGH, IPS_VERSION_LOW); copy_info(&info, "\tDriver Build : %d\n", IPS_BUILD_IDENT); copy_info(&info, "\tMax Physical Devices : %d\n", ha->enq->ucMaxPhysicalDevices); copy_info(&info, "\tMax Active Commands : %d\n", ha->max_cmds); copy_info(&info, "\tCurrent Queued Commands : %d\n", ha->scb_waitlist.count); copy_info(&info, "\tCurrent Active Commands : %d\n", ha->scb_activelist.count - ha->num_ioctl); copy_info(&info, "\tCurrent Queued PT Commands : %d\n", ha->copp_waitlist.count); copy_info(&info, "\tCurrent Active PT Commands : %d\n", ha->num_ioctl); copy_info(&info, "\n"); return (info.localpos); } /****************************************************************************/ /* */ /* Routine Name: copy_mem_info */ /* */ /* Routine Description: */ /* */ /* Copy data into an IPS_INFOSTR structure */ /* */ /****************************************************************************/ static void copy_mem_info(IPS_INFOSTR * info, char *data, int len) { METHOD_TRACE("copy_mem_info", 1); if (info->pos + len < info->offset) { info->pos += len; return; } if (info->pos < info->offset) { data += (info->offset - info->pos); len -= (info->offset - info->pos); info->pos += (info->offset - info->pos); } if (info->localpos + len > info->length) len = info->length - info->localpos; if (len > 0) { memcpy(info->buffer + info->localpos, data, len); info->pos += len; info->localpos += len; } } /****************************************************************************/ /* */ /* Routine Name: copy_info */ /* */ /* Routine Description: */ /* */ /* printf style wrapper for an info structure */ /* */ /****************************************************************************/ static int copy_info(IPS_INFOSTR * info, char *fmt, ...) { va_list args; char buf[128]; int len; METHOD_TRACE("copy_info", 1); va_start(args, fmt); len = vsprintf(buf, fmt, args); va_end(args); copy_mem_info(info, buf, len); return (len); } /****************************************************************************/ /* */ /* Routine Name: ips_identify_controller */ /* */ /* Routine Description: */ /* */ /* Identify this controller */ /* */ /****************************************************************************/ static void ips_identify_controller(ips_ha_t * ha) { METHOD_TRACE("ips_identify_controller", 1); switch (ha->pcidev->device) { case IPS_DEVICEID_COPPERHEAD: if (ha->pcidev->revision <= IPS_REVID_SERVERAID) { ha->ad_type = IPS_ADTYPE_SERVERAID; } else if (ha->pcidev->revision == IPS_REVID_SERVERAID2) { ha->ad_type = IPS_ADTYPE_SERVERAID2; } else if (ha->pcidev->revision == IPS_REVID_NAVAJO) { ha->ad_type = IPS_ADTYPE_NAVAJO; } else if ((ha->pcidev->revision == IPS_REVID_SERVERAID2) && (ha->slot_num == 0)) { ha->ad_type = IPS_ADTYPE_KIOWA; } else if ((ha->pcidev->revision >= IPS_REVID_CLARINETP1) && (ha->pcidev->revision <= IPS_REVID_CLARINETP3)) { if (ha->enq->ucMaxPhysicalDevices == 15) ha->ad_type = IPS_ADTYPE_SERVERAID3L; else ha->ad_type = IPS_ADTYPE_SERVERAID3; } else if ((ha->pcidev->revision >= IPS_REVID_TROMBONE32) && (ha->pcidev->revision <= IPS_REVID_TROMBONE64)) { ha->ad_type = IPS_ADTYPE_SERVERAID4H; } break; case IPS_DEVICEID_MORPHEUS: switch (ha->pcidev->subsystem_device) { case IPS_SUBDEVICEID_4L: ha->ad_type = IPS_ADTYPE_SERVERAID4L; break; case IPS_SUBDEVICEID_4M: ha->ad_type = IPS_ADTYPE_SERVERAID4M; break; case IPS_SUBDEVICEID_4MX: ha->ad_type = IPS_ADTYPE_SERVERAID4MX; break; case IPS_SUBDEVICEID_4LX: ha->ad_type = IPS_ADTYPE_SERVERAID4LX; break; case IPS_SUBDEVICEID_5I2: ha->ad_type = IPS_ADTYPE_SERVERAID5I2; break; case IPS_SUBDEVICEID_5I1: ha->ad_type = IPS_ADTYPE_SERVERAID5I1; break; } break; case IPS_DEVICEID_MARCO: switch (ha->pcidev->subsystem_device) { case IPS_SUBDEVICEID_6M: ha->ad_type = IPS_ADTYPE_SERVERAID6M; break; case IPS_SUBDEVICEID_6I: ha->ad_type = IPS_ADTYPE_SERVERAID6I; break; case IPS_SUBDEVICEID_7k: ha->ad_type = IPS_ADTYPE_SERVERAID7k; break; case IPS_SUBDEVICEID_7M: ha->ad_type = IPS_ADTYPE_SERVERAID7M; break; } break; } } /****************************************************************************/ /* */ /* Routine Name: ips_get_bios_version */ /* */ /* Routine Description: */ /* */ /* Get the BIOS revision number */ /* */ /****************************************************************************/ static void ips_get_bios_version(ips_ha_t * ha, int intr) { ips_scb_t *scb; int ret; uint8_t major; uint8_t minor; uint8_t subminor; uint8_t *buffer; char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; METHOD_TRACE("ips_get_bios_version", 1); major = 0; minor = 0; strncpy(ha->bios_version, " ?", 8); if (ha->pcidev->device == IPS_DEVICEID_COPPERHEAD) { if (IPS_USE_MEMIO(ha)) { /* Memory Mapped I/O */ /* test 1st byte */ writel(0, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0x55) return; writel(1, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0xAA) return; /* Get Major version */ writel(0x1FF, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ major = readb(ha->mem_ptr + IPS_REG_FLDP); /* Get Minor version */ writel(0x1FE, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ minor = readb(ha->mem_ptr + IPS_REG_FLDP); /* Get SubMinor version */ writel(0x1FD, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ subminor = readb(ha->mem_ptr + IPS_REG_FLDP); } else { /* Programmed I/O */ /* test 1st byte */ outl(0, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ if (inb(ha->io_addr + IPS_REG_FLDP) != 0x55) return; outl(1, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ if (inb(ha->io_addr + IPS_REG_FLDP) != 0xAA) return; /* Get Major version */ outl(0x1FF, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ major = inb(ha->io_addr + IPS_REG_FLDP); /* Get Minor version */ outl(0x1FE, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ minor = inb(ha->io_addr + IPS_REG_FLDP); /* Get SubMinor version */ outl(0x1FD, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ subminor = inb(ha->io_addr + IPS_REG_FLDP); } } else { /* Morpheus Family - Send Command to the card */ buffer = ha->ioctl_data; memset(buffer, 0, 0x1000); scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_RW_BIOSFW; scb->cmd.flashfw.op_code = IPS_CMD_RW_BIOSFW; scb->cmd.flashfw.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.flashfw.type = 1; scb->cmd.flashfw.direction = 0; scb->cmd.flashfw.count = cpu_to_le32(0x800); scb->cmd.flashfw.total_packets = 1; scb->cmd.flashfw.packet_num = 0; scb->data_len = 0x1000; scb->cmd.flashfw.buffer_addr = ha->ioctl_busaddr; /* issue the command */ if (((ret = ips_send_wait(ha, scb, ips_cmd_timeout, intr)) == IPS_FAILURE) || (ret == IPS_SUCCESS_IMM) || ((scb->basic_status & IPS_GSC_STATUS_MASK) > 1)) { /* Error occurred */ return; } if ((buffer[0xC0] == 0x55) && (buffer[0xC1] == 0xAA)) { major = buffer[0x1ff + 0xC0]; /* Offset 0x1ff after the header (0xc0) */ minor = buffer[0x1fe + 0xC0]; /* Offset 0x1fe after the header (0xc0) */ subminor = buffer[0x1fd + 0xC0]; /* Offset 0x1fd after the header (0xc0) */ } else { return; } } ha->bios_version[0] = hexDigits[(major & 0xF0) >> 4]; ha->bios_version[1] = '.'; ha->bios_version[2] = hexDigits[major & 0x0F]; ha->bios_version[3] = hexDigits[subminor]; ha->bios_version[4] = '.'; ha->bios_version[5] = hexDigits[(minor & 0xF0) >> 4]; ha->bios_version[6] = hexDigits[minor & 0x0F]; ha->bios_version[7] = 0; } /****************************************************************************/ /* */ /* Routine Name: ips_hainit */ /* */ /* Routine Description: */ /* */ /* Initialize the controller */ /* */ /* NOTE: Assumes to be called from with a lock */ /* */ /****************************************************************************/ static int ips_hainit(ips_ha_t * ha) { int i; struct timeval tv; METHOD_TRACE("ips_hainit", 1); if (!ha) return (0); if (ha->func.statinit) (*ha->func.statinit) (ha); if (ha->func.enableint) (*ha->func.enableint) (ha); /* Send FFDC */ ha->reset_count = 1; do_gettimeofday(&tv); ha->last_ffdc = tv.tv_sec; ips_ffdc_reset(ha, IPS_INTR_IORL); if (!ips_read_config(ha, IPS_INTR_IORL)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to read config from controller.\n"); return (0); } /* end if */ if (!ips_read_adapter_status(ha, IPS_INTR_IORL)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to read controller status.\n"); return (0); } /* Identify this controller */ ips_identify_controller(ha); if (!ips_read_subsystem_parameters(ha, IPS_INTR_IORL)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to read subsystem parameters.\n"); return (0); } /* write nvram user page 5 */ if (!ips_write_driver_status(ha, IPS_INTR_IORL)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to write driver info to controller.\n"); return (0); } /* If there are Logical Drives and a Reset Occurred, then an EraseStripeLock is Needed */ if ((ha->conf->ucLogDriveCount > 0) && (ha->requires_esl == 1)) ips_clear_adapter(ha, IPS_INTR_IORL); /* set limits on SID, LUN, BUS */ ha->ntargets = IPS_MAX_TARGETS + 1; ha->nlun = 1; ha->nbus = (ha->enq->ucMaxPhysicalDevices / IPS_MAX_TARGETS) + 1; switch (ha->conf->logical_drive[0].ucStripeSize) { case 4: ha->max_xfer = 0x10000; break; case 5: ha->max_xfer = 0x20000; break; case 6: ha->max_xfer = 0x40000; break; case 7: default: ha->max_xfer = 0x80000; break; } /* setup max concurrent commands */ if (le32_to_cpu(ha->subsys->param[4]) & 0x1) { /* Use the new method */ ha->max_cmds = ha->enq->ucConcurrentCmdCount; } else { /* use the old method */ switch (ha->conf->logical_drive[0].ucStripeSize) { case 4: ha->max_cmds = 32; break; case 5: ha->max_cmds = 16; break; case 6: ha->max_cmds = 8; break; case 7: default: ha->max_cmds = 4; break; } } /* Limit the Active Commands on a Lite Adapter */ if ((ha->ad_type == IPS_ADTYPE_SERVERAID3L) || (ha->ad_type == IPS_ADTYPE_SERVERAID4L) || (ha->ad_type == IPS_ADTYPE_SERVERAID4LX)) { if ((ha->max_cmds > MaxLiteCmds) && (MaxLiteCmds)) ha->max_cmds = MaxLiteCmds; } /* set controller IDs */ ha->ha_id[0] = IPS_ADAPTER_ID; for (i = 1; i < ha->nbus; i++) { ha->ha_id[i] = ha->conf->init_id[i - 1] & 0x1f; ha->dcdb_active[i - 1] = 0; } return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_next */ /* */ /* Routine Description: */ /* */ /* Take the next command off the queue and send it to the controller */ /* */ /****************************************************************************/ static void ips_next(ips_ha_t * ha, int intr) { ips_scb_t *scb; struct scsi_cmnd *SC; struct scsi_cmnd *p; struct scsi_cmnd *q; ips_copp_wait_item_t *item; int ret; struct Scsi_Host *host; METHOD_TRACE("ips_next", 1); if (!ha) return; host = ips_sh[ha->host_num]; /* * Block access to the queue function so * this command won't time out */ if (intr == IPS_INTR_ON) spin_lock(host->host_lock); if ((ha->subsys->param[3] & 0x300000) && (ha->scb_activelist.count == 0)) { struct timeval tv; do_gettimeofday(&tv); if (tv.tv_sec - ha->last_ffdc > IPS_SECS_8HOURS) { ha->last_ffdc = tv.tv_sec; ips_ffdc_time(ha); } } /* * Send passthru commands * These have priority over normal I/O * but shouldn't affect performance too much * since we limit the number that can be active * on the card at any one time */ while ((ha->num_ioctl < IPS_MAX_IOCTL) && (ha->copp_waitlist.head) && (scb = ips_getscb(ha))) { item = ips_removeq_copp_head(&ha->copp_waitlist); ha->num_ioctl++; if (intr == IPS_INTR_ON) spin_unlock(host->host_lock); scb->scsi_cmd = item->scsi_cmd; kfree(item); ret = ips_make_passthru(ha, scb->scsi_cmd, scb, intr); if (intr == IPS_INTR_ON) spin_lock(host->host_lock); switch (ret) { case IPS_FAILURE: if (scb->scsi_cmd) { scb->scsi_cmd->result = DID_ERROR << 16; scb->scsi_cmd->scsi_done(scb->scsi_cmd); } ips_freescb(ha, scb); break; case IPS_SUCCESS_IMM: if (scb->scsi_cmd) { scb->scsi_cmd->result = DID_OK << 16; scb->scsi_cmd->scsi_done(scb->scsi_cmd); } ips_freescb(ha, scb); break; default: break; } /* end case */ if (ret != IPS_SUCCESS) { ha->num_ioctl--; continue; } ret = ips_send_cmd(ha, scb); if (ret == IPS_SUCCESS) ips_putq_scb_head(&ha->scb_activelist, scb); else ha->num_ioctl--; switch (ret) { case IPS_FAILURE: if (scb->scsi_cmd) { scb->scsi_cmd->result = DID_ERROR << 16; } ips_freescb(ha, scb); break; case IPS_SUCCESS_IMM: ips_freescb(ha, scb); break; default: break; } /* end case */ } /* * Send "Normal" I/O commands */ p = ha->scb_waitlist.head; while ((p) && (scb = ips_getscb(ha))) { if ((scmd_channel(p) > 0) && (ha-> dcdb_active[scmd_channel(p) - 1] & (1 << scmd_id(p)))) { ips_freescb(ha, scb); p = (struct scsi_cmnd *) p->host_scribble; continue; } q = p; SC = ips_removeq_wait(&ha->scb_waitlist, q); if (intr == IPS_INTR_ON) spin_unlock(host->host_lock); /* Unlock HA after command is taken off queue */ SC->result = DID_OK; SC->host_scribble = NULL; scb->target_id = SC->device->id; scb->lun = SC->device->lun; scb->bus = SC->device->channel; scb->scsi_cmd = SC; scb->breakup = 0; scb->data_len = 0; scb->callback = ipsintr_done; scb->timeout = ips_cmd_timeout; memset(&scb->cmd, 0, 16); /* copy in the CDB */ memcpy(scb->cdb, SC->cmnd, SC->cmd_len); scb->sg_count = scsi_dma_map(SC); BUG_ON(scb->sg_count < 0); if (scb->sg_count) { struct scatterlist *sg; int i; scb->flags |= IPS_SCB_MAP_SG; scsi_for_each_sg(SC, sg, scb->sg_count, i) { if (ips_fill_scb_sg_single (ha, sg_dma_address(sg), scb, i, sg_dma_len(sg)) < 0) break; } scb->dcdb.transfer_length = scb->data_len; } else { scb->data_busaddr = 0L; scb->sg_len = 0; scb->data_len = 0; scb->dcdb.transfer_length = 0; } scb->dcdb.cmd_attribute = ips_command_direction[scb->scsi_cmd->cmnd[0]]; /* Allow a WRITE BUFFER Command to Have no Data */ /* This is Used by Tape Flash Utilites */ if ((scb->scsi_cmd->cmnd[0] == WRITE_BUFFER) && (scb->data_len == 0)) scb->dcdb.cmd_attribute = 0; if (!(scb->dcdb.cmd_attribute & 0x3)) scb->dcdb.transfer_length = 0; if (scb->data_len >= IPS_MAX_XFER) { scb->dcdb.cmd_attribute |= IPS_TRANSFER64K; scb->dcdb.transfer_length = 0; } if (intr == IPS_INTR_ON) spin_lock(host->host_lock); ret = ips_send_cmd(ha, scb); switch (ret) { case IPS_SUCCESS: ips_putq_scb_head(&ha->scb_activelist, scb); break; case IPS_FAILURE: if (scb->scsi_cmd) { scb->scsi_cmd->result = DID_ERROR << 16; scb->scsi_cmd->scsi_done(scb->scsi_cmd); } if (scb->bus) ha->dcdb_active[scb->bus - 1] &= ~(1 << scb->target_id); ips_freescb(ha, scb); break; case IPS_SUCCESS_IMM: if (scb->scsi_cmd) scb->scsi_cmd->scsi_done(scb->scsi_cmd); if (scb->bus) ha->dcdb_active[scb->bus - 1] &= ~(1 << scb->target_id); ips_freescb(ha, scb); break; default: break; } /* end case */ p = (struct scsi_cmnd *) p->host_scribble; } /* end while */ if (intr == IPS_INTR_ON) spin_unlock(host->host_lock); } /****************************************************************************/ /* */ /* Routine Name: ips_putq_scb_head */ /* */ /* Routine Description: */ /* */ /* Add an item to the head of the queue */ /* */ /* ASSUMED to be called from within the HA lock */ /* */ /****************************************************************************/ static void ips_putq_scb_head(ips_scb_queue_t * queue, ips_scb_t * item) { METHOD_TRACE("ips_putq_scb_head", 1); if (!item) return; item->q_next = queue->head; queue->head = item; if (!queue->tail) queue->tail = item; queue->count++; } /****************************************************************************/ /* */ /* Routine Name: ips_removeq_scb_head */ /* */ /* Routine Description: */ /* */ /* Remove the head of the queue */ /* */ /* ASSUMED to be called from within the HA lock */ /* */ /****************************************************************************/ static ips_scb_t * ips_removeq_scb_head(ips_scb_queue_t * queue) { ips_scb_t *item; METHOD_TRACE("ips_removeq_scb_head", 1); item = queue->head; if (!item) { return (NULL); } queue->head = item->q_next; item->q_next = NULL; if (queue->tail == item) queue->tail = NULL; queue->count--; return (item); } /****************************************************************************/ /* */ /* Routine Name: ips_removeq_scb */ /* */ /* Routine Description: */ /* */ /* Remove an item from a queue */ /* */ /* ASSUMED to be called from within the HA lock */ /* */ /****************************************************************************/ static ips_scb_t * ips_removeq_scb(ips_scb_queue_t * queue, ips_scb_t * item) { ips_scb_t *p; METHOD_TRACE("ips_removeq_scb", 1); if (!item) return (NULL); if (item == queue->head) { return (ips_removeq_scb_head(queue)); } p = queue->head; while ((p) && (item != p->q_next)) p = p->q_next; if (p) { /* found a match */ p->q_next = item->q_next; if (!item->q_next) queue->tail = p; item->q_next = NULL; queue->count--; return (item); } return (NULL); } /****************************************************************************/ /* */ /* Routine Name: ips_putq_wait_tail */ /* */ /* Routine Description: */ /* */ /* Add an item to the tail of the queue */ /* */ /* ASSUMED to be called from within the HA lock */ /* */ /****************************************************************************/ static void ips_putq_wait_tail(ips_wait_queue_t *queue, struct scsi_cmnd *item) { METHOD_TRACE("ips_putq_wait_tail", 1); if (!item) return; item->host_scribble = NULL; if (queue->tail) queue->tail->host_scribble = (char *) item; queue->tail = item; if (!queue->head) queue->head = item; queue->count++; } /****************************************************************************/ /* */ /* Routine Name: ips_removeq_wait_head */ /* */ /* Routine Description: */ /* */ /* Remove the head of the queue */ /* */ /* ASSUMED to be called from within the HA lock */ /* */ /****************************************************************************/ static struct scsi_cmnd *ips_removeq_wait_head(ips_wait_queue_t *queue) { struct scsi_cmnd *item; METHOD_TRACE("ips_removeq_wait_head", 1); item = queue->head; if (!item) { return (NULL); } queue->head = (struct scsi_cmnd *) item->host_scribble; item->host_scribble = NULL; if (queue->tail == item) queue->tail = NULL; queue->count--; return (item); } /****************************************************************************/ /* */ /* Routine Name: ips_removeq_wait */ /* */ /* Routine Description: */ /* */ /* Remove an item from a queue */ /* */ /* ASSUMED to be called from within the HA lock */ /* */ /****************************************************************************/ static struct scsi_cmnd *ips_removeq_wait(ips_wait_queue_t *queue, struct scsi_cmnd *item) { struct scsi_cmnd *p; METHOD_TRACE("ips_removeq_wait", 1); if (!item) return (NULL); if (item == queue->head) { return (ips_removeq_wait_head(queue)); } p = queue->head; while ((p) && (item != (struct scsi_cmnd *) p->host_scribble)) p = (struct scsi_cmnd *) p->host_scribble; if (p) { /* found a match */ p->host_scribble = item->host_scribble; if (!item->host_scribble) queue->tail = p; item->host_scribble = NULL; queue->count--; return (item); } return (NULL); } /****************************************************************************/ /* */ /* Routine Name: ips_putq_copp_tail */ /* */ /* Routine Description: */ /* */ /* Add an item to the tail of the queue */ /* */ /* ASSUMED to be called from within the HA lock */ /* */ /****************************************************************************/ static void ips_putq_copp_tail(ips_copp_queue_t * queue, ips_copp_wait_item_t * item) { METHOD_TRACE("ips_putq_copp_tail", 1); if (!item) return; item->next = NULL; if (queue->tail) queue->tail->next = item; queue->tail = item; if (!queue->head) queue->head = item; queue->count++; } /****************************************************************************/ /* */ /* Routine Name: ips_removeq_copp_head */ /* */ /* Routine Description: */ /* */ /* Remove the head of the queue */ /* */ /* ASSUMED to be called from within the HA lock */ /* */ /****************************************************************************/ static ips_copp_wait_item_t * ips_removeq_copp_head(ips_copp_queue_t * queue) { ips_copp_wait_item_t *item; METHOD_TRACE("ips_removeq_copp_head", 1); item = queue->head; if (!item) { return (NULL); } queue->head = item->next; item->next = NULL; if (queue->tail == item) queue->tail = NULL; queue->count--; return (item); } /****************************************************************************/ /* */ /* Routine Name: ips_removeq_copp */ /* */ /* Routine Description: */ /* */ /* Remove an item from a queue */ /* */ /* ASSUMED to be called from within the HA lock */ /* */ /****************************************************************************/ static ips_copp_wait_item_t * ips_removeq_copp(ips_copp_queue_t * queue, ips_copp_wait_item_t * item) { ips_copp_wait_item_t *p; METHOD_TRACE("ips_removeq_copp", 1); if (!item) return (NULL); if (item == queue->head) { return (ips_removeq_copp_head(queue)); } p = queue->head; while ((p) && (item != p->next)) p = p->next; if (p) { /* found a match */ p->next = item->next; if (!item->next) queue->tail = p; item->next = NULL; queue->count--; return (item); } return (NULL); } /****************************************************************************/ /* */ /* Routine Name: ipsintr_blocking */ /* */ /* Routine Description: */ /* */ /* Finalize an interrupt for internal commands */ /* */ /****************************************************************************/ static void ipsintr_blocking(ips_ha_t * ha, ips_scb_t * scb) { METHOD_TRACE("ipsintr_blocking", 2); ips_freescb(ha, scb); if ((ha->waitflag == TRUE) && (ha->cmd_in_progress == scb->cdb[0])) { ha->waitflag = FALSE; return; } } /****************************************************************************/ /* */ /* Routine Name: ipsintr_done */ /* */ /* Routine Description: */ /* */ /* Finalize an interrupt for non-internal commands */ /* */ /****************************************************************************/ static void ipsintr_done(ips_ha_t * ha, ips_scb_t * scb) { METHOD_TRACE("ipsintr_done", 2); if (!scb) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "Spurious interrupt; scb NULL.\n"); return; } if (scb->scsi_cmd == NULL) { /* unexpected interrupt */ IPS_PRINTK(KERN_WARNING, ha->pcidev, "Spurious interrupt; scsi_cmd not set.\n"); return; } ips_done(ha, scb); } /****************************************************************************/ /* */ /* Routine Name: ips_done */ /* */ /* Routine Description: */ /* */ /* Do housekeeping on completed commands */ /* ASSUMED to be called form within the request lock */ /****************************************************************************/ static void ips_done(ips_ha_t * ha, ips_scb_t * scb) { int ret; METHOD_TRACE("ips_done", 1); if (!scb) return; if ((scb->scsi_cmd) && (ips_is_passthru(scb->scsi_cmd))) { ips_cleanup_passthru(ha, scb); ha->num_ioctl--; } else { /* * Check to see if this command had too much * data and had to be broke up. If so, queue * the rest of the data and continue. */ if ((scb->breakup) || (scb->sg_break)) { struct scatterlist *sg; int i, sg_dma_index, ips_sg_index = 0; /* we had a data breakup */ scb->data_len = 0; sg = scsi_sglist(scb->scsi_cmd); /* Spin forward to last dma chunk */ sg_dma_index = scb->breakup; for (i = 0; i < scb->breakup; i++) sg = sg_next(sg); /* Take care of possible partial on last chunk */ ips_fill_scb_sg_single(ha, sg_dma_address(sg), scb, ips_sg_index++, sg_dma_len(sg)); for (; sg_dma_index < scsi_sg_count(scb->scsi_cmd); sg_dma_index++, sg = sg_next(sg)) { if (ips_fill_scb_sg_single (ha, sg_dma_address(sg), scb, ips_sg_index++, sg_dma_len(sg)) < 0) break; } scb->dcdb.transfer_length = scb->data_len; scb->dcdb.cmd_attribute |= ips_command_direction[scb->scsi_cmd->cmnd[0]]; if (!(scb->dcdb.cmd_attribute & 0x3)) scb->dcdb.transfer_length = 0; if (scb->data_len >= IPS_MAX_XFER) { scb->dcdb.cmd_attribute |= IPS_TRANSFER64K; scb->dcdb.transfer_length = 0; } ret = ips_send_cmd(ha, scb); switch (ret) { case IPS_FAILURE: if (scb->scsi_cmd) { scb->scsi_cmd->result = DID_ERROR << 16; scb->scsi_cmd->scsi_done(scb->scsi_cmd); } ips_freescb(ha, scb); break; case IPS_SUCCESS_IMM: if (scb->scsi_cmd) { scb->scsi_cmd->result = DID_ERROR << 16; scb->scsi_cmd->scsi_done(scb->scsi_cmd); } ips_freescb(ha, scb); break; default: break; } /* end case */ return; } } /* end if passthru */ if (scb->bus) { ha->dcdb_active[scb->bus - 1] &= ~(1 << scb->target_id); } scb->scsi_cmd->scsi_done(scb->scsi_cmd); ips_freescb(ha, scb); } /****************************************************************************/ /* */ /* Routine Name: ips_map_status */ /* */ /* Routine Description: */ /* */ /* Map Controller Error codes to Linux Error Codes */ /* */ /****************************************************************************/ static int ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp) { int errcode; int device_error; uint32_t transfer_len; IPS_DCDB_TABLE_TAPE *tapeDCDB; IPS_SCSI_INQ_DATA inquiryData; METHOD_TRACE("ips_map_status", 1); if (scb->bus) { DEBUG_VAR(2, "(%s%d) Physical device error (%d %d %d): %x %x, Sense Key: %x, ASC: %x, ASCQ: %x", ips_name, ha->host_num, scb->scsi_cmd->device->channel, scb->scsi_cmd->device->id, scb->scsi_cmd->device->lun, scb->basic_status, scb->extended_status, scb->extended_status == IPS_ERR_CKCOND ? scb->dcdb.sense_info[2] & 0xf : 0, scb->extended_status == IPS_ERR_CKCOND ? scb->dcdb.sense_info[12] : 0, scb->extended_status == IPS_ERR_CKCOND ? scb->dcdb.sense_info[13] : 0); } /* default driver error */ errcode = DID_ERROR; device_error = 0; switch (scb->basic_status & IPS_GSC_STATUS_MASK) { case IPS_CMD_TIMEOUT: errcode = DID_TIME_OUT; break; case IPS_INVAL_OPCO: case IPS_INVAL_CMD_BLK: case IPS_INVAL_PARM_BLK: case IPS_LD_ERROR: case IPS_CMD_CMPLT_WERROR: break; case IPS_PHYS_DRV_ERROR: switch (scb->extended_status) { case IPS_ERR_SEL_TO: if (scb->bus) errcode = DID_NO_CONNECT; break; case IPS_ERR_OU_RUN: if ((scb->cmd.dcdb.op_code == IPS_CMD_EXTENDED_DCDB) || (scb->cmd.dcdb.op_code == IPS_CMD_EXTENDED_DCDB_SG)) { tapeDCDB = (IPS_DCDB_TABLE_TAPE *) & scb->dcdb; transfer_len = tapeDCDB->transfer_length; } else { transfer_len = (uint32_t) scb->dcdb.transfer_length; } if ((scb->bus) && (transfer_len < scb->data_len)) { /* Underrun - set default to no error */ errcode = DID_OK; /* Restrict access to physical DASD */ if (scb->scsi_cmd->cmnd[0] == INQUIRY) { ips_scmd_buf_read(scb->scsi_cmd, &inquiryData, sizeof (inquiryData)); if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK) { errcode = DID_TIME_OUT; break; } } } else errcode = DID_ERROR; break; case IPS_ERR_RECOVERY: /* don't fail recovered errors */ if (scb->bus) errcode = DID_OK; break; case IPS_ERR_HOST_RESET: case IPS_ERR_DEV_RESET: errcode = DID_RESET; break; case IPS_ERR_CKCOND: if (scb->bus) { if ((scb->cmd.dcdb.op_code == IPS_CMD_EXTENDED_DCDB) || (scb->cmd.dcdb.op_code == IPS_CMD_EXTENDED_DCDB_SG)) { tapeDCDB = (IPS_DCDB_TABLE_TAPE *) & scb->dcdb; memcpy(scb->scsi_cmd->sense_buffer, tapeDCDB->sense_info, SCSI_SENSE_BUFFERSIZE); } else { memcpy(scb->scsi_cmd->sense_buffer, scb->dcdb.sense_info, SCSI_SENSE_BUFFERSIZE); } device_error = 2; /* check condition */ } errcode = DID_OK; break; default: errcode = DID_ERROR; break; } /* end switch */ } /* end switch */ scb->scsi_cmd->result = device_error | (errcode << 16); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_send_wait */ /* */ /* Routine Description: */ /* */ /* Send a command to the controller and wait for it to return */ /* */ /* The FFDC Time Stamp use this function for the callback, but doesn't */ /* actually need to wait. */ /****************************************************************************/ static int ips_send_wait(ips_ha_t * ha, ips_scb_t * scb, int timeout, int intr) { int ret; METHOD_TRACE("ips_send_wait", 1); if (intr != IPS_FFDC) { /* Won't be Waiting if this is a Time Stamp */ ha->waitflag = TRUE; ha->cmd_in_progress = scb->cdb[0]; } scb->callback = ipsintr_blocking; ret = ips_send_cmd(ha, scb); if ((ret == IPS_FAILURE) || (ret == IPS_SUCCESS_IMM)) return (ret); if (intr != IPS_FFDC) /* Don't Wait around if this is a Time Stamp */ ret = ips_wait(ha, timeout, intr); return (ret); } /****************************************************************************/ /* */ /* Routine Name: ips_scmd_buf_write */ /* */ /* Routine Description: */ /* Write data to struct scsi_cmnd request_buffer at proper offsets */ /****************************************************************************/ static void ips_scmd_buf_write(struct scsi_cmnd *scmd, void *data, unsigned int count) { unsigned long flags; local_irq_save(flags); scsi_sg_copy_from_buffer(scmd, data, count); local_irq_restore(flags); } /****************************************************************************/ /* */ /* Routine Name: ips_scmd_buf_read */ /* */ /* Routine Description: */ /* Copy data from a struct scsi_cmnd to a new, linear buffer */ /****************************************************************************/ static void ips_scmd_buf_read(struct scsi_cmnd *scmd, void *data, unsigned int count) { unsigned long flags; local_irq_save(flags); scsi_sg_copy_to_buffer(scmd, data, count); local_irq_restore(flags); } /****************************************************************************/ /* */ /* Routine Name: ips_send_cmd */ /* */ /* Routine Description: */ /* */ /* Map SCSI commands to ServeRAID commands for logical drives */ /* */ /****************************************************************************/ static int ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) { int ret; char *sp; int device_error; IPS_DCDB_TABLE_TAPE *tapeDCDB; int TimeOut; METHOD_TRACE("ips_send_cmd", 1); ret = IPS_SUCCESS; if (!scb->scsi_cmd) { /* internal command */ if (scb->bus > 0) { /* Controller commands can't be issued */ /* to real devices -- fail them */ if ((ha->waitflag == TRUE) && (ha->cmd_in_progress == scb->cdb[0])) { ha->waitflag = FALSE; } return (1); } } else if ((scb->bus == 0) && (!ips_is_passthru(scb->scsi_cmd))) { /* command to logical bus -- interpret */ ret = IPS_SUCCESS_IMM; switch (scb->scsi_cmd->cmnd[0]) { case ALLOW_MEDIUM_REMOVAL: case REZERO_UNIT: case ERASE: case WRITE_FILEMARKS: case SPACE: scb->scsi_cmd->result = DID_ERROR << 16; break; case START_STOP: scb->scsi_cmd->result = DID_OK << 16; case TEST_UNIT_READY: case INQUIRY: if (scb->target_id == IPS_ADAPTER_ID) { /* * Either we have a TUR * or we have a SCSI inquiry */ if (scb->scsi_cmd->cmnd[0] == TEST_UNIT_READY) scb->scsi_cmd->result = DID_OK << 16; if (scb->scsi_cmd->cmnd[0] == INQUIRY) { IPS_SCSI_INQ_DATA inquiry; memset(&inquiry, 0, sizeof (IPS_SCSI_INQ_DATA)); inquiry.DeviceType = IPS_SCSI_INQ_TYPE_PROCESSOR; inquiry.DeviceTypeQualifier = IPS_SCSI_INQ_LU_CONNECTED; inquiry.Version = IPS_SCSI_INQ_REV2; inquiry.ResponseDataFormat = IPS_SCSI_INQ_RD_REV2; inquiry.AdditionalLength = 31; inquiry.Flags[0] = IPS_SCSI_INQ_Address16; inquiry.Flags[1] = IPS_SCSI_INQ_WBus16 | IPS_SCSI_INQ_Sync; strncpy(inquiry.VendorId, "IBM ", 8); strncpy(inquiry.ProductId, "SERVERAID ", 16); strncpy(inquiry.ProductRevisionLevel, "1.00", 4); ips_scmd_buf_write(scb->scsi_cmd, &inquiry, sizeof (inquiry)); scb->scsi_cmd->result = DID_OK << 16; } } else { scb->cmd.logical_info.op_code = IPS_CMD_GET_LD_INFO; scb->cmd.logical_info.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.logical_info.reserved = 0; scb->cmd.logical_info.reserved2 = 0; scb->data_len = sizeof (IPS_LD_INFO); scb->data_busaddr = ha->logical_drive_info_dma_addr; scb->flags = 0; scb->cmd.logical_info.buffer_addr = scb->data_busaddr; ret = IPS_SUCCESS; } break; case REQUEST_SENSE: ips_reqsen(ha, scb); scb->scsi_cmd->result = DID_OK << 16; break; case READ_6: case WRITE_6: if (!scb->sg_len) { scb->cmd.basic_io.op_code = (scb->scsi_cmd->cmnd[0] == READ_6) ? IPS_CMD_READ : IPS_CMD_WRITE; scb->cmd.basic_io.enhanced_sg = 0; scb->cmd.basic_io.sg_addr = cpu_to_le32(scb->data_busaddr); } else { scb->cmd.basic_io.op_code = (scb->scsi_cmd->cmnd[0] == READ_6) ? IPS_CMD_READ_SG : IPS_CMD_WRITE_SG; scb->cmd.basic_io.enhanced_sg = IPS_USE_ENH_SGLIST(ha) ? 0xFF : 0; scb->cmd.basic_io.sg_addr = cpu_to_le32(scb->sg_busaddr); } scb->cmd.basic_io.segment_4G = 0; scb->cmd.basic_io.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.basic_io.log_drv = scb->target_id; scb->cmd.basic_io.sg_count = scb->sg_len; if (scb->cmd.basic_io.lba) le32_add_cpu(&scb->cmd.basic_io.lba, le16_to_cpu(scb->cmd.basic_io. sector_count)); else scb->cmd.basic_io.lba = (((scb->scsi_cmd-> cmnd[1] & 0x1f) << 16) | (scb->scsi_cmd-> cmnd[2] << 8) | (scb->scsi_cmd->cmnd[3])); scb->cmd.basic_io.sector_count = cpu_to_le16(scb->data_len / IPS_BLKSIZE); if (le16_to_cpu(scb->cmd.basic_io.sector_count) == 0) scb->cmd.basic_io.sector_count = cpu_to_le16(256); ret = IPS_SUCCESS; break; case READ_10: case WRITE_10: if (!scb->sg_len) { scb->cmd.basic_io.op_code = (scb->scsi_cmd->cmnd[0] == READ_10) ? IPS_CMD_READ : IPS_CMD_WRITE; scb->cmd.basic_io.enhanced_sg = 0; scb->cmd.basic_io.sg_addr = cpu_to_le32(scb->data_busaddr); } else { scb->cmd.basic_io.op_code = (scb->scsi_cmd->cmnd[0] == READ_10) ? IPS_CMD_READ_SG : IPS_CMD_WRITE_SG; scb->cmd.basic_io.enhanced_sg = IPS_USE_ENH_SGLIST(ha) ? 0xFF : 0; scb->cmd.basic_io.sg_addr = cpu_to_le32(scb->sg_busaddr); } scb->cmd.basic_io.segment_4G = 0; scb->cmd.basic_io.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.basic_io.log_drv = scb->target_id; scb->cmd.basic_io.sg_count = scb->sg_len; if (scb->cmd.basic_io.lba) le32_add_cpu(&scb->cmd.basic_io.lba, le16_to_cpu(scb->cmd.basic_io. sector_count)); else scb->cmd.basic_io.lba = ((scb->scsi_cmd->cmnd[2] << 24) | (scb-> scsi_cmd-> cmnd[3] << 16) | (scb->scsi_cmd->cmnd[4] << 8) | scb-> scsi_cmd->cmnd[5]); scb->cmd.basic_io.sector_count = cpu_to_le16(scb->data_len / IPS_BLKSIZE); if (cpu_to_le16(scb->cmd.basic_io.sector_count) == 0) { /* * This is a null condition * we don't have to do anything * so just return */ scb->scsi_cmd->result = DID_OK << 16; } else ret = IPS_SUCCESS; break; case RESERVE: case RELEASE: scb->scsi_cmd->result = DID_OK << 16; break; case MODE_SENSE: scb->cmd.basic_io.op_code = IPS_CMD_ENQUIRY; scb->cmd.basic_io.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.basic_io.segment_4G = 0; scb->cmd.basic_io.enhanced_sg = 0; scb->data_len = sizeof (*ha->enq); scb->cmd.basic_io.sg_addr = ha->enq_busaddr; ret = IPS_SUCCESS; break; case READ_CAPACITY: scb->cmd.logical_info.op_code = IPS_CMD_GET_LD_INFO; scb->cmd.logical_info.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.logical_info.reserved = 0; scb->cmd.logical_info.reserved2 = 0; scb->cmd.logical_info.reserved3 = 0; scb->data_len = sizeof (IPS_LD_INFO); scb->data_busaddr = ha->logical_drive_info_dma_addr; scb->flags = 0; scb->cmd.logical_info.buffer_addr = scb->data_busaddr; ret = IPS_SUCCESS; break; case SEND_DIAGNOSTIC: case REASSIGN_BLOCKS: case FORMAT_UNIT: case SEEK_10: case VERIFY: case READ_DEFECT_DATA: case READ_BUFFER: case WRITE_BUFFER: scb->scsi_cmd->result = DID_OK << 16; break; default: /* Set the Return Info to appear like the Command was */ /* attempted, a Check Condition occurred, and Sense */ /* Data indicating an Invalid CDB OpCode is returned. */ sp = (char *) scb->scsi_cmd->sense_buffer; sp[0] = 0x70; /* Error Code */ sp[2] = ILLEGAL_REQUEST; /* Sense Key 5 Illegal Req. */ sp[7] = 0x0A; /* Additional Sense Length */ sp[12] = 0x20; /* ASC = Invalid OpCode */ sp[13] = 0x00; /* ASCQ */ device_error = 2; /* Indicate Check Condition */ scb->scsi_cmd->result = device_error | (DID_OK << 16); break; } /* end switch */ } /* end if */ if (ret == IPS_SUCCESS_IMM) return (ret); /* setup DCDB */ if (scb->bus > 0) { /* If we already know the Device is Not there, no need to attempt a Command */ /* This also protects an NT FailOver Controller from getting CDB's sent to it */ if (ha->conf->dev[scb->bus - 1][scb->target_id].ucState == 0) { scb->scsi_cmd->result = DID_NO_CONNECT << 16; return (IPS_SUCCESS_IMM); } ha->dcdb_active[scb->bus - 1] |= (1 << scb->target_id); scb->cmd.dcdb.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.dcdb.dcdb_address = cpu_to_le32(scb->scb_busaddr + (unsigned long) &scb-> dcdb - (unsigned long) scb); scb->cmd.dcdb.reserved = 0; scb->cmd.dcdb.reserved2 = 0; scb->cmd.dcdb.reserved3 = 0; scb->cmd.dcdb.segment_4G = 0; scb->cmd.dcdb.enhanced_sg = 0; TimeOut = scb->scsi_cmd->request->timeout; if (ha->subsys->param[4] & 0x00100000) { /* If NEW Tape DCDB is Supported */ if (!scb->sg_len) { scb->cmd.dcdb.op_code = IPS_CMD_EXTENDED_DCDB; } else { scb->cmd.dcdb.op_code = IPS_CMD_EXTENDED_DCDB_SG; scb->cmd.dcdb.enhanced_sg = IPS_USE_ENH_SGLIST(ha) ? 0xFF : 0; } tapeDCDB = (IPS_DCDB_TABLE_TAPE *) & scb->dcdb; /* Use Same Data Area as Old DCDB Struct */ tapeDCDB->device_address = ((scb->bus - 1) << 4) | scb->target_id; tapeDCDB->cmd_attribute |= IPS_DISCONNECT_ALLOWED; tapeDCDB->cmd_attribute &= ~IPS_TRANSFER64K; /* Always Turn OFF 64K Size Flag */ if (TimeOut) { if (TimeOut < (10 * HZ)) tapeDCDB->cmd_attribute |= IPS_TIMEOUT10; /* TimeOut is 10 Seconds */ else if (TimeOut < (60 * HZ)) tapeDCDB->cmd_attribute |= IPS_TIMEOUT60; /* TimeOut is 60 Seconds */ else if (TimeOut < (1200 * HZ)) tapeDCDB->cmd_attribute |= IPS_TIMEOUT20M; /* TimeOut is 20 Minutes */ } tapeDCDB->cdb_length = scb->scsi_cmd->cmd_len; tapeDCDB->reserved_for_LUN = 0; tapeDCDB->transfer_length = scb->data_len; if (scb->cmd.dcdb.op_code == IPS_CMD_EXTENDED_DCDB_SG) tapeDCDB->buffer_pointer = cpu_to_le32(scb->sg_busaddr); else tapeDCDB->buffer_pointer = cpu_to_le32(scb->data_busaddr); tapeDCDB->sg_count = scb->sg_len; tapeDCDB->sense_length = sizeof (tapeDCDB->sense_info); tapeDCDB->scsi_status = 0; tapeDCDB->reserved = 0; memcpy(tapeDCDB->scsi_cdb, scb->scsi_cmd->cmnd, scb->scsi_cmd->cmd_len); } else { if (!scb->sg_len) { scb->cmd.dcdb.op_code = IPS_CMD_DCDB; } else { scb->cmd.dcdb.op_code = IPS_CMD_DCDB_SG; scb->cmd.dcdb.enhanced_sg = IPS_USE_ENH_SGLIST(ha) ? 0xFF : 0; } scb->dcdb.device_address = ((scb->bus - 1) << 4) | scb->target_id; scb->dcdb.cmd_attribute |= IPS_DISCONNECT_ALLOWED; if (TimeOut) { if (TimeOut < (10 * HZ)) scb->dcdb.cmd_attribute |= IPS_TIMEOUT10; /* TimeOut is 10 Seconds */ else if (TimeOut < (60 * HZ)) scb->dcdb.cmd_attribute |= IPS_TIMEOUT60; /* TimeOut is 60 Seconds */ else if (TimeOut < (1200 * HZ)) scb->dcdb.cmd_attribute |= IPS_TIMEOUT20M; /* TimeOut is 20 Minutes */ } scb->dcdb.transfer_length = scb->data_len; if (scb->dcdb.cmd_attribute & IPS_TRANSFER64K) scb->dcdb.transfer_length = 0; if (scb->cmd.dcdb.op_code == IPS_CMD_DCDB_SG) scb->dcdb.buffer_pointer = cpu_to_le32(scb->sg_busaddr); else scb->dcdb.buffer_pointer = cpu_to_le32(scb->data_busaddr); scb->dcdb.cdb_length = scb->scsi_cmd->cmd_len; scb->dcdb.sense_length = sizeof (scb->dcdb.sense_info); scb->dcdb.sg_count = scb->sg_len; scb->dcdb.reserved = 0; memcpy(scb->dcdb.scsi_cdb, scb->scsi_cmd->cmnd, scb->scsi_cmd->cmd_len); scb->dcdb.scsi_status = 0; scb->dcdb.reserved2[0] = 0; scb->dcdb.reserved2[1] = 0; scb->dcdb.reserved2[2] = 0; } } return ((*ha->func.issue) (ha, scb)); } /****************************************************************************/ /* */ /* Routine Name: ips_chk_status */ /* */ /* Routine Description: */ /* */ /* Check the status of commands to logical drives */ /* Assumed to be called with the HA lock */ /****************************************************************************/ static void ips_chkstatus(ips_ha_t * ha, IPS_STATUS * pstatus) { ips_scb_t *scb; ips_stat_t *sp; uint8_t basic_status; uint8_t ext_status; int errcode; IPS_SCSI_INQ_DATA inquiryData; METHOD_TRACE("ips_chkstatus", 1); scb = &ha->scbs[pstatus->fields.command_id]; scb->basic_status = basic_status = pstatus->fields.basic_status & IPS_BASIC_STATUS_MASK; scb->extended_status = ext_status = pstatus->fields.extended_status; sp = &ha->sp; sp->residue_len = 0; sp->scb_addr = (void *) scb; /* Remove the item from the active queue */ ips_removeq_scb(&ha->scb_activelist, scb); if (!scb->scsi_cmd) /* internal commands are handled in do_ipsintr */ return; DEBUG_VAR(2, "(%s%d) ips_chkstatus: cmd 0x%X id %d (%d %d %d)", ips_name, ha->host_num, scb->cdb[0], scb->cmd.basic_io.command_id, scb->bus, scb->target_id, scb->lun); if ((scb->scsi_cmd) && (ips_is_passthru(scb->scsi_cmd))) /* passthru - just returns the raw result */ return; errcode = DID_OK; if (((basic_status & IPS_GSC_STATUS_MASK) == IPS_CMD_SUCCESS) || ((basic_status & IPS_GSC_STATUS_MASK) == IPS_CMD_RECOVERED_ERROR)) { if (scb->bus == 0) { if ((basic_status & IPS_GSC_STATUS_MASK) == IPS_CMD_RECOVERED_ERROR) { DEBUG_VAR(1, "(%s%d) Recovered Logical Drive Error OpCode: %x, BSB: %x, ESB: %x", ips_name, ha->host_num, scb->cmd.basic_io.op_code, basic_status, ext_status); } switch (scb->scsi_cmd->cmnd[0]) { case ALLOW_MEDIUM_REMOVAL: case REZERO_UNIT: case ERASE: case WRITE_FILEMARKS: case SPACE: errcode = DID_ERROR; break; case START_STOP: break; case TEST_UNIT_READY: if (!ips_online(ha, scb)) { errcode = DID_TIME_OUT; } break; case INQUIRY: if (ips_online(ha, scb)) { ips_inquiry(ha, scb); } else { errcode = DID_TIME_OUT; } break; case REQUEST_SENSE: ips_reqsen(ha, scb); break; case READ_6: case WRITE_6: case READ_10: case WRITE_10: case RESERVE: case RELEASE: break; case MODE_SENSE: if (!ips_online(ha, scb) || !ips_msense(ha, scb)) { errcode = DID_ERROR; } break; case READ_CAPACITY: if (ips_online(ha, scb)) ips_rdcap(ha, scb); else { errcode = DID_TIME_OUT; } break; case SEND_DIAGNOSTIC: case REASSIGN_BLOCKS: break; case FORMAT_UNIT: errcode = DID_ERROR; break; case SEEK_10: case VERIFY: case READ_DEFECT_DATA: case READ_BUFFER: case WRITE_BUFFER: break; default: errcode = DID_ERROR; } /* end switch */ scb->scsi_cmd->result = errcode << 16; } else { /* bus == 0 */ /* restrict access to physical drives */ if (scb->scsi_cmd->cmnd[0] == INQUIRY) { ips_scmd_buf_read(scb->scsi_cmd, &inquiryData, sizeof (inquiryData)); if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK) scb->scsi_cmd->result = DID_TIME_OUT << 16; } } /* else */ } else { /* recovered error / success */ if (scb->bus == 0) { DEBUG_VAR(1, "(%s%d) Unrecovered Logical Drive Error OpCode: %x, BSB: %x, ESB: %x", ips_name, ha->host_num, scb->cmd.basic_io.op_code, basic_status, ext_status); } ips_map_status(ha, scb, sp); } /* else */ } /****************************************************************************/ /* */ /* Routine Name: ips_online */ /* */ /* Routine Description: */ /* */ /* Determine if a logical drive is online */ /* */ /****************************************************************************/ static int ips_online(ips_ha_t * ha, ips_scb_t * scb) { METHOD_TRACE("ips_online", 1); if (scb->target_id >= IPS_MAX_LD) return (0); if ((scb->basic_status & IPS_GSC_STATUS_MASK) > 1) { memset(ha->logical_drive_info, 0, sizeof (IPS_LD_INFO)); return (0); } if (ha->logical_drive_info->drive_info[scb->target_id].state != IPS_LD_OFFLINE && ha->logical_drive_info->drive_info[scb->target_id].state != IPS_LD_FREE && ha->logical_drive_info->drive_info[scb->target_id].state != IPS_LD_CRS && ha->logical_drive_info->drive_info[scb->target_id].state != IPS_LD_SYS) return (1); else return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_inquiry */ /* */ /* Routine Description: */ /* */ /* Simulate an inquiry command to a logical drive */ /* */ /****************************************************************************/ static int ips_inquiry(ips_ha_t * ha, ips_scb_t * scb) { IPS_SCSI_INQ_DATA inquiry; METHOD_TRACE("ips_inquiry", 1); memset(&inquiry, 0, sizeof (IPS_SCSI_INQ_DATA)); inquiry.DeviceType = IPS_SCSI_INQ_TYPE_DASD; inquiry.DeviceTypeQualifier = IPS_SCSI_INQ_LU_CONNECTED; inquiry.Version = IPS_SCSI_INQ_REV2; inquiry.ResponseDataFormat = IPS_SCSI_INQ_RD_REV2; inquiry.AdditionalLength = 31; inquiry.Flags[0] = IPS_SCSI_INQ_Address16; inquiry.Flags[1] = IPS_SCSI_INQ_WBus16 | IPS_SCSI_INQ_Sync | IPS_SCSI_INQ_CmdQue; strncpy(inquiry.VendorId, "IBM ", 8); strncpy(inquiry.ProductId, "SERVERAID ", 16); strncpy(inquiry.ProductRevisionLevel, "1.00", 4); ips_scmd_buf_write(scb->scsi_cmd, &inquiry, sizeof (inquiry)); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_rdcap */ /* */ /* Routine Description: */ /* */ /* Simulate a read capacity command to a logical drive */ /* */ /****************************************************************************/ static int ips_rdcap(ips_ha_t * ha, ips_scb_t * scb) { IPS_SCSI_CAPACITY cap; METHOD_TRACE("ips_rdcap", 1); if (scsi_bufflen(scb->scsi_cmd) < 8) return (0); cap.lba = cpu_to_be32(le32_to_cpu (ha->logical_drive_info-> drive_info[scb->target_id].sector_count) - 1); cap.len = cpu_to_be32((uint32_t) IPS_BLKSIZE); ips_scmd_buf_write(scb->scsi_cmd, &cap, sizeof (cap)); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_msense */ /* */ /* Routine Description: */ /* */ /* Simulate a mode sense command to a logical drive */ /* */ /****************************************************************************/ static int ips_msense(ips_ha_t * ha, ips_scb_t * scb) { uint16_t heads; uint16_t sectors; uint32_t cylinders; IPS_SCSI_MODE_PAGE_DATA mdata; METHOD_TRACE("ips_msense", 1); if (le32_to_cpu(ha->enq->ulDriveSize[scb->target_id]) > 0x400000 && (ha->enq->ucMiscFlag & 0x8) == 0) { heads = IPS_NORM_HEADS; sectors = IPS_NORM_SECTORS; } else { heads = IPS_COMP_HEADS; sectors = IPS_COMP_SECTORS; } cylinders = (le32_to_cpu(ha->enq->ulDriveSize[scb->target_id]) - 1) / (heads * sectors); memset(&mdata, 0, sizeof (IPS_SCSI_MODE_PAGE_DATA)); mdata.hdr.BlockDescLength = 8; switch (scb->scsi_cmd->cmnd[2] & 0x3f) { case 0x03: /* page 3 */ mdata.pdata.pg3.PageCode = 3; mdata.pdata.pg3.PageLength = sizeof (IPS_SCSI_MODE_PAGE3); mdata.hdr.DataLength = 3 + mdata.hdr.BlockDescLength + mdata.pdata.pg3.PageLength; mdata.pdata.pg3.TracksPerZone = 0; mdata.pdata.pg3.AltSectorsPerZone = 0; mdata.pdata.pg3.AltTracksPerZone = 0; mdata.pdata.pg3.AltTracksPerVolume = 0; mdata.pdata.pg3.SectorsPerTrack = cpu_to_be16(sectors); mdata.pdata.pg3.BytesPerSector = cpu_to_be16(IPS_BLKSIZE); mdata.pdata.pg3.Interleave = cpu_to_be16(1); mdata.pdata.pg3.TrackSkew = 0; mdata.pdata.pg3.CylinderSkew = 0; mdata.pdata.pg3.flags = IPS_SCSI_MP3_SoftSector; break; case 0x4: mdata.pdata.pg4.PageCode = 4; mdata.pdata.pg4.PageLength = sizeof (IPS_SCSI_MODE_PAGE4); mdata.hdr.DataLength = 3 + mdata.hdr.BlockDescLength + mdata.pdata.pg4.PageLength; mdata.pdata.pg4.CylindersHigh = cpu_to_be16((cylinders >> 8) & 0xFFFF); mdata.pdata.pg4.CylindersLow = (cylinders & 0xFF); mdata.pdata.pg4.Heads = heads; mdata.pdata.pg4.WritePrecompHigh = 0; mdata.pdata.pg4.WritePrecompLow = 0; mdata.pdata.pg4.ReducedWriteCurrentHigh = 0; mdata.pdata.pg4.ReducedWriteCurrentLow = 0; mdata.pdata.pg4.StepRate = cpu_to_be16(1); mdata.pdata.pg4.LandingZoneHigh = 0; mdata.pdata.pg4.LandingZoneLow = 0; mdata.pdata.pg4.flags = 0; mdata.pdata.pg4.RotationalOffset = 0; mdata.pdata.pg4.MediumRotationRate = 0; break; case 0x8: mdata.pdata.pg8.PageCode = 8; mdata.pdata.pg8.PageLength = sizeof (IPS_SCSI_MODE_PAGE8); mdata.hdr.DataLength = 3 + mdata.hdr.BlockDescLength + mdata.pdata.pg8.PageLength; /* everything else is left set to 0 */ break; default: return (0); } /* end switch */ ips_scmd_buf_write(scb->scsi_cmd, &mdata, sizeof (mdata)); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_reqsen */ /* */ /* Routine Description: */ /* */ /* Simulate a request sense command to a logical drive */ /* */ /****************************************************************************/ static int ips_reqsen(ips_ha_t * ha, ips_scb_t * scb) { IPS_SCSI_REQSEN reqsen; METHOD_TRACE("ips_reqsen", 1); memset(&reqsen, 0, sizeof (IPS_SCSI_REQSEN)); reqsen.ResponseCode = IPS_SCSI_REQSEN_VALID | IPS_SCSI_REQSEN_CURRENT_ERR; reqsen.AdditionalLength = 10; reqsen.AdditionalSenseCode = IPS_SCSI_REQSEN_NO_SENSE; reqsen.AdditionalSenseCodeQual = IPS_SCSI_REQSEN_NO_SENSE; ips_scmd_buf_write(scb->scsi_cmd, &reqsen, sizeof (reqsen)); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_free */ /* */ /* Routine Description: */ /* */ /* Free any allocated space for this controller */ /* */ /****************************************************************************/ static void ips_free(ips_ha_t * ha) { METHOD_TRACE("ips_free", 1); if (ha) { if (ha->enq) { pci_free_consistent(ha->pcidev, sizeof(IPS_ENQ), ha->enq, ha->enq_busaddr); ha->enq = NULL; } kfree(ha->conf); ha->conf = NULL; if (ha->adapt) { pci_free_consistent(ha->pcidev, sizeof (IPS_ADAPTER) + sizeof (IPS_IO_CMD), ha->adapt, ha->adapt->hw_status_start); ha->adapt = NULL; } if (ha->logical_drive_info) { pci_free_consistent(ha->pcidev, sizeof (IPS_LD_INFO), ha->logical_drive_info, ha->logical_drive_info_dma_addr); ha->logical_drive_info = NULL; } kfree(ha->nvram); ha->nvram = NULL; kfree(ha->subsys); ha->subsys = NULL; if (ha->ioctl_data) { pci_free_consistent(ha->pcidev, ha->ioctl_len, ha->ioctl_data, ha->ioctl_busaddr); ha->ioctl_data = NULL; ha->ioctl_datasize = 0; ha->ioctl_len = 0; } ips_deallocatescbs(ha, ha->max_cmds); /* free memory mapped (if applicable) */ if (ha->mem_ptr) { iounmap(ha->ioremap_ptr); ha->ioremap_ptr = NULL; ha->mem_ptr = NULL; } ha->mem_addr = 0; } } /****************************************************************************/ /* */ /* Routine Name: ips_deallocatescbs */ /* */ /* Routine Description: */ /* */ /* Free the command blocks */ /* */ /****************************************************************************/ static int ips_deallocatescbs(ips_ha_t * ha, int cmds) { if (ha->scbs) { pci_free_consistent(ha->pcidev, IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * cmds, ha->scbs->sg_list.list, ha->scbs->sg_busaddr); pci_free_consistent(ha->pcidev, sizeof (ips_scb_t) * cmds, ha->scbs, ha->scbs->scb_busaddr); ha->scbs = NULL; } /* end if */ return 1; } /****************************************************************************/ /* */ /* Routine Name: ips_allocatescbs */ /* */ /* Routine Description: */ /* */ /* Allocate the command blocks */ /* */ /****************************************************************************/ static int ips_allocatescbs(ips_ha_t * ha) { ips_scb_t *scb_p; IPS_SG_LIST ips_sg; int i; dma_addr_t command_dma, sg_dma; METHOD_TRACE("ips_allocatescbs", 1); /* Allocate memory for the SCBs */ ha->scbs = pci_alloc_consistent(ha->pcidev, ha->max_cmds * sizeof (ips_scb_t), &command_dma); if (ha->scbs == NULL) return 0; ips_sg.list = pci_alloc_consistent(ha->pcidev, IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * ha->max_cmds, &sg_dma); if (ips_sg.list == NULL) { pci_free_consistent(ha->pcidev, ha->max_cmds * sizeof (ips_scb_t), ha->scbs, command_dma); return 0; } memset(ha->scbs, 0, ha->max_cmds * sizeof (ips_scb_t)); for (i = 0; i < ha->max_cmds; i++) { scb_p = &ha->scbs[i]; scb_p->scb_busaddr = command_dma + sizeof (ips_scb_t) * i; /* set up S/G list */ if (IPS_USE_ENH_SGLIST(ha)) { scb_p->sg_list.enh_list = ips_sg.enh_list + i * IPS_MAX_SG; scb_p->sg_busaddr = sg_dma + IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * i; } else { scb_p->sg_list.std_list = ips_sg.std_list + i * IPS_MAX_SG; scb_p->sg_busaddr = sg_dma + IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * i; } /* add to the free list */ if (i < ha->max_cmds - 1) { scb_p->q_next = ha->scb_freelist; ha->scb_freelist = scb_p; } } /* success */ return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_init_scb */ /* */ /* Routine Description: */ /* */ /* Initialize a CCB to default values */ /* */ /****************************************************************************/ static void ips_init_scb(ips_ha_t * ha, ips_scb_t * scb) { IPS_SG_LIST sg_list; uint32_t cmd_busaddr, sg_busaddr; METHOD_TRACE("ips_init_scb", 1); if (scb == NULL) return; sg_list.list = scb->sg_list.list; cmd_busaddr = scb->scb_busaddr; sg_busaddr = scb->sg_busaddr; /* zero fill */ memset(scb, 0, sizeof (ips_scb_t)); memset(ha->dummy, 0, sizeof (IPS_IO_CMD)); /* Initialize dummy command bucket */ ha->dummy->op_code = 0xFF; ha->dummy->ccsar = cpu_to_le32(ha->adapt->hw_status_start + sizeof (IPS_ADAPTER)); ha->dummy->command_id = IPS_MAX_CMDS; /* set bus address of scb */ scb->scb_busaddr = cmd_busaddr; scb->sg_busaddr = sg_busaddr; scb->sg_list.list = sg_list.list; /* Neptune Fix */ scb->cmd.basic_io.cccr = cpu_to_le32((uint32_t) IPS_BIT_ILE); scb->cmd.basic_io.ccsar = cpu_to_le32(ha->adapt->hw_status_start + sizeof (IPS_ADAPTER)); } /****************************************************************************/ /* */ /* Routine Name: ips_get_scb */ /* */ /* Routine Description: */ /* */ /* Initialize a CCB to default values */ /* */ /* ASSUMED to be called from within a lock */ /* */ /****************************************************************************/ static ips_scb_t * ips_getscb(ips_ha_t * ha) { ips_scb_t *scb; METHOD_TRACE("ips_getscb", 1); if ((scb = ha->scb_freelist) == NULL) { return (NULL); } ha->scb_freelist = scb->q_next; scb->flags = 0; scb->q_next = NULL; ips_init_scb(ha, scb); return (scb); } /****************************************************************************/ /* */ /* Routine Name: ips_free_scb */ /* */ /* Routine Description: */ /* */ /* Return an unused CCB back to the free list */ /* */ /* ASSUMED to be called from within a lock */ /* */ /****************************************************************************/ static void ips_freescb(ips_ha_t * ha, ips_scb_t * scb) { METHOD_TRACE("ips_freescb", 1); if (scb->flags & IPS_SCB_MAP_SG) scsi_dma_unmap(scb->scsi_cmd); else if (scb->flags & IPS_SCB_MAP_SINGLE) pci_unmap_single(ha->pcidev, scb->data_busaddr, scb->data_len, IPS_DMA_DIR(scb)); /* check to make sure this is not our "special" scb */ if (IPS_COMMAND_ID(ha, scb) < (ha->max_cmds - 1)) { scb->q_next = ha->scb_freelist; ha->scb_freelist = scb; } } /****************************************************************************/ /* */ /* Routine Name: ips_isinit_copperhead */ /* */ /* Routine Description: */ /* */ /* Is controller initialized ? */ /* */ /****************************************************************************/ static int ips_isinit_copperhead(ips_ha_t * ha) { uint8_t scpr; uint8_t isr; METHOD_TRACE("ips_isinit_copperhead", 1); isr = inb(ha->io_addr + IPS_REG_HISR); scpr = inb(ha->io_addr + IPS_REG_SCPR); if (((isr & IPS_BIT_EI) == 0) && ((scpr & IPS_BIT_EBM) == 0)) return (0); else return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_isinit_copperhead_memio */ /* */ /* Routine Description: */ /* */ /* Is controller initialized ? */ /* */ /****************************************************************************/ static int ips_isinit_copperhead_memio(ips_ha_t * ha) { uint8_t isr = 0; uint8_t scpr; METHOD_TRACE("ips_is_init_copperhead_memio", 1); isr = readb(ha->mem_ptr + IPS_REG_HISR); scpr = readb(ha->mem_ptr + IPS_REG_SCPR); if (((isr & IPS_BIT_EI) == 0) && ((scpr & IPS_BIT_EBM) == 0)) return (0); else return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_isinit_morpheus */ /* */ /* Routine Description: */ /* */ /* Is controller initialized ? */ /* */ /****************************************************************************/ static int ips_isinit_morpheus(ips_ha_t * ha) { uint32_t post; uint32_t bits; METHOD_TRACE("ips_is_init_morpheus", 1); if (ips_isintr_morpheus(ha)) ips_flush_and_reset(ha); post = readl(ha->mem_ptr + IPS_REG_I960_MSG0); bits = readl(ha->mem_ptr + IPS_REG_I2O_HIR); if (post == 0) return (0); else if (bits & 0x3) return (0); else return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_flush_and_reset */ /* */ /* Routine Description: */ /* */ /* Perform cleanup ( FLUSH and RESET ) when the adapter is in an unknown */ /* state ( was trying to INIT and an interrupt was already pending ) ... */ /* */ /****************************************************************************/ static void ips_flush_and_reset(ips_ha_t *ha) { ips_scb_t *scb; int ret; int time; int done; dma_addr_t command_dma; /* Create a usuable SCB */ scb = pci_alloc_consistent(ha->pcidev, sizeof(ips_scb_t), &command_dma); if (scb) { memset(scb, 0, sizeof(ips_scb_t)); ips_init_scb(ha, scb); scb->scb_busaddr = command_dma; scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_FLUSH; scb->cmd.flush_cache.op_code = IPS_CMD_FLUSH; scb->cmd.flush_cache.command_id = IPS_MAX_CMDS; /* Use an ID that would otherwise not exist */ scb->cmd.flush_cache.state = IPS_NORM_STATE; scb->cmd.flush_cache.reserved = 0; scb->cmd.flush_cache.reserved2 = 0; scb->cmd.flush_cache.reserved3 = 0; scb->cmd.flush_cache.reserved4 = 0; ret = ips_send_cmd(ha, scb); /* Send the Flush Command */ if (ret == IPS_SUCCESS) { time = 60 * IPS_ONE_SEC; /* Max Wait time is 60 seconds */ done = 0; while ((time > 0) && (!done)) { done = ips_poll_for_flush_complete(ha); /* This may look evil, but it's only done during extremely rare start-up conditions ! */ udelay(1000); time--; } } } /* Now RESET and INIT the adapter */ (*ha->func.reset) (ha); pci_free_consistent(ha->pcidev, sizeof(ips_scb_t), scb, command_dma); return; } /****************************************************************************/ /* */ /* Routine Name: ips_poll_for_flush_complete */ /* */ /* Routine Description: */ /* */ /* Poll for the Flush Command issued by ips_flush_and_reset() to complete */ /* All other responses are just taken off the queue and ignored */ /* */ /****************************************************************************/ static int ips_poll_for_flush_complete(ips_ha_t * ha) { IPS_STATUS cstatus; while (TRUE) { cstatus.value = (*ha->func.statupd) (ha); if (cstatus.value == 0xffffffff) /* If No Interrupt to process */ break; /* Success is when we see the Flush Command ID */ if (cstatus.fields.command_id == IPS_MAX_CMDS) return 1; } return 0; } /****************************************************************************/ /* */ /* Routine Name: ips_enable_int_copperhead */ /* */ /* Routine Description: */ /* Turn on interrupts */ /* */ /****************************************************************************/ static void ips_enable_int_copperhead(ips_ha_t * ha) { METHOD_TRACE("ips_enable_int_copperhead", 1); outb(ha->io_addr + IPS_REG_HISR, IPS_BIT_EI); inb(ha->io_addr + IPS_REG_HISR); /*Ensure PCI Posting Completes*/ } /****************************************************************************/ /* */ /* Routine Name: ips_enable_int_copperhead_memio */ /* */ /* Routine Description: */ /* Turn on interrupts */ /* */ /****************************************************************************/ static void ips_enable_int_copperhead_memio(ips_ha_t * ha) { METHOD_TRACE("ips_enable_int_copperhead_memio", 1); writeb(IPS_BIT_EI, ha->mem_ptr + IPS_REG_HISR); readb(ha->mem_ptr + IPS_REG_HISR); /*Ensure PCI Posting Completes*/ } /****************************************************************************/ /* */ /* Routine Name: ips_enable_int_morpheus */ /* */ /* Routine Description: */ /* Turn on interrupts */ /* */ /****************************************************************************/ static void ips_enable_int_morpheus(ips_ha_t * ha) { uint32_t Oimr; METHOD_TRACE("ips_enable_int_morpheus", 1); Oimr = readl(ha->mem_ptr + IPS_REG_I960_OIMR); Oimr &= ~0x08; writel(Oimr, ha->mem_ptr + IPS_REG_I960_OIMR); readl(ha->mem_ptr + IPS_REG_I960_OIMR); /*Ensure PCI Posting Completes*/ } /****************************************************************************/ /* */ /* Routine Name: ips_init_copperhead */ /* */ /* Routine Description: */ /* */ /* Initialize a copperhead controller */ /* */ /****************************************************************************/ static int ips_init_copperhead(ips_ha_t * ha) { uint8_t Isr; uint8_t Cbsp; uint8_t PostByte[IPS_MAX_POST_BYTES]; uint8_t ConfigByte[IPS_MAX_CONFIG_BYTES]; int i, j; METHOD_TRACE("ips_init_copperhead", 1); for (i = 0; i < IPS_MAX_POST_BYTES; i++) { for (j = 0; j < 45; j++) { Isr = inb(ha->io_addr + IPS_REG_HISR); if (Isr & IPS_BIT_GHI) break; /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); } if (j >= 45) /* error occurred */ return (0); PostByte[i] = inb(ha->io_addr + IPS_REG_ISPR); outb(Isr, ha->io_addr + IPS_REG_HISR); } if (PostByte[0] < IPS_GOOD_POST_STATUS) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "reset controller fails (post status %x %x).\n", PostByte[0], PostByte[1]); return (0); } for (i = 0; i < IPS_MAX_CONFIG_BYTES; i++) { for (j = 0; j < 240; j++) { Isr = inb(ha->io_addr + IPS_REG_HISR); if (Isr & IPS_BIT_GHI) break; /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); } if (j >= 240) /* error occurred */ return (0); ConfigByte[i] = inb(ha->io_addr + IPS_REG_ISPR); outb(Isr, ha->io_addr + IPS_REG_HISR); } for (i = 0; i < 240; i++) { Cbsp = inb(ha->io_addr + IPS_REG_CBSP); if ((Cbsp & IPS_BIT_OP) == 0) break; /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); } if (i >= 240) /* reset failed */ return (0); /* setup CCCR */ outl(0x1010, ha->io_addr + IPS_REG_CCCR); /* Enable busmastering */ outb(IPS_BIT_EBM, ha->io_addr + IPS_REG_SCPR); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) /* fix for anaconda64 */ outl(0, ha->io_addr + IPS_REG_NDAE); /* Enable interrupts */ outb(IPS_BIT_EI, ha->io_addr + IPS_REG_HISR); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_init_copperhead_memio */ /* */ /* Routine Description: */ /* */ /* Initialize a copperhead controller with memory mapped I/O */ /* */ /****************************************************************************/ static int ips_init_copperhead_memio(ips_ha_t * ha) { uint8_t Isr = 0; uint8_t Cbsp; uint8_t PostByte[IPS_MAX_POST_BYTES]; uint8_t ConfigByte[IPS_MAX_CONFIG_BYTES]; int i, j; METHOD_TRACE("ips_init_copperhead_memio", 1); for (i = 0; i < IPS_MAX_POST_BYTES; i++) { for (j = 0; j < 45; j++) { Isr = readb(ha->mem_ptr + IPS_REG_HISR); if (Isr & IPS_BIT_GHI) break; /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); } if (j >= 45) /* error occurred */ return (0); PostByte[i] = readb(ha->mem_ptr + IPS_REG_ISPR); writeb(Isr, ha->mem_ptr + IPS_REG_HISR); } if (PostByte[0] < IPS_GOOD_POST_STATUS) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "reset controller fails (post status %x %x).\n", PostByte[0], PostByte[1]); return (0); } for (i = 0; i < IPS_MAX_CONFIG_BYTES; i++) { for (j = 0; j < 240; j++) { Isr = readb(ha->mem_ptr + IPS_REG_HISR); if (Isr & IPS_BIT_GHI) break; /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); } if (j >= 240) /* error occurred */ return (0); ConfigByte[i] = readb(ha->mem_ptr + IPS_REG_ISPR); writeb(Isr, ha->mem_ptr + IPS_REG_HISR); } for (i = 0; i < 240; i++) { Cbsp = readb(ha->mem_ptr + IPS_REG_CBSP); if ((Cbsp & IPS_BIT_OP) == 0) break; /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); } if (i >= 240) /* error occurred */ return (0); /* setup CCCR */ writel(0x1010, ha->mem_ptr + IPS_REG_CCCR); /* Enable busmastering */ writeb(IPS_BIT_EBM, ha->mem_ptr + IPS_REG_SCPR); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) /* fix for anaconda64 */ writel(0, ha->mem_ptr + IPS_REG_NDAE); /* Enable interrupts */ writeb(IPS_BIT_EI, ha->mem_ptr + IPS_REG_HISR); /* if we get here then everything went OK */ return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_init_morpheus */ /* */ /* Routine Description: */ /* */ /* Initialize a morpheus controller */ /* */ /****************************************************************************/ static int ips_init_morpheus(ips_ha_t * ha) { uint32_t Post; uint32_t Config; uint32_t Isr; uint32_t Oimr; int i; METHOD_TRACE("ips_init_morpheus", 1); /* Wait up to 45 secs for Post */ for (i = 0; i < 45; i++) { Isr = readl(ha->mem_ptr + IPS_REG_I2O_HIR); if (Isr & IPS_BIT_I960_MSG0I) break; /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); } if (i >= 45) { /* error occurred */ IPS_PRINTK(KERN_WARNING, ha->pcidev, "timeout waiting for post.\n"); return (0); } Post = readl(ha->mem_ptr + IPS_REG_I960_MSG0); if (Post == 0x4F00) { /* If Flashing the Battery PIC */ IPS_PRINTK(KERN_WARNING, ha->pcidev, "Flashing Battery PIC, Please wait ...\n"); /* Clear the interrupt bit */ Isr = (uint32_t) IPS_BIT_I960_MSG0I; writel(Isr, ha->mem_ptr + IPS_REG_I2O_HIR); for (i = 0; i < 120; i++) { /* Wait Up to 2 Min. for Completion */ Post = readl(ha->mem_ptr + IPS_REG_I960_MSG0); if (Post != 0x4F00) break; /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); } if (i >= 120) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "timeout waiting for Battery PIC Flash\n"); return (0); } } /* Clear the interrupt bit */ Isr = (uint32_t) IPS_BIT_I960_MSG0I; writel(Isr, ha->mem_ptr + IPS_REG_I2O_HIR); if (Post < (IPS_GOOD_POST_STATUS << 8)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "reset controller fails (post status %x).\n", Post); return (0); } /* Wait up to 240 secs for config bytes */ for (i = 0; i < 240; i++) { Isr = readl(ha->mem_ptr + IPS_REG_I2O_HIR); if (Isr & IPS_BIT_I960_MSG1I) break; /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); } if (i >= 240) { /* error occurred */ IPS_PRINTK(KERN_WARNING, ha->pcidev, "timeout waiting for config.\n"); return (0); } Config = readl(ha->mem_ptr + IPS_REG_I960_MSG1); /* Clear interrupt bit */ Isr = (uint32_t) IPS_BIT_I960_MSG1I; writel(Isr, ha->mem_ptr + IPS_REG_I2O_HIR); /* Turn on the interrupts */ Oimr = readl(ha->mem_ptr + IPS_REG_I960_OIMR); Oimr &= ~0x8; writel(Oimr, ha->mem_ptr + IPS_REG_I960_OIMR); /* if we get here then everything went OK */ /* Since we did a RESET, an EraseStripeLock may be needed */ if (Post == 0xEF10) { if ((Config == 0x000F) || (Config == 0x0009)) ha->requires_esl = 1; } return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_reset_copperhead */ /* */ /* Routine Description: */ /* */ /* Reset the controller */ /* */ /****************************************************************************/ static int ips_reset_copperhead(ips_ha_t * ha) { int reset_counter; METHOD_TRACE("ips_reset_copperhead", 1); DEBUG_VAR(1, "(%s%d) ips_reset_copperhead: io addr: %x, irq: %d", ips_name, ha->host_num, ha->io_addr, ha->pcidev->irq); reset_counter = 0; while (reset_counter < 2) { reset_counter++; outb(IPS_BIT_RST, ha->io_addr + IPS_REG_SCPR); /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); outb(0, ha->io_addr + IPS_REG_SCPR); /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); if ((*ha->func.init) (ha)) break; else if (reset_counter >= 2) { return (0); } } return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_reset_copperhead_memio */ /* */ /* Routine Description: */ /* */ /* Reset the controller */ /* */ /****************************************************************************/ static int ips_reset_copperhead_memio(ips_ha_t * ha) { int reset_counter; METHOD_TRACE("ips_reset_copperhead_memio", 1); DEBUG_VAR(1, "(%s%d) ips_reset_copperhead_memio: mem addr: %x, irq: %d", ips_name, ha->host_num, ha->mem_addr, ha->pcidev->irq); reset_counter = 0; while (reset_counter < 2) { reset_counter++; writeb(IPS_BIT_RST, ha->mem_ptr + IPS_REG_SCPR); /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); writeb(0, ha->mem_ptr + IPS_REG_SCPR); /* Delay for 1 Second */ MDELAY(IPS_ONE_SEC); if ((*ha->func.init) (ha)) break; else if (reset_counter >= 2) { return (0); } } return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_reset_morpheus */ /* */ /* Routine Description: */ /* */ /* Reset the controller */ /* */ /****************************************************************************/ static int ips_reset_morpheus(ips_ha_t * ha) { int reset_counter; uint8_t junk; METHOD_TRACE("ips_reset_morpheus", 1); DEBUG_VAR(1, "(%s%d) ips_reset_morpheus: mem addr: %x, irq: %d", ips_name, ha->host_num, ha->mem_addr, ha->pcidev->irq); reset_counter = 0; while (reset_counter < 2) { reset_counter++; writel(0x80000000, ha->mem_ptr + IPS_REG_I960_IDR); /* Delay for 5 Seconds */ MDELAY(5 * IPS_ONE_SEC); /* Do a PCI config read to wait for adapter */ pci_read_config_byte(ha->pcidev, 4, &junk); if ((*ha->func.init) (ha)) break; else if (reset_counter >= 2) { return (0); } } return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_statinit */ /* */ /* Routine Description: */ /* */ /* Initialize the status queues on the controller */ /* */ /****************************************************************************/ static void ips_statinit(ips_ha_t * ha) { uint32_t phys_status_start; METHOD_TRACE("ips_statinit", 1); ha->adapt->p_status_start = ha->adapt->status; ha->adapt->p_status_end = ha->adapt->status + IPS_MAX_CMDS; ha->adapt->p_status_tail = ha->adapt->status; phys_status_start = ha->adapt->hw_status_start; outl(phys_status_start, ha->io_addr + IPS_REG_SQSR); outl(phys_status_start + IPS_STATUS_Q_SIZE, ha->io_addr + IPS_REG_SQER); outl(phys_status_start + IPS_STATUS_SIZE, ha->io_addr + IPS_REG_SQHR); outl(phys_status_start, ha->io_addr + IPS_REG_SQTR); ha->adapt->hw_status_tail = phys_status_start; } /****************************************************************************/ /* */ /* Routine Name: ips_statinit_memio */ /* */ /* Routine Description: */ /* */ /* Initialize the status queues on the controller */ /* */ /****************************************************************************/ static void ips_statinit_memio(ips_ha_t * ha) { uint32_t phys_status_start; METHOD_TRACE("ips_statinit_memio", 1); ha->adapt->p_status_start = ha->adapt->status; ha->adapt->p_status_end = ha->adapt->status + IPS_MAX_CMDS; ha->adapt->p_status_tail = ha->adapt->status; phys_status_start = ha->adapt->hw_status_start; writel(phys_status_start, ha->mem_ptr + IPS_REG_SQSR); writel(phys_status_start + IPS_STATUS_Q_SIZE, ha->mem_ptr + IPS_REG_SQER); writel(phys_status_start + IPS_STATUS_SIZE, ha->mem_ptr + IPS_REG_SQHR); writel(phys_status_start, ha->mem_ptr + IPS_REG_SQTR); ha->adapt->hw_status_tail = phys_status_start; } /****************************************************************************/ /* */ /* Routine Name: ips_statupd_copperhead */ /* */ /* Routine Description: */ /* */ /* Remove an element from the status queue */ /* */ /****************************************************************************/ static uint32_t ips_statupd_copperhead(ips_ha_t * ha) { METHOD_TRACE("ips_statupd_copperhead", 1); if (ha->adapt->p_status_tail != ha->adapt->p_status_end) { ha->adapt->p_status_tail++; ha->adapt->hw_status_tail += sizeof (IPS_STATUS); } else { ha->adapt->p_status_tail = ha->adapt->p_status_start; ha->adapt->hw_status_tail = ha->adapt->hw_status_start; } outl(ha->adapt->hw_status_tail, ha->io_addr + IPS_REG_SQTR); return (ha->adapt->p_status_tail->value); } /****************************************************************************/ /* */ /* Routine Name: ips_statupd_copperhead_memio */ /* */ /* Routine Description: */ /* */ /* Remove an element from the status queue */ /* */ /****************************************************************************/ static uint32_t ips_statupd_copperhead_memio(ips_ha_t * ha) { METHOD_TRACE("ips_statupd_copperhead_memio", 1); if (ha->adapt->p_status_tail != ha->adapt->p_status_end) { ha->adapt->p_status_tail++; ha->adapt->hw_status_tail += sizeof (IPS_STATUS); } else { ha->adapt->p_status_tail = ha->adapt->p_status_start; ha->adapt->hw_status_tail = ha->adapt->hw_status_start; } writel(ha->adapt->hw_status_tail, ha->mem_ptr + IPS_REG_SQTR); return (ha->adapt->p_status_tail->value); } /****************************************************************************/ /* */ /* Routine Name: ips_statupd_morpheus */ /* */ /* Routine Description: */ /* */ /* Remove an element from the status queue */ /* */ /****************************************************************************/ static uint32_t ips_statupd_morpheus(ips_ha_t * ha) { uint32_t val; METHOD_TRACE("ips_statupd_morpheus", 1); val = readl(ha->mem_ptr + IPS_REG_I2O_OUTMSGQ); return (val); } /****************************************************************************/ /* */ /* Routine Name: ips_issue_copperhead */ /* */ /* Routine Description: */ /* */ /* Send a command down to the controller */ /* */ /****************************************************************************/ static int ips_issue_copperhead(ips_ha_t * ha, ips_scb_t * scb) { uint32_t TimeOut; uint32_t val; METHOD_TRACE("ips_issue_copperhead", 1); if (scb->scsi_cmd) { DEBUG_VAR(2, "(%s%d) ips_issue: cmd 0x%X id %d (%d %d %d)", ips_name, ha->host_num, scb->cdb[0], scb->cmd.basic_io.command_id, scb->bus, scb->target_id, scb->lun); } else { DEBUG_VAR(2, KERN_NOTICE "(%s%d) ips_issue: logical cmd id %d", ips_name, ha->host_num, scb->cmd.basic_io.command_id); } TimeOut = 0; while ((val = le32_to_cpu(inl(ha->io_addr + IPS_REG_CCCR))) & IPS_BIT_SEM) { udelay(1000); if (++TimeOut >= IPS_SEM_TIMEOUT) { if (!(val & IPS_BIT_START_STOP)) break; IPS_PRINTK(KERN_WARNING, ha->pcidev, "ips_issue val [0x%x].\n", val); IPS_PRINTK(KERN_WARNING, ha->pcidev, "ips_issue semaphore chk timeout.\n"); return (IPS_FAILURE); } /* end if */ } /* end while */ outl(scb->scb_busaddr, ha->io_addr + IPS_REG_CCSAR); outw(IPS_BIT_START_CMD, ha->io_addr + IPS_REG_CCCR); return (IPS_SUCCESS); } /****************************************************************************/ /* */ /* Routine Name: ips_issue_copperhead_memio */ /* */ /* Routine Description: */ /* */ /* Send a command down to the controller */ /* */ /****************************************************************************/ static int ips_issue_copperhead_memio(ips_ha_t * ha, ips_scb_t * scb) { uint32_t TimeOut; uint32_t val; METHOD_TRACE("ips_issue_copperhead_memio", 1); if (scb->scsi_cmd) { DEBUG_VAR(2, "(%s%d) ips_issue: cmd 0x%X id %d (%d %d %d)", ips_name, ha->host_num, scb->cdb[0], scb->cmd.basic_io.command_id, scb->bus, scb->target_id, scb->lun); } else { DEBUG_VAR(2, "(%s%d) ips_issue: logical cmd id %d", ips_name, ha->host_num, scb->cmd.basic_io.command_id); } TimeOut = 0; while ((val = readl(ha->mem_ptr + IPS_REG_CCCR)) & IPS_BIT_SEM) { udelay(1000); if (++TimeOut >= IPS_SEM_TIMEOUT) { if (!(val & IPS_BIT_START_STOP)) break; IPS_PRINTK(KERN_WARNING, ha->pcidev, "ips_issue val [0x%x].\n", val); IPS_PRINTK(KERN_WARNING, ha->pcidev, "ips_issue semaphore chk timeout.\n"); return (IPS_FAILURE); } /* end if */ } /* end while */ writel(scb->scb_busaddr, ha->mem_ptr + IPS_REG_CCSAR); writel(IPS_BIT_START_CMD, ha->mem_ptr + IPS_REG_CCCR); return (IPS_SUCCESS); } /****************************************************************************/ /* */ /* Routine Name: ips_issue_i2o */ /* */ /* Routine Description: */ /* */ /* Send a command down to the controller */ /* */ /****************************************************************************/ static int ips_issue_i2o(ips_ha_t * ha, ips_scb_t * scb) { METHOD_TRACE("ips_issue_i2o", 1); if (scb->scsi_cmd) { DEBUG_VAR(2, "(%s%d) ips_issue: cmd 0x%X id %d (%d %d %d)", ips_name, ha->host_num, scb->cdb[0], scb->cmd.basic_io.command_id, scb->bus, scb->target_id, scb->lun); } else { DEBUG_VAR(2, "(%s%d) ips_issue: logical cmd id %d", ips_name, ha->host_num, scb->cmd.basic_io.command_id); } outl(scb->scb_busaddr, ha->io_addr + IPS_REG_I2O_INMSGQ); return (IPS_SUCCESS); } /****************************************************************************/ /* */ /* Routine Name: ips_issue_i2o_memio */ /* */ /* Routine Description: */ /* */ /* Send a command down to the controller */ /* */ /****************************************************************************/ static int ips_issue_i2o_memio(ips_ha_t * ha, ips_scb_t * scb) { METHOD_TRACE("ips_issue_i2o_memio", 1); if (scb->scsi_cmd) { DEBUG_VAR(2, "(%s%d) ips_issue: cmd 0x%X id %d (%d %d %d)", ips_name, ha->host_num, scb->cdb[0], scb->cmd.basic_io.command_id, scb->bus, scb->target_id, scb->lun); } else { DEBUG_VAR(2, "(%s%d) ips_issue: logical cmd id %d", ips_name, ha->host_num, scb->cmd.basic_io.command_id); } writel(scb->scb_busaddr, ha->mem_ptr + IPS_REG_I2O_INMSGQ); return (IPS_SUCCESS); } /****************************************************************************/ /* */ /* Routine Name: ips_isintr_copperhead */ /* */ /* Routine Description: */ /* */ /* Test to see if an interrupt is for us */ /* */ /****************************************************************************/ static int ips_isintr_copperhead(ips_ha_t * ha) { uint8_t Isr; METHOD_TRACE("ips_isintr_copperhead", 2); Isr = inb(ha->io_addr + IPS_REG_HISR); if (Isr == 0xFF) /* ?!?! Nothing really there */ return (0); if (Isr & IPS_BIT_SCE) return (1); else if (Isr & (IPS_BIT_SQO | IPS_BIT_GHI)) { /* status queue overflow or GHI */ /* just clear the interrupt */ outb(Isr, ha->io_addr + IPS_REG_HISR); } return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_isintr_copperhead_memio */ /* */ /* Routine Description: */ /* */ /* Test to see if an interrupt is for us */ /* */ /****************************************************************************/ static int ips_isintr_copperhead_memio(ips_ha_t * ha) { uint8_t Isr; METHOD_TRACE("ips_isintr_memio", 2); Isr = readb(ha->mem_ptr + IPS_REG_HISR); if (Isr == 0xFF) /* ?!?! Nothing really there */ return (0); if (Isr & IPS_BIT_SCE) return (1); else if (Isr & (IPS_BIT_SQO | IPS_BIT_GHI)) { /* status queue overflow or GHI */ /* just clear the interrupt */ writeb(Isr, ha->mem_ptr + IPS_REG_HISR); } return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_isintr_morpheus */ /* */ /* Routine Description: */ /* */ /* Test to see if an interrupt is for us */ /* */ /****************************************************************************/ static int ips_isintr_morpheus(ips_ha_t * ha) { uint32_t Isr; METHOD_TRACE("ips_isintr_morpheus", 2); Isr = readl(ha->mem_ptr + IPS_REG_I2O_HIR); if (Isr & IPS_BIT_I2O_OPQI) return (1); else return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_wait */ /* */ /* Routine Description: */ /* */ /* Wait for a command to complete */ /* */ /****************************************************************************/ static int ips_wait(ips_ha_t * ha, int time, int intr) { int ret; int done; METHOD_TRACE("ips_wait", 1); ret = IPS_FAILURE; done = FALSE; time *= IPS_ONE_SEC; /* convert seconds */ while ((time > 0) && (!done)) { if (intr == IPS_INTR_ON) { if (ha->waitflag == FALSE) { ret = IPS_SUCCESS; done = TRUE; break; } } else if (intr == IPS_INTR_IORL) { if (ha->waitflag == FALSE) { /* * controller generated an interrupt to * acknowledge completion of the command * and ips_intr() has serviced the interrupt. */ ret = IPS_SUCCESS; done = TRUE; break; } /* * NOTE: we already have the io_request_lock so * even if we get an interrupt it won't get serviced * until after we finish. */ (*ha->func.intr) (ha); } /* This looks like a very evil loop, but it only does this during start-up */ udelay(1000); time--; } return (ret); } /****************************************************************************/ /* */ /* Routine Name: ips_write_driver_status */ /* */ /* Routine Description: */ /* */ /* Write OS/Driver version to Page 5 of the nvram on the controller */ /* */ /****************************************************************************/ static int ips_write_driver_status(ips_ha_t * ha, int intr) { METHOD_TRACE("ips_write_driver_status", 1); if (!ips_readwrite_page5(ha, FALSE, intr)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to read NVRAM page 5.\n"); return (0); } /* check to make sure the page has a valid */ /* signature */ if (le32_to_cpu(ha->nvram->signature) != IPS_NVRAM_P5_SIG) { DEBUG_VAR(1, "(%s%d) NVRAM page 5 has an invalid signature: %X.", ips_name, ha->host_num, ha->nvram->signature); ha->nvram->signature = IPS_NVRAM_P5_SIG; } DEBUG_VAR(2, "(%s%d) Ad Type: %d, Ad Slot: %d, BIOS: %c%c%c%c %c%c%c%c.", ips_name, ha->host_num, le16_to_cpu(ha->nvram->adapter_type), ha->nvram->adapter_slot, ha->nvram->bios_high[0], ha->nvram->bios_high[1], ha->nvram->bios_high[2], ha->nvram->bios_high[3], ha->nvram->bios_low[0], ha->nvram->bios_low[1], ha->nvram->bios_low[2], ha->nvram->bios_low[3]); ips_get_bios_version(ha, intr); /* change values (as needed) */ ha->nvram->operating_system = IPS_OS_LINUX; ha->nvram->adapter_type = ha->ad_type; strncpy((char *) ha->nvram->driver_high, IPS_VERSION_HIGH, 4); strncpy((char *) ha->nvram->driver_low, IPS_VERSION_LOW, 4); strncpy((char *) ha->nvram->bios_high, ha->bios_version, 4); strncpy((char *) ha->nvram->bios_low, ha->bios_version + 4, 4); ha->nvram->versioning = 0; /* Indicate the Driver Does Not Support Versioning */ /* now update the page */ if (!ips_readwrite_page5(ha, TRUE, intr)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to write NVRAM page 5.\n"); return (0); } /* IF NVRAM Page 5 is OK, Use it for Slot Number Info Because Linux Doesn't Do Slots */ ha->slot_num = ha->nvram->adapter_slot; return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_read_adapter_status */ /* */ /* Routine Description: */ /* */ /* Do an Inquiry command to the adapter */ /* */ /****************************************************************************/ static int ips_read_adapter_status(ips_ha_t * ha, int intr) { ips_scb_t *scb; int ret; METHOD_TRACE("ips_read_adapter_status", 1); scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_ENQUIRY; scb->cmd.basic_io.op_code = IPS_CMD_ENQUIRY; scb->cmd.basic_io.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.basic_io.sg_count = 0; scb->cmd.basic_io.lba = 0; scb->cmd.basic_io.sector_count = 0; scb->cmd.basic_io.log_drv = 0; scb->data_len = sizeof (*ha->enq); scb->cmd.basic_io.sg_addr = ha->enq_busaddr; /* send command */ if (((ret = ips_send_wait(ha, scb, ips_cmd_timeout, intr)) == IPS_FAILURE) || (ret == IPS_SUCCESS_IMM) || ((scb->basic_status & IPS_GSC_STATUS_MASK) > 1)) return (0); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_read_subsystem_parameters */ /* */ /* Routine Description: */ /* */ /* Read subsystem parameters from the adapter */ /* */ /****************************************************************************/ static int ips_read_subsystem_parameters(ips_ha_t * ha, int intr) { ips_scb_t *scb; int ret; METHOD_TRACE("ips_read_subsystem_parameters", 1); scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_GET_SUBSYS; scb->cmd.basic_io.op_code = IPS_CMD_GET_SUBSYS; scb->cmd.basic_io.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.basic_io.sg_count = 0; scb->cmd.basic_io.lba = 0; scb->cmd.basic_io.sector_count = 0; scb->cmd.basic_io.log_drv = 0; scb->data_len = sizeof (*ha->subsys); scb->cmd.basic_io.sg_addr = ha->ioctl_busaddr; /* send command */ if (((ret = ips_send_wait(ha, scb, ips_cmd_timeout, intr)) == IPS_FAILURE) || (ret == IPS_SUCCESS_IMM) || ((scb->basic_status & IPS_GSC_STATUS_MASK) > 1)) return (0); memcpy(ha->subsys, ha->ioctl_data, sizeof(*ha->subsys)); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_read_config */ /* */ /* Routine Description: */ /* */ /* Read the configuration on the adapter */ /* */ /****************************************************************************/ static int ips_read_config(ips_ha_t * ha, int intr) { ips_scb_t *scb; int i; int ret; METHOD_TRACE("ips_read_config", 1); /* set defaults for initiator IDs */ for (i = 0; i < 4; i++) ha->conf->init_id[i] = 7; scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_READ_CONF; scb->cmd.basic_io.op_code = IPS_CMD_READ_CONF; scb->cmd.basic_io.command_id = IPS_COMMAND_ID(ha, scb); scb->data_len = sizeof (*ha->conf); scb->cmd.basic_io.sg_addr = ha->ioctl_busaddr; /* send command */ if (((ret = ips_send_wait(ha, scb, ips_cmd_timeout, intr)) == IPS_FAILURE) || (ret == IPS_SUCCESS_IMM) || ((scb->basic_status & IPS_GSC_STATUS_MASK) > 1)) { memset(ha->conf, 0, sizeof (IPS_CONF)); /* reset initiator IDs */ for (i = 0; i < 4; i++) ha->conf->init_id[i] = 7; /* Allow Completed with Errors, so JCRM can access the Adapter to fix the problems */ if ((scb->basic_status & IPS_GSC_STATUS_MASK) == IPS_CMD_CMPLT_WERROR) return (1); return (0); } memcpy(ha->conf, ha->ioctl_data, sizeof(*ha->conf)); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_readwrite_page5 */ /* */ /* Routine Description: */ /* */ /* Read nvram page 5 from the adapter */ /* */ /****************************************************************************/ static int ips_readwrite_page5(ips_ha_t * ha, int write, int intr) { ips_scb_t *scb; int ret; METHOD_TRACE("ips_readwrite_page5", 1); scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_RW_NVRAM_PAGE; scb->cmd.nvram.op_code = IPS_CMD_RW_NVRAM_PAGE; scb->cmd.nvram.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.nvram.page = 5; scb->cmd.nvram.write = write; scb->cmd.nvram.reserved = 0; scb->cmd.nvram.reserved2 = 0; scb->data_len = sizeof (*ha->nvram); scb->cmd.nvram.buffer_addr = ha->ioctl_busaddr; if (write) memcpy(ha->ioctl_data, ha->nvram, sizeof(*ha->nvram)); /* issue the command */ if (((ret = ips_send_wait(ha, scb, ips_cmd_timeout, intr)) == IPS_FAILURE) || (ret == IPS_SUCCESS_IMM) || ((scb->basic_status & IPS_GSC_STATUS_MASK) > 1)) { memset(ha->nvram, 0, sizeof (IPS_NVRAM_P5)); return (0); } if (!write) memcpy(ha->nvram, ha->ioctl_data, sizeof(*ha->nvram)); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_clear_adapter */ /* */ /* Routine Description: */ /* */ /* Clear the stripe lock tables */ /* */ /****************************************************************************/ static int ips_clear_adapter(ips_ha_t * ha, int intr) { ips_scb_t *scb; int ret; METHOD_TRACE("ips_clear_adapter", 1); scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_reset_timeout; scb->cdb[0] = IPS_CMD_CONFIG_SYNC; scb->cmd.config_sync.op_code = IPS_CMD_CONFIG_SYNC; scb->cmd.config_sync.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.config_sync.channel = 0; scb->cmd.config_sync.source_target = IPS_POCL; scb->cmd.config_sync.reserved = 0; scb->cmd.config_sync.reserved2 = 0; scb->cmd.config_sync.reserved3 = 0; /* issue command */ if (((ret = ips_send_wait(ha, scb, ips_reset_timeout, intr)) == IPS_FAILURE) || (ret == IPS_SUCCESS_IMM) || ((scb->basic_status & IPS_GSC_STATUS_MASK) > 1)) return (0); /* send unlock stripe command */ ips_init_scb(ha, scb); scb->cdb[0] = IPS_CMD_ERROR_TABLE; scb->timeout = ips_reset_timeout; scb->cmd.unlock_stripe.op_code = IPS_CMD_ERROR_TABLE; scb->cmd.unlock_stripe.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.unlock_stripe.log_drv = 0; scb->cmd.unlock_stripe.control = IPS_CSL; scb->cmd.unlock_stripe.reserved = 0; scb->cmd.unlock_stripe.reserved2 = 0; scb->cmd.unlock_stripe.reserved3 = 0; /* issue command */ if (((ret = ips_send_wait(ha, scb, ips_cmd_timeout, intr)) == IPS_FAILURE) || (ret == IPS_SUCCESS_IMM) || ((scb->basic_status & IPS_GSC_STATUS_MASK) > 1)) return (0); return (1); } /****************************************************************************/ /* */ /* Routine Name: ips_ffdc_reset */ /* */ /* Routine Description: */ /* */ /* FFDC: write reset info */ /* */ /****************************************************************************/ static void ips_ffdc_reset(ips_ha_t * ha, int intr) { ips_scb_t *scb; METHOD_TRACE("ips_ffdc_reset", 1); scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_FFDC; scb->cmd.ffdc.op_code = IPS_CMD_FFDC; scb->cmd.ffdc.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.ffdc.reset_count = ha->reset_count; scb->cmd.ffdc.reset_type = 0x80; /* convert time to what the card wants */ ips_fix_ffdc_time(ha, scb, ha->last_ffdc); /* issue command */ ips_send_wait(ha, scb, ips_cmd_timeout, intr); } /****************************************************************************/ /* */ /* Routine Name: ips_ffdc_time */ /* */ /* Routine Description: */ /* */ /* FFDC: write time info */ /* */ /****************************************************************************/ static void ips_ffdc_time(ips_ha_t * ha) { ips_scb_t *scb; METHOD_TRACE("ips_ffdc_time", 1); DEBUG_VAR(1, "(%s%d) Sending time update.", ips_name, ha->host_num); scb = &ha->scbs[ha->max_cmds - 1]; ips_init_scb(ha, scb); scb->timeout = ips_cmd_timeout; scb->cdb[0] = IPS_CMD_FFDC; scb->cmd.ffdc.op_code = IPS_CMD_FFDC; scb->cmd.ffdc.command_id = IPS_COMMAND_ID(ha, scb); scb->cmd.ffdc.reset_count = 0; scb->cmd.ffdc.reset_type = 0; /* convert time to what the card wants */ ips_fix_ffdc_time(ha, scb, ha->last_ffdc); /* issue command */ ips_send_wait(ha, scb, ips_cmd_timeout, IPS_FFDC); } /****************************************************************************/ /* */ /* Routine Name: ips_fix_ffdc_time */ /* */ /* Routine Description: */ /* Adjust time_t to what the card wants */ /* */ /****************************************************************************/ static void ips_fix_ffdc_time(ips_ha_t * ha, ips_scb_t * scb, time_t current_time) { long days; long rem; int i; int year; int yleap; int year_lengths[2] = { IPS_DAYS_NORMAL_YEAR, IPS_DAYS_LEAP_YEAR }; int month_lengths[12][2] = { {31, 31}, {28, 29}, {31, 31}, {30, 30}, {31, 31}, {30, 30}, {31, 31}, {31, 31}, {30, 30}, {31, 31}, {30, 30}, {31, 31} }; METHOD_TRACE("ips_fix_ffdc_time", 1); days = current_time / IPS_SECS_DAY; rem = current_time % IPS_SECS_DAY; scb->cmd.ffdc.hour = (rem / IPS_SECS_HOUR); rem = rem % IPS_SECS_HOUR; scb->cmd.ffdc.minute = (rem / IPS_SECS_MIN); scb->cmd.ffdc.second = (rem % IPS_SECS_MIN); year = IPS_EPOCH_YEAR; while (days < 0 || days >= year_lengths[yleap = IPS_IS_LEAP_YEAR(year)]) { int newy; newy = year + (days / IPS_DAYS_NORMAL_YEAR); if (days < 0) --newy; days -= (newy - year) * IPS_DAYS_NORMAL_YEAR + IPS_NUM_LEAP_YEARS_THROUGH(newy - 1) - IPS_NUM_LEAP_YEARS_THROUGH(year - 1); year = newy; } scb->cmd.ffdc.yearH = year / 100; scb->cmd.ffdc.yearL = year % 100; for (i = 0; days >= month_lengths[i][yleap]; ++i) days -= month_lengths[i][yleap]; scb->cmd.ffdc.month = i + 1; scb->cmd.ffdc.day = days + 1; } /**************************************************************************** * BIOS Flash Routines * ****************************************************************************/ /****************************************************************************/ /* */ /* Routine Name: ips_erase_bios */ /* */ /* Routine Description: */ /* Erase the BIOS on the adapter */ /* */ /****************************************************************************/ static int ips_erase_bios(ips_ha_t * ha) { int timeout; uint8_t status = 0; METHOD_TRACE("ips_erase_bios", 1); status = 0; /* Clear the status register */ outl(0, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ outb(0x50, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* Erase Setup */ outb(0x20, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* Erase Confirm */ outb(0xD0, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* Erase Status */ outb(0x70, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ timeout = 80000; /* 80 seconds */ while (timeout > 0) { if (ha->pcidev->revision == IPS_REVID_TROMBONE64) { outl(0, ha->io_addr + IPS_REG_FLAP); udelay(25); /* 25 us */ } status = inb(ha->io_addr + IPS_REG_FLDP); if (status & 0x80) break; MDELAY(1); timeout--; } /* check for timeout */ if (timeout <= 0) { /* timeout */ /* try to suspend the erase */ outb(0xB0, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* wait for 10 seconds */ timeout = 10000; while (timeout > 0) { if (ha->pcidev->revision == IPS_REVID_TROMBONE64) { outl(0, ha->io_addr + IPS_REG_FLAP); udelay(25); /* 25 us */ } status = inb(ha->io_addr + IPS_REG_FLDP); if (status & 0xC0) break; MDELAY(1); timeout--; } return (1); } /* check for valid VPP */ if (status & 0x08) /* VPP failure */ return (1); /* check for successful flash */ if (status & 0x30) /* sequence error */ return (1); /* Otherwise, we were successful */ /* clear status */ outb(0x50, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* enable reads */ outb(0xFF, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_erase_bios_memio */ /* */ /* Routine Description: */ /* Erase the BIOS on the adapter */ /* */ /****************************************************************************/ static int ips_erase_bios_memio(ips_ha_t * ha) { int timeout; uint8_t status; METHOD_TRACE("ips_erase_bios_memio", 1); status = 0; /* Clear the status register */ writel(0, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ writeb(0x50, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* Erase Setup */ writeb(0x20, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* Erase Confirm */ writeb(0xD0, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* Erase Status */ writeb(0x70, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ timeout = 80000; /* 80 seconds */ while (timeout > 0) { if (ha->pcidev->revision == IPS_REVID_TROMBONE64) { writel(0, ha->mem_ptr + IPS_REG_FLAP); udelay(25); /* 25 us */ } status = readb(ha->mem_ptr + IPS_REG_FLDP); if (status & 0x80) break; MDELAY(1); timeout--; } /* check for timeout */ if (timeout <= 0) { /* timeout */ /* try to suspend the erase */ writeb(0xB0, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* wait for 10 seconds */ timeout = 10000; while (timeout > 0) { if (ha->pcidev->revision == IPS_REVID_TROMBONE64) { writel(0, ha->mem_ptr + IPS_REG_FLAP); udelay(25); /* 25 us */ } status = readb(ha->mem_ptr + IPS_REG_FLDP); if (status & 0xC0) break; MDELAY(1); timeout--; } return (1); } /* check for valid VPP */ if (status & 0x08) /* VPP failure */ return (1); /* check for successful flash */ if (status & 0x30) /* sequence error */ return (1); /* Otherwise, we were successful */ /* clear status */ writeb(0x50, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* enable reads */ writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_program_bios */ /* */ /* Routine Description: */ /* Program the BIOS on the adapter */ /* */ /****************************************************************************/ static int ips_program_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, uint32_t offset) { int i; int timeout; uint8_t status = 0; METHOD_TRACE("ips_program_bios", 1); status = 0; for (i = 0; i < buffersize; i++) { /* write a byte */ outl(i + offset, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ outb(0x40, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ outb(buffer[i], ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* wait up to one second */ timeout = 1000; while (timeout > 0) { if (ha->pcidev->revision == IPS_REVID_TROMBONE64) { outl(0, ha->io_addr + IPS_REG_FLAP); udelay(25); /* 25 us */ } status = inb(ha->io_addr + IPS_REG_FLDP); if (status & 0x80) break; MDELAY(1); timeout--; } if (timeout == 0) { /* timeout error */ outl(0, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ outb(0xFF, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ return (1); } /* check the status */ if (status & 0x18) { /* programming error */ outl(0, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ outb(0xFF, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ return (1); } } /* end for */ /* Enable reading */ outl(0, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ outb(0xFF, ha->io_addr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_program_bios_memio */ /* */ /* Routine Description: */ /* Program the BIOS on the adapter */ /* */ /****************************************************************************/ static int ips_program_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, uint32_t offset) { int i; int timeout; uint8_t status = 0; METHOD_TRACE("ips_program_bios_memio", 1); status = 0; for (i = 0; i < buffersize; i++) { /* write a byte */ writel(i + offset, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ writeb(0x40, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ writeb(buffer[i], ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ /* wait up to one second */ timeout = 1000; while (timeout > 0) { if (ha->pcidev->revision == IPS_REVID_TROMBONE64) { writel(0, ha->mem_ptr + IPS_REG_FLAP); udelay(25); /* 25 us */ } status = readb(ha->mem_ptr + IPS_REG_FLDP); if (status & 0x80) break; MDELAY(1); timeout--; } if (timeout == 0) { /* timeout error */ writel(0, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ return (1); } /* check the status */ if (status & 0x18) { /* programming error */ writel(0, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ return (1); } } /* end for */ /* Enable reading */ writel(0, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_verify_bios */ /* */ /* Routine Description: */ /* Verify the BIOS on the adapter */ /* */ /****************************************************************************/ static int ips_verify_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, uint32_t offset) { uint8_t checksum; int i; METHOD_TRACE("ips_verify_bios", 1); /* test 1st byte */ outl(0, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ if (inb(ha->io_addr + IPS_REG_FLDP) != 0x55) return (1); outl(1, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ if (inb(ha->io_addr + IPS_REG_FLDP) != 0xAA) return (1); checksum = 0xff; for (i = 2; i < buffersize; i++) { outl(i + offset, ha->io_addr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ checksum = (uint8_t) checksum + inb(ha->io_addr + IPS_REG_FLDP); } if (checksum != 0) /* failure */ return (1); else /* success */ return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_verify_bios_memio */ /* */ /* Routine Description: */ /* Verify the BIOS on the adapter */ /* */ /****************************************************************************/ static int ips_verify_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, uint32_t offset) { uint8_t checksum; int i; METHOD_TRACE("ips_verify_bios_memio", 1); /* test 1st byte */ writel(0, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0x55) return (1); writel(1, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0xAA) return (1); checksum = 0xff; for (i = 2; i < buffersize; i++) { writel(i + offset, ha->mem_ptr + IPS_REG_FLAP); if (ha->pcidev->revision == IPS_REVID_TROMBONE64) udelay(25); /* 25 us */ checksum = (uint8_t) checksum + readb(ha->mem_ptr + IPS_REG_FLDP); } if (checksum != 0) /* failure */ return (1); else /* success */ return (0); } /****************************************************************************/ /* */ /* Routine Name: ips_abort_init */ /* */ /* Routine Description: */ /* cleanup routine for a failed adapter initialization */ /****************************************************************************/ static int ips_abort_init(ips_ha_t * ha, int index) { ha->active = 0; ips_free(ha); ips_ha[index] = NULL; ips_sh[index] = NULL; return -1; } /****************************************************************************/ /* */ /* Routine Name: ips_shift_controllers */ /* */ /* Routine Description: */ /* helper function for ordering adapters */ /****************************************************************************/ static void ips_shift_controllers(int lowindex, int highindex) { ips_ha_t *ha_sav = ips_ha[highindex]; struct Scsi_Host *sh_sav = ips_sh[highindex]; int i; for (i = highindex; i > lowindex; i--) { ips_ha[i] = ips_ha[i - 1]; ips_sh[i] = ips_sh[i - 1]; ips_ha[i]->host_num = i; } ha_sav->host_num = lowindex; ips_ha[lowindex] = ha_sav; ips_sh[lowindex] = sh_sav; } /****************************************************************************/ /* */ /* Routine Name: ips_order_controllers */ /* */ /* Routine Description: */ /* place controllers is the "proper" boot order */ /****************************************************************************/ static void ips_order_controllers(void) { int i, j, tmp, position = 0; IPS_NVRAM_P5 *nvram; if (!ips_ha[0]) return; nvram = ips_ha[0]->nvram; if (nvram->adapter_order[0]) { for (i = 1; i <= nvram->adapter_order[0]; i++) { for (j = position; j < ips_num_controllers; j++) { switch (ips_ha[j]->ad_type) { case IPS_ADTYPE_SERVERAID6M: case IPS_ADTYPE_SERVERAID7M: if (nvram->adapter_order[i] == 'M') { ips_shift_controllers(position, j); position++; } break; case IPS_ADTYPE_SERVERAID4L: case IPS_ADTYPE_SERVERAID4M: case IPS_ADTYPE_SERVERAID4MX: case IPS_ADTYPE_SERVERAID4LX: if (nvram->adapter_order[i] == 'N') { ips_shift_controllers(position, j); position++; } break; case IPS_ADTYPE_SERVERAID6I: case IPS_ADTYPE_SERVERAID5I2: case IPS_ADTYPE_SERVERAID5I1: case IPS_ADTYPE_SERVERAID7k: if (nvram->adapter_order[i] == 'S') { ips_shift_controllers(position, j); position++; } break; case IPS_ADTYPE_SERVERAID: case IPS_ADTYPE_SERVERAID2: case IPS_ADTYPE_NAVAJO: case IPS_ADTYPE_KIOWA: case IPS_ADTYPE_SERVERAID3L: case IPS_ADTYPE_SERVERAID3: case IPS_ADTYPE_SERVERAID4H: if (nvram->adapter_order[i] == 'A') { ips_shift_controllers(position, j); position++; } break; default: break; } } } /* if adapter_order[0], then ordering is complete */ return; } /* old bios, use older ordering */ tmp = 0; for (i = position; i < ips_num_controllers; i++) { if (ips_ha[i]->ad_type == IPS_ADTYPE_SERVERAID5I2 || ips_ha[i]->ad_type == IPS_ADTYPE_SERVERAID5I1) { ips_shift_controllers(position, i); position++; tmp = 1; } } /* if there were no 5I cards, then don't do any extra ordering */ if (!tmp) return; for (i = position; i < ips_num_controllers; i++) { if (ips_ha[i]->ad_type == IPS_ADTYPE_SERVERAID4L || ips_ha[i]->ad_type == IPS_ADTYPE_SERVERAID4M || ips_ha[i]->ad_type == IPS_ADTYPE_SERVERAID4LX || ips_ha[i]->ad_type == IPS_ADTYPE_SERVERAID4MX) { ips_shift_controllers(position, i); position++; } } return; } /****************************************************************************/ /* */ /* Routine Name: ips_register_scsi */ /* */ /* Routine Description: */ /* perform any registration and setup with the scsi layer */ /****************************************************************************/ static int ips_register_scsi(int index) { struct Scsi_Host *sh; ips_ha_t *ha, *oldha = ips_ha[index]; sh = scsi_host_alloc(&ips_driver_template, sizeof (ips_ha_t)); if (!sh) { IPS_PRINTK(KERN_WARNING, oldha->pcidev, "Unable to register controller with SCSI subsystem\n"); return -1; } ha = IPS_HA(sh); memcpy(ha, oldha, sizeof (ips_ha_t)); free_irq(oldha->pcidev->irq, oldha); /* Install the interrupt handler with the new ha */ if (request_irq(ha->pcidev->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "Unable to install interrupt handler\n"); goto err_out_sh; } kfree(oldha); /* Store away needed values for later use */ sh->unique_id = (ha->io_addr) ? ha->io_addr : ha->mem_addr; sh->sg_tablesize = sh->hostt->sg_tablesize; sh->can_queue = sh->hostt->can_queue; sh->cmd_per_lun = sh->hostt->cmd_per_lun; sh->use_clustering = sh->hostt->use_clustering; sh->max_sectors = 128; sh->max_id = ha->ntargets; sh->max_lun = ha->nlun; sh->max_channel = ha->nbus - 1; sh->can_queue = ha->max_cmds - 1; if (scsi_add_host(sh, &ha->pcidev->dev)) goto err_out; ips_sh[index] = sh; ips_ha[index] = ha; scsi_scan_host(sh); return 0; err_out: free_irq(ha->pcidev->irq, ha); err_out_sh: scsi_host_put(sh); return -1; } /*---------------------------------------------------------------------------*/ /* Routine Name: ips_remove_device */ /* */ /* Routine Description: */ /* Remove one Adapter ( Hot Plugging ) */ /*---------------------------------------------------------------------------*/ static void __devexit ips_remove_device(struct pci_dev *pci_dev) { struct Scsi_Host *sh = pci_get_drvdata(pci_dev); pci_set_drvdata(pci_dev, NULL); ips_release(sh); pci_release_regions(pci_dev); pci_disable_device(pci_dev); } /****************************************************************************/ /* */ /* Routine Name: ips_module_init */ /* */ /* Routine Description: */ /* function called on module load */ /****************************************************************************/ static int __init ips_module_init(void) { if (pci_register_driver(&ips_pci_driver) < 0) return -ENODEV; ips_driver_template.module = THIS_MODULE; ips_order_controllers(); if (!ips_detect(&ips_driver_template)) { pci_unregister_driver(&ips_pci_driver); return -ENODEV; } register_reboot_notifier(&ips_notifier); return 0; } /****************************************************************************/ /* */ /* Routine Name: ips_module_exit */ /* */ /* Routine Description: */ /* function called on module unload */ /****************************************************************************/ static void __exit ips_module_exit(void) { pci_unregister_driver(&ips_pci_driver); unregister_reboot_notifier(&ips_notifier); } module_init(ips_module_init); module_exit(ips_module_exit); /*---------------------------------------------------------------------------*/ /* Routine Name: ips_insert_device */ /* */ /* Routine Description: */ /* Add One Adapter ( Hot Plug ) */ /* */ /* Return Value: */ /* 0 if Successful, else non-zero */ /*---------------------------------------------------------------------------*/ static int __devinit ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent) { int index = -1; int rc; METHOD_TRACE("ips_insert_device", 1); rc = pci_enable_device(pci_dev); if (rc) return rc; rc = pci_request_regions(pci_dev, "ips"); if (rc) goto err_out; rc = ips_init_phase1(pci_dev, &index); if (rc == SUCCESS) rc = ips_init_phase2(index); if (ips_hotplug) if (ips_register_scsi(index)) { ips_free(ips_ha[index]); rc = -1; } if (rc == SUCCESS) ips_num_controllers++; ips_next_controller = ips_num_controllers; if (rc < 0) { rc = -ENODEV; goto err_out_regions; } pci_set_drvdata(pci_dev, ips_sh[index]); return 0; err_out_regions: pci_release_regions(pci_dev); err_out: pci_disable_device(pci_dev); return rc; } /*---------------------------------------------------------------------------*/ /* Routine Name: ips_init_phase1 */ /* */ /* Routine Description: */ /* Adapter Initialization */ /* */ /* Return Value: */ /* 0 if Successful, else non-zero */ /*---------------------------------------------------------------------------*/ static int ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) { ips_ha_t *ha; uint32_t io_addr; uint32_t mem_addr; uint32_t io_len; uint32_t mem_len; uint8_t bus; uint8_t func; int j; int index; dma_addr_t dma_address; char __iomem *ioremap_ptr; char __iomem *mem_ptr; uint32_t IsDead; METHOD_TRACE("ips_init_phase1", 1); index = IPS_MAX_ADAPTERS; for (j = 0; j < IPS_MAX_ADAPTERS; j++) { if (ips_ha[j] == NULL) { index = j; break; } } if (index >= IPS_MAX_ADAPTERS) return -1; /* stuff that we get in dev */ bus = pci_dev->bus->number; func = pci_dev->devfn; /* Init MEM/IO addresses to 0 */ mem_addr = 0; io_addr = 0; mem_len = 0; io_len = 0; for (j = 0; j < 2; j++) { if (!pci_resource_start(pci_dev, j)) break; if (pci_resource_flags(pci_dev, j) & IORESOURCE_IO) { io_addr = pci_resource_start(pci_dev, j); io_len = pci_resource_len(pci_dev, j); } else { mem_addr = pci_resource_start(pci_dev, j); mem_len = pci_resource_len(pci_dev, j); } } /* setup memory mapped area (if applicable) */ if (mem_addr) { uint32_t base; uint32_t offs; base = mem_addr & PAGE_MASK; offs = mem_addr - base; ioremap_ptr = ioremap(base, PAGE_SIZE); if (!ioremap_ptr) return -1; mem_ptr = ioremap_ptr + offs; } else { ioremap_ptr = NULL; mem_ptr = NULL; } /* found a controller */ ha = kzalloc(sizeof (ips_ha_t), GFP_KERNEL); if (ha == NULL) { IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate temporary ha struct\n"); return -1; } ips_sh[index] = NULL; ips_ha[index] = ha; ha->active = 1; /* Store info in HA structure */ ha->io_addr = io_addr; ha->io_len = io_len; ha->mem_addr = mem_addr; ha->mem_len = mem_len; ha->mem_ptr = mem_ptr; ha->ioremap_ptr = ioremap_ptr; ha->host_num = (uint32_t) index; ha->slot_num = PCI_SLOT(pci_dev->devfn); ha->pcidev = pci_dev; /* * Set the pci_dev's dma_mask. Not all adapters support 64bit * addressing so don't enable it if the adapter can't support * it! Also, don't use 64bit addressing if dma addresses * are guaranteed to be < 4G. */ if (IPS_ENABLE_DMA64 && IPS_HAS_ENH_SGLIST(ha) && !pci_set_dma_mask(ha->pcidev, DMA_BIT_MASK(64))) { (ha)->flags |= IPS_HA_ENH_SG; } else { if (pci_set_dma_mask(ha->pcidev, DMA_BIT_MASK(32)) != 0) { printk(KERN_WARNING "Unable to set DMA Mask\n"); return ips_abort_init(ha, index); } } if(ips_cd_boot && !ips_FlashData){ ips_FlashData = pci_alloc_consistent(pci_dev, PAGE_SIZE << 7, &ips_flashbusaddr); } ha->enq = pci_alloc_consistent(pci_dev, sizeof (IPS_ENQ), &ha->enq_busaddr); if (!ha->enq) { IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate host inquiry structure\n"); return ips_abort_init(ha, index); } ha->adapt = pci_alloc_consistent(pci_dev, sizeof (IPS_ADAPTER) + sizeof (IPS_IO_CMD), &dma_address); if (!ha->adapt) { IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate host adapt & dummy structures\n"); return ips_abort_init(ha, index); } ha->adapt->hw_status_start = dma_address; ha->dummy = (void *) (ha->adapt + 1); ha->logical_drive_info = pci_alloc_consistent(pci_dev, sizeof (IPS_LD_INFO), &dma_address); if (!ha->logical_drive_info) { IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate logical drive info structure\n"); return ips_abort_init(ha, index); } ha->logical_drive_info_dma_addr = dma_address; ha->conf = kmalloc(sizeof (IPS_CONF), GFP_KERNEL); if (!ha->conf) { IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate host conf structure\n"); return ips_abort_init(ha, index); } ha->nvram = kmalloc(sizeof (IPS_NVRAM_P5), GFP_KERNEL); if (!ha->nvram) { IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate host NVRAM structure\n"); return ips_abort_init(ha, index); } ha->subsys = kmalloc(sizeof (IPS_SUBSYS), GFP_KERNEL); if (!ha->subsys) { IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate host subsystem structure\n"); return ips_abort_init(ha, index); } /* the ioctl buffer is now used during adapter initialization, so its * successful allocation is now required */ if (ips_ioctlsize < PAGE_SIZE) ips_ioctlsize = PAGE_SIZE; ha->ioctl_data = pci_alloc_consistent(pci_dev, ips_ioctlsize, &ha->ioctl_busaddr); ha->ioctl_len = ips_ioctlsize; if (!ha->ioctl_data) { IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate IOCTL data\n"); return ips_abort_init(ha, index); } /* * Setup Functions */ ips_setup_funclist(ha); if ((IPS_IS_MORPHEUS(ha)) || (IPS_IS_MARCO(ha))) { /* If Morpheus appears dead, reset it */ IsDead = readl(ha->mem_ptr + IPS_REG_I960_MSG1); if (IsDead == 0xDEADBEEF) { ips_reset_morpheus(ha); } } /* * Initialize the card if it isn't already */ if (!(*ha->func.isinit) (ha)) { if (!(*ha->func.init) (ha)) { /* * Initialization failed */ IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to initialize controller\n"); return ips_abort_init(ha, index); } } *indexPtr = index; return SUCCESS; } /*---------------------------------------------------------------------------*/ /* Routine Name: ips_init_phase2 */ /* */ /* Routine Description: */ /* Adapter Initialization Phase 2 */ /* */ /* Return Value: */ /* 0 if Successful, else non-zero */ /*---------------------------------------------------------------------------*/ static int ips_init_phase2(int index) { ips_ha_t *ha; ha = ips_ha[index]; METHOD_TRACE("ips_init_phase2", 1); if (!ha->active) { ips_ha[index] = NULL; return -1; } /* Install the interrupt handler */ if (request_irq(ha->pcidev->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "Unable to install interrupt handler\n"); return ips_abort_init(ha, index); } /* * Allocate a temporary SCB for initialization */ ha->max_cmds = 1; if (!ips_allocatescbs(ha)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "Unable to allocate a CCB\n"); free_irq(ha->pcidev->irq, ha); return ips_abort_init(ha, index); } if (!ips_hainit(ha)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "Unable to initialize controller\n"); free_irq(ha->pcidev->irq, ha); return ips_abort_init(ha, index); } /* Free the temporary SCB */ ips_deallocatescbs(ha, 1); /* allocate CCBs */ if (!ips_allocatescbs(ha)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "Unable to allocate CCBs\n"); free_irq(ha->pcidev->irq, ha); return ips_abort_init(ha, index); } return SUCCESS; } MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("IBM ServeRAID Adapter Driver " IPS_VER_STRING); MODULE_VERSION(IPS_VER_STRING); /* * Overrides for Emacs so that we almost follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically * adjust the settings for this buffer only. This must remain at the end * of the file. * --------------------------------------------------------------------------- * Local variables: * c-indent-level: 2 * c-brace-imaginary-offset: 0 * c-brace-offset: -2 * c-argdecl-indent: 2 * c-label-offset: -2 * c-continued-statement-offset: 2 * c-continued-brace-offset: 0 * indent-tabs-mode: nil * tab-width: 8 * End: */
gpl-2.0
ShinySide/HispAsian_S5
drivers/media/video/videobuf-vmalloc.c
8311
8530
/* * helper functions for vmalloc video4linux capture buffers * * The functions expect the hardware being able to scatter gather * (i.e. the buffers are not linear in physical memory, but fragmented * into PAGE_SIZE chunks). They also assume the driver does not need * to touch the video data. * * (c) 2007 Mauro Carvalho Chehab, <mchehab@infradead.org> * * 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 */ #include <linux/init.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/pci.h> #include <linux/vmalloc.h> #include <linux/pagemap.h> #include <asm/page.h> #include <asm/pgtable.h> #include <media/videobuf-vmalloc.h> #define MAGIC_DMABUF 0x17760309 #define MAGIC_VMAL_MEM 0x18221223 #define MAGIC_CHECK(is, should) \ if (unlikely((is) != (should))) { \ printk(KERN_ERR "magic mismatch: %x (expected %x)\n", \ is, should); \ BUG(); \ } static int debug; module_param(debug, int, 0644); MODULE_DESCRIPTION("helper module to manage video4linux vmalloc buffers"); MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); MODULE_LICENSE("GPL"); #define dprintk(level, fmt, arg...) \ if (debug >= level) \ printk(KERN_DEBUG "vbuf-vmalloc: " fmt , ## arg) /***************************************************************************/ static void videobuf_vm_open(struct vm_area_struct *vma) { struct videobuf_mapping *map = vma->vm_private_data; dprintk(2, "vm_open %p [count=%u,vma=%08lx-%08lx]\n", map, map->count, vma->vm_start, vma->vm_end); map->count++; } static void videobuf_vm_close(struct vm_area_struct *vma) { struct videobuf_mapping *map = vma->vm_private_data; struct videobuf_queue *q = map->q; int i; dprintk(2, "vm_close %p [count=%u,vma=%08lx-%08lx]\n", map, map->count, vma->vm_start, vma->vm_end); map->count--; if (0 == map->count) { struct videobuf_vmalloc_memory *mem; dprintk(1, "munmap %p q=%p\n", map, q); videobuf_queue_lock(q); /* We need first to cancel streams, before unmapping */ if (q->streaming) videobuf_queue_cancel(q); for (i = 0; i < VIDEO_MAX_FRAME; i++) { if (NULL == q->bufs[i]) continue; if (q->bufs[i]->map != map) continue; mem = q->bufs[i]->priv; if (mem) { /* This callback is called only if kernel has allocated memory and this memory is mmapped. In this case, memory should be freed, in order to do memory unmap. */ MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); /* vfree is not atomic - can't be called with IRQ's disabled */ dprintk(1, "%s: buf[%d] freeing (%p)\n", __func__, i, mem->vaddr); vfree(mem->vaddr); mem->vaddr = NULL; } q->bufs[i]->map = NULL; q->bufs[i]->baddr = 0; } kfree(map); videobuf_queue_unlock(q); } return; } static const struct vm_operations_struct videobuf_vm_ops = { .open = videobuf_vm_open, .close = videobuf_vm_close, }; /* --------------------------------------------------------------------- * vmalloc handlers for the generic methods */ /* Allocated area consists on 3 parts: struct video_buffer struct <driver>_buffer (cx88_buffer, saa7134_buf, ...) struct videobuf_dma_sg_memory */ static struct videobuf_buffer *__videobuf_alloc_vb(size_t size) { struct videobuf_vmalloc_memory *mem; struct videobuf_buffer *vb; vb = kzalloc(size + sizeof(*mem), GFP_KERNEL); if (!vb) return vb; mem = vb->priv = ((char *)vb) + size; mem->magic = MAGIC_VMAL_MEM; dprintk(1, "%s: allocated at %p(%ld+%ld) & %p(%ld)\n", __func__, vb, (long)sizeof(*vb), (long)size - sizeof(*vb), mem, (long)sizeof(*mem)); return vb; } static int __videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, struct v4l2_framebuffer *fbuf) { struct videobuf_vmalloc_memory *mem = vb->priv; int pages; BUG_ON(!mem); MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); switch (vb->memory) { case V4L2_MEMORY_MMAP: dprintk(1, "%s memory method MMAP\n", __func__); /* All handling should be done by __videobuf_mmap_mapper() */ if (!mem->vaddr) { printk(KERN_ERR "memory is not alloced/mmapped.\n"); return -EINVAL; } break; case V4L2_MEMORY_USERPTR: pages = PAGE_ALIGN(vb->size); dprintk(1, "%s memory method USERPTR\n", __func__); if (vb->baddr) { printk(KERN_ERR "USERPTR is currently not supported\n"); return -EINVAL; } /* The only USERPTR currently supported is the one needed for * read() method. */ mem->vaddr = vmalloc_user(pages); if (!mem->vaddr) { printk(KERN_ERR "vmalloc (%d pages) failed\n", pages); return -ENOMEM; } dprintk(1, "vmalloc is at addr %p (%d pages)\n", mem->vaddr, pages); #if 0 int rc; /* Kernel userptr is used also by read() method. In this case, there's no need to remap, since data will be copied to user */ if (!vb->baddr) return 0; /* FIXME: to properly support USERPTR, remap should occur. The code below won't work, since mem->vma = NULL */ /* Try to remap memory */ rc = remap_vmalloc_range(mem->vma, (void *)vb->baddr, 0); if (rc < 0) { printk(KERN_ERR "mmap: remap failed with error %d", rc); return -ENOMEM; } #endif break; case V4L2_MEMORY_OVERLAY: default: dprintk(1, "%s memory method OVERLAY/unknown\n", __func__); /* Currently, doesn't support V4L2_MEMORY_OVERLAY */ printk(KERN_ERR "Memory method currently unsupported.\n"); return -EINVAL; } return 0; } static int __videobuf_mmap_mapper(struct videobuf_queue *q, struct videobuf_buffer *buf, struct vm_area_struct *vma) { struct videobuf_vmalloc_memory *mem; struct videobuf_mapping *map; int retval, pages; dprintk(1, "%s\n", __func__); /* create mapping + update buffer list */ map = kzalloc(sizeof(struct videobuf_mapping), GFP_KERNEL); if (NULL == map) return -ENOMEM; buf->map = map; map->q = q; buf->baddr = vma->vm_start; mem = buf->priv; BUG_ON(!mem); MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); pages = PAGE_ALIGN(vma->vm_end - vma->vm_start); mem->vaddr = vmalloc_user(pages); if (!mem->vaddr) { printk(KERN_ERR "vmalloc (%d pages) failed\n", pages); goto error; } dprintk(1, "vmalloc is at addr %p (%d pages)\n", mem->vaddr, pages); /* Try to remap memory */ retval = remap_vmalloc_range(vma, mem->vaddr, 0); if (retval < 0) { printk(KERN_ERR "mmap: remap failed with error %d. ", retval); vfree(mem->vaddr); goto error; } vma->vm_ops = &videobuf_vm_ops; vma->vm_flags |= VM_DONTEXPAND | VM_RESERVED; vma->vm_private_data = map; dprintk(1, "mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\n", map, q, vma->vm_start, vma->vm_end, (long int)buf->bsize, vma->vm_pgoff, buf->i); videobuf_vm_open(vma); return 0; error: mem = NULL; kfree(map); return -ENOMEM; } static struct videobuf_qtype_ops qops = { .magic = MAGIC_QTYPE_OPS, .alloc_vb = __videobuf_alloc_vb, .iolock = __videobuf_iolock, .mmap_mapper = __videobuf_mmap_mapper, .vaddr = videobuf_to_vmalloc, }; void videobuf_queue_vmalloc_init(struct videobuf_queue *q, const struct videobuf_queue_ops *ops, struct device *dev, spinlock_t *irqlock, enum v4l2_buf_type type, enum v4l2_field field, unsigned int msize, void *priv, struct mutex *ext_lock) { videobuf_queue_core_init(q, ops, dev, irqlock, type, field, msize, priv, &qops, ext_lock); } EXPORT_SYMBOL_GPL(videobuf_queue_vmalloc_init); void *videobuf_to_vmalloc(struct videobuf_buffer *buf) { struct videobuf_vmalloc_memory *mem = buf->priv; BUG_ON(!mem); MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); return mem->vaddr; } EXPORT_SYMBOL_GPL(videobuf_to_vmalloc); void videobuf_vmalloc_free(struct videobuf_buffer *buf) { struct videobuf_vmalloc_memory *mem = buf->priv; /* mmapped memory can't be freed here, otherwise mmapped region would be released, while still needed. In this case, the memory release should happen inside videobuf_vm_close(). So, it should free memory only if the memory were allocated for read() operation. */ if ((buf->memory != V4L2_MEMORY_USERPTR) || buf->baddr) return; if (!mem) return; MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); vfree(mem->vaddr); mem->vaddr = NULL; return; } EXPORT_SYMBOL_GPL(videobuf_vmalloc_free);
gpl-2.0
gelotus/hammerhead-nirvana
drivers/acpi/utils.c
9079
9468
/* * acpi_utils.c - ACPI Utility Functions ($Revision: 10 $) * * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.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/slab.h> #include <linux/init.h> #include <linux/types.h> #include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h> #include "internal.h" #define _COMPONENT ACPI_BUS_COMPONENT ACPI_MODULE_NAME("utils"); /* -------------------------------------------------------------------------- Object Evaluation Helpers -------------------------------------------------------------------------- */ static void acpi_util_eval_error(acpi_handle h, acpi_string p, acpi_status s) { #ifdef ACPI_DEBUG_OUTPUT char prefix[80] = {'\0'}; struct acpi_buffer buffer = {sizeof(prefix), prefix}; acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n", (char *) prefix, p, acpi_format_exception(s))); #else return; #endif } acpi_status acpi_extract_package(union acpi_object *package, struct acpi_buffer *format, struct acpi_buffer *buffer) { u32 size_required = 0; u32 tail_offset = 0; char *format_string = NULL; u32 format_count = 0; u32 i = 0; u8 *head = NULL; u8 *tail = NULL; if (!package || (package->type != ACPI_TYPE_PACKAGE) || (package->package.count < 1)) { printk(KERN_WARNING PREFIX "Invalid package argument\n"); return AE_BAD_PARAMETER; } if (!format || !format->pointer || (format->length < 1)) { printk(KERN_WARNING PREFIX "Invalid format argument\n"); return AE_BAD_PARAMETER; } if (!buffer) { printk(KERN_WARNING PREFIX "Invalid buffer argument\n"); return AE_BAD_PARAMETER; } format_count = (format->length / sizeof(char)) - 1; if (format_count > package->package.count) { printk(KERN_WARNING PREFIX "Format specifies more objects [%d]" " than exist in package [%d].\n", format_count, package->package.count); return AE_BAD_DATA; } format_string = format->pointer; /* * Calculate size_required. */ for (i = 0; i < format_count; i++) { union acpi_object *element = &(package->package.elements[i]); if (!element) { return AE_BAD_DATA; } switch (element->type) { case ACPI_TYPE_INTEGER: switch (format_string[i]) { case 'N': size_required += sizeof(u64); tail_offset += sizeof(u64); break; case 'S': size_required += sizeof(char *) + sizeof(u64) + sizeof(char); tail_offset += sizeof(char *); break; default: printk(KERN_WARNING PREFIX "Invalid package element" " [%d]: got number, expecing" " [%c]\n", i, format_string[i]); return AE_BAD_DATA; break; } break; case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: switch (format_string[i]) { case 'S': size_required += sizeof(char *) + (element->string.length * sizeof(char)) + sizeof(char); tail_offset += sizeof(char *); break; case 'B': size_required += sizeof(u8 *) + (element->buffer.length * sizeof(u8)); tail_offset += sizeof(u8 *); break; default: printk(KERN_WARNING PREFIX "Invalid package element" " [%d] got string/buffer," " expecing [%c]\n", i, format_string[i]); return AE_BAD_DATA; break; } break; case ACPI_TYPE_PACKAGE: default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i)); /* TBD: handle nested packages... */ return AE_SUPPORT; break; } } /* * Validate output buffer. */ if (buffer->length < size_required) { buffer->length = size_required; return AE_BUFFER_OVERFLOW; } else if (buffer->length != size_required || !buffer->pointer) { return AE_BAD_PARAMETER; } head = buffer->pointer; tail = buffer->pointer + tail_offset; /* * Extract package data. */ for (i = 0; i < format_count; i++) { u8 **pointer = NULL; union acpi_object *element = &(package->package.elements[i]); if (!element) { return AE_BAD_DATA; } switch (element->type) { case ACPI_TYPE_INTEGER: switch (format_string[i]) { case 'N': *((u64 *) head) = element->integer.value; head += sizeof(u64); break; case 'S': pointer = (u8 **) head; *pointer = tail; *((u64 *) tail) = element->integer.value; head += sizeof(u64 *); tail += sizeof(u64); /* NULL terminate string */ *tail = (char)0; tail += sizeof(char); break; default: /* Should never get here */ break; } break; case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: switch (format_string[i]) { case 'S': pointer = (u8 **) head; *pointer = tail; memcpy(tail, element->string.pointer, element->string.length); head += sizeof(char *); tail += element->string.length * sizeof(char); /* NULL terminate string */ *tail = (char)0; tail += sizeof(char); break; case 'B': pointer = (u8 **) head; *pointer = tail; memcpy(tail, element->buffer.pointer, element->buffer.length); head += sizeof(u8 *); tail += element->buffer.length * sizeof(u8); break; default: /* Should never get here */ break; } break; case ACPI_TYPE_PACKAGE: /* TBD: handle nested packages... */ default: /* Should never get here */ break; } } return AE_OK; } EXPORT_SYMBOL(acpi_extract_package); acpi_status acpi_evaluate_integer(acpi_handle handle, acpi_string pathname, struct acpi_object_list *arguments, unsigned long long *data) { acpi_status status = AE_OK; union acpi_object element; struct acpi_buffer buffer = { 0, NULL }; if (!data) return AE_BAD_PARAMETER; buffer.length = sizeof(union acpi_object); buffer.pointer = &element; status = acpi_evaluate_object(handle, pathname, arguments, &buffer); if (ACPI_FAILURE(status)) { acpi_util_eval_error(handle, pathname, status); return status; } if (element.type != ACPI_TYPE_INTEGER) { acpi_util_eval_error(handle, pathname, AE_BAD_DATA); return AE_BAD_DATA; } *data = element.integer.value; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%llu]\n", *data)); return AE_OK; } EXPORT_SYMBOL(acpi_evaluate_integer); acpi_status acpi_evaluate_reference(acpi_handle handle, acpi_string pathname, struct acpi_object_list *arguments, struct acpi_handle_list *list) { acpi_status status = AE_OK; union acpi_object *package = NULL; union acpi_object *element = NULL; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; u32 i = 0; if (!list) { return AE_BAD_PARAMETER; } /* Evaluate object. */ status = acpi_evaluate_object(handle, pathname, arguments, &buffer); if (ACPI_FAILURE(status)) goto end; package = buffer.pointer; if ((buffer.length == 0) || !package) { printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n", (unsigned)buffer.length, package); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (package->type != ACPI_TYPE_PACKAGE) { printk(KERN_ERR PREFIX "Expecting a [Package], found type %X\n", package->type); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (!package->package.count) { printk(KERN_ERR PREFIX "[Package] has zero elements (%p)\n", package); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (package->package.count > ACPI_MAX_HANDLES) { return AE_NO_MEMORY; } list->count = package->package.count; /* Extract package data. */ for (i = 0; i < list->count; i++) { element = &(package->package.elements[i]); if (element->type != ACPI_TYPE_LOCAL_REFERENCE) { status = AE_BAD_DATA; printk(KERN_ERR PREFIX "Expecting a [Reference] package element, found type %X\n", element->type); acpi_util_eval_error(handle, pathname, status); break; } if (!element->reference.handle) { printk(KERN_WARNING PREFIX "Invalid reference in" " package %s\n", pathname); status = AE_NULL_ENTRY; break; } /* Get the acpi_handle. */ list->handles[i] = element->reference.handle; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n", list->handles[i])); } end: if (ACPI_FAILURE(status)) { list->count = 0; //kfree(list->handles); } kfree(buffer.pointer); return status; } EXPORT_SYMBOL(acpi_evaluate_reference);
gpl-2.0
sammy44nts/linux-kernel
drivers/video/fbdev/msm/mdp_scale_tables.c
12919
20631
/* drivers/video/msm_fb/mdp_scale_tables.c * * Copyright (C) 2007 QUALCOMM Incorporated * Copyright (C) 2007 Google Incorporated * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * 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. */ #include "mdp_scale_tables.h" #include "mdp_hw.h" struct mdp_table_entry mdp_upscale_table[] = { { 0x5fffc, 0x0 }, { 0x50200, 0x7fc00000 }, { 0x5fffc, 0xff80000d }, { 0x50204, 0x7ec003f9 }, { 0x5fffc, 0xfec0001c }, { 0x50208, 0x7d4003f3 }, { 0x5fffc, 0xfe40002b }, { 0x5020c, 0x7b8003ed }, { 0x5fffc, 0xfd80003c }, { 0x50210, 0x794003e8 }, { 0x5fffc, 0xfcc0004d }, { 0x50214, 0x76c003e4 }, { 0x5fffc, 0xfc40005f }, { 0x50218, 0x73c003e0 }, { 0x5fffc, 0xfb800071 }, { 0x5021c, 0x708003de }, { 0x5fffc, 0xfac00085 }, { 0x50220, 0x6d0003db }, { 0x5fffc, 0xfa000098 }, { 0x50224, 0x698003d9 }, { 0x5fffc, 0xf98000ac }, { 0x50228, 0x654003d8 }, { 0x5fffc, 0xf8c000c1 }, { 0x5022c, 0x610003d7 }, { 0x5fffc, 0xf84000d5 }, { 0x50230, 0x5c8003d7 }, { 0x5fffc, 0xf7c000e9 }, { 0x50234, 0x580003d7 }, { 0x5fffc, 0xf74000fd }, { 0x50238, 0x534003d8 }, { 0x5fffc, 0xf6c00112 }, { 0x5023c, 0x4e8003d8 }, { 0x5fffc, 0xf6800126 }, { 0x50240, 0x494003da }, { 0x5fffc, 0xf600013a }, { 0x50244, 0x448003db }, { 0x5fffc, 0xf600014d }, { 0x50248, 0x3f4003dd }, { 0x5fffc, 0xf5c00160 }, { 0x5024c, 0x3a4003df }, { 0x5fffc, 0xf5c00172 }, { 0x50250, 0x354003e1 }, { 0x5fffc, 0xf5c00184 }, { 0x50254, 0x304003e3 }, { 0x5fffc, 0xf6000195 }, { 0x50258, 0x2b0003e6 }, { 0x5fffc, 0xf64001a6 }, { 0x5025c, 0x260003e8 }, { 0x5fffc, 0xf6c001b4 }, { 0x50260, 0x214003eb }, { 0x5fffc, 0xf78001c2 }, { 0x50264, 0x1c4003ee }, { 0x5fffc, 0xf80001cf }, { 0x50268, 0x17c003f1 }, { 0x5fffc, 0xf90001db }, { 0x5026c, 0x134003f3 }, { 0x5fffc, 0xfa0001e5 }, { 0x50270, 0xf0003f6 }, { 0x5fffc, 0xfb4001ee }, { 0x50274, 0xac003f9 }, { 0x5fffc, 0xfcc001f5 }, { 0x50278, 0x70003fb }, { 0x5fffc, 0xfe4001fb }, { 0x5027c, 0x34003fe }, }; static struct mdp_table_entry mdp_downscale_x_table_PT2TOPT4[] = { { 0x5fffc, 0x740008c }, { 0x50280, 0x33800088 }, { 0x5fffc, 0x800008e }, { 0x50284, 0x33400084 }, { 0x5fffc, 0x8400092 }, { 0x50288, 0x33000080 }, { 0x5fffc, 0x9000094 }, { 0x5028c, 0x3300007b }, { 0x5fffc, 0x9c00098 }, { 0x50290, 0x32400077 }, { 0x5fffc, 0xa40009b }, { 0x50294, 0x32000073 }, { 0x5fffc, 0xb00009d }, { 0x50298, 0x31c0006f }, { 0x5fffc, 0xbc000a0 }, { 0x5029c, 0x3140006b }, { 0x5fffc, 0xc8000a2 }, { 0x502a0, 0x31000067 }, { 0x5fffc, 0xd8000a5 }, { 0x502a4, 0x30800062 }, { 0x5fffc, 0xe4000a8 }, { 0x502a8, 0x2fc0005f }, { 0x5fffc, 0xec000aa }, { 0x502ac, 0x2fc0005b }, { 0x5fffc, 0xf8000ad }, { 0x502b0, 0x2f400057 }, { 0x5fffc, 0x108000b0 }, { 0x502b4, 0x2e400054 }, { 0x5fffc, 0x114000b2 }, { 0x502b8, 0x2e000050 }, { 0x5fffc, 0x124000b4 }, { 0x502bc, 0x2d80004c }, { 0x5fffc, 0x130000b6 }, { 0x502c0, 0x2d000049 }, { 0x5fffc, 0x140000b8 }, { 0x502c4, 0x2c800045 }, { 0x5fffc, 0x150000b9 }, { 0x502c8, 0x2c000042 }, { 0x5fffc, 0x15c000bd }, { 0x502cc, 0x2b40003e }, { 0x5fffc, 0x16c000bf }, { 0x502d0, 0x2a80003b }, { 0x5fffc, 0x17c000bf }, { 0x502d4, 0x2a000039 }, { 0x5fffc, 0x188000c2 }, { 0x502d8, 0x29400036 }, { 0x5fffc, 0x19c000c4 }, { 0x502dc, 0x28800032 }, { 0x5fffc, 0x1ac000c5 }, { 0x502e0, 0x2800002f }, { 0x5fffc, 0x1bc000c7 }, { 0x502e4, 0x2740002c }, { 0x5fffc, 0x1cc000c8 }, { 0x502e8, 0x26c00029 }, { 0x5fffc, 0x1dc000c9 }, { 0x502ec, 0x26000027 }, { 0x5fffc, 0x1ec000cc }, { 0x502f0, 0x25000024 }, { 0x5fffc, 0x200000cc }, { 0x502f4, 0x24800021 }, { 0x5fffc, 0x210000cd }, { 0x502f8, 0x23800020 }, { 0x5fffc, 0x220000ce }, { 0x502fc, 0x2300001d }, }; static struct mdp_table_entry mdp_downscale_x_table_PT4TOPT6[] = { { 0x5fffc, 0x740008c }, { 0x50280, 0x33800088 }, { 0x5fffc, 0x800008e }, { 0x50284, 0x33400084 }, { 0x5fffc, 0x8400092 }, { 0x50288, 0x33000080 }, { 0x5fffc, 0x9000094 }, { 0x5028c, 0x3300007b }, { 0x5fffc, 0x9c00098 }, { 0x50290, 0x32400077 }, { 0x5fffc, 0xa40009b }, { 0x50294, 0x32000073 }, { 0x5fffc, 0xb00009d }, { 0x50298, 0x31c0006f }, { 0x5fffc, 0xbc000a0 }, { 0x5029c, 0x3140006b }, { 0x5fffc, 0xc8000a2 }, { 0x502a0, 0x31000067 }, { 0x5fffc, 0xd8000a5 }, { 0x502a4, 0x30800062 }, { 0x5fffc, 0xe4000a8 }, { 0x502a8, 0x2fc0005f }, { 0x5fffc, 0xec000aa }, { 0x502ac, 0x2fc0005b }, { 0x5fffc, 0xf8000ad }, { 0x502b0, 0x2f400057 }, { 0x5fffc, 0x108000b0 }, { 0x502b4, 0x2e400054 }, { 0x5fffc, 0x114000b2 }, { 0x502b8, 0x2e000050 }, { 0x5fffc, 0x124000b4 }, { 0x502bc, 0x2d80004c }, { 0x5fffc, 0x130000b6 }, { 0x502c0, 0x2d000049 }, { 0x5fffc, 0x140000b8 }, { 0x502c4, 0x2c800045 }, { 0x5fffc, 0x150000b9 }, { 0x502c8, 0x2c000042 }, { 0x5fffc, 0x15c000bd }, { 0x502cc, 0x2b40003e }, { 0x5fffc, 0x16c000bf }, { 0x502d0, 0x2a80003b }, { 0x5fffc, 0x17c000bf }, { 0x502d4, 0x2a000039 }, { 0x5fffc, 0x188000c2 }, { 0x502d8, 0x29400036 }, { 0x5fffc, 0x19c000c4 }, { 0x502dc, 0x28800032 }, { 0x5fffc, 0x1ac000c5 }, { 0x502e0, 0x2800002f }, { 0x5fffc, 0x1bc000c7 }, { 0x502e4, 0x2740002c }, { 0x5fffc, 0x1cc000c8 }, { 0x502e8, 0x26c00029 }, { 0x5fffc, 0x1dc000c9 }, { 0x502ec, 0x26000027 }, { 0x5fffc, 0x1ec000cc }, { 0x502f0, 0x25000024 }, { 0x5fffc, 0x200000cc }, { 0x502f4, 0x24800021 }, { 0x5fffc, 0x210000cd }, { 0x502f8, 0x23800020 }, { 0x5fffc, 0x220000ce }, { 0x502fc, 0x2300001d }, }; static struct mdp_table_entry mdp_downscale_x_table_PT6TOPT8[] = { { 0x5fffc, 0xfe000070 }, { 0x50280, 0x4bc00068 }, { 0x5fffc, 0xfe000078 }, { 0x50284, 0x4bc00060 }, { 0x5fffc, 0xfe000080 }, { 0x50288, 0x4b800059 }, { 0x5fffc, 0xfe000089 }, { 0x5028c, 0x4b000052 }, { 0x5fffc, 0xfe400091 }, { 0x50290, 0x4a80004b }, { 0x5fffc, 0xfe40009a }, { 0x50294, 0x4a000044 }, { 0x5fffc, 0xfe8000a3 }, { 0x50298, 0x4940003d }, { 0x5fffc, 0xfec000ac }, { 0x5029c, 0x48400037 }, { 0x5fffc, 0xff0000b4 }, { 0x502a0, 0x47800031 }, { 0x5fffc, 0xff8000bd }, { 0x502a4, 0x4640002b }, { 0x5fffc, 0xc5 }, { 0x502a8, 0x45000026 }, { 0x5fffc, 0x8000ce }, { 0x502ac, 0x43800021 }, { 0x5fffc, 0x10000d6 }, { 0x502b0, 0x4240001c }, { 0x5fffc, 0x18000df }, { 0x502b4, 0x40800018 }, { 0x5fffc, 0x24000e6 }, { 0x502b8, 0x3f000014 }, { 0x5fffc, 0x30000ee }, { 0x502bc, 0x3d400010 }, { 0x5fffc, 0x40000f5 }, { 0x502c0, 0x3b80000c }, { 0x5fffc, 0x50000fc }, { 0x502c4, 0x39800009 }, { 0x5fffc, 0x6000102 }, { 0x502c8, 0x37c00006 }, { 0x5fffc, 0x7000109 }, { 0x502cc, 0x35800004 }, { 0x5fffc, 0x840010e }, { 0x502d0, 0x33800002 }, { 0x5fffc, 0x9800114 }, { 0x502d4, 0x31400000 }, { 0x5fffc, 0xac00119 }, { 0x502d8, 0x2f4003fe }, { 0x5fffc, 0xc40011e }, { 0x502dc, 0x2d0003fc }, { 0x5fffc, 0xdc00121 }, { 0x502e0, 0x2b0003fb }, { 0x5fffc, 0xf400125 }, { 0x502e4, 0x28c003fa }, { 0x5fffc, 0x11000128 }, { 0x502e8, 0x268003f9 }, { 0x5fffc, 0x12c0012a }, { 0x502ec, 0x244003f9 }, { 0x5fffc, 0x1480012c }, { 0x502f0, 0x224003f8 }, { 0x5fffc, 0x1640012e }, { 0x502f4, 0x200003f8 }, { 0x5fffc, 0x1800012f }, { 0x502f8, 0x1e0003f8 }, { 0x5fffc, 0x1a00012f }, { 0x502fc, 0x1c0003f8 }, }; static struct mdp_table_entry mdp_downscale_x_table_PT8TO1[] = { { 0x5fffc, 0x0 }, { 0x50280, 0x7fc00000 }, { 0x5fffc, 0xff80000d }, { 0x50284, 0x7ec003f9 }, { 0x5fffc, 0xfec0001c }, { 0x50288, 0x7d4003f3 }, { 0x5fffc, 0xfe40002b }, { 0x5028c, 0x7b8003ed }, { 0x5fffc, 0xfd80003c }, { 0x50290, 0x794003e8 }, { 0x5fffc, 0xfcc0004d }, { 0x50294, 0x76c003e4 }, { 0x5fffc, 0xfc40005f }, { 0x50298, 0x73c003e0 }, { 0x5fffc, 0xfb800071 }, { 0x5029c, 0x708003de }, { 0x5fffc, 0xfac00085 }, { 0x502a0, 0x6d0003db }, { 0x5fffc, 0xfa000098 }, { 0x502a4, 0x698003d9 }, { 0x5fffc, 0xf98000ac }, { 0x502a8, 0x654003d8 }, { 0x5fffc, 0xf8c000c1 }, { 0x502ac, 0x610003d7 }, { 0x5fffc, 0xf84000d5 }, { 0x502b0, 0x5c8003d7 }, { 0x5fffc, 0xf7c000e9 }, { 0x502b4, 0x580003d7 }, { 0x5fffc, 0xf74000fd }, { 0x502b8, 0x534003d8 }, { 0x5fffc, 0xf6c00112 }, { 0x502bc, 0x4e8003d8 }, { 0x5fffc, 0xf6800126 }, { 0x502c0, 0x494003da }, { 0x5fffc, 0xf600013a }, { 0x502c4, 0x448003db }, { 0x5fffc, 0xf600014d }, { 0x502c8, 0x3f4003dd }, { 0x5fffc, 0xf5c00160 }, { 0x502cc, 0x3a4003df }, { 0x5fffc, 0xf5c00172 }, { 0x502d0, 0x354003e1 }, { 0x5fffc, 0xf5c00184 }, { 0x502d4, 0x304003e3 }, { 0x5fffc, 0xf6000195 }, { 0x502d8, 0x2b0003e6 }, { 0x5fffc, 0xf64001a6 }, { 0x502dc, 0x260003e8 }, { 0x5fffc, 0xf6c001b4 }, { 0x502e0, 0x214003eb }, { 0x5fffc, 0xf78001c2 }, { 0x502e4, 0x1c4003ee }, { 0x5fffc, 0xf80001cf }, { 0x502e8, 0x17c003f1 }, { 0x5fffc, 0xf90001db }, { 0x502ec, 0x134003f3 }, { 0x5fffc, 0xfa0001e5 }, { 0x502f0, 0xf0003f6 }, { 0x5fffc, 0xfb4001ee }, { 0x502f4, 0xac003f9 }, { 0x5fffc, 0xfcc001f5 }, { 0x502f8, 0x70003fb }, { 0x5fffc, 0xfe4001fb }, { 0x502fc, 0x34003fe }, }; struct mdp_table_entry *mdp_downscale_x_table[MDP_DOWNSCALE_MAX] = { [MDP_DOWNSCALE_PT2TOPT4] = mdp_downscale_x_table_PT2TOPT4, [MDP_DOWNSCALE_PT4TOPT6] = mdp_downscale_x_table_PT4TOPT6, [MDP_DOWNSCALE_PT6TOPT8] = mdp_downscale_x_table_PT6TOPT8, [MDP_DOWNSCALE_PT8TO1] = mdp_downscale_x_table_PT8TO1, }; static struct mdp_table_entry mdp_downscale_y_table_PT2TOPT4[] = { { 0x5fffc, 0x740008c }, { 0x50300, 0x33800088 }, { 0x5fffc, 0x800008e }, { 0x50304, 0x33400084 }, { 0x5fffc, 0x8400092 }, { 0x50308, 0x33000080 }, { 0x5fffc, 0x9000094 }, { 0x5030c, 0x3300007b }, { 0x5fffc, 0x9c00098 }, { 0x50310, 0x32400077 }, { 0x5fffc, 0xa40009b }, { 0x50314, 0x32000073 }, { 0x5fffc, 0xb00009d }, { 0x50318, 0x31c0006f }, { 0x5fffc, 0xbc000a0 }, { 0x5031c, 0x3140006b }, { 0x5fffc, 0xc8000a2 }, { 0x50320, 0x31000067 }, { 0x5fffc, 0xd8000a5 }, { 0x50324, 0x30800062 }, { 0x5fffc, 0xe4000a8 }, { 0x50328, 0x2fc0005f }, { 0x5fffc, 0xec000aa }, { 0x5032c, 0x2fc0005b }, { 0x5fffc, 0xf8000ad }, { 0x50330, 0x2f400057 }, { 0x5fffc, 0x108000b0 }, { 0x50334, 0x2e400054 }, { 0x5fffc, 0x114000b2 }, { 0x50338, 0x2e000050 }, { 0x5fffc, 0x124000b4 }, { 0x5033c, 0x2d80004c }, { 0x5fffc, 0x130000b6 }, { 0x50340, 0x2d000049 }, { 0x5fffc, 0x140000b8 }, { 0x50344, 0x2c800045 }, { 0x5fffc, 0x150000b9 }, { 0x50348, 0x2c000042 }, { 0x5fffc, 0x15c000bd }, { 0x5034c, 0x2b40003e }, { 0x5fffc, 0x16c000bf }, { 0x50350, 0x2a80003b }, { 0x5fffc, 0x17c000bf }, { 0x50354, 0x2a000039 }, { 0x5fffc, 0x188000c2 }, { 0x50358, 0x29400036 }, { 0x5fffc, 0x19c000c4 }, { 0x5035c, 0x28800032 }, { 0x5fffc, 0x1ac000c5 }, { 0x50360, 0x2800002f }, { 0x5fffc, 0x1bc000c7 }, { 0x50364, 0x2740002c }, { 0x5fffc, 0x1cc000c8 }, { 0x50368, 0x26c00029 }, { 0x5fffc, 0x1dc000c9 }, { 0x5036c, 0x26000027 }, { 0x5fffc, 0x1ec000cc }, { 0x50370, 0x25000024 }, { 0x5fffc, 0x200000cc }, { 0x50374, 0x24800021 }, { 0x5fffc, 0x210000cd }, { 0x50378, 0x23800020 }, { 0x5fffc, 0x220000ce }, { 0x5037c, 0x2300001d }, }; static struct mdp_table_entry mdp_downscale_y_table_PT4TOPT6[] = { { 0x5fffc, 0x740008c }, { 0x50300, 0x33800088 }, { 0x5fffc, 0x800008e }, { 0x50304, 0x33400084 }, { 0x5fffc, 0x8400092 }, { 0x50308, 0x33000080 }, { 0x5fffc, 0x9000094 }, { 0x5030c, 0x3300007b }, { 0x5fffc, 0x9c00098 }, { 0x50310, 0x32400077 }, { 0x5fffc, 0xa40009b }, { 0x50314, 0x32000073 }, { 0x5fffc, 0xb00009d }, { 0x50318, 0x31c0006f }, { 0x5fffc, 0xbc000a0 }, { 0x5031c, 0x3140006b }, { 0x5fffc, 0xc8000a2 }, { 0x50320, 0x31000067 }, { 0x5fffc, 0xd8000a5 }, { 0x50324, 0x30800062 }, { 0x5fffc, 0xe4000a8 }, { 0x50328, 0x2fc0005f }, { 0x5fffc, 0xec000aa }, { 0x5032c, 0x2fc0005b }, { 0x5fffc, 0xf8000ad }, { 0x50330, 0x2f400057 }, { 0x5fffc, 0x108000b0 }, { 0x50334, 0x2e400054 }, { 0x5fffc, 0x114000b2 }, { 0x50338, 0x2e000050 }, { 0x5fffc, 0x124000b4 }, { 0x5033c, 0x2d80004c }, { 0x5fffc, 0x130000b6 }, { 0x50340, 0x2d000049 }, { 0x5fffc, 0x140000b8 }, { 0x50344, 0x2c800045 }, { 0x5fffc, 0x150000b9 }, { 0x50348, 0x2c000042 }, { 0x5fffc, 0x15c000bd }, { 0x5034c, 0x2b40003e }, { 0x5fffc, 0x16c000bf }, { 0x50350, 0x2a80003b }, { 0x5fffc, 0x17c000bf }, { 0x50354, 0x2a000039 }, { 0x5fffc, 0x188000c2 }, { 0x50358, 0x29400036 }, { 0x5fffc, 0x19c000c4 }, { 0x5035c, 0x28800032 }, { 0x5fffc, 0x1ac000c5 }, { 0x50360, 0x2800002f }, { 0x5fffc, 0x1bc000c7 }, { 0x50364, 0x2740002c }, { 0x5fffc, 0x1cc000c8 }, { 0x50368, 0x26c00029 }, { 0x5fffc, 0x1dc000c9 }, { 0x5036c, 0x26000027 }, { 0x5fffc, 0x1ec000cc }, { 0x50370, 0x25000024 }, { 0x5fffc, 0x200000cc }, { 0x50374, 0x24800021 }, { 0x5fffc, 0x210000cd }, { 0x50378, 0x23800020 }, { 0x5fffc, 0x220000ce }, { 0x5037c, 0x2300001d }, }; static struct mdp_table_entry mdp_downscale_y_table_PT6TOPT8[] = { { 0x5fffc, 0xfe000070 }, { 0x50300, 0x4bc00068 }, { 0x5fffc, 0xfe000078 }, { 0x50304, 0x4bc00060 }, { 0x5fffc, 0xfe000080 }, { 0x50308, 0x4b800059 }, { 0x5fffc, 0xfe000089 }, { 0x5030c, 0x4b000052 }, { 0x5fffc, 0xfe400091 }, { 0x50310, 0x4a80004b }, { 0x5fffc, 0xfe40009a }, { 0x50314, 0x4a000044 }, { 0x5fffc, 0xfe8000a3 }, { 0x50318, 0x4940003d }, { 0x5fffc, 0xfec000ac }, { 0x5031c, 0x48400037 }, { 0x5fffc, 0xff0000b4 }, { 0x50320, 0x47800031 }, { 0x5fffc, 0xff8000bd }, { 0x50324, 0x4640002b }, { 0x5fffc, 0xc5 }, { 0x50328, 0x45000026 }, { 0x5fffc, 0x8000ce }, { 0x5032c, 0x43800021 }, { 0x5fffc, 0x10000d6 }, { 0x50330, 0x4240001c }, { 0x5fffc, 0x18000df }, { 0x50334, 0x40800018 }, { 0x5fffc, 0x24000e6 }, { 0x50338, 0x3f000014 }, { 0x5fffc, 0x30000ee }, { 0x5033c, 0x3d400010 }, { 0x5fffc, 0x40000f5 }, { 0x50340, 0x3b80000c }, { 0x5fffc, 0x50000fc }, { 0x50344, 0x39800009 }, { 0x5fffc, 0x6000102 }, { 0x50348, 0x37c00006 }, { 0x5fffc, 0x7000109 }, { 0x5034c, 0x35800004 }, { 0x5fffc, 0x840010e }, { 0x50350, 0x33800002 }, { 0x5fffc, 0x9800114 }, { 0x50354, 0x31400000 }, { 0x5fffc, 0xac00119 }, { 0x50358, 0x2f4003fe }, { 0x5fffc, 0xc40011e }, { 0x5035c, 0x2d0003fc }, { 0x5fffc, 0xdc00121 }, { 0x50360, 0x2b0003fb }, { 0x5fffc, 0xf400125 }, { 0x50364, 0x28c003fa }, { 0x5fffc, 0x11000128 }, { 0x50368, 0x268003f9 }, { 0x5fffc, 0x12c0012a }, { 0x5036c, 0x244003f9 }, { 0x5fffc, 0x1480012c }, { 0x50370, 0x224003f8 }, { 0x5fffc, 0x1640012e }, { 0x50374, 0x200003f8 }, { 0x5fffc, 0x1800012f }, { 0x50378, 0x1e0003f8 }, { 0x5fffc, 0x1a00012f }, { 0x5037c, 0x1c0003f8 }, }; static struct mdp_table_entry mdp_downscale_y_table_PT8TO1[] = { { 0x5fffc, 0x0 }, { 0x50300, 0x7fc00000 }, { 0x5fffc, 0xff80000d }, { 0x50304, 0x7ec003f9 }, { 0x5fffc, 0xfec0001c }, { 0x50308, 0x7d4003f3 }, { 0x5fffc, 0xfe40002b }, { 0x5030c, 0x7b8003ed }, { 0x5fffc, 0xfd80003c }, { 0x50310, 0x794003e8 }, { 0x5fffc, 0xfcc0004d }, { 0x50314, 0x76c003e4 }, { 0x5fffc, 0xfc40005f }, { 0x50318, 0x73c003e0 }, { 0x5fffc, 0xfb800071 }, { 0x5031c, 0x708003de }, { 0x5fffc, 0xfac00085 }, { 0x50320, 0x6d0003db }, { 0x5fffc, 0xfa000098 }, { 0x50324, 0x698003d9 }, { 0x5fffc, 0xf98000ac }, { 0x50328, 0x654003d8 }, { 0x5fffc, 0xf8c000c1 }, { 0x5032c, 0x610003d7 }, { 0x5fffc, 0xf84000d5 }, { 0x50330, 0x5c8003d7 }, { 0x5fffc, 0xf7c000e9 }, { 0x50334, 0x580003d7 }, { 0x5fffc, 0xf74000fd }, { 0x50338, 0x534003d8 }, { 0x5fffc, 0xf6c00112 }, { 0x5033c, 0x4e8003d8 }, { 0x5fffc, 0xf6800126 }, { 0x50340, 0x494003da }, { 0x5fffc, 0xf600013a }, { 0x50344, 0x448003db }, { 0x5fffc, 0xf600014d }, { 0x50348, 0x3f4003dd }, { 0x5fffc, 0xf5c00160 }, { 0x5034c, 0x3a4003df }, { 0x5fffc, 0xf5c00172 }, { 0x50350, 0x354003e1 }, { 0x5fffc, 0xf5c00184 }, { 0x50354, 0x304003e3 }, { 0x5fffc, 0xf6000195 }, { 0x50358, 0x2b0003e6 }, { 0x5fffc, 0xf64001a6 }, { 0x5035c, 0x260003e8 }, { 0x5fffc, 0xf6c001b4 }, { 0x50360, 0x214003eb }, { 0x5fffc, 0xf78001c2 }, { 0x50364, 0x1c4003ee }, { 0x5fffc, 0xf80001cf }, { 0x50368, 0x17c003f1 }, { 0x5fffc, 0xf90001db }, { 0x5036c, 0x134003f3 }, { 0x5fffc, 0xfa0001e5 }, { 0x50370, 0xf0003f6 }, { 0x5fffc, 0xfb4001ee }, { 0x50374, 0xac003f9 }, { 0x5fffc, 0xfcc001f5 }, { 0x50378, 0x70003fb }, { 0x5fffc, 0xfe4001fb }, { 0x5037c, 0x34003fe }, }; struct mdp_table_entry *mdp_downscale_y_table[MDP_DOWNSCALE_MAX] = { [MDP_DOWNSCALE_PT2TOPT4] = mdp_downscale_y_table_PT2TOPT4, [MDP_DOWNSCALE_PT4TOPT6] = mdp_downscale_y_table_PT4TOPT6, [MDP_DOWNSCALE_PT6TOPT8] = mdp_downscale_y_table_PT6TOPT8, [MDP_DOWNSCALE_PT8TO1] = mdp_downscale_y_table_PT8TO1, }; struct mdp_table_entry mdp_gaussian_blur_table[] = { /* max variance */ { 0x5fffc, 0x20000080 }, { 0x50280, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50284, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50288, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x5028c, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50290, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50294, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50298, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x5029c, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502a0, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502a4, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502a8, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502ac, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502b0, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502b4, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502b8, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502bc, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502c0, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502c4, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502c8, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502cc, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502d0, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502d4, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502d8, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502dc, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502e0, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502e4, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502e8, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502ec, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502f0, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502f4, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502f8, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x502fc, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50300, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50304, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50308, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x5030c, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50310, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50314, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50318, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x5031c, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50320, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50324, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50328, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x5032c, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50330, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50334, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50338, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x5033c, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50340, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50344, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50348, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x5034c, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50350, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50354, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50358, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x5035c, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50360, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50364, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50368, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x5036c, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50370, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50374, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x50378, 0x20000080 }, { 0x5fffc, 0x20000080 }, { 0x5037c, 0x20000080 }, };
gpl-2.0
steppnasty/platform_kernel_msm7x30
drivers/misc/video_core/720p/vcd/vcd_sub.c
376
76267
/* Copyright (c) 2010, Code Aurora Forum. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only 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 Street, Fifth Floor, Boston, MA * 02110-1301, USA. * */ #include <asm/div64.h> #include "video_core_type.h" #include "vcd.h" #include "vdec_internal.h" static phys_addr_t vcd_pmem_get_physical(struct video_client_ctx *client_ctx, void *kern_addr) { phys_addr_t phys_addr; void __user *user_addr; int pmem_fd; struct file *file; s32 buffer_index = -1; if (vid_c_lookup_addr_table(client_ctx, BUFFER_TYPE_INPUT, false, &user_addr, &kern_addr, &phys_addr, &pmem_fd, &file, &buffer_index)) { return phys_addr; } if (vid_c_lookup_addr_table(client_ctx, BUFFER_TYPE_OUTPUT, false, &user_addr, &kern_addr, &phys_addr, &pmem_fd, &file, &buffer_index)) { return phys_addr; } VCD_MSG_ERROR("Couldn't get physical address"); return 0; } void vcd_reset_device_channels(struct vcd_dev_ctxt *dev_ctxt) { dev_ctxt->ddl_frame_ch_free = dev_ctxt->ddl_frame_ch_depth; dev_ctxt->ddl_cmd_ch_free = dev_ctxt->ddl_cmd_ch_depth; dev_ctxt->ddl_frame_ch_interim = 0; dev_ctxt->ddl_cmd_ch_interim = 0; } u32 vcd_get_command_channel(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc **pp_transc) { u32 result = false; *pp_transc = NULL; if (dev_ctxt->ddl_cmd_ch_free > 0) { if (dev_ctxt->ddl_cmd_concurrency) { --dev_ctxt->ddl_cmd_ch_free; result = true; } else if ((dev_ctxt->ddl_frame_ch_free + dev_ctxt->ddl_frame_ch_interim) == dev_ctxt->ddl_frame_ch_depth) { --dev_ctxt->ddl_cmd_ch_free; result = true; } } if (result) { *pp_transc = vcd_get_free_trans_tbl_entry(dev_ctxt); if (!*pp_transc) { result = false; vcd_release_command_channel(dev_ctxt, *pp_transc); } } return result; } u32 vcd_get_command_channel_in_loop(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc **pp_transc) { u32 result = false; *pp_transc = NULL; if (dev_ctxt->ddl_cmd_ch_interim > 0) { if (dev_ctxt->ddl_cmd_concurrency) { --dev_ctxt->ddl_cmd_ch_interim; result = true; } else if ((dev_ctxt->ddl_frame_ch_free + dev_ctxt->ddl_frame_ch_interim) == dev_ctxt->ddl_frame_ch_depth) { --dev_ctxt->ddl_cmd_ch_interim; result = true; } } else { result = vcd_get_command_channel(dev_ctxt, pp_transc); } if (result && !*pp_transc) { *pp_transc = vcd_get_free_trans_tbl_entry(dev_ctxt); if (!*pp_transc) { result = false; ++dev_ctxt->ddl_cmd_ch_interim; } } return result; } void vcd_mark_command_channel(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc) { ++dev_ctxt->ddl_cmd_ch_interim; vcd_release_trans_tbl_entry(transc); if (dev_ctxt->ddl_cmd_ch_interim + dev_ctxt->ddl_cmd_ch_free > dev_ctxt->ddl_cmd_ch_depth) { VCD_MSG_ERROR("\n Command channel access counters messed up"); vcd_assert(); } } void vcd_release_command_channel(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc) { ++dev_ctxt->ddl_cmd_ch_free; vcd_release_trans_tbl_entry(transc); if (dev_ctxt->ddl_cmd_ch_interim + dev_ctxt->ddl_cmd_ch_free > dev_ctxt->ddl_cmd_ch_depth) { VCD_MSG_ERROR("\n Command channel access counters messed up"); vcd_assert(); } } void vcd_release_multiple_command_channels(struct vcd_dev_ctxt *dev_ctxt, u32 channels) { dev_ctxt->ddl_cmd_ch_free += channels; if (dev_ctxt->ddl_cmd_ch_interim + dev_ctxt->ddl_cmd_ch_free > dev_ctxt->ddl_cmd_ch_depth) { VCD_MSG_ERROR("\n Command channel access counters messed up"); vcd_assert(); } } void vcd_release_interim_command_channels(struct vcd_dev_ctxt *dev_ctxt) { dev_ctxt->ddl_cmd_ch_free += dev_ctxt->ddl_cmd_ch_interim; dev_ctxt->ddl_cmd_ch_interim = 0; if (dev_ctxt->ddl_cmd_ch_interim + dev_ctxt->ddl_cmd_ch_free > dev_ctxt->ddl_cmd_ch_depth) { VCD_MSG_ERROR("\n Command channel access counters messed up"); vcd_assert(); } } u32 vcd_get_frame_channel(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc **pp_transc) { u32 result = false; if (dev_ctxt->ddl_frame_ch_free > 0) { if (dev_ctxt->ddl_cmd_concurrency) { --dev_ctxt->ddl_frame_ch_free; result = true; } else if ((dev_ctxt->ddl_cmd_ch_free + dev_ctxt->ddl_cmd_ch_interim) == dev_ctxt->ddl_cmd_ch_depth) { --dev_ctxt->ddl_frame_ch_free; result = true; } } if (result) { *pp_transc = vcd_get_free_trans_tbl_entry(dev_ctxt); if (!*pp_transc) { result = false; vcd_release_frame_channel(dev_ctxt, *pp_transc); } else { (*pp_transc)->type = VCD_CMD_CODE_FRAME; } } return result; } u32 vcd_get_frame_channel_in_loop(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc **pp_transc) { u32 result = false; *pp_transc = NULL; if (dev_ctxt->ddl_frame_ch_interim > 0) { if (dev_ctxt->ddl_cmd_concurrency) { --dev_ctxt->ddl_frame_ch_interim; result = true; } else if ((dev_ctxt->ddl_cmd_ch_free + dev_ctxt->ddl_cmd_ch_interim) == dev_ctxt->ddl_cmd_ch_depth) { --dev_ctxt->ddl_frame_ch_interim; result = true; } } else { result = vcd_get_frame_channel(dev_ctxt, pp_transc); } if (result && !*pp_transc) { *pp_transc = vcd_get_free_trans_tbl_entry(dev_ctxt); if (!*pp_transc) { result = false; VCD_MSG_FATAL("\n%s: All transactions are busy;" "Couldnt find free one\n", __func__); ++dev_ctxt->ddl_frame_ch_interim; } } return result; } void vcd_mark_frame_channel(struct vcd_dev_ctxt *dev_ctxt) { ++dev_ctxt->ddl_frame_ch_interim; if (dev_ctxt->ddl_frame_ch_interim + dev_ctxt->ddl_frame_ch_free > dev_ctxt->ddl_cmd_ch_depth) { VCD_MSG_FATAL("Frame channel access counters messed up"); vcd_assert(); } } void vcd_release_frame_channel(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc) { ++dev_ctxt->ddl_frame_ch_free; vcd_release_trans_tbl_entry(transc); if (dev_ctxt->ddl_frame_ch_interim + dev_ctxt->ddl_frame_ch_free > dev_ctxt->ddl_cmd_ch_depth) { VCD_MSG_FATAL("Frame channel access counters messed up"); vcd_assert(); } } void vcd_release_multiple_frame_channels(struct vcd_dev_ctxt *dev_ctxt, u32 channels) { dev_ctxt->ddl_frame_ch_free += channels; if (dev_ctxt->ddl_frame_ch_interim + dev_ctxt->ddl_frame_ch_free > dev_ctxt->ddl_frame_ch_depth) { VCD_MSG_FATAL("Frame channel access counters messed up"); vcd_assert(); } } void vcd_release_interim_frame_channels(struct vcd_dev_ctxt *dev_ctxt) { dev_ctxt->ddl_frame_ch_free += dev_ctxt->ddl_frame_ch_interim; dev_ctxt->ddl_frame_ch_interim = 0; if (dev_ctxt->ddl_frame_ch_free > dev_ctxt->ddl_cmd_ch_depth) { VCD_MSG_FATAL("Frame channel access counters messed up"); vcd_assert(); } } u32 vcd_core_is_busy(struct vcd_dev_ctxt *dev_ctxt) { if (((dev_ctxt->ddl_cmd_ch_free + dev_ctxt->ddl_cmd_ch_interim) != dev_ctxt->ddl_cmd_ch_depth) || ((dev_ctxt->ddl_frame_ch_free + dev_ctxt->ddl_frame_ch_interim) != dev_ctxt->ddl_frame_ch_depth)) { return true; } else { return false; } } void vcd_device_timer_start(struct vcd_dev_ctxt *dev_ctxt) { if (dev_ctxt->config.pf_timer_start) dev_ctxt->config.pf_timer_start(dev_ctxt->hw_timer_handle, dev_ctxt->hw_time_out); } void vcd_device_timer_stop(struct vcd_dev_ctxt *dev_ctxt) { if (dev_ctxt->config.pf_timer_stop) dev_ctxt->config.pf_timer_stop(dev_ctxt->hw_timer_handle); } u32 vcd_common_allocate_set_buffer(struct vcd_clnt_ctxt *cctxt, enum vcd_buffer_type buffer, size_t sz, struct vcd_buffer_pool **pp_buf_pool) { u32 rc = VCD_S_SUCCESS; struct vcd_buffer_requirement buf_req; struct vcd_property_hdr prop_hdr; struct vcd_buffer_pool *buf_pool; if (buffer == VCD_BUFFER_INPUT) { prop_hdr.id = DDL_I_INPUT_BUF_REQ; buf_pool = &cctxt->in_buf_pool; } else if (buffer == VCD_BUFFER_OUTPUT) { prop_hdr.id = DDL_I_OUTPUT_BUF_REQ; buf_pool = &cctxt->out_buf_pool; } else { rc = VCD_ERR_ILLEGAL_PARM; } VCD_FAILED_RETURN(rc, "Invalid buffer type provided"); *pp_buf_pool = buf_pool; if (buf_pool->count > 0 && buf_pool->validated == buf_pool->count) { VCD_MSG_ERROR("Buffer pool is full"); return VCD_ERR_FAIL; } if (!buf_pool->entries) { prop_hdr.sz = sizeof(buf_req); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &buf_req); if (!VCD_FAILED(rc)) rc = vcd_alloc_buffer_pool_entries(buf_pool, &buf_req); else VCD_MSG_ERROR("rc = 0x%x. Failed ddl_get_property", rc); } if (!VCD_FAILED(rc)) { if (buf_pool->buf_req.size > sz) { VCD_MSG_ERROR("required buffer size %u allocated size " "%u", buf_pool->buf_req.size, sz); rc = VCD_ERR_ILLEGAL_PARM; } } return rc; } u32 vcd_set_buffer_internal(struct vcd_clnt_ctxt *cctxt, struct vcd_buffer_pool *buf_pool, void *buf, size_t sz) { struct vcd_buffer_entry *buf_entry; buf_entry = vcd_find_buffer_pool_entry(buf_pool, buf); if (buf_entry) { VCD_MSG_ERROR("This buffer address already exists"); return VCD_ERR_ILLEGAL_OP; } if (!IS_ALIGNED((unsigned long)buf, buf_pool->buf_req.align)) { VCD_MSG_ERROR("Provided addr is not aligned"); return VCD_ERR_BAD_POINTER; } buf_entry = vcd_get_free_buffer_pool_entry(buf_pool); if (!buf_entry) { VCD_MSG_ERROR("Can't allocate buffer pool is full"); return VCD_ERR_FAIL; } printk("npelly adding %p to buf_pool %p\n", buf, buf_entry); buf_entry->virt_addr = buf; buf_entry->phys_addr = vcd_pmem_get_physical(cctxt->client_data, buf); if (!buf_entry->phys_addr) { VCD_MSG_ERROR("Couldn't get physical address"); return VCD_ERR_BAD_POINTER; } if (!IS_ALIGNED((unsigned long)buf_entry->phys_addr, buf_pool->buf_req.align)) { VCD_MSG_ERROR("Physical addr is not aligned"); return VCD_ERR_BAD_POINTER; } buf_entry->size = sz; buf_entry->frame.alloc_len = sz; buf_entry->allocated = false; buf_entry->frame.virt_addr = buf_entry->virt_addr; buf_entry->frame.phys_addr = buf_entry->phys_addr; buf_pool->validated++; return VCD_S_SUCCESS; } u32 vcd_allocate_buffer_internal(struct vcd_clnt_ctxt *cctxt, struct vcd_buffer_pool *buf_pool, size_t buf_size, void **virt_addr, phys_addr_t *phys_addr) { struct vcd_buffer_entry *buf_entry; struct vcd_buffer_requirement *buf_req; // u32 addr; // int rc = 0; buf_entry = vcd_get_free_buffer_pool_entry(buf_pool); if (!buf_entry) { VCD_MSG_ERROR("Can't allocate buffer pool is full"); return VCD_ERR_FAIL; } buf_req = &buf_pool->buf_req; //TODO strip align crap // buf_size += buf_req->align; buf_entry->buffer.virt_addr = dma_alloc_coherent(NULL, buf_size, &buf_entry->buffer.phys_addr, GFP_KERNEL); if (!buf_entry->buffer.virt_addr) { VCD_MSG_ERROR("Buffer allocation failed"); return VCD_ERR_ALLOC_FAIL; } buf_entry->buffer.size = buf_size; buf_entry->allocated = true; buf_entry->frame.alloc_len = buf_entry->buffer.size; buf_entry->frame.virt_addr = buf_entry->buffer.virt_addr; buf_entry->frame.phys_addr = buf_entry->buffer.phys_addr; *virt_addr = buf_entry->buffer.virt_addr; *phys_addr = buf_entry->buffer.phys_addr; buf_pool->allocated++; buf_pool->validated++; return VCD_S_SUCCESS; } u32 vcd_free_one_buffer_internal(struct vcd_clnt_ctxt *cctxt, enum vcd_buffer_type vcd_buffer_type, u8 *buffer) { struct vcd_buffer_pool *buf_pool; u32 rc = VCD_S_SUCCESS; struct vcd_buffer_entry *buf_entry; if (vcd_buffer_type == VCD_BUFFER_INPUT) buf_pool = &cctxt->in_buf_pool; else if (vcd_buffer_type == VCD_BUFFER_OUTPUT) buf_pool = &cctxt->out_buf_pool; else rc = VCD_ERR_ILLEGAL_PARM; VCD_FAILED_RETURN(rc, "Invalid buffer type provided"); buf_entry = vcd_find_buffer_pool_entry(buf_pool, buffer); if (!buf_entry) { VCD_MSG_ERROR("Buffer addr %p not found. Can't free buffer", buffer); return VCD_ERR_ILLEGAL_PARM; } if (buf_entry->in_use) { VCD_MSG_ERROR("\n Buffer is in use and is not flushed"); return VCD_ERR_ILLEGAL_OP; } VCD_MSG_LOW("Freeing buffer %p. Allocated %d", buf_entry->virt_addr, buf_entry->allocated); if (buf_entry->allocated) { dma_free_coherent(NULL, buf_entry->size, buf_entry->virt_addr, buf_entry->phys_addr); buf_entry->virt_addr = NULL; buf_pool->allocated--; } memset(buf_entry, 0, sizeof(struct vcd_buffer_entry)); buf_pool->validated--; return VCD_S_SUCCESS; } u32 vcd_free_buffers_internal(struct vcd_clnt_ctxt *cctxt, struct vcd_buffer_pool *buf_pool) { u32 rc = VCD_S_SUCCESS; u32 i; VCD_MSG_LOW("vcd_free_buffers_internal:"); if (!buf_pool->entries) return rc; for (i = 1; i <= buf_pool->count; i++) { struct vcd_buffer_entry *b = &buf_pool->entries[i]; if (!b->valid || !b->allocated) continue; dma_free_coherent(NULL, b->size, b->virt_addr, b->phys_addr); } vcd_reset_buffer_pool_for_reuse(buf_pool); return rc; } u32 vcd_alloc_buffer_pool_entries(struct vcd_buffer_pool *buf_pool, struct vcd_buffer_requirement *buf_req) { VCD_MSG_LOW("vcd_alloc_buffer_pool_entries:"); buf_pool->buf_req = *buf_req; buf_pool->count = buf_req->actual_count; buf_pool->entries = kzalloc(sizeof(struct vcd_buffer_entry) * (buf_pool->count + 1), GFP_KERNEL); if (!buf_pool->entries) { VCD_MSG_ERROR("Buf_pool entries alloc failed"); return VCD_ERR_ALLOC_FAIL; } buf_pool->queue = kzalloc(sizeof(struct vcd_buffer_entry *) * buf_pool->count, GFP_KERNEL); if (!buf_pool->queue) { VCD_MSG_ERROR("Buf_pool queue alloc failed"); kfree(buf_pool->entries); return VCD_ERR_ALLOC_FAIL; } buf_pool->entries[0].valid = true; buf_pool->q_head = 0; buf_pool->q_tail = (u16) (buf_pool->count - 1); buf_pool->q_len = 0; buf_pool->validated = 0; buf_pool->allocated = 0; buf_pool->in_use = 0; return VCD_S_SUCCESS; } void vcd_free_buffer_pool_entries(struct vcd_buffer_pool *buf_pool) { VCD_MSG_LOW("vcd_free_buffer_pool_entries:"); kfree(buf_pool->entries); kfree(buf_pool->queue); memset(buf_pool, 0, sizeof(struct vcd_buffer_pool)); } void vcd_flush_in_use_buffer_pool_entries(struct vcd_clnt_ctxt *cctxt, struct vcd_buffer_pool *buf_pool, u32 event) { u32 i; VCD_MSG_LOW("vcd_flush_buffer_pool_entries: event=0x%x", event); if (!buf_pool->entries) return; for (i = 0; i <= buf_pool->count; i++) { if (buf_pool->entries[i].virt_addr && buf_pool->entries[i].in_use) { cctxt->callback(event, VCD_S_SUCCESS, &buf_pool->entries[i].frame, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); buf_pool->entries[i].in_use = false; VCD_BUFFERPOOL_INUSE_DECREMENT(buf_pool->in_use); } } } void vcd_reset_buffer_pool_for_reuse(struct vcd_buffer_pool *buf_pool) { VCD_MSG_LOW("vcd_reset_buffer_pool_for_reuse:"); memset(&buf_pool->entries[1], 0, sizeof(struct vcd_buffer_entry) * buf_pool->count); memset(buf_pool->queue, 0, sizeof(struct vcd_buffer_entry *) * buf_pool->count); buf_pool->q_head = 0; buf_pool->q_tail = (u16) (buf_pool->count - 1); buf_pool->q_len = 0; buf_pool->validated = 0; buf_pool->allocated = 0; buf_pool->in_use = 0; } struct vcd_buffer_entry *vcd_get_free_buffer_pool_entry(struct vcd_buffer_pool *pool) { int i; for (i = 1; i <= pool->count; i++) { if (!pool->entries[i].valid) { pool->entries[i].valid = true; return &pool->entries[i]; } } return NULL; } struct vcd_buffer_entry *vcd_find_buffer_pool_entry(struct vcd_buffer_pool *pool, void *virt_addr) { int i; for (i = 0; i <= pool->count; i++) if (pool->entries[i].virt_addr == virt_addr) return &pool->entries[i]; return NULL; } u32 vcd_buffer_pool_entry_en_q(struct vcd_buffer_pool *pool, struct vcd_buffer_entry *entry) { u16 i; u16 q_cntr; u32 found = false; if (pool->q_len == pool->count) return false; for (i = 0, q_cntr = pool->q_head; !found && i < pool->q_len; i++, q_cntr = (q_cntr + 1) % pool->count) { if (pool->queue[q_cntr] == entry) found = true; } if (found) { VCD_MSG_HIGH("this output buffer is already present in queue"); VCD_MSG_HIGH("virt_addr %p phys_addr %x", entry->virt_addr, entry->phys_addr); return false; } pool->q_tail = (pool->q_tail + 1) % pool->count; pool->q_len++; pool->queue[pool->q_tail] = entry; return true; } struct vcd_buffer_entry *vcd_buffer_pool_entry_de_q(struct vcd_buffer_pool *pool) { struct vcd_buffer_entry *entry; if (!pool || !pool->q_len) return NULL; entry = pool->queue[pool->q_head]; pool->q_head = (pool->q_head + 1) % pool->count; pool->q_len--; return entry; } void vcd_flush_output_buffers(struct vcd_clnt_ctxt *cctxt) { struct vcd_buffer_pool *buf_pool; struct vcd_buffer_entry *buf_entry; u32 count = 0; struct vcd_property_hdr prop_hdr; VCD_MSG_LOW("vcd_flush_output_buffers:"); buf_pool = &cctxt->out_buf_pool; buf_entry = vcd_buffer_pool_entry_de_q(buf_pool); while (buf_entry) { if (!cctxt->decoding || buf_entry->in_use) { buf_entry->frame.data_len = 0; cctxt->callback(VCD_EVT_RESP_OUTPUT_FLUSHED, VCD_S_SUCCESS, &buf_entry->frame, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); buf_entry->in_use = false; count++; } buf_entry = vcd_buffer_pool_entry_de_q(buf_pool); } buf_pool->in_use = 0; if (cctxt->sched_clnt_valid && count > 0) { VCD_MSG_LOW("Updating scheduler O tkns = %u", count); sched_update_client_o_tkn(cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, false, count * cctxt->sched_o_tkn_per_ip_frm); } if (cctxt->ddl_hdl_valid && cctxt->decoding) { prop_hdr.id = DDL_I_REQ_OUTPUT_FLUSH; prop_hdr.sz = sizeof(u32); count = 0x1; ddl_set_property(cctxt->ddl_handle, &prop_hdr, &count); } } u32 vcd_flush_buffers(struct vcd_clnt_ctxt *cctxt, u32 mode) { struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; u32 rc = VCD_S_SUCCESS; struct vcd_buffer_entry *buf_entry; VCD_MSG_LOW("vcd_flush_buffers:"); if (mode > VCD_FLUSH_ALL || !(mode & VCD_FLUSH_ALL)) { VCD_MSG_ERROR("Invalid flush mode %d", mode); return VCD_ERR_ILLEGAL_PARM; } VCD_MSG_MED("Flush mode %d requested", mode); if ((mode & VCD_FLUSH_INPUT) && cctxt->sched_clnt_valid) { rc = vcd_map_sched_status(sched_flush_client_buffer( dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, (void **)&buf_entry)); while (!VCD_FAILED(rc) && rc != VCD_S_SCHED_QEMPTY && buf_entry) { if (buf_entry->virt_addr) { cctxt->callback(VCD_EVT_RESP_INPUT_FLUSHED, VCD_S_SUCCESS, &buf_entry->frame, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); } buf_entry->in_use = false; VCD_BUFFERPOOL_INUSE_DECREMENT( cctxt->in_buf_pool.in_use); buf_entry = NULL; rc = vcd_map_sched_status(sched_flush_client_buffer( dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, (void **)&buf_entry)); } } VCD_FAILED_RETURN(rc, "Failed: sched_flush_client_buffer"); if (cctxt->status.frame_submitted > 0) { cctxt->status.flush_mode |= mode; } else { if (mode & VCD_FLUSH_OUTPUT) { vcd_flush_output_buffers(cctxt); vcd_release_all_clnt_frm_transc(cctxt); } } return VCD_S_SUCCESS; } void vcd_flush_buffers_in_err_fatal(struct vcd_clnt_ctxt *cctxt) { VCD_MSG_LOW("\n vcd_flush_buffers_in_err_fatal:"); vcd_flush_buffers(cctxt, VCD_FLUSH_ALL); vcd_flush_in_use_buffer_pool_entries(cctxt, &cctxt->in_buf_pool, VCD_EVT_RESP_INPUT_FLUSHED); vcd_flush_in_use_buffer_pool_entries(cctxt, &cctxt->out_buf_pool, VCD_EVT_RESP_OUTPUT_FLUSHED); cctxt->status.flush_mode = VCD_FLUSH_ALL; vcd_send_flush_done(cctxt, VCD_S_SUCCESS); } u32 vcd_init_client_context(struct vcd_clnt_ctxt *cctxt) { u32 rc; VCD_MSG_LOW("vcd_init_client_context:"); rc = ddl_open(&cctxt->ddl_handle, cctxt->decoding); VCD_FAILED_RETURN(rc, "Failed: ddl_open"); cctxt->ddl_hdl_valid = true; cctxt->clnt_state.state = VCD_CLIENT_STATE_OPEN; cctxt->clnt_state.state_table = vcd_get_client_state_table( VCD_CLIENT_STATE_OPEN); cctxt->signature = VCD_SIGNATURE; cctxt->live = true; cctxt->cmd_q.pending_cmd = VCD_CMD_NONE; return rc; } void vcd_destroy_client_context(struct vcd_clnt_ctxt *cctxt) { struct vcd_dev_ctxt *dev_ctxt; struct vcd_clnt_ctxt *client; u32 rc = VCD_S_SUCCESS; int idx; VCD_MSG_LOW("vcd_destroy_client_context:"); dev_ctxt = cctxt->dev_ctxt; if (cctxt == dev_ctxt->cctxt_list_head) { VCD_MSG_MED("Clnt list head clnt being removed"); dev_ctxt->cctxt_list_head = cctxt->next; } else { client = dev_ctxt->cctxt_list_head; while (client && cctxt != client->next) client = client->next; if (client) client->next = cctxt->next; if (!client) { rc = VCD_ERR_FAIL; VCD_MSG_ERROR("Client not found in client list"); } } if (VCD_FAILED(rc)) return; if (cctxt->sched_clnt_valid) { rc = VCD_S_SUCCESS; while (!VCD_FAILED(rc) && rc != VCD_S_SCHED_QEMPTY) { rc = vcd_map_sched_status(sched_flush_client_buffer( dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, (void *)&idx)); if (VCD_FAILED(rc)) VCD_MSG_ERROR("\n Failed: " "sched_flush_client_buffer"); } rc = vcd_map_sched_status(sched_remove_client( dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl)); if (VCD_FAILED(rc)) VCD_MSG_ERROR("\n Failed: sched_remove_client"); cctxt->sched_clnt_valid = false; } if (cctxt->seq_hdr.addr) { dma_free_coherent(NULL, cctxt->seq_hdr.sz, cctxt->seq_hdr.addr, cctxt->seq_hdr_phys_addr); cctxt->seq_hdr.addr = NULL; } vcd_free_buffers_internal(cctxt, &cctxt->in_buf_pool); vcd_free_buffers_internal(cctxt, &cctxt->out_buf_pool); vcd_free_buffer_pool_entries(&cctxt->in_buf_pool); vcd_free_buffer_pool_entries(&cctxt->out_buf_pool); vcd_release_all_clnt_transc(cctxt); if (cctxt->ddl_hdl_valid) { ddl_close(&cctxt->ddl_handle); cctxt->ddl_hdl_valid = false; } kfree(cctxt); } u32 vcd_check_for_client_context(struct vcd_dev_ctxt *dev_ctxt, s32 driver_id) { struct vcd_clnt_ctxt *client; client = dev_ctxt->cctxt_list_head; while (client && client->driver_id != driver_id) client = client->next; if (!client) return false; else return true; } u32 vcd_validate_driver_handle(struct vcd_dev_ctxt *dev_ctxt, s32 driver_handle) { driver_handle--; if (driver_handle < 0 || driver_handle >= VCD_DRIVER_INSTANCE_MAX || !dev_ctxt->driver_ids[driver_handle]) { return false; } else { return true; } } u32 vcd_client_cmd_en_q(struct vcd_clnt_ctxt *cctxt, enum vcd_command_type command) { u32 result; if (cctxt->cmd_q.pending_cmd == VCD_CMD_NONE) { cctxt->cmd_q.pending_cmd = command; result = true; } else { result = false; } return result; } void vcd_client_cmd_flush_and_en_q(struct vcd_clnt_ctxt *cctxt, enum vcd_command_type command) { cctxt->cmd_q.pending_cmd = command; } u32 vcd_client_cmd_de_q(struct vcd_clnt_ctxt *cctxt, enum vcd_command_type *command) { if (cctxt->cmd_q.pending_cmd == VCD_CMD_NONE) return false; *command = cctxt->cmd_q.pending_cmd; cctxt->cmd_q.pending_cmd = VCD_CMD_NONE; return true; } u32 vcd_get_next_queued_client_cmd(struct vcd_dev_ctxt *dev_ctxt, struct vcd_clnt_ctxt **cctxt, enum vcd_command_type *command) { struct vcd_clnt_ctxt *client = dev_ctxt->cctxt_list_head; u32 result = false; while (client && !result) { *cctxt = client; result = vcd_client_cmd_de_q(client, command); client = client->next; } return result; } u32 vcd_map_sched_status(enum sched_status sched_status) { u32 rc = VCD_S_SUCCESS; switch (sched_status) { case SCHED_S_OK: rc = VCD_S_SUCCESS; break; case SCHED_S_EOF: rc = VCD_S_SCHED_EOS; break; case SCHED_S_QEMPTY: rc = VCD_S_SCHED_QEMPTY; break; case SCHED_S_QFULL: rc = VCD_S_SCHED_QFULL; break; default: rc = VCD_ERR_FAIL; break; } return rc; } u32 vcd_submit_cmd_sess_start(struct vcd_transc *transc) { u32 rc; struct vcd_phys_sequence_hdr seq_hdr; VCD_MSG_LOW("vcd_submit_cmd_sess_start:"); if (transc->cctxt->decoding) { if (transc->cctxt->seq_hdr.addr) { seq_hdr.sz = transc->cctxt->seq_hdr.sz; seq_hdr.addr = transc->cctxt->seq_hdr_phys_addr; rc = ddl_decode_start(transc->cctxt->ddl_handle, &seq_hdr, (void *)transc); } else { rc = ddl_decode_start(transc->cctxt->ddl_handle, NULL, (void *)transc); } } else { rc = ddl_encode_start(transc->cctxt->ddl_handle, (void *)transc); } if (!VCD_FAILED(rc)) { transc->cctxt->status.cmd_submitted++; vcd_device_timer_start(transc->cctxt->dev_ctxt); } else VCD_MSG_ERROR("rc = 0x%x. Failed: ddl start", rc); return rc; } u32 vcd_submit_cmd_sess_end(struct vcd_transc *transc) { u32 rc; VCD_MSG_LOW("vcd_submit_cmd_sess_end:"); if (transc->cctxt->decoding) { rc = ddl_decode_end(transc->cctxt->ddl_handle, (void *)transc); } else { rc = ddl_encode_end(transc->cctxt->ddl_handle, (void *)transc); } if (!VCD_FAILED(rc)) { transc->cctxt->status.cmd_submitted++; vcd_device_timer_start(transc->cctxt->dev_ctxt); } else VCD_MSG_ERROR("rc = 0x%x. Failed: ddl end", rc); return rc; } void vcd_submit_cmd_client_close(struct vcd_clnt_ctxt *cctxt) { ddl_close(&cctxt->ddl_handle); cctxt->ddl_hdl_valid = false; cctxt->status.cleaning_up = false; if (cctxt->status.close_pending) { vcd_destroy_client_context(cctxt); vcd_handle_for_last_clnt_close(cctxt->dev_ctxt, true); } } u32 vcd_submit_command_in_continue(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc) { struct vcd_property_hdr prop_hdr; struct vcd_clnt_ctxt *client = NULL; enum vcd_command_type cmd = VCD_CMD_NONE; u32 rc = VCD_ERR_FAIL; u32 result = false; u32 flush = 0; u32 event = 0; VCD_MSG_LOW("\n vcd_submit_command_in_continue:"); while (1) { result = vcd_get_next_queued_client_cmd(dev_ctxt, &client, &cmd); if (!result) break; transc->type = cmd; transc->cctxt = client; switch (cmd) { case VCD_CMD_CODEC_START: rc = vcd_submit_cmd_sess_start(transc); event = VCD_EVT_RESP_START; break; case VCD_CMD_CODEC_STOP: rc = vcd_submit_cmd_sess_end(transc); event = VCD_EVT_RESP_STOP; break; case VCD_CMD_OUTPUT_FLUSH: prop_hdr.id = DDL_I_REQ_OUTPUT_FLUSH; prop_hdr.sz = sizeof(u32); flush = 0x1; ddl_set_property(client->ddl_handle, &prop_hdr, &flush); vcd_release_command_channel(dev_ctxt, transc); rc = VCD_S_SUCCESS; break; case VCD_CMD_CLIENT_CLOSE: vcd_submit_cmd_client_close(client); vcd_release_command_channel(dev_ctxt, transc); rc = VCD_S_SUCCESS; break; default: VCD_MSG_ERROR("\n vcd_submit_command: Unknown" "command %d", (int)cmd); vcd_assert(); break; } if (!VCD_FAILED(rc)) { break; } else { VCD_MSG_ERROR("vcd_submit_command %d: failed 0x%x", cmd, rc); client->callback(event, rc, NULL, 0, client, client->client_data); } } return result; } u32 vcd_schedule_frame(struct vcd_dev_ctxt *dev_ctxt, struct vcd_clnt_ctxt **pp_cctxt, struct vcd_buffer_entry **pp_ip_buf_entry) { u32 rc = VCD_S_SUCCESS; VCD_MSG_LOW("vcd_schedule_frame:"); if (!dev_ctxt->cctxt_list_head) { VCD_MSG_HIGH("Client list empty"); return false; } rc = vcd_map_sched_status(sched_de_queue_frame(dev_ctxt->sched_hdl, (void **) pp_ip_buf_entry, (void **) pp_cctxt)); if (VCD_FAILED(rc)) { VCD_MSG_FATAL("vcd_submit_frame: sched_de_queue_frame" "failed 0x%x", rc); return false; } if (rc == VCD_S_SCHED_QEMPTY) { VCD_MSG_HIGH("No frame available. Sched queues are empty"); return false; } if (!*pp_cctxt || !*pp_ip_buf_entry) { VCD_MSG_FATAL("Sched returned invalid values. ctxt=%p," "ipbuf=%p", *pp_cctxt, *pp_ip_buf_entry); return false; } if (rc == VCD_S_SCHED_EOS) (*pp_ip_buf_entry)->frame.flags |= VCD_FRAME_FLAG_EOS; return true; } void vcd_try_submit_frame(struct vcd_dev_ctxt *dev_ctxt) { struct vcd_transc *transc; u32 rc = VCD_S_SUCCESS; struct vcd_clnt_ctxt *cctxt = NULL; struct vcd_buffer_entry *ip_buf_entry = NULL; u32 result = false; VCD_MSG_LOW("vcd_try_submit_frame:"); if (!vcd_get_frame_channel(dev_ctxt, &transc)) return; if (!vcd_schedule_frame(dev_ctxt, &cctxt, &ip_buf_entry)) { vcd_release_frame_channel(dev_ctxt, transc); return; } rc = vcd_power_event(dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_CMD_BEGIN); if (!VCD_FAILED(rc)) { transc->cctxt = cctxt; transc->ip_buf_entry = ip_buf_entry; result = vcd_submit_frame(dev_ctxt, transc); } else { VCD_MSG_ERROR("Failed: VCD_EVT_PWR_CLNT_CMD_BEGIN"); vcd_requeue_input_frame(dev_ctxt, cctxt, ip_buf_entry); vcd_map_sched_status(sched_update_client_o_tkn( dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, true, cctxt->sched_o_tkn_per_ip_frm)); } if (!result) { vcd_release_frame_channel(dev_ctxt, transc); vcd_power_event(dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_CMD_FAIL); } } u32 vcd_submit_frame(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc) { struct vcd_clnt_ctxt *cctxt = NULL; struct vcd_frame_data *ip_frm_entry; struct vcd_buffer_entry *op_buf_entry = NULL; u32 rc = VCD_S_SUCCESS; u32 evcode = 0; struct ddl_frame_data_tag ddl_ip_frm; struct ddl_frame_data_tag ddl_op_frm; VCD_MSG_LOW("vcd_submit_frame:"); cctxt = transc->cctxt; ip_frm_entry = &transc->ip_buf_entry->frame; transc->op_buf_entry = op_buf_entry; transc->ip_frm_tag = ip_frm_entry->ip_frm_tag; transc->time_stamp = ip_frm_entry->time_stamp; ip_frm_entry->ip_frm_tag = (u32) transc; memset(&ddl_ip_frm, 0, sizeof(ddl_ip_frm)); memset(&ddl_op_frm, 0, sizeof(ddl_op_frm)); if (cctxt->decoding) { evcode = CLIENT_STATE_EVENT_NUMBER(pf_decode_frame); ddl_ip_frm.vcd_frm = *ip_frm_entry; rc = ddl_decode_frame(cctxt->ddl_handle, &ddl_ip_frm, (void *) transc); } else { op_buf_entry = vcd_buffer_pool_entry_de_q(&cctxt->out_buf_pool); if (!op_buf_entry) { VCD_MSG_ERROR("Sched provided frame when no" "op buffer was present"); rc = VCD_ERR_FAIL; } else { op_buf_entry->in_use = true; cctxt->out_buf_pool.in_use++; ddl_ip_frm.vcd_frm = *ip_frm_entry; ddl_ip_frm.frm_delta = vcd_calculate_frame_delta(cctxt, ip_frm_entry); ddl_op_frm.vcd_frm = op_buf_entry->frame; evcode = CLIENT_STATE_EVENT_NUMBER(pf_encode_frame); rc = ddl_encode_frame(cctxt->ddl_handle, &ddl_ip_frm, &ddl_op_frm, (void *) transc); } } ip_frm_entry->ip_frm_tag = transc->ip_frm_tag; if (!VCD_FAILED(rc)) { vcd_device_timer_start(dev_ctxt); cctxt->status.frame_submitted++; if (ip_frm_entry->flags & VCD_FRAME_FLAG_EOS) vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_EOS, evcode); } else { VCD_MSG_ERROR("Frame submission failed. rc = 0x%x", rc); vcd_handle_submit_frame_failed(dev_ctxt, transc); } return true; } u32 vcd_try_submit_frame_in_continue(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc) { struct vcd_clnt_ctxt *cctxt = NULL; struct vcd_buffer_entry *ip_buf_entry = NULL; VCD_MSG_LOW("vcd_try_submit_frame_in_continue:"); if (!vcd_schedule_frame(dev_ctxt, &cctxt, &ip_buf_entry)) return false; transc->cctxt = cctxt; transc->ip_buf_entry = ip_buf_entry; return vcd_submit_frame(dev_ctxt, transc); } u32 vcd_process_cmd_sess_start(struct vcd_clnt_ctxt *cctxt) { struct vcd_transc *transc; u32 rc = VCD_S_SUCCESS; VCD_MSG_LOW("vcd_process_cmd_sess_start:"); if (vcd_get_command_channel(cctxt->dev_ctxt, &transc)) { rc = vcd_power_event(cctxt->dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_CMD_BEGIN); if (!VCD_FAILED(rc)) { transc->type = VCD_CMD_CODEC_START; transc->cctxt = cctxt; rc = vcd_submit_cmd_sess_start(transc); } else { VCD_MSG_ERROR("Failed: VCD_EVT_PWR_CLNT_CMD_BEGIN"); } if (VCD_FAILED(rc)) { vcd_release_command_channel(cctxt->dev_ctxt, transc); } } else { u32 result; result = vcd_client_cmd_en_q(cctxt, VCD_CMD_CODEC_START); if (!result) { rc = VCD_ERR_BUSY; VCD_MSG_ERROR("%s(): vcd_client_cmd_en_q() " "failed\n", __func__); vcd_assert(); } } if (VCD_FAILED(rc)) { vcd_power_event(cctxt->dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_CMD_FAIL); } return rc; } void vcd_send_frame_done_in_eos(struct vcd_clnt_ctxt *cctxt, struct vcd_frame_data *input_frame, u32 valid_opbuf) { VCD_MSG_LOW("vcd_send_frame_done_in_eos:"); if (!input_frame->virt_addr && !valid_opbuf) { VCD_MSG_MED("Sending NULL output with EOS"); cctxt->out_buf_pool.entries[0].frame.flags = VCD_FRAME_FLAG_EOS; cctxt->out_buf_pool.entries[0].frame.data_len = 0; cctxt->out_buf_pool.entries[0].frame.time_stamp = input_frame->time_stamp; cctxt->out_buf_pool.entries[0].frame.ip_frm_tag = input_frame->ip_frm_tag; cctxt->callback(VCD_EVT_RESP_OUTPUT_DONE, VCD_S_SUCCESS, &cctxt->out_buf_pool.entries[0].frame, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); memset(&cctxt->out_buf_pool.entries[0].frame, 0, sizeof(struct vcd_frame_data)); } else if (!input_frame->data_len) { if (cctxt->decoding) vcd_send_frame_done_in_eos_for_dec(cctxt, input_frame); else vcd_send_frame_done_in_eos_for_enc(cctxt, input_frame); } } void vcd_send_frame_done_in_eos_for_dec(struct vcd_clnt_ctxt *cctxt, struct vcd_frame_data *input_frame) { struct vcd_buffer_entry *buf_entry; struct vcd_property_hdr prop_hdr; u32 rc; struct ddl_frame_data_tag ddl_frm; prop_hdr.id = DDL_I_DPB_RETRIEVE; prop_hdr.sz = sizeof(struct ddl_frame_data_tag); memset(&ddl_frm, 0, sizeof(ddl_frm)); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &ddl_frm); if (VCD_FAILED(rc) || !ddl_frm.vcd_frm.virt_addr) { cctxt->status.eos_trig_ip_frm = *input_frame; cctxt->status.eos_wait_for_op_buf = true; return; } buf_entry = vcd_find_buffer_pool_entry(&cctxt->out_buf_pool, ddl_frm.vcd_frm.virt_addr); if (!buf_entry) { VCD_MSG_ERROR("Unrecognized buffer address provided %p", ddl_frm.vcd_frm.virt_addr); vcd_assert(); } else { vcd_map_sched_status(sched_update_client_o_tkn( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl,\ false, cctxt->sched_o_tkn_per_ip_frm)); VCD_MSG_MED("Sending non-NULL output with EOS"); buf_entry->frame.data_len = 0; buf_entry->frame.offset = 0; buf_entry->frame.flags |= VCD_FRAME_FLAG_EOS; buf_entry->frame.ip_frm_tag = input_frame->ip_frm_tag; buf_entry->frame.time_stamp = input_frame->time_stamp; cctxt->callback(VCD_EVT_RESP_OUTPUT_DONE, VCD_S_SUCCESS, &buf_entry->frame, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); buf_entry->in_use = false; VCD_BUFFERPOOL_INUSE_DECREMENT(cctxt->out_buf_pool.in_use); } } void vcd_send_frame_done_in_eos_for_enc(struct vcd_clnt_ctxt *cctxt, struct vcd_frame_data *input_frame) { struct vcd_buffer_entry *op_buf_entry; if (!cctxt->out_buf_pool.q_len) { cctxt->status.eos_trig_ip_frm = *input_frame; cctxt->status.eos_wait_for_op_buf = true; return; } op_buf_entry = vcd_buffer_pool_entry_de_q(&cctxt->out_buf_pool); if (!op_buf_entry) { VCD_MSG_ERROR("%s(): vcd_buffer_pool_entry_de_q() " "failed\n", __func__); vcd_assert(); } else { vcd_map_sched_status(sched_update_client_o_tkn( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, false, cctxt->sched_o_tkn_per_ip_frm)); VCD_MSG_MED("Sending non-NULL output with EOS"); op_buf_entry->frame.data_len = 0; op_buf_entry->frame.flags |= VCD_FRAME_FLAG_EOS; op_buf_entry->frame.ip_frm_tag = input_frame->ip_frm_tag; op_buf_entry->frame.time_stamp = input_frame->time_stamp; cctxt->callback(VCD_EVT_RESP_OUTPUT_DONE, VCD_S_SUCCESS, &op_buf_entry->frame, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); } } u32 vcd_handle_recvd_eos(struct vcd_clnt_ctxt *cctxt, struct vcd_frame_data *input_frame, u32 *pb_eos_handled) { union sched_value_type sched_val; u32 rc; VCD_MSG_LOW("vcd_handle_recvd_eos:"); *pb_eos_handled = false; if (input_frame->virt_addr && input_frame->data_len) return VCD_S_SUCCESS; input_frame->data_len = 0; rc = vcd_map_sched_status(sched_get_client_param( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, SCHED_I_CLNT_CURRQLEN, &sched_val)); VCD_FAILED_RETURN(rc, "Failed: sched_get_client_param"); if (sched_val.un_value > 0) { rc = vcd_map_sched_status(sched_mark_client_eof( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl)); if (!VCD_FAILED(rc)) { *pb_eos_handled = true; } else { VCD_MSG_ERROR("rc = 0x%x. Failed: " "sched_mark_client_eof", rc); } } else if (cctxt->decoding && !input_frame->virt_addr) { rc = vcd_map_sched_status(sched_update_client_o_tkn( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, true, cctxt->sched_o_tkn_per_ip_frm)); } else if (!cctxt->decoding) { vcd_send_frame_done_in_eos(cctxt, input_frame, false); if (cctxt->status.eos_wait_for_op_buf) { vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_EOS, CLIENT_STATE_EVENT_NUMBER(pf_encode_frame)); } *pb_eos_handled = true; } if (*pb_eos_handled && input_frame->virt_addr && !input_frame->data_len) { cctxt->callback(VCD_EVT_RESP_INPUT_DONE, VCD_S_SUCCESS, input_frame, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); } return rc; } u32 vcd_handle_first_decode_frame(struct vcd_clnt_ctxt *cctxt) { struct ddl_property_dec_pic_buffers dpb; struct vcd_property_hdr prop_hdr; u32 rc; u16 i; u16 q_cntr; struct ddl_frame_data_tag *frm_entry; struct ddl_frame_data_tag ddl_frm; struct vcd_buffer_pool *out_buf_pool; VCD_MSG_LOW("vcd_handle_first_decode_frame:"); if (!cctxt->in_buf_pool.entries || !cctxt->out_buf_pool.entries || cctxt->in_buf_pool.validated != cctxt->in_buf_pool.count || cctxt->out_buf_pool.validated != cctxt->out_buf_pool.count) { VCD_MSG_ERROR("Buffer pool is not completely setup yet"); return VCD_ERR_BAD_STATE; } rc = vcd_add_client_to_sched(cctxt); VCD_FAILED_RETURN(rc, "Failed: vcd_add_client_to_sched"); prop_hdr.id = DDL_I_DPB; prop_hdr.sz = sizeof(dpb); out_buf_pool = &cctxt->out_buf_pool; frm_entry = kmalloc(sizeof(struct ddl_frame_data_tag) * out_buf_pool->count, GFP_KERNEL); if (!frm_entry) { VCD_MSG_ERROR("Memory allocation failure"); return VCD_ERR_ALLOC_FAIL; } for (i = 1; i <= out_buf_pool->count; i++) frm_entry[i - 1].vcd_frm = out_buf_pool->entries[i].frame; dpb.dec_pic_buffers = frm_entry; dpb.no_of_dec_pic_buf = out_buf_pool->count; rc = ddl_set_property(cctxt->ddl_handle, &prop_hdr, &dpb); kfree(frm_entry); VCD_FAILED_RETURN(rc, "Failed: DDL set DDL_I_DPB"); if (out_buf_pool->q_len > 0) { prop_hdr.id = DDL_I_DPB_RELEASE; prop_hdr.sz = sizeof(struct ddl_frame_data_tag); for (i = 0, q_cntr = out_buf_pool->q_head; !VCD_FAILED(rc) && i < out_buf_pool->q_len; i++, q_cntr = (q_cntr + 1) % out_buf_pool->count) { ddl_frm.vcd_frm = out_buf_pool->queue[q_cntr]->frame; rc = ddl_set_property(cctxt->ddl_handle, &prop_hdr, &ddl_frm); if (VCD_FAILED(rc)) { VCD_MSG_ERROR ("Error returning output buffer to HW"); out_buf_pool->queue[q_cntr]->in_use = false; } else { out_buf_pool->queue[q_cntr]->in_use = true; out_buf_pool->in_use++; } } if (VCD_FAILED(rc)) return rc; rc = vcd_map_sched_status(sched_update_client_o_tkn( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, true, cctxt->sched_o_tkn_per_ip_frm * out_buf_pool->q_len)); } return rc; } u32 vcd_setup_with_ddl_capabilities(struct vcd_dev_ctxt *dev_ctxt) { struct vcd_property_hdr prop_hdr; struct ddl_property_capability capability; u32 rc = VCD_S_SUCCESS; VCD_MSG_LOW("vcd_setup_with_ddl_capabilities:"); if (dev_ctxt->ddl_cmd_ch_depth) goto out; prop_hdr.id = DDL_I_CAPABILITY; prop_hdr.sz = sizeof(capability); /* * Since this is underlying core's property we don't need a * ddl client handle. */ rc = ddl_get_property(NULL, &prop_hdr, &capability); if (VCD_FAILED(rc)) goto out; /* ** Allocate the transaction table. */ dev_ctxt->trans_tbl_size = VCD_MAX_CLIENT_TRANSACTIONS * capability.max_num_client + capability.general_command_depth; dev_ctxt->trans_tbl = kzalloc(sizeof(struct vcd_transc) * dev_ctxt->trans_tbl_size, GFP_KERNEL); if (!dev_ctxt->trans_tbl) { VCD_MSG_ERROR("Transaction table alloc failed"); rc = VCD_ERR_ALLOC_FAIL; goto out; } /* ** Set the command/frame depth */ dev_ctxt->ddl_cmd_concurrency = !capability.exclusive; dev_ctxt->ddl_frame_ch_depth = capability.frame_command_depth; dev_ctxt->ddl_cmd_ch_depth = capability.general_command_depth; vcd_reset_device_channels(dev_ctxt); dev_ctxt->hw_time_out = capability.ddl_time_out_in_ms; out: return rc; } struct vcd_transc *vcd_get_free_trans_tbl_entry(struct vcd_dev_ctxt *dev_ctxt) { u8 i; if (!dev_ctxt->trans_tbl) return NULL; i = 0; while (i < dev_ctxt->trans_tbl_size && dev_ctxt->trans_tbl[i].in_use) i++; if (i == dev_ctxt->trans_tbl_size) { return NULL; } else { memset(&dev_ctxt->trans_tbl[i], 0, sizeof(struct vcd_transc)); dev_ctxt->trans_tbl[i].in_use = true; return &dev_ctxt->trans_tbl[i]; } } void vcd_release_trans_tbl_entry(struct vcd_transc *trans_entry) { if (trans_entry) trans_entry->in_use = false; } u32 vcd_add_client_to_sched(struct vcd_clnt_ctxt *cctxt) { struct vcd_property_hdr prop_hdr; struct sched_client_init_param sched_input_init; u32 rc, seqhdr_present = 0;; if (cctxt->sched_clnt_valid) { VCD_MSG_HIGH("Schedulder client is already added "); return VCD_S_SUCCESS; } prop_hdr.id = DDL_I_FRAME_PROC_UNITS; prop_hdr.sz = sizeof(cctxt->frm_p_units); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &cctxt->frm_p_units); VCD_FAILED_RETURN(rc, "Failed: Get DDL_I_FRAME_PROC_UNITS"); if (cctxt->decoding) { cctxt->frm_rate.fps_numerator = VCD_DEC_INITIAL_FRAME_RATE; cctxt->frm_rate.fps_denominator = 1; sched_input_init.o_tkn_per_ip_frm = VCD_SCHEDULER_DEC_DFLT_OTKN_PERFRM; cctxt->sched_o_tkn_per_ip_frm = VCD_SCHEDULER_DEC_DFLT_OTKN_PERFRM; sched_input_init.o_tkn_max = cctxt->sched_o_tkn_per_ip_frm * cctxt->out_buf_pool.count+1; } else { sched_input_init.o_tkn_per_ip_frm = VCD_SCHEDULER_ENC_DFLT_OTKN_PERFRM; cctxt->sched_o_tkn_per_ip_frm = VCD_SCHEDULER_ENC_DFLT_OTKN_PERFRM; prop_hdr.id = DDL_I_SEQHDR_PRESENT; prop_hdr.sz = sizeof(seqhdr_present); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &seqhdr_present); if (!VCD_FAILED(rc)) { if (seqhdr_present == 0x1) { VCD_MSG_MED("Sequence hdr present"); sched_input_init.o_tkn_per_ip_frm++; } sched_input_init.o_tkn_max = cctxt->out_buf_pool.count; prop_hdr.id = VCD_I_FRAME_RATE; prop_hdr.sz = sizeof(cctxt->frm_rate); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &cctxt->frm_rate); } } VCD_FAILED_RETURN(rc, "Failed: DDL get VCD_I_FRAME_RATE"); if (cctxt->live) sched_input_init.client_ctgy = SCHED_CLNT_RT_NOBUFF; else sched_input_init.client_ctgy = SCHED_CLNT_NONRT; sched_input_init.max_queue_len = max(cctxt->in_buf_pool.count, VCD_MAX_SCHEDULER_QUEUE_SIZE(cctxt->frm_rate.fps_numerator, cctxt->frm_rate.fps_denominator)); cctxt->reqd_perf_lvl = cctxt->frm_p_units * cctxt->frm_rate.fps_numerator / cctxt->frm_rate.fps_denominator; sched_input_init.frm_rate.numer = cctxt->frm_rate.fps_numerator; sched_input_init.frm_rate.denom = cctxt->frm_rate.fps_denominator; sched_input_init.tkn_per_frm = cctxt->frm_p_units; sched_input_init.alloc_p_tkn_rate = cctxt->reqd_perf_lvl; sched_input_init.o_tkn_init = 0; sched_input_init.client_data = cctxt; rc = vcd_map_sched_status(sched_add_client(cctxt->dev_ctxt->sched_hdl, &sched_input_init, &cctxt->sched_clnt_hdl)); if (!VCD_FAILED(rc)) cctxt->sched_clnt_valid = true; return rc; } u32 vcd_handle_input_done(struct vcd_clnt_ctxt *cctxt, void *payload, u32 event, u32 status) { struct vcd_transc *transc; struct ddl_frame_data_tag *frame = (struct ddl_frame_data_tag *)payload; u32 rc; if (!cctxt->status.frame_submitted && !cctxt->status.frame_delayed) { VCD_MSG_ERROR("Input done was not expected"); vcd_assert(); return VCD_ERR_BAD_STATE; } rc = vcd_validate_io_done_pyld(payload, status); VCD_FAILED_RETURN(rc, "Bad input done payload"); transc = (struct vcd_transc *)frame->vcd_frm.ip_frm_tag; if (transc->ip_buf_entry->frame.virt_addr != frame->vcd_frm.virt_addr || !transc->ip_buf_entry->in_use) { VCD_MSG_ERROR("Bad frm transaction state"); vcd_assert(); } frame->vcd_frm.ip_frm_tag = transc->ip_frm_tag; cctxt->callback(event, status, &frame->vcd_frm, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); transc->frame_type = frame->vcd_frm.frame_type; transc->ip_buf_entry->in_use = false; VCD_BUFFERPOOL_INUSE_DECREMENT(cctxt->in_buf_pool.in_use); transc->ip_buf_entry = NULL; transc->input_done = true; if (transc->input_done && transc->frame_done) transc->in_use = false; if (VCD_FAILED(status)) { VCD_MSG_ERROR("INPUT_DONE returned err = 0x%x", status); vcd_handle_input_done_failed(cctxt, transc); } if (cctxt->status.frame_submitted > 0) cctxt->status.frame_submitted--; else cctxt->status.frame_delayed--; if (!VCD_FAILED(status) && cctxt->decoding) { if (frame->vcd_frm.interlaced) vcd_handle_input_done_for_interlacing(cctxt); if (frame->frm_trans_end) vcd_handle_input_done_with_trans_end(cctxt); } return VCD_S_SUCCESS; } void vcd_handle_input_done_in_eos(struct vcd_clnt_ctxt *cctxt, void *payload, u32 status) { struct vcd_transc *transc; struct ddl_frame_data_tag *frame = (struct ddl_frame_data_tag *)payload; if (VCD_FAILED(vcd_validate_io_done_pyld(payload, status))) return; transc = (struct vcd_transc *)frame->vcd_frm.ip_frm_tag; vcd_handle_input_done(cctxt, payload, VCD_EVT_RESP_INPUT_DONE, status); if ((frame->vcd_frm.flags & VCD_FRAME_FLAG_EOS)) { VCD_MSG_HIGH("Got input done for EOS initiator"); transc->input_done = false; transc->in_use = true; } } u32 vcd_validate_io_done_pyld(void *payload, u32 status) { struct ddl_frame_data_tag *frame = (struct ddl_frame_data_tag *)payload; if (!frame) { VCD_MSG_ERROR("Bad payload from DDL"); vcd_assert(); return VCD_ERR_BAD_POINTER; } if (!frame->vcd_frm.ip_frm_tag || frame->vcd_frm.ip_frm_tag == VCD_FRAMETAG_INVALID) { VCD_MSG_ERROR("bad input frame tag"); vcd_assert(); return VCD_ERR_BAD_POINTER; } if (!frame->vcd_frm.virt_addr && status != VCD_ERR_INTRLCD_FIELD_DROP) return VCD_ERR_BAD_POINTER; return VCD_S_SUCCESS; } void vcd_handle_input_done_failed(struct vcd_clnt_ctxt *cctxt, struct vcd_transc *transc) { if (cctxt->decoding) { vcd_map_sched_status(sched_update_client_o_tkn( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, true, cctxt->sched_o_tkn_per_ip_frm)); transc->in_use = false; } } void vcd_handle_input_done_for_interlacing(struct vcd_clnt_ctxt *cctxt) { u32 rc; cctxt->status.int_field_cnt++; if (cctxt->status.int_field_cnt == 1) { rc = vcd_map_sched_status(sched_update_client_o_tkn( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, true, cctxt->sched_o_tkn_per_ip_frm)); if (VCD_FAILED(rc)) VCD_MSG_ERROR("sched_update_client_o_tkn failed"); } else if (cctxt->status.int_field_cnt == VCD_DEC_NUM_INTERLACED_FIELDS) cctxt->status.int_field_cnt = 0; } void vcd_handle_input_done_with_trans_end(struct vcd_clnt_ctxt *cctxt) { u32 rc; union sched_value_type sched_val; if (!cctxt->decoding) return; if (cctxt->out_buf_pool.in_use < cctxt->out_buf_pool.buf_req.min_count) return; rc = vcd_map_sched_status(sched_get_client_param( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, SCHED_I_CLNT_OTKNCURRENT, &sched_val)); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("sched_get_client_param:OTKNCURRENT failed"); return; } if (!sched_val.un_value) { VCD_MSG_MED("All output buffers with core are pending display"); rc = vcd_map_sched_status(sched_update_client_o_tkn( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, true, cctxt->sched_o_tkn_per_ip_frm)); if (VCD_FAILED(rc)) VCD_MSG_ERROR("sched_update_client_o_tkn failed"); } } u32 vcd_handle_output_required(struct vcd_clnt_ctxt *cctxt, void *payload, u32 status) { struct vcd_transc *transc; struct ddl_frame_data_tag *frame = (struct ddl_frame_data_tag *)payload; u32 rc; if (!cctxt->status.frame_submitted && !cctxt->status.frame_delayed) { VCD_MSG_ERROR("\n Input done was not expected"); return VCD_ERR_BAD_STATE; } rc = vcd_validate_io_done_pyld(payload, status); VCD_FAILED_RETURN(rc, "\n Bad input done payload"); transc = (struct vcd_transc *)frame->vcd_frm.ip_frm_tag; if (transc->ip_buf_entry->frame.virt_addr != frame->vcd_frm.virt_addr || !transc->ip_buf_entry->in_use) { VCD_MSG_ERROR("\n Bad frm transaction state"); return VCD_ERR_BAD_STATE; } rc = vcd_map_sched_status(sched_re_queue_frame( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, (void *) transc->ip_buf_entry)); VCD_FAILED_RETURN(rc, "Failed: sched_queue_frame"); if (transc->ip_buf_entry->frame.flags & VCD_FRAME_FLAG_EOS) { rc = vcd_map_sched_status(sched_mark_client_eof( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl)); } VCD_FAILED_RETURN(rc, "Failed: sched_mark_client_eof"); transc->ip_buf_entry = NULL; transc->in_use = false; frame->frm_trans_end = true; if (VCD_FAILED(status)) VCD_MSG_ERROR("\n OUTPUT_REQ returned err = 0x%x", status); if (cctxt->status.frame_submitted > 0) cctxt->status.frame_submitted--; else cctxt->status.frame_delayed--; if (!VCD_FAILED(status) && cctxt->decoding && frame->vcd_frm.interlaced) { if (cctxt->status.int_field_cnt > 0) VCD_MSG_ERROR("\n Not expected: OUTPUT_REQ" "for 2nd interlace field"); } return VCD_S_SUCCESS; } u32 vcd_handle_output_required_in_flushing(struct vcd_clnt_ctxt *cctxt, void *payload) { u32 rc; struct vcd_transc *transc; rc = vcd_validate_io_done_pyld(payload, VCD_S_SUCCESS); VCD_FAILED_RETURN(rc, "Bad input done payload"); transc = (struct vcd_transc *) (((struct ddl_frame_data_tag *)payload)-> vcd_frm.ip_frm_tag); ((struct ddl_frame_data_tag *)payload)->vcd_frm.interlaced = false; rc = vcd_handle_input_done(cctxt, payload, VCD_EVT_RESP_INPUT_FLUSHED, VCD_S_SUCCESS); transc->in_use = false; ((struct ddl_frame_data_tag *)payload)->frm_trans_end = true; return rc; } u32 vcd_handle_frame_done(struct vcd_clnt_ctxt *cctxt, void *payload, u32 event, u32 status) { struct vcd_buffer_entry *op_buf_entry; struct ddl_frame_data_tag *op_frm = (struct ddl_frame_data_tag *) payload; struct vcd_transc *transc; u32 rc; rc = vcd_validate_io_done_pyld(payload, status); VCD_FAILED_RETURN(rc, "Bad payload recvd"); transc = (struct vcd_transc *)op_frm->vcd_frm.ip_frm_tag; if (op_frm->vcd_frm.virt_addr) { if (!transc->op_buf_entry) { op_buf_entry = vcd_find_buffer_pool_entry( &cctxt->out_buf_pool, op_frm->vcd_frm.virt_addr); } else { op_buf_entry = transc->op_buf_entry; } if (!op_buf_entry) { VCD_MSG_ERROR("Invalid output buffer returned" "from DDL"); vcd_assert(); rc = VCD_ERR_BAD_POINTER; } else if (!op_buf_entry->in_use) { VCD_MSG_ERROR("Bad output buffer %p recv from DDL", op_buf_entry->frame.virt_addr); vcd_assert(); rc = VCD_ERR_BAD_POINTER; } else { op_buf_entry->in_use = false; VCD_BUFFERPOOL_INUSE_DECREMENT( cctxt->out_buf_pool.in_use); VCD_MSG_LOW("outBufPool.InUse = %d", cctxt->out_buf_pool.in_use); } } VCD_FAILED_RETURN(rc, "Bad output buffer pointer"); op_frm->vcd_frm.time_stamp = transc->time_stamp; op_frm->vcd_frm.ip_frm_tag = transc->ip_frm_tag; op_frm->vcd_frm.frame_type = transc->frame_type; transc->frame_done = true; if (transc->input_done && transc->frame_done) transc->in_use = false; if (status == VCD_ERR_INTRLCD_FIELD_DROP || (op_frm->intrlcd_ip_frm_tag != VCD_FRAMETAG_INVALID && op_frm->intrlcd_ip_frm_tag)) { vcd_handle_frame_done_for_interlacing(cctxt, transc, op_frm, status); } if (status != VCD_ERR_INTRLCD_FIELD_DROP) { cctxt->callback(event, status, &op_frm->vcd_frm, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); } return VCD_S_SUCCESS; } void vcd_handle_frame_done_in_eos(struct vcd_clnt_ctxt *cctxt, void *payload, u32 status) { struct ddl_frame_data_tag *frame = (struct ddl_frame_data_tag *)payload; VCD_MSG_LOW("vcd_handle_frame_done_in_eos:"); if (VCD_FAILED(vcd_validate_io_done_pyld(payload, status))) return; if (cctxt->status.eos_prev_valid) { vcd_handle_frame_done(cctxt, (void *)&cctxt->status.eos_prev_op_frm, VCD_EVT_RESP_OUTPUT_DONE, status); } cctxt->status.eos_prev_op_frm = *frame; cctxt->status.eos_prev_valid = true; } void vcd_handle_frame_done_for_interlacing(struct vcd_clnt_ctxt *cctxt, struct vcd_transc *transc_ip1, struct ddl_frame_data_tag *op_frm, u32 status) { struct vcd_transc *transc_ip2 = (struct vcd_transc *) op_frm->intrlcd_ip_frm_tag; if (status == VCD_ERR_INTRLCD_FIELD_DROP) { cctxt->status.int_field_cnt = 0; return; } op_frm->intrlcd_ip_frm_tag = transc_ip2->ip_frm_tag; transc_ip2->frame_done = true; if (transc_ip2->input_done && transc_ip2->frame_done) transc_ip2->in_use = false; if (!transc_ip1->frame_type || !transc_ip2->frame_type) { VCD_MSG_ERROR("DDL didn't provided frame type"); return; } } u32 vcd_handle_first_frame_done(struct vcd_clnt_ctxt *cctxt, void *payload) { if (!cctxt->decoding) return vcd_handle_first_encode_frame_done(cctxt, payload); return VCD_S_SUCCESS; } u32 vcd_handle_first_encode_frame_done(struct vcd_clnt_ctxt *cctxt, void *payload) { struct vcd_buffer_entry *buf_entry; struct vcd_frame_data *frm_entry; u32 rc, seqhdr_present; struct vcd_property_hdr prop_hdr; struct vcd_sequence_hdr seq_hdr; struct vcd_property_codec codec; union sched_value_type sched_val; struct vcd_transc *transc; struct ddl_frame_data_tag *payload_frm = (struct ddl_frame_data_tag *) payload; VCD_MSG_LOW("vcd_handle_first_encode_frame_done:"); rc = vcd_validate_io_done_pyld(payload, VCD_S_SUCCESS); VCD_FAILED_RETURN(rc, "Validate frame done payload failed"); transc = (struct vcd_transc *)payload_frm->vcd_frm.ip_frm_tag; prop_hdr.id = DDL_I_SEQHDR_PRESENT; prop_hdr.sz = sizeof(seqhdr_present); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &seqhdr_present); VCD_FAILED_RETURN(rc, "Failed: DDL_I_SEQHDR_PRESENT"); if (!seqhdr_present) return VCD_S_SUCCESS; buf_entry = vcd_buffer_pool_entry_de_q(&cctxt->out_buf_pool); if (!buf_entry) { VCD_MSG_ERROR("Sched provided frame when 2nd op buffer " "was unavailable"); rc = VCD_ERR_FAIL; vcd_assert(); return rc; } frm_entry = &buf_entry->frame; prop_hdr.id = VCD_I_CODEC; prop_hdr.sz = sizeof(struct vcd_property_codec); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &codec); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("rc = 0x%x. Failed: ddl_get_property:VCD_I_CODEC", rc); goto out; } if (codec.codec != VCD_CODEC_H263) { prop_hdr.id = VCD_I_SEQ_HEADER; prop_hdr.sz = sizeof(struct vcd_sequence_hdr); seq_hdr.addr = frm_entry->virt_addr; seq_hdr.sz = buf_entry->size; rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &seq_hdr); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("rc = 0x%x. Failed: " "ddl_get_property:VCD_I_SEQ_HEADER", rc); goto out; } } else { VCD_MSG_LOW("Codec Type is H.263\n"); } sched_val.un_value = VCD_SCHEDULER_ENC_DFLT_OTKN_PERFRM; rc = vcd_map_sched_status(sched_set_client_param( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, SCHED_I_CLNT_OTKNPERIPFRM, &sched_val)); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("rc = 0x%x.Failed: sched_set_client_param", rc); goto out; } frm_entry->data_len = seq_hdr.sz; frm_entry->time_stamp = transc->time_stamp; frm_entry->ip_frm_tag = transc->ip_frm_tag; frm_entry->flags |= VCD_FRAME_FLAG_CODECCONFIG; cctxt->callback(VCD_EVT_RESP_OUTPUT_DONE, VCD_S_SUCCESS, frm_entry, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); out: if (VCD_FAILED(rc)) vcd_buffer_pool_entry_en_q(&cctxt->out_buf_pool, buf_entry); return rc; } void vcd_handle_eos_trans_end(struct vcd_clnt_ctxt *cctxt) { if (cctxt->status.eos_prev_valid) { vcd_handle_frame_done(cctxt, (void *)&cctxt->status.eos_prev_op_frm, VCD_EVT_RESP_OUTPUT_DONE, VCD_S_SUCCESS); cctxt->status.eos_prev_valid = false; } if (cctxt->status.flush_mode) vcd_process_pending_flush_in_eos(cctxt); if (cctxt->status.stop_pending) vcd_process_pending_stop_in_eos(cctxt); else { vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_RUN, CLIENT_STATE_EVENT_NUMBER(pf_clnt_cb)); } } void vcd_handle_eos_done(struct vcd_clnt_ctxt *cctxt, struct vcd_transc *transc, u32 status) { struct vcd_frame_data vcd_frm; VCD_MSG_LOW("vcd_handle_eos_done:"); if (VCD_FAILED(status)) VCD_MSG_ERROR("EOS DONE returned error = 0x%x", status); if (cctxt->status.eos_prev_valid) { cctxt->status.eos_prev_op_frm.vcd_frm.flags |= VCD_FRAME_FLAG_EOS; vcd_handle_frame_done(cctxt, (void *)&cctxt->status.eos_prev_op_frm, VCD_EVT_RESP_OUTPUT_DONE, VCD_S_SUCCESS); cctxt->status.eos_prev_valid = false; } else { if (transc->ip_buf_entry) { transc->ip_buf_entry->frame.ip_frm_tag = transc->ip_frm_tag; vcd_send_frame_done_in_eos(cctxt, &transc->ip_buf_entry->frame, false); } else { memset(&vcd_frm, 0, sizeof(struct vcd_frame_data)); vcd_frm.ip_frm_tag = transc->ip_frm_tag; vcd_frm.time_stamp = transc->time_stamp; vcd_frm.flags = VCD_FRAME_FLAG_EOS; vcd_send_frame_done_in_eos(cctxt, &vcd_frm, true); } } if (transc->ip_buf_entry) { if (transc->ip_buf_entry->frame.virt_addr) { transc->ip_buf_entry->frame.ip_frm_tag = transc->ip_frm_tag; cctxt->callback(VCD_EVT_RESP_INPUT_DONE, VCD_S_SUCCESS, &transc->ip_buf_entry->frame, sizeof(struct vcd_frame_data), cctxt, cctxt->client_data); } transc->ip_buf_entry->in_use = false; VCD_BUFFERPOOL_INUSE_DECREMENT(cctxt->in_buf_pool.in_use); transc->ip_buf_entry = NULL; cctxt->status.frame_submitted--; } transc->in_use = false; vcd_mark_frame_channel(cctxt->dev_ctxt); if (cctxt->status.flush_mode) vcd_process_pending_flush_in_eos(cctxt); if (cctxt->status.stop_pending) { vcd_process_pending_stop_in_eos(cctxt); } else if (!cctxt->status.eos_wait_for_op_buf) { vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_RUN, CLIENT_STATE_EVENT_NUMBER(pf_clnt_cb)); } } void vcd_handle_start_done(struct vcd_clnt_ctxt *cctxt, struct vcd_transc *transc, u32 status) { cctxt->status.cmd_submitted--; vcd_mark_command_channel(cctxt->dev_ctxt, transc); if (!VCD_FAILED(status)) { cctxt->callback(VCD_EVT_RESP_START, status, NULL, 0, cctxt, cctxt->client_data); vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_RUN, CLIENT_STATE_EVENT_NUMBER(pf_clnt_cb)); } else { VCD_MSG_ERROR("ddl callback returned failure.status = 0x%x", status); vcd_handle_err_in_starting(cctxt, status); } } void vcd_handle_stop_done(struct vcd_clnt_ctxt *cctxt, struct vcd_transc *transc, u32 status) { u32 rc = VCD_S_SUCCESS; u32 seq_hdrpresent = 0; union sched_value_type sched_val; struct vcd_property_hdr prop_hdr; VCD_MSG_LOW("vcd_handle_stop_done:"); cctxt->status.cmd_submitted--; vcd_mark_command_channel(cctxt->dev_ctxt, transc); if (VCD_FAILED(status)) { VCD_MSG_FATAL("STOP_DONE returned error = 0x%x", status); status = VCD_ERR_HW_FATAL; vcd_handle_device_err_fatal(cctxt->dev_ctxt, cctxt); vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_INVALID, CLIENT_STATE_EVENT_NUMBER(pf_clnt_cb)); goto out; } if (!cctxt->decoding) { prop_hdr.id = DDL_I_SEQHDR_PRESENT; prop_hdr.sz = sizeof(seq_hdrpresent); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &seq_hdrpresent); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("Failed: DDL Get DDL_I_SEQHDR_PRESENT %d", rc); goto open_out; } if (seq_hdrpresent == 0x1) { sched_val.un_value = VCD_SCHEDULER_ENC_DFLT_OTKN_PERFRM + 1; rc = vcd_map_sched_status(sched_set_client_param( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, SCHED_I_CLNT_OTKNPERIPFRM, &sched_val)); if (VCD_FAILED(rc)) VCD_MSG_ERROR("Failed: sched_set_client_param " "%d", rc); } } open_out: vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_OPEN, CLIENT_STATE_EVENT_NUMBER(pf_clnt_cb)); out: cctxt->callback(VCD_EVT_RESP_STOP, status, NULL, 0, cctxt, cctxt->client_data); memset(&cctxt->status, 0, sizeof(struct vcd_clnt_status)); } void vcd_handle_stop_done_in_starting(struct vcd_clnt_ctxt *cctxt, struct vcd_transc *transc, u32 status) { VCD_MSG_LOW("vcd_handle_stop_done_in_starting:"); cctxt->status.cmd_submitted--; vcd_mark_command_channel(cctxt->dev_ctxt, transc); if (!VCD_FAILED(status)) { cctxt->callback(VCD_EVT_RESP_START, cctxt->status.last_err, NULL, 0, cctxt, cctxt->client_data); vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_OPEN, CLIENT_STATE_EVENT_NUMBER(pf_clnt_cb)); } else { VCD_MSG_FATAL("VCD Cleanup: STOP_DONE returned error " "= 0x%x", status); vcd_handle_err_fatal(cctxt, VCD_EVT_RESP_START, VCD_ERR_HW_FATAL); } } void vcd_handle_stop_done_in_invalid(struct vcd_clnt_ctxt *cctxt, u32 status) { u32 rc; VCD_MSG_LOW("vcd_handle_stop_done_in_invalid:"); if (!VCD_FAILED(status)) { vcd_client_cmd_flush_and_en_q(cctxt, VCD_CMD_CLIENT_CLOSE); if (cctxt->status.frame_submitted) { vcd_release_multiple_frame_channels(cctxt->dev_ctxt, cctxt->status.frame_submitted); cctxt->status.frame_submitted = 0; cctxt->status.frame_delayed = 0; } if (cctxt->status.cmd_submitted) { vcd_release_multiple_command_channels(cctxt->dev_ctxt, cctxt->status.cmd_submitted); cctxt->status.cmd_submitted = 0; } } else { VCD_MSG_FATAL("VCD Cleanup: STOP_DONE returned error " "= 0x%x", status); vcd_handle_device_err_fatal(cctxt->dev_ctxt, cctxt); cctxt->status.cleaning_up = false; } vcd_flush_buffers_in_err_fatal(cctxt); VCD_MSG_HIGH("VCD cleanup: All buffers are returned"); if (cctxt->status.stop_pending) { cctxt->callback(VCD_EVT_RESP_STOP, VCD_S_SUCCESS, NULL, 0, cctxt, cctxt->client_data); cctxt->status.stop_pending = false; } rc = vcd_power_event(cctxt->dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_ERRFATAL); if (VCD_FAILED(rc)) VCD_MSG_ERROR("VCD_EVT_PWR_CLNT_ERRFATAL failed"); if (!cctxt->status.cleaning_up && cctxt->status.close_pending) { vcd_destroy_client_context(cctxt); vcd_handle_for_last_clnt_close(cctxt->dev_ctxt, false); } } u32 vcd_handle_input_frame(struct vcd_clnt_ctxt *cctxt, struct vcd_frame_data *input_frame) { struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; struct vcd_buffer_entry *buf_entry; struct vcd_frame_data *frm_entry; u32 rc = VCD_S_SUCCESS; u32 eos_handled = false; VCD_MSG_LOW("vcd_handle_input_frame:"); VCD_MSG_LOW("input buffer: addr=(0x%p), size=(%d), len=(%d)", input_frame->virt_addr, input_frame->alloc_len, input_frame->data_len); if ((!input_frame->virt_addr || !input_frame->data_len) && !(input_frame->flags & VCD_FRAME_FLAG_EOS)) { VCD_MSG_ERROR("Bad frame ptr/len/EOS combination"); return VCD_ERR_ILLEGAL_PARM; } if (!cctxt->status.b1st_frame_recvd) { if (cctxt->decoding) rc = vcd_handle_first_decode_frame(cctxt); if (!VCD_FAILED(rc)) { cctxt->status.first_ts = input_frame->time_stamp; cctxt->status.prev_ts = cctxt->status.first_ts; cctxt->status.b1st_frame_recvd = true; vcd_power_event(cctxt->dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_FIRST_FRAME); } } VCD_FAILED_RETURN(rc, "Failed: Frist frame handling"); buf_entry = vcd_find_buffer_pool_entry(&cctxt->in_buf_pool, input_frame->virt_addr); if (!buf_entry) { VCD_MSG_ERROR("Bad buffer addr: %p", input_frame->virt_addr); return VCD_ERR_FAIL; } if (buf_entry->in_use) { VCD_MSG_ERROR("An inuse input frame is being re-queued to " "scheduler"); return VCD_ERR_FAIL; } if (input_frame->alloc_len > buf_entry->size) { VCD_MSG_ERROR("Bad buffer Alloc_len %d, Actual size=%d", input_frame->alloc_len, buf_entry->size); return VCD_ERR_ILLEGAL_PARM; } frm_entry = &buf_entry->frame; *frm_entry = *input_frame; frm_entry->phys_addr = buf_entry->phys_addr; if (input_frame->flags & VCD_FRAME_FLAG_EOS) rc = vcd_handle_recvd_eos(cctxt, input_frame, &eos_handled); if (VCD_FAILED(rc) || eos_handled) { VCD_MSG_HIGH("rc = 0x%x, eos_handled = %d", rc, eos_handled); return rc; } rc = vcd_map_sched_status(sched_queue_frame(dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, (void *)buf_entry)); VCD_FAILED_RETURN(rc, "Failed: sched_queue_frame"); buf_entry->in_use = true; cctxt->in_buf_pool.in_use++; if (input_frame->flags & VCD_FRAME_FLAG_EOS) { rc = vcd_map_sched_status(sched_mark_client_eof( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl)); } VCD_FAILED_RETURN(rc, "Failed: sched_mark_client_eof"); vcd_try_submit_frame(dev_ctxt); return rc; } void vcd_release_all_clnt_frm_transc(struct vcd_clnt_ctxt *cctxt) { struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; u8 i; VCD_MSG_LOW("vcd_release_all_clnt_frm_transc:"); for (i = 0; i < dev_ctxt->trans_tbl_size; i++) { if (dev_ctxt->trans_tbl[i].in_use && cctxt == dev_ctxt->trans_tbl[i].cctxt && dev_ctxt->trans_tbl[i].type == VCD_CMD_CODE_FRAME) { vcd_release_trans_tbl_entry(&dev_ctxt->trans_tbl[i]); } } } void vcd_release_all_clnt_def_frm_transc(struct vcd_clnt_ctxt *cctxt) { struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; u8 i; VCD_MSG_LOW("vcd_release_all_clnt_def_frm_transc:"); for (i = 0; i < dev_ctxt->trans_tbl_size; i++) { if (dev_ctxt->trans_tbl[i].in_use && cctxt == dev_ctxt->trans_tbl[i].cctxt && dev_ctxt->trans_tbl[i].type == VCD_CMD_NONE) { vcd_release_trans_tbl_entry(&dev_ctxt->trans_tbl[i]); } } } void vcd_release_all_clnt_transc(struct vcd_clnt_ctxt *cctxt) { struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; u8 i; VCD_MSG_LOW("vcd_release_all_clnt_def_frm_transc:"); for (i = 0; i < dev_ctxt->trans_tbl_size; i++) { if (dev_ctxt->trans_tbl[i].in_use && cctxt == dev_ctxt->trans_tbl[i].cctxt) { vcd_release_trans_tbl_entry(&dev_ctxt->trans_tbl[i]); } } } void vcd_send_flush_done(struct vcd_clnt_ctxt *cctxt, u32 status) { VCD_MSG_LOW("vcd_send_flush_done:"); if (cctxt->status.flush_mode & VCD_FLUSH_INPUT) { cctxt->callback(VCD_EVT_RESP_FLUSH_INPUT_DONE, status, NULL, 0, cctxt, cctxt->client_data); cctxt->status.flush_mode &= ~VCD_FLUSH_INPUT; } if (cctxt->status.flush_mode & VCD_FLUSH_OUTPUT) { cctxt->callback(VCD_EVT_RESP_FLUSH_OUTPUT_DONE, status, NULL, 0, cctxt, cctxt->client_data); cctxt->status.flush_mode &= ~VCD_FLUSH_OUTPUT; } } u32 vcd_store_seq_hdr(struct vcd_clnt_ctxt *cctxt, struct vcd_sequence_hdr *seq_hdr) { // u32 rc; // struct vcd_property_hdr prop_hdr; // u32 align; // u32 addr; // int ret = 0; if (!seq_hdr->sz || !seq_hdr->addr) { VCD_MSG_ERROR("Bad seq hdr"); return VCD_ERR_BAD_POINTER; } if (cctxt->seq_hdr.addr) { VCD_MSG_HIGH("Old seq hdr detected"); dma_free_coherent(NULL, cctxt->seq_hdr.sz + VCD_SEQ_HDR_PADDING_BYTES, cctxt->seq_hdr.addr, cctxt->seq_hdr_phys_addr); cctxt->seq_hdr.addr = NULL; } cctxt->seq_hdr.sz = seq_hdr->sz; //TODO strip out all this alignment crap? #if 0 prop_hdr.id = DDL_I_SEQHDR_ALIGN_BYTES; prop_hdr.size = sizeof(u32); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &align); VCD_FAILED_RETURN(rc, "Failed: ddl_get_property DDL_I_SEQHDR_ALIGN_BYTES"); VCD_MSG_MED("Seq hdr alignment bytes = %d", align); #endif cctxt->seq_hdr.addr = dma_alloc_coherent(NULL, cctxt->seq_hdr.sz + VCD_SEQ_HDR_PADDING_BYTES, &cctxt->seq_hdr_phys_addr, GFP_KERNEL); if (!cctxt->seq_hdr.addr) { VCD_MSG_ERROR("Seq hdr allocation failed"); return VCD_ERR_ALLOC_FAIL; } memset(cctxt->seq_hdr.addr, 0, cctxt->seq_hdr.sz + VCD_SEQ_HDR_PADDING_BYTES); memcpy(cctxt->seq_hdr.addr, seq_hdr->addr, seq_hdr->sz); return VCD_S_SUCCESS; } u32 vcd_set_frame_rate(struct vcd_clnt_ctxt *cctxt, struct vcd_property_frame_rate *fps) { union sched_value_type sched_val; u32 rc; sched_val.frm_rate.numer = fps->fps_numerator; sched_val.frm_rate.denom = fps->fps_denominator; cctxt->frm_rate = *fps; rc = vcd_map_sched_status(sched_set_client_param( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, SCHED_I_CLNT_FRAMERATE, &sched_val)); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("rc = 0x%x. Failed: Set SCHED_I_CLNT_FRAMERATE", rc); } rc = vcd_update_clnt_perf_lvl(cctxt, &cctxt->frm_rate, cctxt->frm_p_units); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_update_clnt_perf_lvl", rc); } sched_val.un_value = cctxt->reqd_perf_lvl; rc = vcd_map_sched_status(sched_set_client_param( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, SCHED_I_CLNT_PTKNRATE, &sched_val)); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("rc = 0x%x. Failed: Set SCHED_I_CLNT_PTKNRATE", rc); } return VCD_S_SUCCESS; } u32 vcd_set_frame_size(struct vcd_clnt_ctxt *cctxt, struct vcd_property_frame_size *frm_size) { struct vcd_property_hdr prop_hdr; union sched_value_type sched_val; u32 rc; u32 frm_p_units; frm_size = NULL; prop_hdr.id = DDL_I_FRAME_PROC_UNITS; prop_hdr.sz = sizeof(frm_p_units); rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &frm_p_units); VCD_FAILED_RETURN(rc, "Failed: Get DDL_I_FRAME_PROC_UNITS"); cctxt->frm_p_units = sched_val.un_value = frm_p_units; rc = vcd_map_sched_status(sched_set_client_param( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, SCHED_I_CLNT_PTKNPERFRM, &sched_val)); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("rc = 0x%x. Failed: Set SCHED_I_CLNT_PTKNPERFRM", rc); } rc = vcd_update_clnt_perf_lvl(cctxt, &cctxt->frm_rate, frm_p_units); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_update_clnt_perf_lvl", rc); } sched_val.un_value = cctxt->reqd_perf_lvl; rc = vcd_map_sched_status(sched_set_client_param( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, SCHED_I_CLNT_PTKNRATE, &sched_val)); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("rc = 0x%x. Failed: Set SCHED_I_CLNT_PTKNRATE", rc); } return VCD_S_SUCCESS; } void vcd_process_pending_flush_in_eos(struct vcd_clnt_ctxt *cctxt) { u32 rc = VCD_S_SUCCESS; VCD_MSG_HIGH("Buffer flush is pending"); rc = vcd_flush_buffers(cctxt, cctxt->status.flush_mode); if (VCD_FAILED(rc)) VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_flush_buffers", rc); cctxt->status.eos_wait_for_op_buf = false; vcd_send_flush_done(cctxt, VCD_S_SUCCESS); } void vcd_process_pending_stop_in_eos(struct vcd_clnt_ctxt *cctxt) { u32 rc = VCD_S_SUCCESS; rc = vcd_flush_buffers(cctxt, VCD_FLUSH_ALL); if (VCD_FAILED(rc)) VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_flush_buffers", rc); VCD_MSG_HIGH("All buffers are returned. Enqueuing stop cmd"); vcd_client_cmd_flush_and_en_q(cctxt, VCD_CMD_CODEC_STOP); cctxt->status.stop_pending = false; vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_STOPPING, CLIENT_STATE_EVENT_NUMBER(pf_stop)); } u32 vcd_calculate_frame_delta(struct vcd_clnt_ctxt *cctxt, struct vcd_frame_data *frame) { u32 frm_delta; u64 temp, temp1; temp = frame->time_stamp - cctxt->status.prev_ts; VCD_MSG_LOW("Curr_ts=%lld Prev_ts=%lld Diff=%llu", frame->time_stamp, cctxt->status.prev_ts, temp); temp = temp * cctxt->time_resoln; temp = (temp + (VCD_TIMESTAMP_RESOLUTION >> 1)); temp1 = do_div(temp, VCD_TIMESTAMP_RESOLUTION); frm_delta = temp; VCD_MSG_LOW("temp1=%lld temp=%lld", temp1, temp); cctxt->status.time_elapsed += frm_delta; temp = ((u64)cctxt->status.time_elapsed * VCD_TIMESTAMP_RESOLUTION); temp = (temp + (cctxt->time_resoln >> 1)); temp1 = do_div(temp, cctxt->time_resoln); cctxt->status.prev_ts = cctxt->status.first_ts + temp; VCD_MSG_LOW("Time_elapsed=%u, Drift=%llu, new Prev_ts=%lld", cctxt->status.time_elapsed, temp1, cctxt->status.prev_ts); return frm_delta; } struct vcd_buffer_entry *vcd_check_fill_output_buffer(struct vcd_clnt_ctxt *cctxt, struct vcd_frame_data *buffer) { struct vcd_buffer_pool *buf_pool = &cctxt->out_buf_pool; struct vcd_buffer_entry *buf_entry; if (!buf_pool->entries) { VCD_MSG_ERROR("Buffers not set or allocated yet"); return NULL; } if (!buffer->virt_addr) { VCD_MSG_ERROR("NULL buffer address provided"); return NULL; } buf_entry = vcd_find_buffer_pool_entry(buf_pool, buffer->virt_addr); if (!buf_entry) { VCD_MSG_ERROR("Unrecognized buffer address provided %p", buffer->virt_addr); return NULL; } if (buf_entry->in_use) { VCD_MSG_ERROR("An inuse output frame is being provided for " "reuse"); return NULL; } if (buffer->alloc_len < buf_pool->buf_req.size || buffer->alloc_len > buf_entry->size) { VCD_MSG_ERROR("Bad buffer Alloc_len = %d, Actual size = %d, " " Min size = %u", buffer->alloc_len, buf_entry->size, buf_pool->buf_req.size); return NULL; } return buf_entry; } void vcd_handle_ind_hw_err_fatal(struct vcd_clnt_ctxt *cctxt, u32 event, u32 status) { if (cctxt->status.frame_submitted) { cctxt->status.frame_submitted--; vcd_mark_frame_channel(cctxt->dev_ctxt); } vcd_handle_err_fatal(cctxt, event, status); } void vcd_handle_err_fatal(struct vcd_clnt_ctxt *cctxt, u32 event, u32 status) { u32 rc; VCD_MSG_LOW("vcd_handle_err_fatal: event=%x, err=%x", event, status); if (!VCD_FAILED_FATAL(status)) return; if (VCD_FAILED_DEVICE_FATAL(status)) { vcd_clnt_handle_device_err_fatal(cctxt, event); vcd_handle_device_err_fatal(cctxt->dev_ctxt, cctxt); } else if (VCD_FAILED_CLIENT_FATAL(status)) { cctxt->status.last_evt = event; if (cctxt->sched_clnt_valid) { rc = vcd_map_sched_status(sched_suspend_resume_client( cctxt->dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, false)); if (VCD_FAILED(rc)) { VCD_MSG_ERROR("Failed: sched_suspend_resume_" "client rc=0x%x", rc); } } cctxt->callback(event, VCD_ERR_HW_FATAL, NULL, 0, cctxt, cctxt->client_data); cctxt->status.cleaning_up = true; vcd_client_cmd_flush_and_en_q(cctxt, VCD_CMD_CODEC_STOP); vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_INVALID, CLIENT_STATE_EVENT_NUMBER(pf_clnt_cb)); } } void vcd_handle_err_in_starting(struct vcd_clnt_ctxt *cctxt, u32 status) { VCD_MSG_LOW("\n vcd_handle_err_in_starting:"); if (VCD_FAILED_FATAL(status)) { vcd_handle_err_fatal(cctxt, VCD_EVT_RESP_START, status); } else { cctxt->status.last_err = status; VCD_MSG_HIGH("\n VCD cleanup: Enqueuing stop cmd"); vcd_client_cmd_flush_and_en_q(cctxt, VCD_CMD_CODEC_STOP); } } void vcd_handle_trans_pending(struct vcd_clnt_ctxt *cctxt) { if (!cctxt->status.frame_submitted) { VCD_MSG_ERROR("Transaction pending response was not expected"); vcd_assert(); return; } cctxt->status.frame_submitted--; cctxt->status.frame_delayed++; vcd_mark_frame_channel(cctxt->dev_ctxt); } u32 vcd_requeue_input_frame(struct vcd_dev_ctxt *dev_ctxt, struct vcd_clnt_ctxt *cctxt, struct vcd_buffer_entry *buf_entry) { u32 rc; rc = vcd_map_sched_status(sched_re_queue_frame(dev_ctxt->sched_hdl, cctxt->sched_clnt_hdl, (void *) buf_entry)); VCD_FAILED_RETURN(rc, "Failed: Sched_ReQueueFrame"); if (buf_entry->frame.flags & VCD_FRAME_FLAG_EOS) { rc = vcd_map_sched_status(sched_mark_client_eof(dev_ctxt-> sched_hdl, cctxt->sched_clnt_hdl)); } if (VCD_FAILED(rc)) VCD_MSG_ERROR("rc = 0x%x: Failed: Sched_MarkClientEOF", rc); return rc; } void vcd_handle_submit_frame_failed(struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc) { struct vcd_clnt_ctxt *cctxt = transc->cctxt; u32 rc; vcd_mark_frame_channel(dev_ctxt); transc->in_use = false; vcd_handle_err_fatal(cctxt, VCD_EVT_IND_HWERRFATAL, VCD_ERR_CLIENT_FATAL); if (vcd_get_command_channel(dev_ctxt, &transc)) { transc->type = VCD_CMD_CODEC_STOP; transc->cctxt = cctxt; rc = vcd_submit_cmd_sess_end(transc); if (VCD_FAILED(rc)) { vcd_release_command_channel(dev_ctxt, transc); VCD_MSG_ERROR("rc = 0x%x. Failed: VCD_SubmitCmdSessEnd", rc); } } }
gpl-2.0
werty100/android_kernel_boxer8_ouya
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
376
144836
/* * Copyright (c) 2010-2011 Atheros Communications Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <asm/unaligned.h> #include "hw.h" #include "ar9003_phy.h" #include "ar9003_eeprom.h" #define COMP_HDR_LEN 4 #define COMP_CKSUM_LEN 2 #define AR_CH0_TOP (0x00016288) #define AR_CH0_TOP_XPABIASLVL (0x300) #define AR_CH0_TOP_XPABIASLVL_S (8) #define AR_CH0_THERM (0x00016290) #define AR_CH0_THERM_XPABIASLVL_MSB 0x3 #define AR_CH0_THERM_XPABIASLVL_MSB_S 0 #define AR_CH0_THERM_XPASHORT2GND 0x4 #define AR_CH0_THERM_XPASHORT2GND_S 2 #define AR_SWITCH_TABLE_COM_ALL (0xffff) #define AR_SWITCH_TABLE_COM_ALL_S (0) #define AR_SWITCH_TABLE_COM2_ALL (0xffffff) #define AR_SWITCH_TABLE_COM2_ALL_S (0) #define AR_SWITCH_TABLE_ALL (0xfff) #define AR_SWITCH_TABLE_ALL_S (0) #define LE16(x) __constant_cpu_to_le16(x) #define LE32(x) __constant_cpu_to_le32(x) /* Local defines to distinguish between extension and control CTL's */ #define EXT_ADDITIVE (0x8000) #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE) #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE) #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE) #define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */ #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 9 /* 10*log10(3)*2 */ #define PWRINCR_3_TO_1_CHAIN 9 /* 10*log(3)*2 */ #define PWRINCR_3_TO_2_CHAIN 3 /* floor(10*log(3/2)*2) */ #define PWRINCR_2_TO_1_CHAIN 6 /* 10*log(2)*2 */ #define SUB_NUM_CTL_MODES_AT_5G_40 2 /* excluding HT40, EXT-OFDM */ #define SUB_NUM_CTL_MODES_AT_2G_40 3 /* excluding HT40, EXT-OFDM, EXT-CCK */ #define CTL(_tpower, _flag) ((_tpower) | ((_flag) << 6)) #define EEPROM_DATA_LEN_9485 1088 static int ar9003_hw_power_interpolate(int32_t x, int32_t *px, int32_t *py, u_int16_t np); static const struct ar9300_eeprom ar9300_default = { .eepromVersion = 2, .templateVersion = 2, .macAddr = {0, 2, 3, 4, 5, 6}, .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, .baseEepHeader = { .regDmn = { LE16(0), LE16(0x1f) }, .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */ .opCapFlags = { .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A, .eepMisc = 0, }, .rfSilent = 0, .blueToothOptions = 0, .deviceCap = 0, .deviceType = 5, /* takes lower byte in eeprom location */ .pwrTableOffset = AR9300_PWR_TABLE_OFFSET, .params_for_tuning_caps = {0, 0}, .featureEnable = 0x0c, /* * bit0 - enable tx temp comp - disabled * bit1 - enable tx volt comp - disabled * bit2 - enable fastClock - enabled * bit3 - enable doubling - enabled * bit4 - enable internal regulator - disabled * bit5 - enable pa predistortion - disabled */ .miscConfiguration = 0, /* bit0 - turn down drivestrength */ .eepromWriteEnableGpio = 3, .wlanDisableGpio = 0, .wlanLedGpio = 8, .rxBandSelectGpio = 0xff, .txrxgain = 0, .swreg = 0, }, .modalHeader2G = { /* ar9300_modal_eep_header 2g */ /* 4 idle,t1,t2,b(4 bits per setting) */ .antCtrlCommon = LE32(0x110), /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ .antCtrlCommon2 = LE32(0x22222), /* * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r, * rx1, rx12, b (2 bits each) */ .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) }, /* * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db * for ar9280 (0xa20c/b20c 5:0) */ .xatten1DB = {0, 0, 0}, /* * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin * for ar9280 (0xa20c/b20c 16:12 */ .xatten1Margin = {0, 0, 0}, .tempSlope = 36, .voltSlope = 0, /* * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur * channels in usual fbin coding format */ .spurChans = {0, 0, 0, 0, 0}, /* * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check * if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, .ob = {1, 1, 1},/* 3 chain */ .db_stage2 = {1, 1, 1}, /* 3 chain */ .db_stage3 = {0, 0, 0}, .db_stage4 = {0, 0, 0}, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */ .antennaGain = 0, .switchSettling = 0x2c, .adcDesiredSize = -30, .txEndToXpaOff = 0, .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, .papdRateMaskHt20 = LE32(0x0cf0e0e0), .papdRateMaskHt40 = LE32(0x6cf0e0e0), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }, .base_ext1 = { .ant_div_control = 0, .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, .calFreqPier2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1), }, /* ar9300_cal_data_per_freq_op_loop 2g */ .calPierData2G = { { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, }, .calTarget_freqbin_Cck = { FREQ2FBIN(2412, 1), FREQ2FBIN(2484, 1), }, .calTarget_freqbin_2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTarget_freqbin_2GHT20 = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTarget_freqbin_2GHT40 = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTargetPowerCck = { /* 1L-5L,5S,11L,11S */ { {36, 36, 36, 36} }, { {36, 36, 36, 36} }, }, .calTargetPower2G = { /* 6-24,36,48,54 */ { {32, 32, 28, 24} }, { {32, 32, 28, 24} }, { {32, 32, 28, 24} }, }, .calTargetPower2GHT20 = { { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} }, { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} }, { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} }, }, .calTargetPower2GHT40 = { { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} }, { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} }, { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} }, }, .ctlIndex_2G = { 0x11, 0x12, 0x15, 0x17, 0x41, 0x42, 0x45, 0x47, 0x31, 0x32, 0x35, 0x37, }, .ctl_freqbin_2G = { { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2457, 1), FREQ2FBIN(2462, 1) }, { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2462, 1), 0xFF, }, { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2462, 1), 0xFF, }, { FREQ2FBIN(2422, 1), FREQ2FBIN(2427, 1), FREQ2FBIN(2447, 1), FREQ2FBIN(2452, 1) }, { /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1), }, { /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0, }, { /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), FREQ2FBIN(2472, 1), 0, }, { /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1), /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1), /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1), /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1), }, { /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), }, { /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0 }, { /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0 }, { /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1), /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1), /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1), /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1), } }, .ctlPowerData_2G = { { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } }, }, .modalHeader5G = { /* 4 idle,t1,t2,b (4 bits per setting) */ .antCtrlCommon = LE32(0x110), /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */ .antCtrlCommon2 = LE32(0x22222), /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */ .antCtrlChain = { LE16(0x000), LE16(0x000), LE16(0x000), }, /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */ .xatten1DB = {0, 0, 0}, /* * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin * for merlin (0xa20c/b20c 16:12 */ .xatten1Margin = {0, 0, 0}, .tempSlope = 68, .voltSlope = 0, /* spurChans spur channels in usual fbin coding format */ .spurChans = {0, 0, 0, 0, 0}, /* noiseFloorThreshCh Check if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, .ob = {3, 3, 3}, /* 3 chain */ .db_stage2 = {3, 3, 3}, /* 3 chain */ .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */ .antennaGain = 0, .switchSettling = 0x2d, .adcDesiredSize = -30, .txEndToXpaOff = 0, .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, .papdRateMaskHt20 = LE32(0x0c80c080), .papdRateMaskHt40 = LE32(0x0080c080), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }, .base_ext2 = { .tempSlopeLow = 0, .tempSlopeHigh = 0, .xatten1DBLow = {0, 0, 0}, .xatten1MarginLow = {0, 0, 0}, .xatten1DBHigh = {0, 0, 0}, .xatten1MarginHigh = {0, 0, 0} }, .calFreqPier5G = { FREQ2FBIN(5180, 0), FREQ2FBIN(5220, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5725, 0), FREQ2FBIN(5825, 0) }, .calPierData5G = { { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, }, .calTarget_freqbin_5G = { FREQ2FBIN(5180, 0), FREQ2FBIN(5220, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5725, 0), FREQ2FBIN(5825, 0) }, .calTarget_freqbin_5GHT20 = { FREQ2FBIN(5180, 0), FREQ2FBIN(5240, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5745, 0), FREQ2FBIN(5725, 0), FREQ2FBIN(5825, 0) }, .calTarget_freqbin_5GHT40 = { FREQ2FBIN(5180, 0), FREQ2FBIN(5240, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5745, 0), FREQ2FBIN(5725, 0), FREQ2FBIN(5825, 0) }, .calTargetPower5G = { /* 6-24,36,48,54 */ { {20, 20, 20, 10} }, { {20, 20, 20, 10} }, { {20, 20, 20, 10} }, { {20, 20, 20, 10} }, { {20, 20, 20, 10} }, { {20, 20, 20, 10} }, { {20, 20, 20, 10} }, { {20, 20, 20, 10} }, }, .calTargetPower5GHT20 = { /* * 0_8_16,1-3_9-11_17-19, * 4,5,6,7,12,13,14,15,20,21,22,23 */ { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, }, .calTargetPower5GHT40 = { /* * 0_8_16,1-3_9-11_17-19, * 4,5,6,7,12,13,14,15,20,21,22,23 */ { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} }, }, .ctlIndex_5G = { 0x10, 0x16, 0x18, 0x40, 0x46, 0x48, 0x30, 0x36, 0x38 }, .ctl_freqbin_5G = { { /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0), /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0), /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0), /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0), /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0), /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0), /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0), /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0), /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0), /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0), /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0) }, { /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0), /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0), /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0), /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0), /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[3].ctlEdges[6].bChannel */ 0xFF, /* Data[3].ctlEdges[7].bChannel */ 0xFF, }, { /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0), /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0), /* Data[4].ctlEdges[4].bChannel */ 0xFF, /* Data[4].ctlEdges[5].bChannel */ 0xFF, /* Data[4].ctlEdges[6].bChannel */ 0xFF, /* Data[4].ctlEdges[7].bChannel */ 0xFF, }, { /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0), /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0), /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0), /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0), /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0), /* Data[5].ctlEdges[6].bChannel */ 0xFF, /* Data[5].ctlEdges[7].bChannel */ 0xFF }, { /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0), /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0), /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0), /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0), /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0), /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0), /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0) }, { /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0), /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0), /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0), /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0), /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0), /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0), /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0), /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0), /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0) } }, .ctlPowerData_5G = { { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), } }, } }; static const struct ar9300_eeprom ar9300_x113 = { .eepromVersion = 2, .templateVersion = 6, .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0}, .custData = {"x113-023-f0000"}, .baseEepHeader = { .regDmn = { LE16(0), LE16(0x1f) }, .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */ .opCapFlags = { .opFlags = AR5416_OPFLAGS_11A, .eepMisc = 0, }, .rfSilent = 0, .blueToothOptions = 0, .deviceCap = 0, .deviceType = 5, /* takes lower byte in eeprom location */ .pwrTableOffset = AR9300_PWR_TABLE_OFFSET, .params_for_tuning_caps = {0, 0}, .featureEnable = 0x0d, /* * bit0 - enable tx temp comp - disabled * bit1 - enable tx volt comp - disabled * bit2 - enable fastClock - enabled * bit3 - enable doubling - enabled * bit4 - enable internal regulator - disabled * bit5 - enable pa predistortion - disabled */ .miscConfiguration = 0, /* bit0 - turn down drivestrength */ .eepromWriteEnableGpio = 6, .wlanDisableGpio = 0, .wlanLedGpio = 8, .rxBandSelectGpio = 0xff, .txrxgain = 0x21, .swreg = 0, }, .modalHeader2G = { /* ar9300_modal_eep_header 2g */ /* 4 idle,t1,t2,b(4 bits per setting) */ .antCtrlCommon = LE32(0x110), /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ .antCtrlCommon2 = LE32(0x44444), /* * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r, * rx1, rx12, b (2 bits each) */ .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) }, /* * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db * for ar9280 (0xa20c/b20c 5:0) */ .xatten1DB = {0, 0, 0}, /* * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin * for ar9280 (0xa20c/b20c 16:12 */ .xatten1Margin = {0, 0, 0}, .tempSlope = 25, .voltSlope = 0, /* * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur * channels in usual fbin coding format */ .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0}, /* * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check * if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, .ob = {1, 1, 1},/* 3 chain */ .db_stage2 = {1, 1, 1}, /* 3 chain */ .db_stage3 = {0, 0, 0}, .db_stage4 = {0, 0, 0}, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */ .antennaGain = 0, .switchSettling = 0x2c, .adcDesiredSize = -30, .txEndToXpaOff = 0, .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, .papdRateMaskHt20 = LE32(0x0c80c080), .papdRateMaskHt40 = LE32(0x0080c080), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }, .base_ext1 = { .ant_div_control = 0, .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, .calFreqPier2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1), }, /* ar9300_cal_data_per_freq_op_loop 2g */ .calPierData2G = { { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, }, .calTarget_freqbin_Cck = { FREQ2FBIN(2412, 1), FREQ2FBIN(2472, 1), }, .calTarget_freqbin_2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTarget_freqbin_2GHT20 = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTarget_freqbin_2GHT40 = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTargetPowerCck = { /* 1L-5L,5S,11L,11S */ { {34, 34, 34, 34} }, { {34, 34, 34, 34} }, }, .calTargetPower2G = { /* 6-24,36,48,54 */ { {34, 34, 32, 32} }, { {34, 34, 32, 32} }, { {34, 34, 32, 32} }, }, .calTargetPower2GHT20 = { { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} }, { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} }, { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} }, }, .calTargetPower2GHT40 = { { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} }, { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} }, { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} }, }, .ctlIndex_2G = { 0x11, 0x12, 0x15, 0x17, 0x41, 0x42, 0x45, 0x47, 0x31, 0x32, 0x35, 0x37, }, .ctl_freqbin_2G = { { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2457, 1), FREQ2FBIN(2462, 1) }, { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2462, 1), 0xFF, }, { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2462, 1), 0xFF, }, { FREQ2FBIN(2422, 1), FREQ2FBIN(2427, 1), FREQ2FBIN(2447, 1), FREQ2FBIN(2452, 1) }, { /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1), }, { /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0, }, { /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), FREQ2FBIN(2472, 1), 0, }, { /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1), /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1), /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1), /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1), }, { /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), }, { /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0 }, { /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0 }, { /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1), /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1), /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1), /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1), } }, .ctlPowerData_2G = { { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } }, }, .modalHeader5G = { /* 4 idle,t1,t2,b (4 bits per setting) */ .antCtrlCommon = LE32(0x220), /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */ .antCtrlCommon2 = LE32(0x11111), /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */ .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150), }, /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */ .xatten1DB = {0, 0, 0}, /* * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin * for merlin (0xa20c/b20c 16:12 */ .xatten1Margin = {0, 0, 0}, .tempSlope = 68, .voltSlope = 0, /* spurChans spur channels in usual fbin coding format */ .spurChans = {FREQ2FBIN(5500, 0), 0, 0, 0, 0}, /* noiseFloorThreshCh Check if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, .ob = {3, 3, 3}, /* 3 chain */ .db_stage2 = {3, 3, 3}, /* 3 chain */ .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ .xpaBiasLvl = 0xf, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */ .antennaGain = 0, .switchSettling = 0x2d, .adcDesiredSize = -30, .txEndToXpaOff = 0, .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, .papdRateMaskHt20 = LE32(0x0cf0e0e0), .papdRateMaskHt40 = LE32(0x6cf0e0e0), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }, .base_ext2 = { .tempSlopeLow = 72, .tempSlopeHigh = 105, .xatten1DBLow = {0, 0, 0}, .xatten1MarginLow = {0, 0, 0}, .xatten1DBHigh = {0, 0, 0}, .xatten1MarginHigh = {0, 0, 0} }, .calFreqPier5G = { FREQ2FBIN(5180, 0), FREQ2FBIN(5240, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5745, 0), FREQ2FBIN(5785, 0) }, .calPierData5G = { { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, }, .calTarget_freqbin_5G = { FREQ2FBIN(5180, 0), FREQ2FBIN(5220, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5745, 0), FREQ2FBIN(5785, 0) }, .calTarget_freqbin_5GHT20 = { FREQ2FBIN(5180, 0), FREQ2FBIN(5240, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5745, 0), FREQ2FBIN(5825, 0) }, .calTarget_freqbin_5GHT40 = { FREQ2FBIN(5190, 0), FREQ2FBIN(5230, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5410, 0), FREQ2FBIN(5510, 0), FREQ2FBIN(5670, 0), FREQ2FBIN(5755, 0), FREQ2FBIN(5825, 0) }, .calTargetPower5G = { /* 6-24,36,48,54 */ { {42, 40, 40, 34} }, { {42, 40, 40, 34} }, { {42, 40, 40, 34} }, { {42, 40, 40, 34} }, { {42, 40, 40, 34} }, { {42, 40, 40, 34} }, { {42, 40, 40, 34} }, { {42, 40, 40, 34} }, }, .calTargetPower5GHT20 = { /* * 0_8_16,1-3_9-11_17-19, * 4,5,6,7,12,13,14,15,20,21,22,23 */ { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} }, { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} }, { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} }, { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} }, { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} }, { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} }, { {38, 38, 38, 38, 32, 28, 38, 38, 32, 28, 38, 38, 32, 26} }, { {36, 36, 36, 36, 32, 28, 36, 36, 32, 28, 36, 36, 32, 26} }, }, .calTargetPower5GHT40 = { /* * 0_8_16,1-3_9-11_17-19, * 4,5,6,7,12,13,14,15,20,21,22,23 */ { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} }, { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} }, { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} }, { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} }, { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} }, { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} }, { {36, 36, 36, 36, 30, 26, 36, 36, 30, 26, 36, 36, 30, 24} }, { {34, 34, 34, 34, 30, 26, 34, 34, 30, 26, 34, 34, 30, 24} }, }, .ctlIndex_5G = { 0x10, 0x16, 0x18, 0x40, 0x46, 0x48, 0x30, 0x36, 0x38 }, .ctl_freqbin_5G = { { /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0), /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0), /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0), /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0), /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0), /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0), /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0), /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0), /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0), /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0), /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0) }, { /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0), /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0), /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0), /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0), /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[3].ctlEdges[6].bChannel */ 0xFF, /* Data[3].ctlEdges[7].bChannel */ 0xFF, }, { /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0), /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0), /* Data[4].ctlEdges[4].bChannel */ 0xFF, /* Data[4].ctlEdges[5].bChannel */ 0xFF, /* Data[4].ctlEdges[6].bChannel */ 0xFF, /* Data[4].ctlEdges[7].bChannel */ 0xFF, }, { /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0), /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0), /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0), /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0), /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0), /* Data[5].ctlEdges[6].bChannel */ 0xFF, /* Data[5].ctlEdges[7].bChannel */ 0xFF }, { /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0), /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0), /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0), /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0), /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0), /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0), /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0) }, { /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0), /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0), /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0), /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0), /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0), /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0), /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0), /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0), /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0) } }, .ctlPowerData_5G = { { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), } }, } }; static const struct ar9300_eeprom ar9300_h112 = { .eepromVersion = 2, .templateVersion = 3, .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0}, .custData = {"h112-241-f0000"}, .baseEepHeader = { .regDmn = { LE16(0), LE16(0x1f) }, .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */ .opCapFlags = { .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A, .eepMisc = 0, }, .rfSilent = 0, .blueToothOptions = 0, .deviceCap = 0, .deviceType = 5, /* takes lower byte in eeprom location */ .pwrTableOffset = AR9300_PWR_TABLE_OFFSET, .params_for_tuning_caps = {0, 0}, .featureEnable = 0x0d, /* * bit0 - enable tx temp comp - disabled * bit1 - enable tx volt comp - disabled * bit2 - enable fastClock - enabled * bit3 - enable doubling - enabled * bit4 - enable internal regulator - disabled * bit5 - enable pa predistortion - disabled */ .miscConfiguration = 0, /* bit0 - turn down drivestrength */ .eepromWriteEnableGpio = 6, .wlanDisableGpio = 0, .wlanLedGpio = 8, .rxBandSelectGpio = 0xff, .txrxgain = 0x10, .swreg = 0, }, .modalHeader2G = { /* ar9300_modal_eep_header 2g */ /* 4 idle,t1,t2,b(4 bits per setting) */ .antCtrlCommon = LE32(0x110), /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ .antCtrlCommon2 = LE32(0x44444), /* * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r, * rx1, rx12, b (2 bits each) */ .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) }, /* * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db * for ar9280 (0xa20c/b20c 5:0) */ .xatten1DB = {0, 0, 0}, /* * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin * for ar9280 (0xa20c/b20c 16:12 */ .xatten1Margin = {0, 0, 0}, .tempSlope = 25, .voltSlope = 0, /* * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur * channels in usual fbin coding format */ .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0}, /* * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check * if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, .ob = {1, 1, 1},/* 3 chain */ .db_stage2 = {1, 1, 1}, /* 3 chain */ .db_stage3 = {0, 0, 0}, .db_stage4 = {0, 0, 0}, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */ .antennaGain = 0, .switchSettling = 0x2c, .adcDesiredSize = -30, .txEndToXpaOff = 0, .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, .papdRateMaskHt20 = LE32(0x80c080), .papdRateMaskHt40 = LE32(0x80c080), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }, .base_ext1 = { .ant_div_control = 0, .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, .calFreqPier2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1), }, /* ar9300_cal_data_per_freq_op_loop 2g */ .calPierData2G = { { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, }, .calTarget_freqbin_Cck = { FREQ2FBIN(2412, 1), FREQ2FBIN(2484, 1), }, .calTarget_freqbin_2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTarget_freqbin_2GHT20 = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTarget_freqbin_2GHT40 = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTargetPowerCck = { /* 1L-5L,5S,11L,11S */ { {34, 34, 34, 34} }, { {34, 34, 34, 34} }, }, .calTargetPower2G = { /* 6-24,36,48,54 */ { {34, 34, 32, 32} }, { {34, 34, 32, 32} }, { {34, 34, 32, 32} }, }, .calTargetPower2GHT20 = { { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} }, { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} }, { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} }, }, .calTargetPower2GHT40 = { { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} }, { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} }, { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} }, }, .ctlIndex_2G = { 0x11, 0x12, 0x15, 0x17, 0x41, 0x42, 0x45, 0x47, 0x31, 0x32, 0x35, 0x37, }, .ctl_freqbin_2G = { { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2457, 1), FREQ2FBIN(2462, 1) }, { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2462, 1), 0xFF, }, { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2462, 1), 0xFF, }, { FREQ2FBIN(2422, 1), FREQ2FBIN(2427, 1), FREQ2FBIN(2447, 1), FREQ2FBIN(2452, 1) }, { /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1), }, { /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0, }, { /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), FREQ2FBIN(2472, 1), 0, }, { /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1), /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1), /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1), /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1), }, { /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), }, { /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0 }, { /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0 }, { /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1), /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1), /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1), /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1), } }, .ctlPowerData_2G = { { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } }, }, .modalHeader5G = { /* 4 idle,t1,t2,b (4 bits per setting) */ .antCtrlCommon = LE32(0x220), /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */ .antCtrlCommon2 = LE32(0x44444), /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */ .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150), }, /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */ .xatten1DB = {0, 0, 0}, /* * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin * for merlin (0xa20c/b20c 16:12 */ .xatten1Margin = {0, 0, 0}, .tempSlope = 45, .voltSlope = 0, /* spurChans spur channels in usual fbin coding format */ .spurChans = {0, 0, 0, 0, 0}, /* noiseFloorThreshCh Check if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, .ob = {3, 3, 3}, /* 3 chain */ .db_stage2 = {3, 3, 3}, /* 3 chain */ .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */ .antennaGain = 0, .switchSettling = 0x2d, .adcDesiredSize = -30, .txEndToXpaOff = 0, .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, .papdRateMaskHt20 = LE32(0x0cf0e0e0), .papdRateMaskHt40 = LE32(0x6cf0e0e0), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }, .base_ext2 = { .tempSlopeLow = 40, .tempSlopeHigh = 50, .xatten1DBLow = {0, 0, 0}, .xatten1MarginLow = {0, 0, 0}, .xatten1DBHigh = {0, 0, 0}, .xatten1MarginHigh = {0, 0, 0} }, .calFreqPier5G = { FREQ2FBIN(5180, 0), FREQ2FBIN(5220, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5825, 0) }, .calPierData5G = { { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, }, .calTarget_freqbin_5G = { FREQ2FBIN(5180, 0), FREQ2FBIN(5240, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5825, 0) }, .calTarget_freqbin_5GHT20 = { FREQ2FBIN(5180, 0), FREQ2FBIN(5240, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5745, 0), FREQ2FBIN(5825, 0) }, .calTarget_freqbin_5GHT40 = { FREQ2FBIN(5180, 0), FREQ2FBIN(5240, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5745, 0), FREQ2FBIN(5825, 0) }, .calTargetPower5G = { /* 6-24,36,48,54 */ { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, }, .calTargetPower5GHT20 = { /* * 0_8_16,1-3_9-11_17-19, * 4,5,6,7,12,13,14,15,20,21,22,23 */ { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} }, { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} }, { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} }, { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} }, { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} }, { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} }, { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} }, { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} }, }, .calTargetPower5GHT40 = { /* * 0_8_16,1-3_9-11_17-19, * 4,5,6,7,12,13,14,15,20,21,22,23 */ { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} }, { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} }, { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} }, { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} }, { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} }, { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} }, { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} }, { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} }, }, .ctlIndex_5G = { 0x10, 0x16, 0x18, 0x40, 0x46, 0x48, 0x30, 0x36, 0x38 }, .ctl_freqbin_5G = { { /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0), /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0), /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0), /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0), /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0), /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0), /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0), /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0), /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0), /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0), /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0) }, { /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0), /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0), /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0), /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0), /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[3].ctlEdges[6].bChannel */ 0xFF, /* Data[3].ctlEdges[7].bChannel */ 0xFF, }, { /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0), /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0), /* Data[4].ctlEdges[4].bChannel */ 0xFF, /* Data[4].ctlEdges[5].bChannel */ 0xFF, /* Data[4].ctlEdges[6].bChannel */ 0xFF, /* Data[4].ctlEdges[7].bChannel */ 0xFF, }, { /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0), /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0), /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0), /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0), /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0), /* Data[5].ctlEdges[6].bChannel */ 0xFF, /* Data[5].ctlEdges[7].bChannel */ 0xFF }, { /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0), /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0), /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0), /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0), /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0), /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0), /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0) }, { /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0), /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0), /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0), /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0), /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0), /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0), /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0), /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0), /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0) } }, .ctlPowerData_5G = { { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), } }, } }; static const struct ar9300_eeprom ar9300_x112 = { .eepromVersion = 2, .templateVersion = 5, .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0}, .custData = {"x112-041-f0000"}, .baseEepHeader = { .regDmn = { LE16(0), LE16(0x1f) }, .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */ .opCapFlags = { .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A, .eepMisc = 0, }, .rfSilent = 0, .blueToothOptions = 0, .deviceCap = 0, .deviceType = 5, /* takes lower byte in eeprom location */ .pwrTableOffset = AR9300_PWR_TABLE_OFFSET, .params_for_tuning_caps = {0, 0}, .featureEnable = 0x0d, /* * bit0 - enable tx temp comp - disabled * bit1 - enable tx volt comp - disabled * bit2 - enable fastclock - enabled * bit3 - enable doubling - enabled * bit4 - enable internal regulator - disabled * bit5 - enable pa predistortion - disabled */ .miscConfiguration = 0, /* bit0 - turn down drivestrength */ .eepromWriteEnableGpio = 6, .wlanDisableGpio = 0, .wlanLedGpio = 8, .rxBandSelectGpio = 0xff, .txrxgain = 0x0, .swreg = 0, }, .modalHeader2G = { /* ar9300_modal_eep_header 2g */ /* 4 idle,t1,t2,b(4 bits per setting) */ .antCtrlCommon = LE32(0x110), /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ .antCtrlCommon2 = LE32(0x22222), /* * antCtrlChain[ar9300_max_chains]; 6 idle, t, r, * rx1, rx12, b (2 bits each) */ .antCtrlChain = { LE16(0x10), LE16(0x10), LE16(0x10) }, /* * xatten1DB[AR9300_max_chains]; 3 xatten1_db * for ar9280 (0xa20c/b20c 5:0) */ .xatten1DB = {0x1b, 0x1b, 0x1b}, /* * xatten1Margin[ar9300_max_chains]; 3 xatten1_margin * for ar9280 (0xa20c/b20c 16:12 */ .xatten1Margin = {0x15, 0x15, 0x15}, .tempSlope = 50, .voltSlope = 0, /* * spurChans[OSPrey_eeprom_modal_sPURS]; spur * channels in usual fbin coding format */ .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0}, /* * noiseFloorThreshch[ar9300_max_cHAINS]; 3 Check * if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, .ob = {1, 1, 1},/* 3 chain */ .db_stage2 = {1, 1, 1}, /* 3 chain */ .db_stage3 = {0, 0, 0}, .db_stage4 = {0, 0, 0}, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */ .antennaGain = 0, .switchSettling = 0x2c, .adcDesiredSize = -30, .txEndToXpaOff = 0, .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, .papdRateMaskHt20 = LE32(0x0c80c080), .papdRateMaskHt40 = LE32(0x0080c080), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }, .base_ext1 = { .ant_div_control = 0, .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, .calFreqPier2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1), }, /* ar9300_cal_data_per_freq_op_loop 2g */ .calPierData2G = { { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, }, .calTarget_freqbin_Cck = { FREQ2FBIN(2412, 1), FREQ2FBIN(2472, 1), }, .calTarget_freqbin_2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTarget_freqbin_2GHT20 = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTarget_freqbin_2GHT40 = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTargetPowerCck = { /* 1L-5L,5S,11L,11s */ { {38, 38, 38, 38} }, { {38, 38, 38, 38} }, }, .calTargetPower2G = { /* 6-24,36,48,54 */ { {38, 38, 36, 34} }, { {38, 38, 36, 34} }, { {38, 38, 34, 32} }, }, .calTargetPower2GHT20 = { { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} }, { {36, 36, 36, 36, 36, 34, 36, 34, 32, 30, 30, 30, 28, 26} }, { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} }, }, .calTargetPower2GHT40 = { { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} }, { {36, 36, 36, 36, 34, 32, 34, 32, 30, 28, 28, 28, 28, 24} }, { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} }, }, .ctlIndex_2G = { 0x11, 0x12, 0x15, 0x17, 0x41, 0x42, 0x45, 0x47, 0x31, 0x32, 0x35, 0x37, }, .ctl_freqbin_2G = { { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2457, 1), FREQ2FBIN(2462, 1) }, { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2462, 1), 0xFF, }, { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2462, 1), 0xFF, }, { FREQ2FBIN(2422, 1), FREQ2FBIN(2427, 1), FREQ2FBIN(2447, 1), FREQ2FBIN(2452, 1) }, { /* Data[4].ctledges[0].bchannel */ FREQ2FBIN(2412, 1), /* Data[4].ctledges[1].bchannel */ FREQ2FBIN(2417, 1), /* Data[4].ctledges[2].bchannel */ FREQ2FBIN(2472, 1), /* Data[4].ctledges[3].bchannel */ FREQ2FBIN(2484, 1), }, { /* Data[5].ctledges[0].bchannel */ FREQ2FBIN(2412, 1), /* Data[5].ctledges[1].bchannel */ FREQ2FBIN(2417, 1), /* Data[5].ctledges[2].bchannel */ FREQ2FBIN(2472, 1), 0, }, { /* Data[6].ctledges[0].bchannel */ FREQ2FBIN(2412, 1), /* Data[6].ctledges[1].bchannel */ FREQ2FBIN(2417, 1), FREQ2FBIN(2472, 1), 0, }, { /* Data[7].ctledges[0].bchannel */ FREQ2FBIN(2422, 1), /* Data[7].ctledges[1].bchannel */ FREQ2FBIN(2427, 1), /* Data[7].ctledges[2].bchannel */ FREQ2FBIN(2447, 1), /* Data[7].ctledges[3].bchannel */ FREQ2FBIN(2462, 1), }, { /* Data[8].ctledges[0].bchannel */ FREQ2FBIN(2412, 1), /* Data[8].ctledges[1].bchannel */ FREQ2FBIN(2417, 1), /* Data[8].ctledges[2].bchannel */ FREQ2FBIN(2472, 1), }, { /* Data[9].ctledges[0].bchannel */ FREQ2FBIN(2412, 1), /* Data[9].ctledges[1].bchannel */ FREQ2FBIN(2417, 1), /* Data[9].ctledges[2].bchannel */ FREQ2FBIN(2472, 1), 0 }, { /* Data[10].ctledges[0].bchannel */ FREQ2FBIN(2412, 1), /* Data[10].ctledges[1].bchannel */ FREQ2FBIN(2417, 1), /* Data[10].ctledges[2].bchannel */ FREQ2FBIN(2472, 1), 0 }, { /* Data[11].ctledges[0].bchannel */ FREQ2FBIN(2422, 1), /* Data[11].ctledges[1].bchannel */ FREQ2FBIN(2427, 1), /* Data[11].ctledges[2].bchannel */ FREQ2FBIN(2447, 1), /* Data[11].ctledges[3].bchannel */ FREQ2FBIN(2462, 1), } }, .ctlPowerData_2G = { { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } }, }, .modalHeader5G = { /* 4 idle,t1,t2,b (4 bits per setting) */ .antCtrlCommon = LE32(0x110), /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */ .antCtrlCommon2 = LE32(0x22222), /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */ .antCtrlChain = { LE16(0x0), LE16(0x0), LE16(0x0), }, /* xatten1DB 3 xatten1_db for ar9280 (0xa20c/b20c 5:0) */ .xatten1DB = {0x13, 0x19, 0x17}, /* * xatten1Margin[ar9300_max_chains]; 3 xatten1_margin * for merlin (0xa20c/b20c 16:12 */ .xatten1Margin = {0x19, 0x19, 0x19}, .tempSlope = 70, .voltSlope = 15, /* spurChans spur channels in usual fbin coding format */ .spurChans = {0, 0, 0, 0, 0}, /* noiseFloorThreshch check if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, .ob = {3, 3, 3}, /* 3 chain */ .db_stage2 = {3, 3, 3}, /* 3 chain */ .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */ .antennaGain = 0, .switchSettling = 0x2d, .adcDesiredSize = -30, .txEndToXpaOff = 0, .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, .papdRateMaskHt20 = LE32(0x0cf0e0e0), .papdRateMaskHt40 = LE32(0x6cf0e0e0), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }, .base_ext2 = { .tempSlopeLow = 72, .tempSlopeHigh = 105, .xatten1DBLow = {0x10, 0x14, 0x10}, .xatten1MarginLow = {0x19, 0x19 , 0x19}, .xatten1DBHigh = {0x1d, 0x20, 0x24}, .xatten1MarginHigh = {0x10, 0x10, 0x10} }, .calFreqPier5G = { FREQ2FBIN(5180, 0), FREQ2FBIN(5220, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5785, 0) }, .calPierData5G = { { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, }, .calTarget_freqbin_5G = { FREQ2FBIN(5180, 0), FREQ2FBIN(5220, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5725, 0), FREQ2FBIN(5825, 0) }, .calTarget_freqbin_5GHT20 = { FREQ2FBIN(5180, 0), FREQ2FBIN(5220, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5725, 0), FREQ2FBIN(5825, 0) }, .calTarget_freqbin_5GHT40 = { FREQ2FBIN(5180, 0), FREQ2FBIN(5220, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5725, 0), FREQ2FBIN(5825, 0) }, .calTargetPower5G = { /* 6-24,36,48,54 */ { {32, 32, 28, 26} }, { {32, 32, 28, 26} }, { {32, 32, 28, 26} }, { {32, 32, 26, 24} }, { {32, 32, 26, 24} }, { {32, 32, 24, 22} }, { {30, 30, 24, 22} }, { {30, 30, 24, 22} }, }, .calTargetPower5GHT20 = { /* * 0_8_16,1-3_9-11_17-19, * 4,5,6,7,12,13,14,15,20,21,22,23 */ { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} }, { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} }, { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} }, { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 22, 22, 20, 20} }, { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 20, 18, 16, 16} }, { {32, 32, 32, 32, 28, 26, 32, 24, 20, 16, 18, 16, 14, 14} }, { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} }, { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} }, }, .calTargetPower5GHT40 = { /* * 0_8_16,1-3_9-11_17-19, * 4,5,6,7,12,13,14,15,20,21,22,23 */ { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} }, { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} }, { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} }, { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 22, 22, 20, 20} }, { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 20, 18, 16, 16} }, { {32, 32, 32, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} }, { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} }, { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} }, }, .ctlIndex_5G = { 0x10, 0x16, 0x18, 0x40, 0x46, 0x48, 0x30, 0x36, 0x38 }, .ctl_freqbin_5G = { { /* Data[0].ctledges[0].bchannel */ FREQ2FBIN(5180, 0), /* Data[0].ctledges[1].bchannel */ FREQ2FBIN(5260, 0), /* Data[0].ctledges[2].bchannel */ FREQ2FBIN(5280, 0), /* Data[0].ctledges[3].bchannel */ FREQ2FBIN(5500, 0), /* Data[0].ctledges[4].bchannel */ FREQ2FBIN(5600, 0), /* Data[0].ctledges[5].bchannel */ FREQ2FBIN(5700, 0), /* Data[0].ctledges[6].bchannel */ FREQ2FBIN(5745, 0), /* Data[0].ctledges[7].bchannel */ FREQ2FBIN(5825, 0) }, { /* Data[1].ctledges[0].bchannel */ FREQ2FBIN(5180, 0), /* Data[1].ctledges[1].bchannel */ FREQ2FBIN(5260, 0), /* Data[1].ctledges[2].bchannel */ FREQ2FBIN(5280, 0), /* Data[1].ctledges[3].bchannel */ FREQ2FBIN(5500, 0), /* Data[1].ctledges[4].bchannel */ FREQ2FBIN(5520, 0), /* Data[1].ctledges[5].bchannel */ FREQ2FBIN(5700, 0), /* Data[1].ctledges[6].bchannel */ FREQ2FBIN(5745, 0), /* Data[1].ctledges[7].bchannel */ FREQ2FBIN(5825, 0) }, { /* Data[2].ctledges[0].bchannel */ FREQ2FBIN(5190, 0), /* Data[2].ctledges[1].bchannel */ FREQ2FBIN(5230, 0), /* Data[2].ctledges[2].bchannel */ FREQ2FBIN(5270, 0), /* Data[2].ctledges[3].bchannel */ FREQ2FBIN(5310, 0), /* Data[2].ctledges[4].bchannel */ FREQ2FBIN(5510, 0), /* Data[2].ctledges[5].bchannel */ FREQ2FBIN(5550, 0), /* Data[2].ctledges[6].bchannel */ FREQ2FBIN(5670, 0), /* Data[2].ctledges[7].bchannel */ FREQ2FBIN(5755, 0) }, { /* Data[3].ctledges[0].bchannel */ FREQ2FBIN(5180, 0), /* Data[3].ctledges[1].bchannel */ FREQ2FBIN(5200, 0), /* Data[3].ctledges[2].bchannel */ FREQ2FBIN(5260, 0), /* Data[3].ctledges[3].bchannel */ FREQ2FBIN(5320, 0), /* Data[3].ctledges[4].bchannel */ FREQ2FBIN(5500, 0), /* Data[3].ctledges[5].bchannel */ FREQ2FBIN(5700, 0), /* Data[3].ctledges[6].bchannel */ 0xFF, /* Data[3].ctledges[7].bchannel */ 0xFF, }, { /* Data[4].ctledges[0].bchannel */ FREQ2FBIN(5180, 0), /* Data[4].ctledges[1].bchannel */ FREQ2FBIN(5260, 0), /* Data[4].ctledges[2].bchannel */ FREQ2FBIN(5500, 0), /* Data[4].ctledges[3].bchannel */ FREQ2FBIN(5700, 0), /* Data[4].ctledges[4].bchannel */ 0xFF, /* Data[4].ctledges[5].bchannel */ 0xFF, /* Data[4].ctledges[6].bchannel */ 0xFF, /* Data[4].ctledges[7].bchannel */ 0xFF, }, { /* Data[5].ctledges[0].bchannel */ FREQ2FBIN(5190, 0), /* Data[5].ctledges[1].bchannel */ FREQ2FBIN(5270, 0), /* Data[5].ctledges[2].bchannel */ FREQ2FBIN(5310, 0), /* Data[5].ctledges[3].bchannel */ FREQ2FBIN(5510, 0), /* Data[5].ctledges[4].bchannel */ FREQ2FBIN(5590, 0), /* Data[5].ctledges[5].bchannel */ FREQ2FBIN(5670, 0), /* Data[5].ctledges[6].bchannel */ 0xFF, /* Data[5].ctledges[7].bchannel */ 0xFF }, { /* Data[6].ctledges[0].bchannel */ FREQ2FBIN(5180, 0), /* Data[6].ctledges[1].bchannel */ FREQ2FBIN(5200, 0), /* Data[6].ctledges[2].bchannel */ FREQ2FBIN(5220, 0), /* Data[6].ctledges[3].bchannel */ FREQ2FBIN(5260, 0), /* Data[6].ctledges[4].bchannel */ FREQ2FBIN(5500, 0), /* Data[6].ctledges[5].bchannel */ FREQ2FBIN(5600, 0), /* Data[6].ctledges[6].bchannel */ FREQ2FBIN(5700, 0), /* Data[6].ctledges[7].bchannel */ FREQ2FBIN(5745, 0) }, { /* Data[7].ctledges[0].bchannel */ FREQ2FBIN(5180, 0), /* Data[7].ctledges[1].bchannel */ FREQ2FBIN(5260, 0), /* Data[7].ctledges[2].bchannel */ FREQ2FBIN(5320, 0), /* Data[7].ctledges[3].bchannel */ FREQ2FBIN(5500, 0), /* Data[7].ctledges[4].bchannel */ FREQ2FBIN(5560, 0), /* Data[7].ctledges[5].bchannel */ FREQ2FBIN(5700, 0), /* Data[7].ctledges[6].bchannel */ FREQ2FBIN(5745, 0), /* Data[7].ctledges[7].bchannel */ FREQ2FBIN(5825, 0) }, { /* Data[8].ctledges[0].bchannel */ FREQ2FBIN(5190, 0), /* Data[8].ctledges[1].bchannel */ FREQ2FBIN(5230, 0), /* Data[8].ctledges[2].bchannel */ FREQ2FBIN(5270, 0), /* Data[8].ctledges[3].bchannel */ FREQ2FBIN(5510, 0), /* Data[8].ctledges[4].bchannel */ FREQ2FBIN(5550, 0), /* Data[8].ctledges[5].bchannel */ FREQ2FBIN(5670, 0), /* Data[8].ctledges[6].bchannel */ FREQ2FBIN(5755, 0), /* Data[8].ctledges[7].bchannel */ FREQ2FBIN(5795, 0) } }, .ctlPowerData_5G = { { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), } }, } }; static const struct ar9300_eeprom ar9300_h116 = { .eepromVersion = 2, .templateVersion = 4, .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0}, .custData = {"h116-041-f0000"}, .baseEepHeader = { .regDmn = { LE16(0), LE16(0x1f) }, .txrxMask = 0x33, /* 4 bits tx and 4 bits rx */ .opCapFlags = { .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A, .eepMisc = 0, }, .rfSilent = 0, .blueToothOptions = 0, .deviceCap = 0, .deviceType = 5, /* takes lower byte in eeprom location */ .pwrTableOffset = AR9300_PWR_TABLE_OFFSET, .params_for_tuning_caps = {0, 0}, .featureEnable = 0x0d, /* * bit0 - enable tx temp comp - disabled * bit1 - enable tx volt comp - disabled * bit2 - enable fastClock - enabled * bit3 - enable doubling - enabled * bit4 - enable internal regulator - disabled * bit5 - enable pa predistortion - disabled */ .miscConfiguration = 0, /* bit0 - turn down drivestrength */ .eepromWriteEnableGpio = 6, .wlanDisableGpio = 0, .wlanLedGpio = 8, .rxBandSelectGpio = 0xff, .txrxgain = 0x10, .swreg = 0, }, .modalHeader2G = { /* ar9300_modal_eep_header 2g */ /* 4 idle,t1,t2,b(4 bits per setting) */ .antCtrlCommon = LE32(0x110), /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ .antCtrlCommon2 = LE32(0x44444), /* * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r, * rx1, rx12, b (2 bits each) */ .antCtrlChain = { LE16(0x10), LE16(0x10), LE16(0x10) }, /* * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db * for ar9280 (0xa20c/b20c 5:0) */ .xatten1DB = {0x1f, 0x1f, 0x1f}, /* * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin * for ar9280 (0xa20c/b20c 16:12 */ .xatten1Margin = {0x12, 0x12, 0x12}, .tempSlope = 25, .voltSlope = 0, /* * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur * channels in usual fbin coding format */ .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0}, /* * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check * if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, .ob = {1, 1, 1},/* 3 chain */ .db_stage2 = {1, 1, 1}, /* 3 chain */ .db_stage3 = {0, 0, 0}, .db_stage4 = {0, 0, 0}, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */ .antennaGain = 0, .switchSettling = 0x2c, .adcDesiredSize = -30, .txEndToXpaOff = 0, .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, .papdRateMaskHt20 = LE32(0x0c80C080), .papdRateMaskHt40 = LE32(0x0080C080), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }, .base_ext1 = { .ant_div_control = 0, .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, .calFreqPier2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1), }, /* ar9300_cal_data_per_freq_op_loop 2g */ .calPierData2G = { { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }, }, .calTarget_freqbin_Cck = { FREQ2FBIN(2412, 1), FREQ2FBIN(2472, 1), }, .calTarget_freqbin_2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTarget_freqbin_2GHT20 = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTarget_freqbin_2GHT40 = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), FREQ2FBIN(2472, 1) }, .calTargetPowerCck = { /* 1L-5L,5S,11L,11S */ { {34, 34, 34, 34} }, { {34, 34, 34, 34} }, }, .calTargetPower2G = { /* 6-24,36,48,54 */ { {34, 34, 32, 32} }, { {34, 34, 32, 32} }, { {34, 34, 32, 32} }, }, .calTargetPower2GHT20 = { { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} }, { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} }, { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} }, }, .calTargetPower2GHT40 = { { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} }, { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} }, { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} }, }, .ctlIndex_2G = { 0x11, 0x12, 0x15, 0x17, 0x41, 0x42, 0x45, 0x47, 0x31, 0x32, 0x35, 0x37, }, .ctl_freqbin_2G = { { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2457, 1), FREQ2FBIN(2462, 1) }, { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2462, 1), 0xFF, }, { FREQ2FBIN(2412, 1), FREQ2FBIN(2417, 1), FREQ2FBIN(2462, 1), 0xFF, }, { FREQ2FBIN(2422, 1), FREQ2FBIN(2427, 1), FREQ2FBIN(2447, 1), FREQ2FBIN(2452, 1) }, { /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1), }, { /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0, }, { /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), FREQ2FBIN(2472, 1), 0, }, { /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1), /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1), /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1), /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1), }, { /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), }, { /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0 }, { /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1), /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1), /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1), 0 }, { /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1), /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1), /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1), /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1), } }, .ctlPowerData_2G = { { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } }, }, .modalHeader5G = { /* 4 idle,t1,t2,b (4 bits per setting) */ .antCtrlCommon = LE32(0x220), /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */ .antCtrlCommon2 = LE32(0x44444), /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */ .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150), }, /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */ .xatten1DB = {0x19, 0x19, 0x19}, /* * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin * for merlin (0xa20c/b20c 16:12 */ .xatten1Margin = {0x14, 0x14, 0x14}, .tempSlope = 70, .voltSlope = 0, /* spurChans spur channels in usual fbin coding format */ .spurChans = {0, 0, 0, 0, 0}, /* noiseFloorThreshCh Check if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, .ob = {3, 3, 3}, /* 3 chain */ .db_stage2 = {3, 3, 3}, /* 3 chain */ .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */ .antennaGain = 0, .switchSettling = 0x2d, .adcDesiredSize = -30, .txEndToXpaOff = 0, .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, .papdRateMaskHt20 = LE32(0x0cf0e0e0), .papdRateMaskHt40 = LE32(0x6cf0e0e0), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }, .base_ext2 = { .tempSlopeLow = 35, .tempSlopeHigh = 50, .xatten1DBLow = {0, 0, 0}, .xatten1MarginLow = {0, 0, 0}, .xatten1DBHigh = {0, 0, 0}, .xatten1MarginHigh = {0, 0, 0} }, .calFreqPier5G = { FREQ2FBIN(5180, 0), FREQ2FBIN(5220, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5785, 0) }, .calPierData5G = { { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, }, }, .calTarget_freqbin_5G = { FREQ2FBIN(5180, 0), FREQ2FBIN(5240, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5825, 0) }, .calTarget_freqbin_5GHT20 = { FREQ2FBIN(5180, 0), FREQ2FBIN(5240, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5745, 0), FREQ2FBIN(5825, 0) }, .calTarget_freqbin_5GHT40 = { FREQ2FBIN(5180, 0), FREQ2FBIN(5240, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), FREQ2FBIN(5500, 0), FREQ2FBIN(5700, 0), FREQ2FBIN(5745, 0), FREQ2FBIN(5825, 0) }, .calTargetPower5G = { /* 6-24,36,48,54 */ { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, { {30, 30, 28, 24} }, }, .calTargetPower5GHT20 = { /* * 0_8_16,1-3_9-11_17-19, * 4,5,6,7,12,13,14,15,20,21,22,23 */ { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} }, { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} }, { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} }, { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} }, { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} }, { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} }, { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} }, { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} }, }, .calTargetPower5GHT40 = { /* * 0_8_16,1-3_9-11_17-19, * 4,5,6,7,12,13,14,15,20,21,22,23 */ { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} }, { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} }, { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} }, { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} }, { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} }, { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} }, { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} }, { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} }, }, .ctlIndex_5G = { 0x10, 0x16, 0x18, 0x40, 0x46, 0x48, 0x30, 0x36, 0x38 }, .ctl_freqbin_5G = { { /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0), /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0), /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0), /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0), /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0), /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0), /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0), /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0), /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0), /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0), /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0) }, { /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0), /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0), /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0), /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0), /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[3].ctlEdges[6].bChannel */ 0xFF, /* Data[3].ctlEdges[7].bChannel */ 0xFF, }, { /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0), /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0), /* Data[4].ctlEdges[4].bChannel */ 0xFF, /* Data[4].ctlEdges[5].bChannel */ 0xFF, /* Data[4].ctlEdges[6].bChannel */ 0xFF, /* Data[4].ctlEdges[7].bChannel */ 0xFF, }, { /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0), /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0), /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0), /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0), /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0), /* Data[5].ctlEdges[6].bChannel */ 0xFF, /* Data[5].ctlEdges[7].bChannel */ 0xFF }, { /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0), /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0), /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0), /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0), /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0), /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0), /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0) }, { /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0), /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0), /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0), /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0), /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0), /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0), /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0), /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0) }, { /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0), /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0), /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0), /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0), /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0), /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0), /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0), /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0) } }, .ctlPowerData_5G = { { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), } }, { { CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1), } }, } }; static const struct ar9300_eeprom *ar9300_eep_templates[] = { &ar9300_default, &ar9300_x112, &ar9300_h116, &ar9300_h112, &ar9300_x113, }; static const struct ar9300_eeprom *ar9003_eeprom_struct_find_by_id(int id) { #define N_LOOP (sizeof(ar9300_eep_templates) / sizeof(ar9300_eep_templates[0])) int it; for (it = 0; it < N_LOOP; it++) if (ar9300_eep_templates[it]->templateVersion == id) return ar9300_eep_templates[it]; return NULL; #undef N_LOOP } static u16 ath9k_hw_fbin2freq(u8 fbin, bool is2GHz) { if (fbin == AR5416_BCHAN_UNUSED) return fbin; return (u16) ((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin)); } static int ath9k_hw_ar9300_check_eeprom(struct ath_hw *ah) { return 0; } static int interpolate(int x, int xa, int xb, int ya, int yb) { int bf, factor, plus; bf = 2 * (yb - ya) * (x - xa) / (xb - xa); factor = bf / 2; plus = bf % 2; return ya + factor + plus; } static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah, enum eeprom_param param) { struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader; switch (param) { case EEP_MAC_LSW: return get_unaligned_be16(eep->macAddr); case EEP_MAC_MID: return get_unaligned_be16(eep->macAddr + 2); case EEP_MAC_MSW: return get_unaligned_be16(eep->macAddr + 4); case EEP_REG_0: return le16_to_cpu(pBase->regDmn[0]); case EEP_REG_1: return le16_to_cpu(pBase->regDmn[1]); case EEP_OP_CAP: return pBase->deviceCap; case EEP_OP_MODE: return pBase->opCapFlags.opFlags; case EEP_RF_SILENT: return pBase->rfSilent; case EEP_TX_MASK: return (pBase->txrxMask >> 4) & 0xf; case EEP_RX_MASK: return pBase->txrxMask & 0xf; case EEP_DRIVE_STRENGTH: #define AR9300_EEP_BASE_DRIV_STRENGTH 0x1 return pBase->miscConfiguration & AR9300_EEP_BASE_DRIV_STRENGTH; case EEP_INTERNAL_REGULATOR: /* Bit 4 is internal regulator flag */ return (pBase->featureEnable & 0x10) >> 4; case EEP_SWREG: return le32_to_cpu(pBase->swreg); case EEP_PAPRD: return !!(pBase->featureEnable & BIT(5)); case EEP_CHAIN_MASK_REDUCE: return (pBase->miscConfiguration >> 0x3) & 0x1; case EEP_ANT_DIV_CTL1: return eep->base_ext1.ant_div_control; default: return 0; } } static bool ar9300_eeprom_read_byte(struct ath_common *common, int address, u8 *buffer) { u16 val; if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val))) return false; *buffer = (val >> (8 * (address % 2))) & 0xff; return true; } static bool ar9300_eeprom_read_word(struct ath_common *common, int address, u8 *buffer) { u16 val; if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val))) return false; buffer[0] = val >> 8; buffer[1] = val & 0xff; return true; } static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer, int count) { struct ath_common *common = ath9k_hw_common(ah); int i; if ((address < 0) || ((address + count) / 2 > AR9300_EEPROM_SIZE - 1)) { ath_dbg(common, ATH_DBG_EEPROM, "eeprom address not in range\n"); return false; } /* * Since we're reading the bytes in reverse order from a little-endian * word stream, an even address means we only use the lower half of * the 16-bit word at that address */ if (address % 2 == 0) { if (!ar9300_eeprom_read_byte(common, address--, buffer++)) goto error; count--; } for (i = 0; i < count / 2; i++) { if (!ar9300_eeprom_read_word(common, address, buffer)) goto error; address -= 2; buffer += 2; } if (count % 2) if (!ar9300_eeprom_read_byte(common, address, buffer)) goto error; return true; error: ath_dbg(common, ATH_DBG_EEPROM, "unable to read eeprom region at offset %d\n", address); return false; } static bool ar9300_otp_read_word(struct ath_hw *ah, int addr, u32 *data) { REG_READ(ah, AR9300_OTP_BASE + (4 * addr)); if (!ath9k_hw_wait(ah, AR9300_OTP_STATUS, AR9300_OTP_STATUS_TYPE, AR9300_OTP_STATUS_VALID, 1000)) return false; *data = REG_READ(ah, AR9300_OTP_READ_DATA); return true; } static bool ar9300_read_otp(struct ath_hw *ah, int address, u8 *buffer, int count) { u32 data; int i; for (i = 0; i < count; i++) { int offset = 8 * ((address - i) % 4); if (!ar9300_otp_read_word(ah, (address - i) / 4, &data)) return false; buffer[i] = (data >> offset) & 0xff; } return true; } static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference, int *length, int *major, int *minor) { unsigned long value[4]; value[0] = best[0]; value[1] = best[1]; value[2] = best[2]; value[3] = best[3]; *code = ((value[0] >> 5) & 0x0007); *reference = (value[0] & 0x001f) | ((value[1] >> 2) & 0x0020); *length = ((value[1] << 4) & 0x07f0) | ((value[2] >> 4) & 0x000f); *major = (value[2] & 0x000f); *minor = (value[3] & 0x00ff); } static u16 ar9300_comp_cksum(u8 *data, int dsize) { int it, checksum = 0; for (it = 0; it < dsize; it++) { checksum += data[it]; checksum &= 0xffff; } return checksum; } static bool ar9300_uncompress_block(struct ath_hw *ah, u8 *mptr, int mdataSize, u8 *block, int size) { int it; int spot; int offset; int length; struct ath_common *common = ath9k_hw_common(ah); spot = 0; for (it = 0; it < size; it += (length+2)) { offset = block[it]; offset &= 0xff; spot += offset; length = block[it+1]; length &= 0xff; if (length > 0 && spot >= 0 && spot+length <= mdataSize) { ath_dbg(common, ATH_DBG_EEPROM, "Restore at %d: spot=%d offset=%d length=%d\n", it, spot, offset, length); memcpy(&mptr[spot], &block[it+2], length); spot += length; } else if (length > 0) { ath_dbg(common, ATH_DBG_EEPROM, "Bad restore at %d: spot=%d offset=%d length=%d\n", it, spot, offset, length); return false; } } return true; } static int ar9300_compress_decision(struct ath_hw *ah, int it, int code, int reference, u8 *mptr, u8 *word, int length, int mdata_size) { struct ath_common *common = ath9k_hw_common(ah); const struct ar9300_eeprom *eep = NULL; switch (code) { case _CompressNone: if (length != mdata_size) { ath_dbg(common, ATH_DBG_EEPROM, "EEPROM structure size mismatch memory=%d eeprom=%d\n", mdata_size, length); return -1; } memcpy(mptr, (u8 *) (word + COMP_HDR_LEN), length); ath_dbg(common, ATH_DBG_EEPROM, "restored eeprom %d: uncompressed, length %d\n", it, length); break; case _CompressBlock: if (reference == 0) { } else { eep = ar9003_eeprom_struct_find_by_id(reference); if (eep == NULL) { ath_dbg(common, ATH_DBG_EEPROM, "can't find reference eeprom struct %d\n", reference); return -1; } memcpy(mptr, eep, mdata_size); } ath_dbg(common, ATH_DBG_EEPROM, "restore eeprom %d: block, reference %d, length %d\n", it, reference, length); ar9300_uncompress_block(ah, mptr, mdata_size, (u8 *) (word + COMP_HDR_LEN), length); break; default: ath_dbg(common, ATH_DBG_EEPROM, "unknown compression code %d\n", code); return -1; } return 0; } typedef bool (*eeprom_read_op)(struct ath_hw *ah, int address, u8 *buffer, int count); static bool ar9300_check_header(void *data) { u32 *word = data; return !(*word == 0 || *word == ~0); } static bool ar9300_check_eeprom_header(struct ath_hw *ah, eeprom_read_op read, int base_addr) { u8 header[4]; if (!read(ah, base_addr, header, 4)) return false; return ar9300_check_header(header); } static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr, int mdata_size) { struct ath_common *common = ath9k_hw_common(ah); u16 *data = (u16 *) mptr; int i; for (i = 0; i < mdata_size / 2; i++, data++) ath9k_hw_nvram_read(common, i, data); return 0; } /* * Read the configuration data from the eeprom. * The data can be put in any specified memory buffer. * * Returns -1 on error. * Returns address of next memory location on success. */ static int ar9300_eeprom_restore_internal(struct ath_hw *ah, u8 *mptr, int mdata_size) { #define MDEFAULT 15 #define MSTATE 100 int cptr; u8 *word; int code; int reference, length, major, minor; int osize; int it; u16 checksum, mchecksum; struct ath_common *common = ath9k_hw_common(ah); eeprom_read_op read; if (ath9k_hw_use_flash(ah)) return ar9300_eeprom_restore_flash(ah, mptr, mdata_size); word = kzalloc(2048, GFP_KERNEL); if (!word) return -1; memcpy(mptr, &ar9300_default, mdata_size); read = ar9300_read_eeprom; if (AR_SREV_9485(ah)) cptr = AR9300_BASE_ADDR_4K; else if (AR_SREV_9330(ah)) cptr = AR9300_BASE_ADDR_512; else cptr = AR9300_BASE_ADDR; ath_dbg(common, ATH_DBG_EEPROM, "Trying EEPROM access at Address 0x%04x\n", cptr); if (ar9300_check_eeprom_header(ah, read, cptr)) goto found; cptr = AR9300_BASE_ADDR_512; ath_dbg(common, ATH_DBG_EEPROM, "Trying EEPROM access at Address 0x%04x\n", cptr); if (ar9300_check_eeprom_header(ah, read, cptr)) goto found; read = ar9300_read_otp; cptr = AR9300_BASE_ADDR; ath_dbg(common, ATH_DBG_EEPROM, "Trying OTP access at Address 0x%04x\n", cptr); if (ar9300_check_eeprom_header(ah, read, cptr)) goto found; cptr = AR9300_BASE_ADDR_512; ath_dbg(common, ATH_DBG_EEPROM, "Trying OTP access at Address 0x%04x\n", cptr); if (ar9300_check_eeprom_header(ah, read, cptr)) goto found; goto fail; found: ath_dbg(common, ATH_DBG_EEPROM, "Found valid EEPROM data\n"); for (it = 0; it < MSTATE; it++) { if (!read(ah, cptr, word, COMP_HDR_LEN)) goto fail; if (!ar9300_check_header(word)) break; ar9300_comp_hdr_unpack(word, &code, &reference, &length, &major, &minor); ath_dbg(common, ATH_DBG_EEPROM, "Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n", cptr, code, reference, length, major, minor); if ((!AR_SREV_9485(ah) && length >= 1024) || (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485)) { ath_dbg(common, ATH_DBG_EEPROM, "Skipping bad header\n"); cptr -= COMP_HDR_LEN; continue; } osize = length; read(ah, cptr, word, COMP_HDR_LEN + osize + COMP_CKSUM_LEN); checksum = ar9300_comp_cksum(&word[COMP_HDR_LEN], length); mchecksum = get_unaligned_le16(&word[COMP_HDR_LEN + osize]); ath_dbg(common, ATH_DBG_EEPROM, "checksum %x %x\n", checksum, mchecksum); if (checksum == mchecksum) { ar9300_compress_decision(ah, it, code, reference, mptr, word, length, mdata_size); } else { ath_dbg(common, ATH_DBG_EEPROM, "skipping block with bad checksum\n"); } cptr -= (COMP_HDR_LEN + osize + COMP_CKSUM_LEN); } kfree(word); return cptr; fail: kfree(word); return -1; } /* * Restore the configuration structure by reading the eeprom. * This function destroys any existing in-memory structure * content. */ static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah) { u8 *mptr = (u8 *) &ah->eeprom.ar9300_eep; if (ar9300_eeprom_restore_internal(ah, mptr, sizeof(struct ar9300_eeprom)) < 0) return false; return true; } /* XXX: review hardware docs */ static int ath9k_hw_ar9300_get_eeprom_ver(struct ath_hw *ah) { return ah->eeprom.ar9300_eep.eepromVersion; } /* XXX: could be read from the eepromVersion, not sure yet */ static int ath9k_hw_ar9300_get_eeprom_rev(struct ath_hw *ah) { return 0; } static s32 ar9003_hw_xpa_bias_level_get(struct ath_hw *ah, bool is2ghz) { struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; if (is2ghz) return eep->modalHeader2G.xpaBiasLvl; else return eep->modalHeader5G.xpaBiasLvl; } static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz) { int bias = ar9003_hw_xpa_bias_level_get(ah, is2ghz); if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) REG_RMW_FIELD(ah, AR_CH0_TOP2, AR_CH0_TOP2_XPABIASLVL, bias); else { REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias); REG_RMW_FIELD(ah, AR_CH0_THERM, AR_CH0_THERM_XPABIASLVL_MSB, bias >> 2); REG_RMW_FIELD(ah, AR_CH0_THERM, AR_CH0_THERM_XPASHORT2GND, 1); } } static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz) { struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; __le32 val; if (is2ghz) val = eep->modalHeader2G.antCtrlCommon; else val = eep->modalHeader5G.antCtrlCommon; return le32_to_cpu(val); } static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz) { struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; __le32 val; if (is2ghz) val = eep->modalHeader2G.antCtrlCommon2; else val = eep->modalHeader5G.antCtrlCommon2; return le32_to_cpu(val); } static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, int chain, bool is2ghz) { struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; __le16 val = 0; if (chain >= 0 && chain < AR9300_MAX_CHAINS) { if (is2ghz) val = eep->modalHeader2G.antCtrlChain[chain]; else val = eep->modalHeader5G.antCtrlChain[chain]; } return le16_to_cpu(val); } static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) { int chain; u32 regval; u32 ant_div_ctl1; static const u32 switch_chain_reg[AR9300_MAX_CHAINS] = { AR_PHY_SWITCH_CHAIN_0, AR_PHY_SWITCH_CHAIN_1, AR_PHY_SWITCH_CHAIN_2, }; u32 value = ar9003_hw_ant_ctrl_common_get(ah, is2ghz); REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM, AR_SWITCH_TABLE_COM_ALL, value); value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz); REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value); for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) { if ((ah->rxchainmask & BIT(chain)) || (ah->txchainmask & BIT(chain))) { value = ar9003_hw_ant_ctrl_chain_get(ah, chain, is2ghz); REG_RMW_FIELD(ah, switch_chain_reg[chain], AR_SWITCH_TABLE_ALL, value); } } if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) { value = ath9k_hw_ar9300_get_eeprom(ah, EEP_ANT_DIV_CTL1); /* * main_lnaconf, alt_lnaconf, main_tb, alt_tb * are the fields present */ regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL); regval &= (~AR_ANT_DIV_CTRL_ALL); regval |= (value & 0x3f) << AR_ANT_DIV_CTRL_ALL_S; /* enable_lnadiv */ regval &= (~AR_PHY_9485_ANT_DIV_LNADIV); regval |= ((value >> 6) & 0x1) << AR_PHY_9485_ANT_DIV_LNADIV_S; REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); /*enable fast_div */ regval = REG_READ(ah, AR_PHY_CCK_DETECT); regval &= (~AR_FAST_DIV_ENABLE); regval |= ((value >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S; REG_WRITE(ah, AR_PHY_CCK_DETECT, regval); ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1); /* check whether antenna diversity is enabled */ if ((ant_div_ctl1 >> 0x6) == 0x3) { regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL); /* * clear bits 25-30 main_lnaconf, alt_lnaconf, * main_tb, alt_tb */ regval &= (~(AR_PHY_9485_ANT_DIV_MAIN_LNACONF | AR_PHY_9485_ANT_DIV_ALT_LNACONF | AR_PHY_9485_ANT_DIV_ALT_GAINTB | AR_PHY_9485_ANT_DIV_MAIN_GAINTB)); /* by default use LNA1 for the main antenna */ regval |= (AR_PHY_9485_ANT_DIV_LNA1 << AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S); regval |= (AR_PHY_9485_ANT_DIV_LNA2 << AR_PHY_9485_ANT_DIV_ALT_LNACONF_S); REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval); } } } static void ar9003_hw_drive_strength_apply(struct ath_hw *ah) { int drive_strength; unsigned long reg; drive_strength = ath9k_hw_ar9300_get_eeprom(ah, EEP_DRIVE_STRENGTH); if (!drive_strength) return; reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS1); reg &= ~0x00ffffc0; reg |= 0x5 << 21; reg |= 0x5 << 18; reg |= 0x5 << 15; reg |= 0x5 << 12; reg |= 0x5 << 9; reg |= 0x5 << 6; REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS1, reg); reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS2); reg &= ~0xffffffe0; reg |= 0x5 << 29; reg |= 0x5 << 26; reg |= 0x5 << 23; reg |= 0x5 << 20; reg |= 0x5 << 17; reg |= 0x5 << 14; reg |= 0x5 << 11; reg |= 0x5 << 8; reg |= 0x5 << 5; REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS2, reg); reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS4); reg &= ~0xff800000; reg |= 0x5 << 29; reg |= 0x5 << 26; reg |= 0x5 << 23; REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS4, reg); } static u16 ar9003_hw_atten_chain_get(struct ath_hw *ah, int chain, struct ath9k_channel *chan) { int f[3], t[3]; u16 value; struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; if (chain >= 0 && chain < 3) { if (IS_CHAN_2GHZ(chan)) return eep->modalHeader2G.xatten1DB[chain]; else if (eep->base_ext2.xatten1DBLow[chain] != 0) { t[0] = eep->base_ext2.xatten1DBLow[chain]; f[0] = 5180; t[1] = eep->modalHeader5G.xatten1DB[chain]; f[1] = 5500; t[2] = eep->base_ext2.xatten1DBHigh[chain]; f[2] = 5785; value = ar9003_hw_power_interpolate((s32) chan->channel, f, t, 3); return value; } else return eep->modalHeader5G.xatten1DB[chain]; } return 0; } static u16 ar9003_hw_atten_chain_get_margin(struct ath_hw *ah, int chain, struct ath9k_channel *chan) { int f[3], t[3]; u16 value; struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; if (chain >= 0 && chain < 3) { if (IS_CHAN_2GHZ(chan)) return eep->modalHeader2G.xatten1Margin[chain]; else if (eep->base_ext2.xatten1MarginLow[chain] != 0) { t[0] = eep->base_ext2.xatten1MarginLow[chain]; f[0] = 5180; t[1] = eep->modalHeader5G.xatten1Margin[chain]; f[1] = 5500; t[2] = eep->base_ext2.xatten1MarginHigh[chain]; f[2] = 5785; value = ar9003_hw_power_interpolate((s32) chan->channel, f, t, 3); return value; } else return eep->modalHeader5G.xatten1Margin[chain]; } return 0; } static void ar9003_hw_atten_apply(struct ath_hw *ah, struct ath9k_channel *chan) { int i; u16 value; unsigned long ext_atten_reg[3] = {AR_PHY_EXT_ATTEN_CTL_0, AR_PHY_EXT_ATTEN_CTL_1, AR_PHY_EXT_ATTEN_CTL_2, }; /* Test value. if 0 then attenuation is unused. Don't load anything. */ for (i = 0; i < 3; i++) { if (ah->txchainmask & BIT(i)) { value = ar9003_hw_atten_chain_get(ah, i, chan); REG_RMW_FIELD(ah, ext_atten_reg[i], AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value); value = ar9003_hw_atten_chain_get_margin(ah, i, chan); REG_RMW_FIELD(ah, ext_atten_reg[i], AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN, value); } } } static bool is_pmu_set(struct ath_hw *ah, u32 pmu_reg, int pmu_set) { int timeout = 100; while (pmu_set != REG_READ(ah, pmu_reg)) { if (timeout-- == 0) return false; REG_WRITE(ah, pmu_reg, pmu_set); udelay(10); } return true; } static void ar9003_hw_internal_regulator_apply(struct ath_hw *ah) { int internal_regulator = ath9k_hw_ar9300_get_eeprom(ah, EEP_INTERNAL_REGULATOR); if (internal_regulator) { if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) { int reg_pmu_set; reg_pmu_set = REG_READ(ah, AR_PHY_PMU2) & ~AR_PHY_PMU2_PGM; REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set); if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set)) return; if (AR_SREV_9330(ah)) { if (ah->is_clk_25mhz) { reg_pmu_set = (3 << 1) | (8 << 4) | (3 << 8) | (1 << 14) | (6 << 17) | (1 << 20) | (3 << 24); } else { reg_pmu_set = (4 << 1) | (7 << 4) | (3 << 8) | (1 << 14) | (6 << 17) | (1 << 20) | (3 << 24); } } else { reg_pmu_set = (5 << 1) | (7 << 4) | (2 << 8) | (2 << 14) | (6 << 17) | (1 << 20) | (3 << 24) | (1 << 28); } REG_WRITE(ah, AR_PHY_PMU1, reg_pmu_set); if (!is_pmu_set(ah, AR_PHY_PMU1, reg_pmu_set)) return; reg_pmu_set = (REG_READ(ah, AR_PHY_PMU2) & ~0xFFC00000) | (4 << 26); REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set); if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set)) return; reg_pmu_set = (REG_READ(ah, AR_PHY_PMU2) & ~0x00200000) | (1 << 21); REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set); if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set)) return; } else { /* Internal regulator is ON. Write swreg register. */ int swreg = ath9k_hw_ar9300_get_eeprom(ah, EEP_SWREG); REG_WRITE(ah, AR_RTC_REG_CONTROL1, REG_READ(ah, AR_RTC_REG_CONTROL1) & (~AR_RTC_REG_CONTROL1_SWREG_PROGRAM)); REG_WRITE(ah, AR_RTC_REG_CONTROL0, swreg); /* Set REG_CONTROL1.SWREG_PROGRAM */ REG_WRITE(ah, AR_RTC_REG_CONTROL1, REG_READ(ah, AR_RTC_REG_CONTROL1) | AR_RTC_REG_CONTROL1_SWREG_PROGRAM); } } else { if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) { REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0); while (REG_READ_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM)) udelay(10); REG_RMW_FIELD(ah, AR_PHY_PMU1, AR_PHY_PMU1_PWD, 0x1); while (!REG_READ_FIELD(ah, AR_PHY_PMU1, AR_PHY_PMU1_PWD)) udelay(10); REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0x1); while (!REG_READ_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM)) udelay(10); } else REG_WRITE(ah, AR_RTC_SLEEP_CLK, (REG_READ(ah, AR_RTC_SLEEP_CLK) | AR_RTC_FORCE_SWREG_PRD)); } } static void ar9003_hw_apply_tuning_caps(struct ath_hw *ah) { struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; u8 tuning_caps_param = eep->baseEepHeader.params_for_tuning_caps[0]; if (eep->baseEepHeader.featureEnable & 0x40) { tuning_caps_param &= 0x7f; REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPINDAC, tuning_caps_param); REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPOUTDAC, tuning_caps_param); } } static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, struct ath9k_channel *chan) { ar9003_hw_xpa_bias_level_apply(ah, IS_CHAN_2GHZ(chan)); ar9003_hw_ant_ctrl_apply(ah, IS_CHAN_2GHZ(chan)); ar9003_hw_drive_strength_apply(ah); ar9003_hw_atten_apply(ah, chan); if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah)) ar9003_hw_internal_regulator_apply(ah); if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) ar9003_hw_apply_tuning_caps(ah); } static void ath9k_hw_ar9300_set_addac(struct ath_hw *ah, struct ath9k_channel *chan) { } /* * Returns the interpolated y value corresponding to the specified x value * from the np ordered pairs of data (px,py). * The pairs do not have to be in any order. * If the specified x value is less than any of the px, * the returned y value is equal to the py for the lowest px. * If the specified x value is greater than any of the px, * the returned y value is equal to the py for the highest px. */ static int ar9003_hw_power_interpolate(int32_t x, int32_t *px, int32_t *py, u_int16_t np) { int ip = 0; int lx = 0, ly = 0, lhave = 0; int hx = 0, hy = 0, hhave = 0; int dx = 0; int y = 0; lhave = 0; hhave = 0; /* identify best lower and higher x calibration measurement */ for (ip = 0; ip < np; ip++) { dx = x - px[ip]; /* this measurement is higher than our desired x */ if (dx <= 0) { if (!hhave || dx > (x - hx)) { /* new best higher x measurement */ hx = px[ip]; hy = py[ip]; hhave = 1; } } /* this measurement is lower than our desired x */ if (dx >= 0) { if (!lhave || dx < (x - lx)) { /* new best lower x measurement */ lx = px[ip]; ly = py[ip]; lhave = 1; } } } /* the low x is good */ if (lhave) { /* so is the high x */ if (hhave) { /* they're the same, so just pick one */ if (hx == lx) y = ly; else /* interpolate */ y = interpolate(x, lx, hx, ly, hy); } else /* only low is good, use it */ y = ly; } else if (hhave) /* only high is good, use it */ y = hy; else /* nothing is good,this should never happen unless np=0, ???? */ y = -(1 << 30); return y; } static u8 ar9003_hw_eeprom_get_tgt_pwr(struct ath_hw *ah, u16 rateIndex, u16 freq, bool is2GHz) { u16 numPiers, i; s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS]; s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS]; struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; struct cal_tgt_pow_legacy *pEepromTargetPwr; u8 *pFreqBin; if (is2GHz) { numPiers = AR9300_NUM_2G_20_TARGET_POWERS; pEepromTargetPwr = eep->calTargetPower2G; pFreqBin = eep->calTarget_freqbin_2G; } else { numPiers = AR9300_NUM_5G_20_TARGET_POWERS; pEepromTargetPwr = eep->calTargetPower5G; pFreqBin = eep->calTarget_freqbin_5G; } /* * create array of channels and targetpower from * targetpower piers stored on eeprom */ for (i = 0; i < numPiers; i++) { freqArray[i] = FBIN2FREQ(pFreqBin[i], is2GHz); targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex]; } /* interpolate to get target power for given frequency */ return (u8) ar9003_hw_power_interpolate((s32) freq, freqArray, targetPowerArray, numPiers); } static u8 ar9003_hw_eeprom_get_ht20_tgt_pwr(struct ath_hw *ah, u16 rateIndex, u16 freq, bool is2GHz) { u16 numPiers, i; s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS]; s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS]; struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; struct cal_tgt_pow_ht *pEepromTargetPwr; u8 *pFreqBin; if (is2GHz) { numPiers = AR9300_NUM_2G_20_TARGET_POWERS; pEepromTargetPwr = eep->calTargetPower2GHT20; pFreqBin = eep->calTarget_freqbin_2GHT20; } else { numPiers = AR9300_NUM_5G_20_TARGET_POWERS; pEepromTargetPwr = eep->calTargetPower5GHT20; pFreqBin = eep->calTarget_freqbin_5GHT20; } /* * create array of channels and targetpower * from targetpower piers stored on eeprom */ for (i = 0; i < numPiers; i++) { freqArray[i] = FBIN2FREQ(pFreqBin[i], is2GHz); targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex]; } /* interpolate to get target power for given frequency */ return (u8) ar9003_hw_power_interpolate((s32) freq, freqArray, targetPowerArray, numPiers); } static u8 ar9003_hw_eeprom_get_ht40_tgt_pwr(struct ath_hw *ah, u16 rateIndex, u16 freq, bool is2GHz) { u16 numPiers, i; s32 targetPowerArray[AR9300_NUM_5G_40_TARGET_POWERS]; s32 freqArray[AR9300_NUM_5G_40_TARGET_POWERS]; struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; struct cal_tgt_pow_ht *pEepromTargetPwr; u8 *pFreqBin; if (is2GHz) { numPiers = AR9300_NUM_2G_40_TARGET_POWERS; pEepromTargetPwr = eep->calTargetPower2GHT40; pFreqBin = eep->calTarget_freqbin_2GHT40; } else { numPiers = AR9300_NUM_5G_40_TARGET_POWERS; pEepromTargetPwr = eep->calTargetPower5GHT40; pFreqBin = eep->calTarget_freqbin_5GHT40; } /* * create array of channels and targetpower from * targetpower piers stored on eeprom */ for (i = 0; i < numPiers; i++) { freqArray[i] = FBIN2FREQ(pFreqBin[i], is2GHz); targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex]; } /* interpolate to get target power for given frequency */ return (u8) ar9003_hw_power_interpolate((s32) freq, freqArray, targetPowerArray, numPiers); } static u8 ar9003_hw_eeprom_get_cck_tgt_pwr(struct ath_hw *ah, u16 rateIndex, u16 freq) { u16 numPiers = AR9300_NUM_2G_CCK_TARGET_POWERS, i; s32 targetPowerArray[AR9300_NUM_2G_CCK_TARGET_POWERS]; s32 freqArray[AR9300_NUM_2G_CCK_TARGET_POWERS]; struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; struct cal_tgt_pow_legacy *pEepromTargetPwr = eep->calTargetPowerCck; u8 *pFreqBin = eep->calTarget_freqbin_Cck; /* * create array of channels and targetpower from * targetpower piers stored on eeprom */ for (i = 0; i < numPiers; i++) { freqArray[i] = FBIN2FREQ(pFreqBin[i], 1); targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex]; } /* interpolate to get target power for given frequency */ return (u8) ar9003_hw_power_interpolate((s32) freq, freqArray, targetPowerArray, numPiers); } /* Set tx power registers to array of values passed in */ static int ar9003_hw_tx_power_regwrite(struct ath_hw *ah, u8 * pPwrArray) { #define POW_SM(_r, _s) (((_r) & 0x3f) << (_s)) /* make sure forced gain is not set */ REG_WRITE(ah, AR_PHY_TX_FORCED_GAIN, 0); /* Write the OFDM power per rate set */ /* 6 (LSB), 9, 12, 18 (MSB) */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(0), POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 16) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0)); /* 24 (LSB), 36, 48, 54 (MSB) */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(1), POW_SM(pPwrArray[ALL_TARGET_LEGACY_54], 24) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_48], 16) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_36], 8) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0)); /* Write the CCK power per rate set */ /* 1L (LSB), reserved, 2L, 2S (MSB) */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(2), POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 24) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) | /* POW_SM(txPowerTimes2, 8) | this is reserved for AR9003 */ POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)); /* 5.5L (LSB), 5.5S, 11L, 11S (MSB) */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(3), POW_SM(pPwrArray[ALL_TARGET_LEGACY_11S], 24) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_11L], 16) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_5S], 8) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0) ); /* Write the power for duplicated frames - HT40 */ /* dup40_cck (LSB), dup40_ofdm, ext20_cck, ext20_ofdm (MSB) */ REG_WRITE(ah, 0xa3e0, POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) | POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0) ); /* Write the HT20 power per rate set */ /* 0/8/16 (LSB), 1-3/9-11/17-19, 4, 5 (MSB) */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(4), POW_SM(pPwrArray[ALL_TARGET_HT20_5], 24) | POW_SM(pPwrArray[ALL_TARGET_HT20_4], 16) | POW_SM(pPwrArray[ALL_TARGET_HT20_1_3_9_11_17_19], 8) | POW_SM(pPwrArray[ALL_TARGET_HT20_0_8_16], 0) ); /* 6 (LSB), 7, 12, 13 (MSB) */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(5), POW_SM(pPwrArray[ALL_TARGET_HT20_13], 24) | POW_SM(pPwrArray[ALL_TARGET_HT20_12], 16) | POW_SM(pPwrArray[ALL_TARGET_HT20_7], 8) | POW_SM(pPwrArray[ALL_TARGET_HT20_6], 0) ); /* 14 (LSB), 15, 20, 21 */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(9), POW_SM(pPwrArray[ALL_TARGET_HT20_21], 24) | POW_SM(pPwrArray[ALL_TARGET_HT20_20], 16) | POW_SM(pPwrArray[ALL_TARGET_HT20_15], 8) | POW_SM(pPwrArray[ALL_TARGET_HT20_14], 0) ); /* Mixed HT20 and HT40 rates */ /* HT20 22 (LSB), HT20 23, HT40 22, HT40 23 (MSB) */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(10), POW_SM(pPwrArray[ALL_TARGET_HT40_23], 24) | POW_SM(pPwrArray[ALL_TARGET_HT40_22], 16) | POW_SM(pPwrArray[ALL_TARGET_HT20_23], 8) | POW_SM(pPwrArray[ALL_TARGET_HT20_22], 0) ); /* * Write the HT40 power per rate set * correct PAR difference between HT40 and HT20/LEGACY * 0/8/16 (LSB), 1-3/9-11/17-19, 4, 5 (MSB) */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(6), POW_SM(pPwrArray[ALL_TARGET_HT40_5], 24) | POW_SM(pPwrArray[ALL_TARGET_HT40_4], 16) | POW_SM(pPwrArray[ALL_TARGET_HT40_1_3_9_11_17_19], 8) | POW_SM(pPwrArray[ALL_TARGET_HT40_0_8_16], 0) ); /* 6 (LSB), 7, 12, 13 (MSB) */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(7), POW_SM(pPwrArray[ALL_TARGET_HT40_13], 24) | POW_SM(pPwrArray[ALL_TARGET_HT40_12], 16) | POW_SM(pPwrArray[ALL_TARGET_HT40_7], 8) | POW_SM(pPwrArray[ALL_TARGET_HT40_6], 0) ); /* 14 (LSB), 15, 20, 21 */ REG_WRITE(ah, AR_PHY_POWER_TX_RATE(11), POW_SM(pPwrArray[ALL_TARGET_HT40_21], 24) | POW_SM(pPwrArray[ALL_TARGET_HT40_20], 16) | POW_SM(pPwrArray[ALL_TARGET_HT40_15], 8) | POW_SM(pPwrArray[ALL_TARGET_HT40_14], 0) ); return 0; #undef POW_SM } static void ar9003_hw_set_target_power_eeprom(struct ath_hw *ah, u16 freq, u8 *targetPowerValT2) { /* XXX: hard code for now, need to get from eeprom struct */ u8 ht40PowerIncForPdadc = 0; bool is2GHz = false; unsigned int i = 0; struct ath_common *common = ath9k_hw_common(ah); if (freq < 4000) is2GHz = true; targetPowerValT2[ALL_TARGET_LEGACY_6_24] = ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_6_24, freq, is2GHz); targetPowerValT2[ALL_TARGET_LEGACY_36] = ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_36, freq, is2GHz); targetPowerValT2[ALL_TARGET_LEGACY_48] = ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_48, freq, is2GHz); targetPowerValT2[ALL_TARGET_LEGACY_54] = ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_54, freq, is2GHz); targetPowerValT2[ALL_TARGET_LEGACY_1L_5L] = ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_1L_5L, freq); targetPowerValT2[ALL_TARGET_LEGACY_5S] = ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_5S, freq); targetPowerValT2[ALL_TARGET_LEGACY_11L] = ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11L, freq); targetPowerValT2[ALL_TARGET_LEGACY_11S] = ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11S, freq); targetPowerValT2[ALL_TARGET_HT20_0_8_16] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_1_3_9_11_17_19] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_1_3_9_11_17_19, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_4] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_4, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_5] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_5, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_6] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_6, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_7] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_7, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_12] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_12, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_13] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_13, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_14] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_14, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_15] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_15, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_20] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_20, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_21] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_21, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_22] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_22, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT20_23] = ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_23, freq, is2GHz); targetPowerValT2[ALL_TARGET_HT40_0_8_16] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_1_3_9_11_17_19] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_1_3_9_11_17_19, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_4] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_4, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_5] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_5, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_6] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_6, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_7] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_7, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_12] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_12, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_13] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_13, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_14] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_14, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_15] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_15, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_20] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_20, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_21] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_21, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_22] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_22, freq, is2GHz) + ht40PowerIncForPdadc; targetPowerValT2[ALL_TARGET_HT40_23] = ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_23, freq, is2GHz) + ht40PowerIncForPdadc; for (i = 0; i < ar9300RateSize; i++) { ath_dbg(common, ATH_DBG_EEPROM, "TPC[%02d] 0x%08x\n", i, targetPowerValT2[i]); } } static int ar9003_hw_cal_pier_get(struct ath_hw *ah, int mode, int ipier, int ichain, int *pfrequency, int *pcorrection, int *ptemperature, int *pvoltage) { u8 *pCalPier; struct ar9300_cal_data_per_freq_op_loop *pCalPierStruct; int is2GHz; struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; struct ath_common *common = ath9k_hw_common(ah); if (ichain >= AR9300_MAX_CHAINS) { ath_dbg(common, ATH_DBG_EEPROM, "Invalid chain index, must be less than %d\n", AR9300_MAX_CHAINS); return -1; } if (mode) { /* 5GHz */ if (ipier >= AR9300_NUM_5G_CAL_PIERS) { ath_dbg(common, ATH_DBG_EEPROM, "Invalid 5GHz cal pier index, must be less than %d\n", AR9300_NUM_5G_CAL_PIERS); return -1; } pCalPier = &(eep->calFreqPier5G[ipier]); pCalPierStruct = &(eep->calPierData5G[ichain][ipier]); is2GHz = 0; } else { if (ipier >= AR9300_NUM_2G_CAL_PIERS) { ath_dbg(common, ATH_DBG_EEPROM, "Invalid 2GHz cal pier index, must be less than %d\n", AR9300_NUM_2G_CAL_PIERS); return -1; } pCalPier = &(eep->calFreqPier2G[ipier]); pCalPierStruct = &(eep->calPierData2G[ichain][ipier]); is2GHz = 1; } *pfrequency = FBIN2FREQ(*pCalPier, is2GHz); *pcorrection = pCalPierStruct->refPower; *ptemperature = pCalPierStruct->tempMeas; *pvoltage = pCalPierStruct->voltMeas; return 0; } static int ar9003_hw_power_control_override(struct ath_hw *ah, int frequency, int *correction, int *voltage, int *temperature) { int tempSlope = 0; struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; int f[3], t[3]; REG_RMW(ah, AR_PHY_TPC_11_B0, (correction[0] << AR_PHY_TPC_OLPC_GAIN_DELTA_S), AR_PHY_TPC_OLPC_GAIN_DELTA); if (ah->caps.tx_chainmask & BIT(1)) REG_RMW(ah, AR_PHY_TPC_11_B1, (correction[1] << AR_PHY_TPC_OLPC_GAIN_DELTA_S), AR_PHY_TPC_OLPC_GAIN_DELTA); if (ah->caps.tx_chainmask & BIT(2)) REG_RMW(ah, AR_PHY_TPC_11_B2, (correction[2] << AR_PHY_TPC_OLPC_GAIN_DELTA_S), AR_PHY_TPC_OLPC_GAIN_DELTA); /* enable open loop power control on chip */ REG_RMW(ah, AR_PHY_TPC_6_B0, (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S), AR_PHY_TPC_6_ERROR_EST_MODE); if (ah->caps.tx_chainmask & BIT(1)) REG_RMW(ah, AR_PHY_TPC_6_B1, (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S), AR_PHY_TPC_6_ERROR_EST_MODE); if (ah->caps.tx_chainmask & BIT(2)) REG_RMW(ah, AR_PHY_TPC_6_B2, (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S), AR_PHY_TPC_6_ERROR_EST_MODE); /* * enable temperature compensation * Need to use register names */ if (frequency < 4000) tempSlope = eep->modalHeader2G.tempSlope; else if (eep->base_ext2.tempSlopeLow != 0) { t[0] = eep->base_ext2.tempSlopeLow; f[0] = 5180; t[1] = eep->modalHeader5G.tempSlope; f[1] = 5500; t[2] = eep->base_ext2.tempSlopeHigh; f[2] = 5785; tempSlope = ar9003_hw_power_interpolate((s32) frequency, f, t, 3); } else tempSlope = eep->modalHeader5G.tempSlope; REG_RMW_FIELD(ah, AR_PHY_TPC_19, AR_PHY_TPC_19_ALPHA_THERM, tempSlope); REG_RMW_FIELD(ah, AR_PHY_TPC_18, AR_PHY_TPC_18_THERM_CAL_VALUE, temperature[0]); return 0; } /* Apply the recorded correction values. */ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency) { int ichain, ipier, npier; int mode; int lfrequency[AR9300_MAX_CHAINS], lcorrection[AR9300_MAX_CHAINS], ltemperature[AR9300_MAX_CHAINS], lvoltage[AR9300_MAX_CHAINS]; int hfrequency[AR9300_MAX_CHAINS], hcorrection[AR9300_MAX_CHAINS], htemperature[AR9300_MAX_CHAINS], hvoltage[AR9300_MAX_CHAINS]; int fdiff; int correction[AR9300_MAX_CHAINS], voltage[AR9300_MAX_CHAINS], temperature[AR9300_MAX_CHAINS]; int pfrequency, pcorrection, ptemperature, pvoltage; struct ath_common *common = ath9k_hw_common(ah); mode = (frequency >= 4000); if (mode) npier = AR9300_NUM_5G_CAL_PIERS; else npier = AR9300_NUM_2G_CAL_PIERS; for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) { lfrequency[ichain] = 0; hfrequency[ichain] = 100000; } /* identify best lower and higher frequency calibration measurement */ for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) { for (ipier = 0; ipier < npier; ipier++) { if (!ar9003_hw_cal_pier_get(ah, mode, ipier, ichain, &pfrequency, &pcorrection, &ptemperature, &pvoltage)) { fdiff = frequency - pfrequency; /* * this measurement is higher than * our desired frequency */ if (fdiff <= 0) { if (hfrequency[ichain] <= 0 || hfrequency[ichain] >= 100000 || fdiff > (frequency - hfrequency[ichain])) { /* * new best higher * frequency measurement */ hfrequency[ichain] = pfrequency; hcorrection[ichain] = pcorrection; htemperature[ichain] = ptemperature; hvoltage[ichain] = pvoltage; } } if (fdiff >= 0) { if (lfrequency[ichain] <= 0 || fdiff < (frequency - lfrequency[ichain])) { /* * new best lower * frequency measurement */ lfrequency[ichain] = pfrequency; lcorrection[ichain] = pcorrection; ltemperature[ichain] = ptemperature; lvoltage[ichain] = pvoltage; } } } } } /* interpolate */ for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) { ath_dbg(common, ATH_DBG_EEPROM, "ch=%d f=%d low=%d %d h=%d %d\n", ichain, frequency, lfrequency[ichain], lcorrection[ichain], hfrequency[ichain], hcorrection[ichain]); /* they're the same, so just pick one */ if (hfrequency[ichain] == lfrequency[ichain]) { correction[ichain] = lcorrection[ichain]; voltage[ichain] = lvoltage[ichain]; temperature[ichain] = ltemperature[ichain]; } /* the low frequency is good */ else if (frequency - lfrequency[ichain] < 1000) { /* so is the high frequency, interpolate */ if (hfrequency[ichain] - frequency < 1000) { correction[ichain] = interpolate(frequency, lfrequency[ichain], hfrequency[ichain], lcorrection[ichain], hcorrection[ichain]); temperature[ichain] = interpolate(frequency, lfrequency[ichain], hfrequency[ichain], ltemperature[ichain], htemperature[ichain]); voltage[ichain] = interpolate(frequency, lfrequency[ichain], hfrequency[ichain], lvoltage[ichain], hvoltage[ichain]); } /* only low is good, use it */ else { correction[ichain] = lcorrection[ichain]; temperature[ichain] = ltemperature[ichain]; voltage[ichain] = lvoltage[ichain]; } } /* only high is good, use it */ else if (hfrequency[ichain] - frequency < 1000) { correction[ichain] = hcorrection[ichain]; temperature[ichain] = htemperature[ichain]; voltage[ichain] = hvoltage[ichain]; } else { /* nothing is good, presume 0???? */ correction[ichain] = 0; temperature[ichain] = 0; voltage[ichain] = 0; } } ar9003_hw_power_control_override(ah, frequency, correction, voltage, temperature); ath_dbg(common, ATH_DBG_EEPROM, "for frequency=%d, calibration correction = %d %d %d\n", frequency, correction[0], correction[1], correction[2]); return 0; } static u16 ar9003_hw_get_direct_edge_power(struct ar9300_eeprom *eep, int idx, int edge, bool is2GHz) { struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G; struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G; if (is2GHz) return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge]); else return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge]); } static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep, int idx, unsigned int edge, u16 freq, bool is2GHz) { struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G; struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G; u8 *ctl_freqbin = is2GHz ? &eep->ctl_freqbin_2G[idx][0] : &eep->ctl_freqbin_5G[idx][0]; if (is2GHz) { if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq && CTL_EDGE_FLAGS(ctl_2g[idx].ctlEdges[edge - 1])) return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge - 1]); } else { if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq && CTL_EDGE_FLAGS(ctl_5g[idx].ctlEdges[edge - 1])) return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge - 1]); } return MAX_RATE_POWER; } /* * Find the maximum conformance test limit for the given channel and CTL info */ static u16 ar9003_hw_get_max_edge_power(struct ar9300_eeprom *eep, u16 freq, int idx, bool is2GHz) { u16 twiceMaxEdgePower = MAX_RATE_POWER; u8 *ctl_freqbin = is2GHz ? &eep->ctl_freqbin_2G[idx][0] : &eep->ctl_freqbin_5G[idx][0]; u16 num_edges = is2GHz ? AR9300_NUM_BAND_EDGES_2G : AR9300_NUM_BAND_EDGES_5G; unsigned int edge; /* Get the edge power */ for (edge = 0; (edge < num_edges) && (ctl_freqbin[edge] != AR5416_BCHAN_UNUSED); edge++) { /* * If there's an exact channel match or an inband flag set * on the lower channel use the given rdEdgePower */ if (freq == ath9k_hw_fbin2freq(ctl_freqbin[edge], is2GHz)) { twiceMaxEdgePower = ar9003_hw_get_direct_edge_power(eep, idx, edge, is2GHz); break; } else if ((edge > 0) && (freq < ath9k_hw_fbin2freq(ctl_freqbin[edge], is2GHz))) { twiceMaxEdgePower = ar9003_hw_get_indirect_edge_power(eep, idx, edge, freq, is2GHz); /* * Leave loop - no more affecting edges possible in * this monotonic increasing list */ break; } } return twiceMaxEdgePower; } static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah, struct ath9k_channel *chan, u8 *pPwrArray, u16 cfgCtl, u8 twiceAntennaReduction, u8 twiceMaxRegulatoryPower, u16 powerLimit) { struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); struct ath_common *common = ath9k_hw_common(ah); struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep; u16 twiceMaxEdgePower = MAX_RATE_POWER; static const u16 tpScaleReductionTable[5] = { 0, 3, 6, 9, MAX_RATE_POWER }; int i; int16_t twiceLargestAntenna; u16 scaledPower = 0, minCtlPower, maxRegAllowedPower; static const u16 ctlModesFor11a[] = { CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40 }; static const u16 ctlModesFor11g[] = { CTL_11B, CTL_11G, CTL_2GHT20, CTL_11B_EXT, CTL_11G_EXT, CTL_2GHT40 }; u16 numCtlModes; const u16 *pCtlMode; u16 ctlMode, freq; struct chan_centers centers; u8 *ctlIndex; u8 ctlNum; u16 twiceMinEdgePower; bool is2ghz = IS_CHAN_2GHZ(chan); ath9k_hw_get_channel_centers(ah, chan, &centers); /* Compute TxPower reduction due to Antenna Gain */ if (is2ghz) twiceLargestAntenna = pEepData->modalHeader2G.antennaGain; else twiceLargestAntenna = pEepData->modalHeader5G.antennaGain; twiceLargestAntenna = (int16_t)min((twiceAntennaReduction) - twiceLargestAntenna, 0); /* * scaledPower is the minimum of the user input power level * and the regulatory allowed power level */ maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna; if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) { maxRegAllowedPower -= (tpScaleReductionTable[(regulatory->tp_scale)] * 2); } scaledPower = min(powerLimit, maxRegAllowedPower); /* * Reduce scaled Power by number of chains active to get * to per chain tx power level */ switch (ar5416_get_ntxchains(ah->txchainmask)) { case 1: break; case 2: if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN) scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN; else scaledPower = 0; break; case 3: if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN) scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN; else scaledPower = 0; break; } scaledPower = max((u16)0, scaledPower); /* * Get target powers from EEPROM - our baseline for TX Power */ if (is2ghz) { /* Setup for CTL modes */ /* CTL_11B, CTL_11G, CTL_2GHT20 */ numCtlModes = ARRAY_SIZE(ctlModesFor11g) - SUB_NUM_CTL_MODES_AT_2G_40; pCtlMode = ctlModesFor11g; if (IS_CHAN_HT40(chan)) /* All 2G CTL's */ numCtlModes = ARRAY_SIZE(ctlModesFor11g); } else { /* Setup for CTL modes */ /* CTL_11A, CTL_5GHT20 */ numCtlModes = ARRAY_SIZE(ctlModesFor11a) - SUB_NUM_CTL_MODES_AT_5G_40; pCtlMode = ctlModesFor11a; if (IS_CHAN_HT40(chan)) /* All 5G CTL's */ numCtlModes = ARRAY_SIZE(ctlModesFor11a); } /* * For MIMO, need to apply regulatory caps individually across * dynamically running modes: CCK, OFDM, HT20, HT40 * * The outer loop walks through each possible applicable runtime mode. * The inner loop walks through each ctlIndex entry in EEPROM. * The ctl value is encoded as [7:4] == test group, [3:0] == test mode. */ for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) { bool isHt40CtlMode = (pCtlMode[ctlMode] == CTL_5GHT40) || (pCtlMode[ctlMode] == CTL_2GHT40); if (isHt40CtlMode) freq = centers.synth_center; else if (pCtlMode[ctlMode] & EXT_ADDITIVE) freq = centers.ext_center; else freq = centers.ctl_center; ath_dbg(common, ATH_DBG_REGULATORY, "LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, EXT_ADDITIVE %d\n", ctlMode, numCtlModes, isHt40CtlMode, (pCtlMode[ctlMode] & EXT_ADDITIVE)); /* walk through each CTL index stored in EEPROM */ if (is2ghz) { ctlIndex = pEepData->ctlIndex_2G; ctlNum = AR9300_NUM_CTLS_2G; } else { ctlIndex = pEepData->ctlIndex_5G; ctlNum = AR9300_NUM_CTLS_5G; } for (i = 0; (i < ctlNum) && ctlIndex[i]; i++) { ath_dbg(common, ATH_DBG_REGULATORY, "LOOP-Ctlidx %d: cfgCtl 0x%2.2x pCtlMode 0x%2.2x ctlIndex 0x%2.2x chan %d\n", i, cfgCtl, pCtlMode[ctlMode], ctlIndex[i], chan->channel); /* * compare test group from regulatory * channel list with test mode from pCtlMode * list */ if ((((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == ctlIndex[i]) || (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == ((ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))) { twiceMinEdgePower = ar9003_hw_get_max_edge_power(pEepData, freq, i, is2ghz); if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL) /* * Find the minimum of all CTL * edge powers that apply to * this channel */ twiceMaxEdgePower = min(twiceMaxEdgePower, twiceMinEdgePower); else { /* specific */ twiceMaxEdgePower = twiceMinEdgePower; break; } } } minCtlPower = (u8)min(twiceMaxEdgePower, scaledPower); ath_dbg(common, ATH_DBG_REGULATORY, "SEL-Min ctlMode %d pCtlMode %d 2xMaxEdge %d sP %d minCtlPwr %d\n", ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower, scaledPower, minCtlPower); /* Apply ctl mode to correct target power set */ switch (pCtlMode[ctlMode]) { case CTL_11B: for (i = ALL_TARGET_LEGACY_1L_5L; i <= ALL_TARGET_LEGACY_11S; i++) pPwrArray[i] = (u8)min((u16)pPwrArray[i], minCtlPower); break; case CTL_11A: case CTL_11G: for (i = ALL_TARGET_LEGACY_6_24; i <= ALL_TARGET_LEGACY_54; i++) pPwrArray[i] = (u8)min((u16)pPwrArray[i], minCtlPower); break; case CTL_5GHT20: case CTL_2GHT20: for (i = ALL_TARGET_HT20_0_8_16; i <= ALL_TARGET_HT20_21; i++) pPwrArray[i] = (u8)min((u16)pPwrArray[i], minCtlPower); pPwrArray[ALL_TARGET_HT20_22] = (u8)min((u16)pPwrArray[ALL_TARGET_HT20_22], minCtlPower); pPwrArray[ALL_TARGET_HT20_23] = (u8)min((u16)pPwrArray[ALL_TARGET_HT20_23], minCtlPower); break; case CTL_5GHT40: case CTL_2GHT40: for (i = ALL_TARGET_HT40_0_8_16; i <= ALL_TARGET_HT40_23; i++) pPwrArray[i] = (u8)min((u16)pPwrArray[i], minCtlPower); break; default: break; } } /* end ctl mode checking */ } static inline u8 mcsidx_to_tgtpwridx(unsigned int mcs_idx, u8 base_pwridx) { u8 mod_idx = mcs_idx % 8; if (mod_idx <= 3) return mod_idx ? (base_pwridx + 1) : base_pwridx; else return base_pwridx + 4 * (mcs_idx / 8) + mod_idx - 2; } static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, struct ath9k_channel *chan, u16 cfgCtl, u8 twiceAntennaReduction, u8 twiceMaxRegulatoryPower, u8 powerLimit, bool test) { struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); struct ath_common *common = ath9k_hw_common(ah); struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; struct ar9300_modal_eep_header *modal_hdr; u8 targetPowerValT2[ar9300RateSize]; u8 target_power_val_t2_eep[ar9300RateSize]; unsigned int i = 0, paprd_scale_factor = 0; u8 pwr_idx, min_pwridx = 0; ar9003_hw_set_target_power_eeprom(ah, chan->channel, targetPowerValT2); if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) { if (IS_CHAN_2GHZ(chan)) modal_hdr = &eep->modalHeader2G; else modal_hdr = &eep->modalHeader5G; ah->paprd_ratemask = le32_to_cpu(modal_hdr->papdRateMaskHt20) & AR9300_PAPRD_RATE_MASK; ah->paprd_ratemask_ht40 = le32_to_cpu(modal_hdr->papdRateMaskHt40) & AR9300_PAPRD_RATE_MASK; paprd_scale_factor = ar9003_get_paprd_scale_factor(ah, chan); min_pwridx = IS_CHAN_HT40(chan) ? ALL_TARGET_HT40_0_8_16 : ALL_TARGET_HT20_0_8_16; if (!ah->paprd_table_write_done) { memcpy(target_power_val_t2_eep, targetPowerValT2, sizeof(targetPowerValT2)); for (i = 0; i < 24; i++) { pwr_idx = mcsidx_to_tgtpwridx(i, min_pwridx); if (ah->paprd_ratemask & (1 << i)) { if (targetPowerValT2[pwr_idx] && targetPowerValT2[pwr_idx] == target_power_val_t2_eep[pwr_idx]) targetPowerValT2[pwr_idx] -= paprd_scale_factor; } } } memcpy(target_power_val_t2_eep, targetPowerValT2, sizeof(targetPowerValT2)); } ar9003_hw_set_power_per_rate_table(ah, chan, targetPowerValT2, cfgCtl, twiceAntennaReduction, twiceMaxRegulatoryPower, powerLimit); if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) { for (i = 0; i < ar9300RateSize; i++) { if ((ah->paprd_ratemask & (1 << i)) && (abs(targetPowerValT2[i] - target_power_val_t2_eep[i]) > paprd_scale_factor)) { ah->paprd_ratemask &= ~(1 << i); ath_dbg(common, ATH_DBG_EEPROM, "paprd disabled for mcs %d\n", i); } } } regulatory->max_power_level = 0; for (i = 0; i < ar9300RateSize; i++) { if (targetPowerValT2[i] > regulatory->max_power_level) regulatory->max_power_level = targetPowerValT2[i]; } if (test) return; for (i = 0; i < ar9300RateSize; i++) { ath_dbg(common, ATH_DBG_EEPROM, "TPC[%02d] 0x%08x\n", i, targetPowerValT2[i]); } /* * This is the TX power we send back to driver core, * and it can use to pass to userspace to display our * currently configured TX power setting. * * Since power is rate dependent, use one of the indices * from the AR9300_Rates enum to select an entry from * targetPowerValT2[] to report. Currently returns the * power for HT40 MCS 0, HT20 MCS 0, or OFDM 6 Mbps * as CCK power is less interesting (?). */ i = ALL_TARGET_LEGACY_6_24; /* legacy */ if (IS_CHAN_HT40(chan)) i = ALL_TARGET_HT40_0_8_16; /* ht40 */ else if (IS_CHAN_HT20(chan)) i = ALL_TARGET_HT20_0_8_16; /* ht20 */ ah->txpower_limit = targetPowerValT2[i]; regulatory->max_power_level = targetPowerValT2[i]; /* Write target power array to registers */ ar9003_hw_tx_power_regwrite(ah, targetPowerValT2); ar9003_hw_calibration_apply(ah, chan->channel); if (IS_CHAN_2GHZ(chan)) { if (IS_CHAN_HT40(chan)) i = ALL_TARGET_HT40_0_8_16; else i = ALL_TARGET_HT20_0_8_16; } else { if (IS_CHAN_HT40(chan)) i = ALL_TARGET_HT40_7; else i = ALL_TARGET_HT20_7; } ah->paprd_target_power = targetPowerValT2[i]; } static u16 ath9k_hw_ar9300_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz) { return AR_NO_SPUR; } s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah) { struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; return (eep->baseEepHeader.txrxgain >> 4) & 0xf; /* bits 7:4 */ } s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah) { struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; return (eep->baseEepHeader.txrxgain) & 0xf; /* bits 3:0 */ } u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is_2ghz) { struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; if (is_2ghz) return eep->modalHeader2G.spurChans; else return eep->modalHeader5G.spurChans; } unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah, struct ath9k_channel *chan) { struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; if (IS_CHAN_2GHZ(chan)) return MS(le32_to_cpu(eep->modalHeader2G.papdRateMaskHt20), AR9300_PAPRD_SCALE_1); else { if (chan->channel >= 5700) return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt20), AR9300_PAPRD_SCALE_1); else if (chan->channel >= 5400) return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt40), AR9300_PAPRD_SCALE_2); else return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt40), AR9300_PAPRD_SCALE_1); } } const struct eeprom_ops eep_ar9300_ops = { .check_eeprom = ath9k_hw_ar9300_check_eeprom, .get_eeprom = ath9k_hw_ar9300_get_eeprom, .fill_eeprom = ath9k_hw_ar9300_fill_eeprom, .get_eeprom_ver = ath9k_hw_ar9300_get_eeprom_ver, .get_eeprom_rev = ath9k_hw_ar9300_get_eeprom_rev, .set_board_values = ath9k_hw_ar9300_set_board_values, .set_addac = ath9k_hw_ar9300_set_addac, .set_txpower = ath9k_hw_ar9300_set_txpower, .get_spur_channel = ath9k_hw_ar9300_get_spur_channel };
gpl-2.0
Pascal-TK/Beagleboard-xM-Kernel
drivers/infiniband/hw/amso1100/c2_pd.c
888
3012
/* * Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Mellanox Technologies. All rights reserved. * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <linux/init.h> #include <linux/errno.h> #include "c2.h" #include "c2_provider.h" int c2_pd_alloc(struct c2_dev *c2dev, int privileged, struct c2_pd *pd) { u32 obj; int ret = 0; spin_lock(&c2dev->pd_table.lock); obj = find_next_zero_bit(c2dev->pd_table.table, c2dev->pd_table.max, c2dev->pd_table.last); if (obj >= c2dev->pd_table.max) obj = find_first_zero_bit(c2dev->pd_table.table, c2dev->pd_table.max); if (obj < c2dev->pd_table.max) { pd->pd_id = obj; __set_bit(obj, c2dev->pd_table.table); c2dev->pd_table.last = obj+1; if (c2dev->pd_table.last >= c2dev->pd_table.max) c2dev->pd_table.last = 0; } else ret = -ENOMEM; spin_unlock(&c2dev->pd_table.lock); return ret; } void c2_pd_free(struct c2_dev *c2dev, struct c2_pd *pd) { spin_lock(&c2dev->pd_table.lock); __clear_bit(pd->pd_id, c2dev->pd_table.table); spin_unlock(&c2dev->pd_table.lock); } int __devinit c2_init_pd_table(struct c2_dev *c2dev) { c2dev->pd_table.last = 0; c2dev->pd_table.max = c2dev->props.max_pd; spin_lock_init(&c2dev->pd_table.lock); c2dev->pd_table.table = kmalloc(BITS_TO_LONGS(c2dev->props.max_pd) * sizeof(long), GFP_KERNEL); if (!c2dev->pd_table.table) return -ENOMEM; bitmap_zero(c2dev->pd_table.table, c2dev->props.max_pd); return 0; } void __devexit c2_cleanup_pd_table(struct c2_dev *c2dev) { kfree(c2dev->pd_table.table); }
gpl-2.0
jmztaylor/kernel_hc_sense_express
drivers/char/genrtc.c
888
13004
/* * Real Time Clock interface for * - q40 and other m68k machines, * - HP PARISC machines * - PowerPC machines * emulate some RTC irq capabilities in software * * Copyright (C) 1999 Richard Zidlicky * * based on Paul Gortmaker's rtc.c device and * Sam Creasey Generic rtc driver * * This driver allows use of the real time clock (built into * nearly all computers) from user space. It exports the /dev/rtc * interface supporting various ioctl() and also the /proc/driver/rtc * pseudo-file for status information. * * The ioctls can be used to set the interrupt behaviour where * supported. * * The /dev/rtc interface will block on reads until an interrupt * has been received. If a RTC interrupt has already happened, * it will output an unsigned long and then block. The output value * contains the interrupt status in the low byte and the number of * interrupts since the last read in the remaining high bytes. The * /dev/rtc interface can also be used with the select(2) call. * * 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. * * 1.01 fix for 2.3.X rz@linux-m68k.org * 1.02 merged with code from genrtc.c rz@linux-m68k.org * 1.03 make it more portable zippel@linux-m68k.org * 1.04 removed useless timer code rz@linux-m68k.org * 1.05 portable RTC_UIE emulation rz@linux-m68k.org * 1.06 set_rtc_time can return an error trini@kernel.crashing.org * 1.07 ported to HP PARISC (hppa) Helge Deller <deller@gmx.de> */ #define RTC_VERSION "1.07" #include <linux/module.h> #include <linux/sched.h> #include <linux/errno.h> #include <linux/miscdevice.h> #include <linux/fcntl.h> #include <linux/rtc.h> #include <linux/init.h> #include <linux/poll.h> #include <linux/proc_fs.h> #include <linux/smp_lock.h> #include <linux/workqueue.h> #include <asm/uaccess.h> #include <asm/system.h> #include <asm/rtc.h> /* * We sponge a minor off of the misc major. No need slurping * up another valuable major dev number for this. If you add * an ioctl, make sure you don't conflict with SPARC's RTC * ioctls. */ static DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait); /* * Bits in gen_rtc_status. */ #define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ static unsigned char gen_rtc_status; /* bitmapped status byte. */ static unsigned long gen_rtc_irq_data; /* our output to the world */ /* months start at 0 now */ static unsigned char days_in_mo[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; static int irq_active; #ifdef CONFIG_GEN_RTC_X static struct work_struct genrtc_task; static struct timer_list timer_task; static unsigned int oldsecs; static int lostint; static unsigned long tt_exp; static void gen_rtc_timer(unsigned long data); static volatile int stask_active; /* schedule_work */ static volatile int ttask_active; /* timer_task */ static int stop_rtc_timers; /* don't requeue tasks */ static DEFINE_SPINLOCK(gen_rtc_lock); static void gen_rtc_interrupt(unsigned long arg); /* * Routine to poll RTC seconds field for change as often as possible, * after first RTC_UIE use timer to reduce polling */ static void genrtc_troutine(struct work_struct *work) { unsigned int tmp = get_rtc_ss(); if (stop_rtc_timers) { stask_active = 0; return; } if (oldsecs != tmp){ oldsecs = tmp; timer_task.function = gen_rtc_timer; timer_task.expires = jiffies + HZ - (HZ/10); tt_exp=timer_task.expires; ttask_active=1; stask_active=0; add_timer(&timer_task); gen_rtc_interrupt(0); } else if (schedule_work(&genrtc_task) == 0) stask_active = 0; } static void gen_rtc_timer(unsigned long data) { lostint = get_rtc_ss() - oldsecs ; if (lostint<0) lostint = 60 - lostint; if (time_after(jiffies, tt_exp)) printk(KERN_INFO "genrtc: timer task delayed by %ld jiffies\n", jiffies-tt_exp); ttask_active=0; stask_active=1; if ((schedule_work(&genrtc_task) == 0)) stask_active = 0; } /* * call gen_rtc_interrupt function to signal an RTC_UIE, * arg is unused. * Could be invoked either from a real interrupt handler or * from some routine that periodically (eg 100HZ) monitors * whether RTC_SECS changed */ static void gen_rtc_interrupt(unsigned long arg) { /* We store the status in the low byte and the number of * interrupts received since the last read in the remainder * of rtc_irq_data. */ gen_rtc_irq_data += 0x100; gen_rtc_irq_data &= ~0xff; gen_rtc_irq_data |= RTC_UIE; if (lostint){ printk("genrtc: system delaying clock ticks?\n"); /* increment count so that userspace knows something is wrong */ gen_rtc_irq_data += ((lostint-1)<<8); lostint = 0; } wake_up_interruptible(&gen_rtc_wait); } /* * Now all the various file operations that we export. */ static ssize_t gen_rtc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { unsigned long data; ssize_t retval; if (count != sizeof (unsigned int) && count != sizeof (unsigned long)) return -EINVAL; if (file->f_flags & O_NONBLOCK && !gen_rtc_irq_data) return -EAGAIN; retval = wait_event_interruptible(gen_rtc_wait, (data = xchg(&gen_rtc_irq_data, 0))); if (retval) goto out; /* first test allows optimizer to nuke this case for 32-bit machines */ if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) { unsigned int uidata = data; retval = put_user(uidata, (unsigned int __user *)buf) ?: sizeof(unsigned int); } else { retval = put_user(data, (unsigned long __user *)buf) ?: sizeof(unsigned long); } out: return retval; } static unsigned int gen_rtc_poll(struct file *file, struct poll_table_struct *wait) { poll_wait(file, &gen_rtc_wait, wait); if (gen_rtc_irq_data != 0) return POLLIN | POLLRDNORM; return 0; } #endif /* * Used to disable/enable interrupts, only RTC_UIE supported * We also clear out any old irq data after an ioctl() that * meddles with the interrupt enable/disable bits. */ static inline void gen_clear_rtc_irq_bit(unsigned char bit) { #ifdef CONFIG_GEN_RTC_X stop_rtc_timers = 1; if (ttask_active){ del_timer_sync(&timer_task); ttask_active = 0; } while (stask_active) schedule(); spin_lock(&gen_rtc_lock); irq_active = 0; spin_unlock(&gen_rtc_lock); #endif } static inline int gen_set_rtc_irq_bit(unsigned char bit) { #ifdef CONFIG_GEN_RTC_X spin_lock(&gen_rtc_lock); if ( !irq_active ) { irq_active = 1; stop_rtc_timers = 0; lostint = 0; INIT_WORK(&genrtc_task, genrtc_troutine); oldsecs = get_rtc_ss(); init_timer(&timer_task); stask_active = 1; if (schedule_work(&genrtc_task) == 0){ stask_active = 0; } } spin_unlock(&gen_rtc_lock); gen_rtc_irq_data = 0; return 0; #else return -EINVAL; #endif } static int gen_rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct rtc_time wtime; struct rtc_pll_info pll; void __user *argp = (void __user *)arg; switch (cmd) { case RTC_PLL_GET: if (get_rtc_pll(&pll)) return -EINVAL; else return copy_to_user(argp, &pll, sizeof pll) ? -EFAULT : 0; case RTC_PLL_SET: if (!capable(CAP_SYS_TIME)) return -EACCES; if (copy_from_user(&pll, argp, sizeof(pll))) return -EFAULT; return set_rtc_pll(&pll); case RTC_UIE_OFF: /* disable ints from RTC updates. */ gen_clear_rtc_irq_bit(RTC_UIE); return 0; case RTC_UIE_ON: /* enable ints for RTC updates. */ return gen_set_rtc_irq_bit(RTC_UIE); case RTC_RD_TIME: /* Read the time/date from RTC */ /* this doesn't get week-day, who cares */ memset(&wtime, 0, sizeof(wtime)); get_rtc_time(&wtime); return copy_to_user(argp, &wtime, sizeof(wtime)) ? -EFAULT : 0; case RTC_SET_TIME: /* Set the RTC */ { int year; unsigned char leap_yr; if (!capable(CAP_SYS_TIME)) return -EACCES; if (copy_from_user(&wtime, argp, sizeof(wtime))) return -EFAULT; year = wtime.tm_year + 1900; leap_yr = ((!(year % 4) && (year % 100)) || !(year % 400)); if ((wtime.tm_mon < 0 || wtime.tm_mon > 11) || (wtime.tm_mday < 1)) return -EINVAL; if (wtime.tm_mday < 0 || wtime.tm_mday > (days_in_mo[wtime.tm_mon] + ((wtime.tm_mon == 1) && leap_yr))) return -EINVAL; if (wtime.tm_hour < 0 || wtime.tm_hour >= 24 || wtime.tm_min < 0 || wtime.tm_min >= 60 || wtime.tm_sec < 0 || wtime.tm_sec >= 60) return -EINVAL; return set_rtc_time(&wtime); } } return -EINVAL; } static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int ret; lock_kernel(); ret = gen_rtc_ioctl(file, cmd, arg); unlock_kernel(); return ret; } /* * We enforce only one user at a time here with the open/close. * Also clear the previous interrupt data on an open, and clean * up things on a close. */ static int gen_rtc_open(struct inode *inode, struct file *file) { lock_kernel(); if (gen_rtc_status & RTC_IS_OPEN) { unlock_kernel(); return -EBUSY; } gen_rtc_status |= RTC_IS_OPEN; gen_rtc_irq_data = 0; irq_active = 0; unlock_kernel(); return 0; } static int gen_rtc_release(struct inode *inode, struct file *file) { /* * Turn off all interrupts once the device is no longer * in use and clear the data. */ gen_clear_rtc_irq_bit(RTC_PIE|RTC_AIE|RTC_UIE); gen_rtc_status &= ~RTC_IS_OPEN; return 0; } #ifdef CONFIG_PROC_FS /* * Info exported via "/proc/driver/rtc". */ static int gen_rtc_proc_output(char *buf) { char *p; struct rtc_time tm; unsigned int flags; struct rtc_pll_info pll; p = buf; flags = get_rtc_time(&tm); p += sprintf(p, "rtc_time\t: %02d:%02d:%02d\n" "rtc_date\t: %04d-%02d-%02d\n" "rtc_epoch\t: %04u\n", tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 1900); tm.tm_hour = tm.tm_min = tm.tm_sec = 0; p += sprintf(p, "alarm\t\t: "); if (tm.tm_hour <= 24) p += sprintf(p, "%02d:", tm.tm_hour); else p += sprintf(p, "**:"); if (tm.tm_min <= 59) p += sprintf(p, "%02d:", tm.tm_min); else p += sprintf(p, "**:"); if (tm.tm_sec <= 59) p += sprintf(p, "%02d\n", tm.tm_sec); else p += sprintf(p, "**\n"); p += sprintf(p, "DST_enable\t: %s\n" "BCD\t\t: %s\n" "24hr\t\t: %s\n" "square_wave\t: %s\n" "alarm_IRQ\t: %s\n" "update_IRQ\t: %s\n" "periodic_IRQ\t: %s\n" "periodic_freq\t: %ld\n" "batt_status\t: %s\n", (flags & RTC_DST_EN) ? "yes" : "no", (flags & RTC_DM_BINARY) ? "no" : "yes", (flags & RTC_24H) ? "yes" : "no", (flags & RTC_SQWE) ? "yes" : "no", (flags & RTC_AIE) ? "yes" : "no", irq_active ? "yes" : "no", (flags & RTC_PIE) ? "yes" : "no", 0L /* freq */, (flags & RTC_BATT_BAD) ? "bad" : "okay"); if (!get_rtc_pll(&pll)) p += sprintf(p, "PLL adjustment\t: %d\n" "PLL max +ve adjustment\t: %d\n" "PLL max -ve adjustment\t: %d\n" "PLL +ve adjustment factor\t: %d\n" "PLL -ve adjustment factor\t: %d\n" "PLL frequency\t: %ld\n", pll.pll_value, pll.pll_max, pll.pll_min, pll.pll_posmult, pll.pll_negmult, pll.pll_clock); return p - buf; } static int gen_rtc_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { int len = gen_rtc_proc_output (page); if (len <= off+count) *eof = 1; *start = page + off; len -= off; if (len>count) len = count; if (len<0) len = 0; return len; } static int __init gen_rtc_proc_init(void) { struct proc_dir_entry *r; r = create_proc_read_entry("driver/rtc", 0, NULL, gen_rtc_read_proc, NULL); if (!r) return -ENOMEM; return 0; } #else static inline int gen_rtc_proc_init(void) { return 0; } #endif /* CONFIG_PROC_FS */ /* * The various file operations we support. */ static const struct file_operations gen_rtc_fops = { .owner = THIS_MODULE, #ifdef CONFIG_GEN_RTC_X .read = gen_rtc_read, .poll = gen_rtc_poll, #endif .unlocked_ioctl = gen_rtc_unlocked_ioctl, .open = gen_rtc_open, .release = gen_rtc_release, }; static struct miscdevice rtc_gen_dev = { .minor = RTC_MINOR, .name = "rtc", .fops = &gen_rtc_fops, }; static int __init rtc_generic_init(void) { int retval; printk(KERN_INFO "Generic RTC Driver v%s\n", RTC_VERSION); retval = misc_register(&rtc_gen_dev); if (retval < 0) return retval; retval = gen_rtc_proc_init(); if (retval) { misc_deregister(&rtc_gen_dev); return retval; } return 0; } static void __exit rtc_generic_exit(void) { remove_proc_entry ("driver/rtc", NULL); misc_deregister(&rtc_gen_dev); } module_init(rtc_generic_init); module_exit(rtc_generic_exit); MODULE_AUTHOR("Richard Zidlicky"); MODULE_LICENSE("GPL"); MODULE_ALIAS_MISCDEV(RTC_MINOR);
gpl-2.0
pbeeler/Linux-stable
arch/arm/mach-mmp/pm-pxa910.c
1144
7038
/* * PXA910 Power Management Routines * * This software program is licensed subject to the GNU General Public License * (GPL).Version 2,June 1991, available at http://www.fsf.org/copyleft/gpl.html * * (C) Copyright 2009 Marvell International Ltd. * All Rights Reserved */ #include <linux/kernel.h> #include <linux/errno.h> #include <linux/err.h> #include <linux/time.h> #include <linux/delay.h> #include <linux/suspend.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/irq.h> #include <asm/mach-types.h> #include <mach/hardware.h> #include <mach/cputype.h> #include <mach/addr-map.h> #include <mach/pm-pxa910.h> #include <mach/regs-icu.h> #include <mach/irqs.h> int pxa910_set_wake(struct irq_data *data, unsigned int on) { uint32_t awucrm = 0, apcr = 0; int irq = data->irq; /* setting wakeup sources */ switch (irq) { /* wakeup line 2 */ case IRQ_PXA910_AP_GPIO: awucrm = MPMU_AWUCRM_WAKEUP(2); apcr |= MPMU_APCR_SLPWP2; break; /* wakeup line 3 */ case IRQ_PXA910_KEYPAD: awucrm = MPMU_AWUCRM_WAKEUP(3) | MPMU_AWUCRM_KEYPRESS; apcr |= MPMU_APCR_SLPWP3; break; case IRQ_PXA910_ROTARY: awucrm = MPMU_AWUCRM_WAKEUP(3) | MPMU_AWUCRM_NEWROTARY; apcr |= MPMU_APCR_SLPWP3; break; case IRQ_PXA910_TRACKBALL: awucrm = MPMU_AWUCRM_WAKEUP(3) | MPMU_AWUCRM_TRACKBALL; apcr |= MPMU_APCR_SLPWP3; break; /* wakeup line 4 */ case IRQ_PXA910_AP1_TIMER1: awucrm = MPMU_AWUCRM_WAKEUP(4) | MPMU_AWUCRM_AP1_TIMER_1; apcr |= MPMU_APCR_SLPWP4; break; case IRQ_PXA910_AP1_TIMER2: awucrm = MPMU_AWUCRM_WAKEUP(4) | MPMU_AWUCRM_AP1_TIMER_2; apcr |= MPMU_APCR_SLPWP4; break; case IRQ_PXA910_AP1_TIMER3: awucrm = MPMU_AWUCRM_WAKEUP(4) | MPMU_AWUCRM_AP1_TIMER_3; apcr |= MPMU_APCR_SLPWP4; break; case IRQ_PXA910_AP2_TIMER1: awucrm = MPMU_AWUCRM_WAKEUP(4) | MPMU_AWUCRM_AP2_TIMER_1; apcr |= MPMU_APCR_SLPWP4; break; case IRQ_PXA910_AP2_TIMER2: awucrm = MPMU_AWUCRM_WAKEUP(4) | MPMU_AWUCRM_AP2_TIMER_2; apcr |= MPMU_APCR_SLPWP4; break; case IRQ_PXA910_AP2_TIMER3: awucrm = MPMU_AWUCRM_WAKEUP(4) | MPMU_AWUCRM_AP2_TIMER_3; apcr |= MPMU_APCR_SLPWP4; break; case IRQ_PXA910_RTC_ALARM: awucrm = MPMU_AWUCRM_WAKEUP(4) | MPMU_AWUCRM_RTC_ALARM; apcr |= MPMU_APCR_SLPWP4; break; /* wakeup line 5 */ case IRQ_PXA910_USB1: case IRQ_PXA910_USB2: awucrm = MPMU_AWUCRM_WAKEUP(5); apcr |= MPMU_APCR_SLPWP5; break; /* wakeup line 6 */ case IRQ_PXA910_MMC: awucrm = MPMU_AWUCRM_WAKEUP(6) | MPMU_AWUCRM_SDH1 | MPMU_AWUCRM_SDH2; apcr |= MPMU_APCR_SLPWP6; break; /* wakeup line 7 */ case IRQ_PXA910_PMIC_INT: awucrm = MPMU_AWUCRM_WAKEUP(7); apcr |= MPMU_APCR_SLPWP7; break; default: if (irq >= IRQ_GPIO_START && irq < IRQ_BOARD_START) { awucrm = MPMU_AWUCRM_WAKEUP(2); apcr |= MPMU_APCR_SLPWP2; } else { /* FIXME: This should return a proper error code ! */ printk(KERN_ERR "Error: no defined wake up source irq: %d\n", irq); } } if (on) { if (awucrm) { awucrm |= __raw_readl(MPMU_AWUCRM); __raw_writel(awucrm, MPMU_AWUCRM); } if (apcr) { apcr = ~apcr & __raw_readl(MPMU_APCR); __raw_writel(apcr, MPMU_APCR); } } else { if (awucrm) { awucrm = ~awucrm & __raw_readl(MPMU_AWUCRM); __raw_writel(awucrm, MPMU_AWUCRM); } if (apcr) { apcr |= __raw_readl(MPMU_APCR); __raw_writel(apcr, MPMU_APCR); } } return 0; } void pxa910_pm_enter_lowpower_mode(int state) { uint32_t idle_cfg, apcr; idle_cfg = __raw_readl(APMU_MOH_IDLE_CFG); apcr = __raw_readl(MPMU_APCR); apcr &= ~(MPMU_APCR_DDRCORSD | MPMU_APCR_APBSD | MPMU_APCR_AXISD | MPMU_APCR_VCTCXOSD | MPMU_APCR_STBYEN); idle_cfg &= ~(APMU_MOH_IDLE_CFG_MOH_IDLE | APMU_MOH_IDLE_CFG_MOH_PWRDWN); switch (state) { case POWER_MODE_UDR: /* only shutdown APB in UDR */ apcr |= MPMU_APCR_STBYEN | MPMU_APCR_APBSD; /* fall through */ case POWER_MODE_SYS_SLEEP: apcr |= MPMU_APCR_SLPEN; /* set the SLPEN bit */ apcr |= MPMU_APCR_VCTCXOSD; /* set VCTCXOSD */ /* fall through */ case POWER_MODE_APPS_SLEEP: apcr |= MPMU_APCR_DDRCORSD; /* set DDRCORSD */ /* fall through */ case POWER_MODE_APPS_IDLE: apcr |= MPMU_APCR_AXISD; /* set AXISDD bit */ /* fall through */ case POWER_MODE_CORE_EXTIDLE: idle_cfg |= APMU_MOH_IDLE_CFG_MOH_IDLE; idle_cfg |= APMU_MOH_IDLE_CFG_MOH_PWRDWN; idle_cfg |= APMU_MOH_IDLE_CFG_MOH_PWR_SW(3) | APMU_MOH_IDLE_CFG_MOH_L2_PWR_SW(3); /* fall through */ case POWER_MODE_CORE_INTIDLE: break; } /* program the memory controller hardware sleep type and auto wakeup */ idle_cfg |= APMU_MOH_IDLE_CFG_MOH_DIS_MC_SW_REQ; idle_cfg |= APMU_MOH_IDLE_CFG_MOH_MC_WAKE_EN; __raw_writel(0x0, APMU_MC_HW_SLP_TYPE); /* auto refresh */ /* set DSPSD, DTCMSD, BBSD, MSASLPEN */ apcr |= MPMU_APCR_DSPSD | MPMU_APCR_DTCMSD | MPMU_APCR_BBSD | MPMU_APCR_MSASLPEN; /*always set SLEPEN bit mainly for MSA*/ apcr |= MPMU_APCR_SLPEN; /* finally write the registers back */ __raw_writel(idle_cfg, APMU_MOH_IDLE_CFG); __raw_writel(apcr, MPMU_APCR); } static int pxa910_pm_enter(suspend_state_t state) { unsigned int idle_cfg, reg = 0; /*pmic thread not completed,exit;otherwise system can't be waked up*/ reg = __raw_readl(ICU_INT_CONF(IRQ_PXA910_PMIC_INT)); if ((reg & 0x3) == 0) return -EAGAIN; idle_cfg = __raw_readl(APMU_MOH_IDLE_CFG); idle_cfg |= APMU_MOH_IDLE_CFG_MOH_PWRDWN | APMU_MOH_IDLE_CFG_MOH_SRAM_PWRDWN; __raw_writel(idle_cfg, APMU_MOH_IDLE_CFG); /* disable L2 */ outer_disable(); /* wait for l2 idle */ while (!(readl(CIU_REG(0x8)) & (1 << 16))) udelay(1); cpu_do_idle(); /* enable L2 */ outer_resume(); /* wait for l2 idle */ while (!(readl(CIU_REG(0x8)) & (1 << 16))) udelay(1); idle_cfg = __raw_readl(APMU_MOH_IDLE_CFG); idle_cfg &= ~(APMU_MOH_IDLE_CFG_MOH_PWRDWN | APMU_MOH_IDLE_CFG_MOH_SRAM_PWRDWN); __raw_writel(idle_cfg, APMU_MOH_IDLE_CFG); return 0; } /* * Called after processes are frozen, but before we shut down devices. */ static int pxa910_pm_prepare(void) { pxa910_pm_enter_lowpower_mode(POWER_MODE_UDR); return 0; } /* * Called after devices are re-setup, but before processes are thawed. */ static void pxa910_pm_finish(void) { pxa910_pm_enter_lowpower_mode(POWER_MODE_CORE_INTIDLE); } static int pxa910_pm_valid(suspend_state_t state) { return ((state == PM_SUSPEND_STANDBY) || (state == PM_SUSPEND_MEM)); } static const struct platform_suspend_ops pxa910_pm_ops = { .valid = pxa910_pm_valid, .prepare = pxa910_pm_prepare, .enter = pxa910_pm_enter, .finish = pxa910_pm_finish, }; static int __init pxa910_pm_init(void) { uint32_t awucrm = 0; if (!cpu_is_pxa910()) return -EIO; suspend_set_ops(&pxa910_pm_ops); /* Set the following bits for MMP3 playback with VCTXO on */ __raw_writel(__raw_readl(APMU_SQU_CLK_GATE_CTRL) | (1 << 30), APMU_SQU_CLK_GATE_CTRL); __raw_writel(__raw_readl(MPMU_FCCR) | (1 << 28), MPMU_FCCR); awucrm |= MPMU_AWUCRM_AP_ASYNC_INT | MPMU_AWUCRM_AP_FULL_IDLE; __raw_writel(awucrm, MPMU_AWUCRM); return 0; } late_initcall(pxa910_pm_init);
gpl-2.0
segment-routing/openwrt
arch/x86/kernel/acpi/apei.c
1656
1723
/* * Arch-specific APEI-related functions. * * 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. */ #include <acpi/apei.h> #include <asm/mce.h> #include <asm/tlbflush.h> int arch_apei_enable_cmcff(struct acpi_hest_header *hest_hdr, void *data) { #ifdef CONFIG_X86_MCE int i; struct acpi_hest_ia_corrected *cmc; struct acpi_hest_ia_error_bank *mc_bank; if (hest_hdr->type != ACPI_HEST_TYPE_IA32_CORRECTED_CHECK) return 0; cmc = (struct acpi_hest_ia_corrected *)hest_hdr; if (!cmc->enabled) return 0; /* * We expect HEST to provide a list of MC banks that report errors * in firmware first mode. Otherwise, return non-zero value to * indicate that we are done parsing HEST. */ if (!(cmc->flags & ACPI_HEST_FIRMWARE_FIRST) || !cmc->num_hardware_banks) return 1; pr_info("HEST: Enabling Firmware First mode for corrected errors.\n"); mc_bank = (struct acpi_hest_ia_error_bank *)(cmc + 1); for (i = 0; i < cmc->num_hardware_banks; i++, mc_bank++) mce_disable_bank(mc_bank->bank_number); #endif return 1; } void arch_apei_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) { #ifdef CONFIG_X86_MCE apei_mce_report_mem_error(sev, mem_err); #endif } void arch_apei_flush_tlb_one(unsigned long addr) { __flush_tlb_one(addr); }
gpl-2.0
riverzhou/kernel-c8500
arch/arm/mach-pxa/am200epd.c
1656
9652
/* * am200epd.c -- Platform device for AM200 EPD kit * * Copyright (C) 2008, Jaya Kumar * * 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. * * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven. * * This work was made possible by help and equipment support from E-Ink * Corporation. http://support.eink.com/community * * This driver is written to be used with the Metronome display controller. * on the AM200 EPD prototype kit/development kit with an E-Ink 800x600 * Vizplex EPD on a Gumstix board using the Lyre interface board. * */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/irq.h> #include <linux/gpio.h> #include <mach/pxa25x.h> #include <mach/gumstix.h> #include <mach/pxafb.h> #include "generic.h" #include <video/metronomefb.h> static unsigned int panel_type = 6; static struct platform_device *am200_device; static struct metronome_board am200_board; static struct pxafb_mode_info am200_fb_mode_9inch7 = { .pixclock = 40000, .xres = 1200, .yres = 842, .bpp = 16, .hsync_len = 2, .left_margin = 2, .right_margin = 2, .vsync_len = 1, .upper_margin = 2, .lower_margin = 25, .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, }; static struct pxafb_mode_info am200_fb_mode_8inch = { .pixclock = 40000, .xres = 1088, .yres = 791, .bpp = 16, .hsync_len = 28, .left_margin = 8, .right_margin = 30, .vsync_len = 8, .upper_margin = 10, .lower_margin = 8, .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, }; static struct pxafb_mode_info am200_fb_mode_6inch = { .pixclock = 40189, .xres = 832, .yres = 622, .bpp = 16, .hsync_len = 28, .left_margin = 34, .right_margin = 34, .vsync_len = 25, .upper_margin = 0, .lower_margin = 2, .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, }; static struct pxafb_mach_info am200_fb_info = { .modes = &am200_fb_mode_6inch, .num_modes = 1, .lcd_conn = LCD_TYPE_COLOR_TFT | LCD_PCLK_EDGE_FALL | LCD_AC_BIAS_FREQ(24), }; /* register offsets for gpio control */ #define LED_GPIO_PIN 51 #define STDBY_GPIO_PIN 48 #define RST_GPIO_PIN 49 #define RDY_GPIO_PIN 32 #define ERR_GPIO_PIN 17 #define PCBPWR_GPIO_PIN 16 static int gpios[] = { LED_GPIO_PIN , STDBY_GPIO_PIN , RST_GPIO_PIN, RDY_GPIO_PIN, ERR_GPIO_PIN, PCBPWR_GPIO_PIN }; static char *gpio_names[] = { "LED" , "STDBY" , "RST", "RDY", "ERR", "PCBPWR" }; static int am200_init_gpio_regs(struct metronomefb_par *par) { int i; int err; for (i = 0; i < ARRAY_SIZE(gpios); i++) { err = gpio_request(gpios[i], gpio_names[i]); if (err) { dev_err(&am200_device->dev, "failed requesting " "gpio %s, err=%d\n", gpio_names[i], err); goto err_req_gpio; } } gpio_direction_output(LED_GPIO_PIN, 0); gpio_direction_output(STDBY_GPIO_PIN, 0); gpio_direction_output(RST_GPIO_PIN, 0); gpio_direction_input(RDY_GPIO_PIN); gpio_direction_input(ERR_GPIO_PIN); gpio_direction_output(PCBPWR_GPIO_PIN, 0); return 0; err_req_gpio: while (i > 0) gpio_free(gpios[i--]); return err; } static void am200_cleanup(struct metronomefb_par *par) { int i; free_irq(IRQ_GPIO(RDY_GPIO_PIN), par); for (i = 0; i < ARRAY_SIZE(gpios); i++) gpio_free(gpios[i]); } static int am200_share_video_mem(struct fb_info *info) { /* rough check if this is our desired fb and not something else */ if ((info->var.xres != am200_fb_info.modes->xres) || (info->var.yres != am200_fb_info.modes->yres)) return 0; /* we've now been notified that we have our new fb */ am200_board.metromem = info->screen_base; am200_board.host_fbinfo = info; /* try to refcount host drv since we are the consumer after this */ if (!try_module_get(info->fbops->owner)) return -ENODEV; return 0; } static int am200_unshare_video_mem(struct fb_info *info) { dev_dbg(&am200_device->dev, "ENTER %s\n", __func__); if (info != am200_board.host_fbinfo) return 0; module_put(am200_board.host_fbinfo->fbops->owner); return 0; } static int am200_fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data) { struct fb_event *evdata = data; struct fb_info *info = evdata->info; dev_dbg(&am200_device->dev, "ENTER %s\n", __func__); if (event == FB_EVENT_FB_REGISTERED) return am200_share_video_mem(info); else if (event == FB_EVENT_FB_UNREGISTERED) return am200_unshare_video_mem(info); return 0; } static struct notifier_block am200_fb_notif = { .notifier_call = am200_fb_notifier_callback, }; /* this gets called as part of our init. these steps must be done now so * that we can use set_pxa_fb_info */ static void __init am200_presetup_fb(void) { int fw; int fh; int padding_size; int totalsize; switch (panel_type) { case 6: am200_fb_info.modes = &am200_fb_mode_6inch; break; case 8: am200_fb_info.modes = &am200_fb_mode_8inch; break; case 97: am200_fb_info.modes = &am200_fb_mode_9inch7; break; default: dev_err(&am200_device->dev, "invalid panel_type selection," " setting to 6\n"); am200_fb_info.modes = &am200_fb_mode_6inch; break; } /* the frame buffer is divided as follows: command | CRC | padding 16kb waveform data | CRC | padding image data | CRC */ fw = am200_fb_info.modes->xres; fh = am200_fb_info.modes->yres; /* waveform must be 16k + 2 for checksum */ am200_board.wfm_size = roundup(16*1024 + 2, fw); padding_size = PAGE_SIZE + (4 * fw); /* total is 1 cmd , 1 wfm, padding and image */ totalsize = fw + am200_board.wfm_size + padding_size + (fw*fh); /* save this off because we're manipulating fw after this and * we'll need it when we're ready to setup the framebuffer */ am200_board.fw = fw; am200_board.fh = fh; /* the reason we do this adjustment is because we want to acquire * more framebuffer memory without imposing custom awareness on the * underlying pxafb driver */ am200_fb_info.modes->yres = DIV_ROUND_UP(totalsize, fw); /* we divide since we told the LCD controller we're 16bpp */ am200_fb_info.modes->xres /= 2; set_pxa_fb_info(&am200_fb_info); } /* this gets called by metronomefb as part of its init, in our case, we * have already completed initial framebuffer init in presetup_fb so we * can just setup the fb access pointers */ static int am200_setup_fb(struct metronomefb_par *par) { int fw; int fh; fw = am200_board.fw; fh = am200_board.fh; /* metromem was set up by the notifier in share_video_mem so now * we can use its value to calculate the other entries */ par->metromem_cmd = (struct metromem_cmd *) am200_board.metromem; par->metromem_wfm = am200_board.metromem + fw; par->metromem_img = par->metromem_wfm + am200_board.wfm_size; par->metromem_img_csum = (u16 *) (par->metromem_img + (fw * fh)); par->metromem_dma = am200_board.host_fbinfo->fix.smem_start; return 0; } static int am200_get_panel_type(void) { return panel_type; } static irqreturn_t am200_handle_irq(int irq, void *dev_id) { struct metronomefb_par *par = dev_id; wake_up_interruptible(&par->waitq); return IRQ_HANDLED; } static int am200_setup_irq(struct fb_info *info) { int ret; ret = request_irq(IRQ_GPIO(RDY_GPIO_PIN), am200_handle_irq, IRQF_DISABLED|IRQF_TRIGGER_FALLING, "AM200", info->par); if (ret) dev_err(&am200_device->dev, "request_irq failed: %d\n", ret); return ret; } static void am200_set_rst(struct metronomefb_par *par, int state) { gpio_set_value(RST_GPIO_PIN, state); } static void am200_set_stdby(struct metronomefb_par *par, int state) { gpio_set_value(STDBY_GPIO_PIN, state); } static int am200_wait_event(struct metronomefb_par *par) { return wait_event_timeout(par->waitq, gpio_get_value(RDY_GPIO_PIN), HZ); } static int am200_wait_event_intr(struct metronomefb_par *par) { return wait_event_interruptible_timeout(par->waitq, gpio_get_value(RDY_GPIO_PIN), HZ); } static struct metronome_board am200_board = { .owner = THIS_MODULE, .setup_irq = am200_setup_irq, .setup_io = am200_init_gpio_regs, .setup_fb = am200_setup_fb, .set_rst = am200_set_rst, .set_stdby = am200_set_stdby, .met_wait_event = am200_wait_event, .met_wait_event_intr = am200_wait_event_intr, .get_panel_type = am200_get_panel_type, .cleanup = am200_cleanup, }; static unsigned long am200_pin_config[] __initdata = { GPIO51_GPIO, GPIO49_GPIO, GPIO48_GPIO, GPIO32_GPIO, GPIO17_GPIO, GPIO16_GPIO, }; int __init am200_init(void) { int ret; /* before anything else, we request notification for any fb * creation events */ fb_register_client(&am200_fb_notif); pxa2xx_mfp_config(ARRAY_AND_SIZE(am200_pin_config)); /* request our platform independent driver */ request_module("metronomefb"); am200_device = platform_device_alloc("metronomefb", -1); if (!am200_device) return -ENOMEM; /* the am200_board that will be seen by metronomefb is a copy */ platform_device_add_data(am200_device, &am200_board, sizeof(am200_board)); /* this _add binds metronomefb to am200. metronomefb refcounts am200 */ ret = platform_device_add(am200_device); if (ret) { platform_device_put(am200_device); fb_unregister_client(&am200_fb_notif); return ret; } am200_presetup_fb(); return 0; } module_param(panel_type, uint, 0); MODULE_PARM_DESC(panel_type, "Select the panel type: 6, 8, 97"); MODULE_DESCRIPTION("board driver for am200 metronome epd kit"); MODULE_AUTHOR("Jaya Kumar"); MODULE_LICENSE("GPL");
gpl-2.0
compulab/trimslice-android-kernel
drivers/video/via/via_i2c.c
3192
7027
/* * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; * either version 2, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; 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/platform_device.h> #include <linux/delay.h> #include <linux/spinlock.h> #include <linux/module.h> #include <linux/via-core.h> #include <linux/via_i2c.h> /* * There can only be one set of these, so there's no point in having * them be dynamically allocated... */ #define VIAFB_NUM_I2C 5 static struct via_i2c_stuff via_i2c_par[VIAFB_NUM_I2C]; static struct viafb_dev *i2c_vdev; /* Passed in from core */ static void via_i2c_setscl(void *data, int state) { u8 val; struct via_port_cfg *adap_data = data; unsigned long flags; spin_lock_irqsave(&i2c_vdev->reg_lock, flags); val = via_read_reg(adap_data->io_port, adap_data->ioport_index) & 0xF0; if (state) val |= 0x20; else val &= ~0x20; switch (adap_data->type) { case VIA_PORT_I2C: val |= 0x01; break; case VIA_PORT_GPIO: val |= 0x80; break; default: printk(KERN_ERR "viafb_i2c: specify wrong i2c type.\n"); } via_write_reg(adap_data->io_port, adap_data->ioport_index, val); spin_unlock_irqrestore(&i2c_vdev->reg_lock, flags); } static int via_i2c_getscl(void *data) { struct via_port_cfg *adap_data = data; unsigned long flags; int ret = 0; spin_lock_irqsave(&i2c_vdev->reg_lock, flags); if (via_read_reg(adap_data->io_port, adap_data->ioport_index) & 0x08) ret = 1; spin_unlock_irqrestore(&i2c_vdev->reg_lock, flags); return ret; } static int via_i2c_getsda(void *data) { struct via_port_cfg *adap_data = data; unsigned long flags; int ret = 0; spin_lock_irqsave(&i2c_vdev->reg_lock, flags); if (via_read_reg(adap_data->io_port, adap_data->ioport_index) & 0x04) ret = 1; spin_unlock_irqrestore(&i2c_vdev->reg_lock, flags); return ret; } static void via_i2c_setsda(void *data, int state) { u8 val; struct via_port_cfg *adap_data = data; unsigned long flags; spin_lock_irqsave(&i2c_vdev->reg_lock, flags); val = via_read_reg(adap_data->io_port, adap_data->ioport_index) & 0xF0; if (state) val |= 0x10; else val &= ~0x10; switch (adap_data->type) { case VIA_PORT_I2C: val |= 0x01; break; case VIA_PORT_GPIO: val |= 0x40; break; default: printk(KERN_ERR "viafb_i2c: specify wrong i2c type.\n"); } via_write_reg(adap_data->io_port, adap_data->ioport_index, val); spin_unlock_irqrestore(&i2c_vdev->reg_lock, flags); } int viafb_i2c_readbyte(u8 adap, u8 slave_addr, u8 index, u8 *pdata) { int ret; u8 mm1[] = {0x00}; struct i2c_msg msgs[2]; if (!via_i2c_par[adap].is_active) return -ENODEV; *pdata = 0; msgs[0].flags = 0; msgs[1].flags = I2C_M_RD; msgs[0].addr = msgs[1].addr = slave_addr / 2; mm1[0] = index; msgs[0].len = 1; msgs[1].len = 1; msgs[0].buf = mm1; msgs[1].buf = pdata; ret = i2c_transfer(&via_i2c_par[adap].adapter, msgs, 2); if (ret == 2) ret = 0; else if (ret >= 0) ret = -EIO; return ret; } int viafb_i2c_writebyte(u8 adap, u8 slave_addr, u8 index, u8 data) { int ret; u8 msg[2] = { index, data }; struct i2c_msg msgs; if (!via_i2c_par[adap].is_active) return -ENODEV; msgs.flags = 0; msgs.addr = slave_addr / 2; msgs.len = 2; msgs.buf = msg; ret = i2c_transfer(&via_i2c_par[adap].adapter, &msgs, 1); if (ret == 1) ret = 0; else if (ret >= 0) ret = -EIO; return ret; } int viafb_i2c_readbytes(u8 adap, u8 slave_addr, u8 index, u8 *buff, int buff_len) { int ret; u8 mm1[] = {0x00}; struct i2c_msg msgs[2]; if (!via_i2c_par[adap].is_active) return -ENODEV; msgs[0].flags = 0; msgs[1].flags = I2C_M_RD; msgs[0].addr = msgs[1].addr = slave_addr / 2; mm1[0] = index; msgs[0].len = 1; msgs[1].len = buff_len; msgs[0].buf = mm1; msgs[1].buf = buff; ret = i2c_transfer(&via_i2c_par[adap].adapter, msgs, 2); if (ret == 2) ret = 0; else if (ret >= 0) ret = -EIO; return ret; } /* * Allow other viafb subdevices to look up a specific adapter * by port name. */ struct i2c_adapter *viafb_find_i2c_adapter(enum viafb_i2c_adap which) { struct via_i2c_stuff *stuff = &via_i2c_par[which]; return &stuff->adapter; } EXPORT_SYMBOL_GPL(viafb_find_i2c_adapter); static int create_i2c_bus(struct i2c_adapter *adapter, struct i2c_algo_bit_data *algo, struct via_port_cfg *adap_cfg, struct pci_dev *pdev) { algo->setsda = via_i2c_setsda; algo->setscl = via_i2c_setscl; algo->getsda = via_i2c_getsda; algo->getscl = via_i2c_getscl; algo->udelay = 10; algo->timeout = 2; algo->data = adap_cfg; sprintf(adapter->name, "viafb i2c io_port idx 0x%02x", adap_cfg->ioport_index); adapter->owner = THIS_MODULE; adapter->class = I2C_CLASS_DDC; adapter->algo_data = algo; if (pdev) adapter->dev.parent = &pdev->dev; else adapter->dev.parent = NULL; /* i2c_set_adapdata(adapter, adap_cfg); */ /* Raise SCL and SDA */ via_i2c_setsda(adap_cfg, 1); via_i2c_setscl(adap_cfg, 1); udelay(20); return i2c_bit_add_bus(adapter); } static int viafb_i2c_probe(struct platform_device *platdev) { int i, ret; struct via_port_cfg *configs; i2c_vdev = platdev->dev.platform_data; configs = i2c_vdev->port_cfg; for (i = 0; i < VIAFB_NUM_PORTS; i++) { struct via_port_cfg *adap_cfg = configs++; struct via_i2c_stuff *i2c_stuff = &via_i2c_par[i]; i2c_stuff->is_active = 0; if (adap_cfg->type == 0 || adap_cfg->mode != VIA_MODE_I2C) continue; ret = create_i2c_bus(&i2c_stuff->adapter, &i2c_stuff->algo, adap_cfg, NULL); /* FIXME: PCIDEV */ if (ret < 0) { printk(KERN_ERR "viafb: cannot create i2c bus %u:%d\n", i, ret); continue; /* Still try to make the rest */ } i2c_stuff->is_active = 1; } return 0; } static int viafb_i2c_remove(struct platform_device *platdev) { int i; for (i = 0; i < VIAFB_NUM_PORTS; i++) { struct via_i2c_stuff *i2c_stuff = &via_i2c_par[i]; /* * Only remove those entries in the array that we've * actually used (and thus initialized algo_data) */ if (i2c_stuff->is_active) i2c_del_adapter(&i2c_stuff->adapter); } return 0; } static struct platform_driver via_i2c_driver = { .driver = { .name = "viafb-i2c", }, .probe = viafb_i2c_probe, .remove = viafb_i2c_remove, }; int viafb_i2c_init(void) { return platform_driver_register(&via_i2c_driver); } void viafb_i2c_exit(void) { platform_driver_unregister(&via_i2c_driver); }
gpl-2.0
FrancescoCG/CrazySuperKernel-TW-MM-KLTE
drivers/dma/ioat/dma_v3.c
3448
38042
/* * This file is provided under a dual BSD/GPLv2 license. When using or * redistributing this file, you may do so under either license. * * GPL LICENSE SUMMARY * * Copyright(c) 2004 - 2009 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions 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. * * The full GNU General Public License is included in this distribution in * the file called "COPYING". * * BSD LICENSE * * Copyright(c) 2004-2009 Intel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ /* * Support routines for v3+ hardware */ #include <linux/pci.h> #include <linux/gfp.h> #include <linux/dmaengine.h> #include <linux/dma-mapping.h> #include <linux/prefetch.h> #include "../dmaengine.h" #include "registers.h" #include "hw.h" #include "dma.h" #include "dma_v2.h" /* ioat hardware assumes at least two sources for raid operations */ #define src_cnt_to_sw(x) ((x) + 2) #define src_cnt_to_hw(x) ((x) - 2) /* provide a lookup table for setting the source address in the base or * extended descriptor of an xor or pq descriptor */ static const u8 xor_idx_to_desc = 0xe0; static const u8 xor_idx_to_field[] = { 1, 4, 5, 6, 7, 0, 1, 2 }; static const u8 pq_idx_to_desc = 0xf8; static const u8 pq_idx_to_field[] = { 1, 4, 5, 0, 1, 2, 4, 5 }; static dma_addr_t xor_get_src(struct ioat_raw_descriptor *descs[2], int idx) { struct ioat_raw_descriptor *raw = descs[xor_idx_to_desc >> idx & 1]; return raw->field[xor_idx_to_field[idx]]; } static void xor_set_src(struct ioat_raw_descriptor *descs[2], dma_addr_t addr, u32 offset, int idx) { struct ioat_raw_descriptor *raw = descs[xor_idx_to_desc >> idx & 1]; raw->field[xor_idx_to_field[idx]] = addr + offset; } static dma_addr_t pq_get_src(struct ioat_raw_descriptor *descs[2], int idx) { struct ioat_raw_descriptor *raw = descs[pq_idx_to_desc >> idx & 1]; return raw->field[pq_idx_to_field[idx]]; } static void pq_set_src(struct ioat_raw_descriptor *descs[2], dma_addr_t addr, u32 offset, u8 coef, int idx) { struct ioat_pq_descriptor *pq = (struct ioat_pq_descriptor *) descs[0]; struct ioat_raw_descriptor *raw = descs[pq_idx_to_desc >> idx & 1]; raw->field[pq_idx_to_field[idx]] = addr + offset; pq->coef[idx] = coef; } static void ioat3_dma_unmap(struct ioat2_dma_chan *ioat, struct ioat_ring_ent *desc, int idx) { struct ioat_chan_common *chan = &ioat->base; struct pci_dev *pdev = chan->device->pdev; size_t len = desc->len; size_t offset = len - desc->hw->size; struct dma_async_tx_descriptor *tx = &desc->txd; enum dma_ctrl_flags flags = tx->flags; switch (desc->hw->ctl_f.op) { case IOAT_OP_COPY: if (!desc->hw->ctl_f.null) /* skip 'interrupt' ops */ ioat_dma_unmap(chan, flags, len, desc->hw); break; case IOAT_OP_FILL: { struct ioat_fill_descriptor *hw = desc->fill; if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) ioat_unmap(pdev, hw->dst_addr - offset, len, PCI_DMA_FROMDEVICE, flags, 1); break; } case IOAT_OP_XOR_VAL: case IOAT_OP_XOR: { struct ioat_xor_descriptor *xor = desc->xor; struct ioat_ring_ent *ext; struct ioat_xor_ext_descriptor *xor_ex = NULL; int src_cnt = src_cnt_to_sw(xor->ctl_f.src_cnt); struct ioat_raw_descriptor *descs[2]; int i; if (src_cnt > 5) { ext = ioat2_get_ring_ent(ioat, idx + 1); xor_ex = ext->xor_ex; } if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) { descs[0] = (struct ioat_raw_descriptor *) xor; descs[1] = (struct ioat_raw_descriptor *) xor_ex; for (i = 0; i < src_cnt; i++) { dma_addr_t src = xor_get_src(descs, i); ioat_unmap(pdev, src - offset, len, PCI_DMA_TODEVICE, flags, 0); } /* dest is a source in xor validate operations */ if (xor->ctl_f.op == IOAT_OP_XOR_VAL) { ioat_unmap(pdev, xor->dst_addr - offset, len, PCI_DMA_TODEVICE, flags, 1); break; } } if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) ioat_unmap(pdev, xor->dst_addr - offset, len, PCI_DMA_FROMDEVICE, flags, 1); break; } case IOAT_OP_PQ_VAL: case IOAT_OP_PQ: { struct ioat_pq_descriptor *pq = desc->pq; struct ioat_ring_ent *ext; struct ioat_pq_ext_descriptor *pq_ex = NULL; int src_cnt = src_cnt_to_sw(pq->ctl_f.src_cnt); struct ioat_raw_descriptor *descs[2]; int i; if (src_cnt > 3) { ext = ioat2_get_ring_ent(ioat, idx + 1); pq_ex = ext->pq_ex; } /* in the 'continue' case don't unmap the dests as sources */ if (dmaf_p_disabled_continue(flags)) src_cnt--; else if (dmaf_continue(flags)) src_cnt -= 3; if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) { descs[0] = (struct ioat_raw_descriptor *) pq; descs[1] = (struct ioat_raw_descriptor *) pq_ex; for (i = 0; i < src_cnt; i++) { dma_addr_t src = pq_get_src(descs, i); ioat_unmap(pdev, src - offset, len, PCI_DMA_TODEVICE, flags, 0); } /* the dests are sources in pq validate operations */ if (pq->ctl_f.op == IOAT_OP_XOR_VAL) { if (!(flags & DMA_PREP_PQ_DISABLE_P)) ioat_unmap(pdev, pq->p_addr - offset, len, PCI_DMA_TODEVICE, flags, 0); if (!(flags & DMA_PREP_PQ_DISABLE_Q)) ioat_unmap(pdev, pq->q_addr - offset, len, PCI_DMA_TODEVICE, flags, 0); break; } } if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) { if (!(flags & DMA_PREP_PQ_DISABLE_P)) ioat_unmap(pdev, pq->p_addr - offset, len, PCI_DMA_BIDIRECTIONAL, flags, 1); if (!(flags & DMA_PREP_PQ_DISABLE_Q)) ioat_unmap(pdev, pq->q_addr - offset, len, PCI_DMA_BIDIRECTIONAL, flags, 1); } break; } default: dev_err(&pdev->dev, "%s: unknown op type: %#x\n", __func__, desc->hw->ctl_f.op); } } static bool desc_has_ext(struct ioat_ring_ent *desc) { struct ioat_dma_descriptor *hw = desc->hw; if (hw->ctl_f.op == IOAT_OP_XOR || hw->ctl_f.op == IOAT_OP_XOR_VAL) { struct ioat_xor_descriptor *xor = desc->xor; if (src_cnt_to_sw(xor->ctl_f.src_cnt) > 5) return true; } else if (hw->ctl_f.op == IOAT_OP_PQ || hw->ctl_f.op == IOAT_OP_PQ_VAL) { struct ioat_pq_descriptor *pq = desc->pq; if (src_cnt_to_sw(pq->ctl_f.src_cnt) > 3) return true; } return false; } /** * __cleanup - reclaim used descriptors * @ioat: channel (ring) to clean * * The difference from the dma_v2.c __cleanup() is that this routine * handles extended descriptors and dma-unmapping raid operations. */ static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete) { struct ioat_chan_common *chan = &ioat->base; struct ioat_ring_ent *desc; bool seen_current = false; int idx = ioat->tail, i; u16 active; dev_dbg(to_dev(chan), "%s: head: %#x tail: %#x issued: %#x\n", __func__, ioat->head, ioat->tail, ioat->issued); active = ioat2_ring_active(ioat); for (i = 0; i < active && !seen_current; i++) { struct dma_async_tx_descriptor *tx; smp_read_barrier_depends(); prefetch(ioat2_get_ring_ent(ioat, idx + i + 1)); desc = ioat2_get_ring_ent(ioat, idx + i); dump_desc_dbg(ioat, desc); tx = &desc->txd; if (tx->cookie) { dma_cookie_complete(tx); ioat3_dma_unmap(ioat, desc, idx + i); if (tx->callback) { tx->callback(tx->callback_param); tx->callback = NULL; } } if (tx->phys == phys_complete) seen_current = true; /* skip extended descriptors */ if (desc_has_ext(desc)) { BUG_ON(i + 1 >= active); i++; } } smp_mb(); /* finish all descriptor reads before incrementing tail */ ioat->tail = idx + i; BUG_ON(active && !seen_current); /* no active descs have written a completion? */ chan->last_completion = phys_complete; if (active - i == 0) { dev_dbg(to_dev(chan), "%s: cancel completion timeout\n", __func__); clear_bit(IOAT_COMPLETION_PENDING, &chan->state); mod_timer(&chan->timer, jiffies + IDLE_TIMEOUT); } /* 5 microsecond delay per pending descriptor */ writew(min((5 * (active - i)), IOAT_INTRDELAY_MASK), chan->device->reg_base + IOAT_INTRDELAY_OFFSET); } static void ioat3_cleanup(struct ioat2_dma_chan *ioat) { struct ioat_chan_common *chan = &ioat->base; dma_addr_t phys_complete; spin_lock_bh(&chan->cleanup_lock); if (ioat_cleanup_preamble(chan, &phys_complete)) __cleanup(ioat, phys_complete); spin_unlock_bh(&chan->cleanup_lock); } static void ioat3_cleanup_event(unsigned long data) { struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data); ioat3_cleanup(ioat); writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET); } static void ioat3_restart_channel(struct ioat2_dma_chan *ioat) { struct ioat_chan_common *chan = &ioat->base; dma_addr_t phys_complete; ioat2_quiesce(chan, 0); if (ioat_cleanup_preamble(chan, &phys_complete)) __cleanup(ioat, phys_complete); __ioat2_restart_chan(ioat); } static void ioat3_timer_event(unsigned long data) { struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data); struct ioat_chan_common *chan = &ioat->base; if (test_bit(IOAT_COMPLETION_PENDING, &chan->state)) { dma_addr_t phys_complete; u64 status; status = ioat_chansts(chan); /* when halted due to errors check for channel * programming errors before advancing the completion state */ if (is_ioat_halted(status)) { u32 chanerr; chanerr = readl(chan->reg_base + IOAT_CHANERR_OFFSET); dev_err(to_dev(chan), "%s: Channel halted (%x)\n", __func__, chanerr); if (test_bit(IOAT_RUN, &chan->state)) BUG_ON(is_ioat_bug(chanerr)); else /* we never got off the ground */ return; } /* if we haven't made progress and we have already * acknowledged a pending completion once, then be more * forceful with a restart */ spin_lock_bh(&chan->cleanup_lock); if (ioat_cleanup_preamble(chan, &phys_complete)) __cleanup(ioat, phys_complete); else if (test_bit(IOAT_COMPLETION_ACK, &chan->state)) { spin_lock_bh(&ioat->prep_lock); ioat3_restart_channel(ioat); spin_unlock_bh(&ioat->prep_lock); } else { set_bit(IOAT_COMPLETION_ACK, &chan->state); mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT); } spin_unlock_bh(&chan->cleanup_lock); } else { u16 active; /* if the ring is idle, empty, and oversized try to step * down the size */ spin_lock_bh(&chan->cleanup_lock); spin_lock_bh(&ioat->prep_lock); active = ioat2_ring_active(ioat); if (active == 0 && ioat->alloc_order > ioat_get_alloc_order()) reshape_ring(ioat, ioat->alloc_order-1); spin_unlock_bh(&ioat->prep_lock); spin_unlock_bh(&chan->cleanup_lock); /* keep shrinking until we get back to our minimum * default size */ if (ioat->alloc_order > ioat_get_alloc_order()) mod_timer(&chan->timer, jiffies + IDLE_TIMEOUT); } } static enum dma_status ioat3_tx_status(struct dma_chan *c, dma_cookie_t cookie, struct dma_tx_state *txstate) { struct ioat2_dma_chan *ioat = to_ioat2_chan(c); enum dma_status ret; ret = dma_cookie_status(c, cookie, txstate); if (ret == DMA_SUCCESS) return ret; ioat3_cleanup(ioat); return dma_cookie_status(c, cookie, txstate); } static struct dma_async_tx_descriptor * ioat3_prep_memset_lock(struct dma_chan *c, dma_addr_t dest, int value, size_t len, unsigned long flags) { struct ioat2_dma_chan *ioat = to_ioat2_chan(c); struct ioat_ring_ent *desc; size_t total_len = len; struct ioat_fill_descriptor *fill; u64 src_data = (0x0101010101010101ULL) * (value & 0xff); int num_descs, idx, i; num_descs = ioat2_xferlen_to_descs(ioat, len); if (likely(num_descs) && ioat2_check_space_lock(ioat, num_descs) == 0) idx = ioat->head; else return NULL; i = 0; do { size_t xfer_size = min_t(size_t, len, 1 << ioat->xfercap_log); desc = ioat2_get_ring_ent(ioat, idx + i); fill = desc->fill; fill->size = xfer_size; fill->src_data = src_data; fill->dst_addr = dest; fill->ctl = 0; fill->ctl_f.op = IOAT_OP_FILL; len -= xfer_size; dest += xfer_size; dump_desc_dbg(ioat, desc); } while (++i < num_descs); desc->txd.flags = flags; desc->len = total_len; fill->ctl_f.int_en = !!(flags & DMA_PREP_INTERRUPT); fill->ctl_f.fence = !!(flags & DMA_PREP_FENCE); fill->ctl_f.compl_write = 1; dump_desc_dbg(ioat, desc); /* we leave the channel locked to ensure in order submission */ return &desc->txd; } static struct dma_async_tx_descriptor * __ioat3_prep_xor_lock(struct dma_chan *c, enum sum_check_flags *result, dma_addr_t dest, dma_addr_t *src, unsigned int src_cnt, size_t len, unsigned long flags) { struct ioat2_dma_chan *ioat = to_ioat2_chan(c); struct ioat_ring_ent *compl_desc; struct ioat_ring_ent *desc; struct ioat_ring_ent *ext; size_t total_len = len; struct ioat_xor_descriptor *xor; struct ioat_xor_ext_descriptor *xor_ex = NULL; struct ioat_dma_descriptor *hw; int num_descs, with_ext, idx, i; u32 offset = 0; u8 op = result ? IOAT_OP_XOR_VAL : IOAT_OP_XOR; BUG_ON(src_cnt < 2); num_descs = ioat2_xferlen_to_descs(ioat, len); /* we need 2x the number of descriptors to cover greater than 5 * sources */ if (src_cnt > 5) { with_ext = 1; num_descs *= 2; } else with_ext = 0; /* completion writes from the raid engine may pass completion * writes from the legacy engine, so we need one extra null * (legacy) descriptor to ensure all completion writes arrive in * order. */ if (likely(num_descs) && ioat2_check_space_lock(ioat, num_descs+1) == 0) idx = ioat->head; else return NULL; i = 0; do { struct ioat_raw_descriptor *descs[2]; size_t xfer_size = min_t(size_t, len, 1 << ioat->xfercap_log); int s; desc = ioat2_get_ring_ent(ioat, idx + i); xor = desc->xor; /* save a branch by unconditionally retrieving the * extended descriptor xor_set_src() knows to not write * to it in the single descriptor case */ ext = ioat2_get_ring_ent(ioat, idx + i + 1); xor_ex = ext->xor_ex; descs[0] = (struct ioat_raw_descriptor *) xor; descs[1] = (struct ioat_raw_descriptor *) xor_ex; for (s = 0; s < src_cnt; s++) xor_set_src(descs, src[s], offset, s); xor->size = xfer_size; xor->dst_addr = dest + offset; xor->ctl = 0; xor->ctl_f.op = op; xor->ctl_f.src_cnt = src_cnt_to_hw(src_cnt); len -= xfer_size; offset += xfer_size; dump_desc_dbg(ioat, desc); } while ((i += 1 + with_ext) < num_descs); /* last xor descriptor carries the unmap parameters and fence bit */ desc->txd.flags = flags; desc->len = total_len; if (result) desc->result = result; xor->ctl_f.fence = !!(flags & DMA_PREP_FENCE); /* completion descriptor carries interrupt bit */ compl_desc = ioat2_get_ring_ent(ioat, idx + i); compl_desc->txd.flags = flags & DMA_PREP_INTERRUPT; hw = compl_desc->hw; hw->ctl = 0; hw->ctl_f.null = 1; hw->ctl_f.int_en = !!(flags & DMA_PREP_INTERRUPT); hw->ctl_f.compl_write = 1; hw->size = NULL_DESC_BUFFER_SIZE; dump_desc_dbg(ioat, compl_desc); /* we leave the channel locked to ensure in order submission */ return &compl_desc->txd; } static struct dma_async_tx_descriptor * ioat3_prep_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src, unsigned int src_cnt, size_t len, unsigned long flags) { return __ioat3_prep_xor_lock(chan, NULL, dest, src, src_cnt, len, flags); } struct dma_async_tx_descriptor * ioat3_prep_xor_val(struct dma_chan *chan, dma_addr_t *src, unsigned int src_cnt, size_t len, enum sum_check_flags *result, unsigned long flags) { /* the cleanup routine only sets bits on validate failure, it * does not clear bits on validate success... so clear it here */ *result = 0; return __ioat3_prep_xor_lock(chan, result, src[0], &src[1], src_cnt - 1, len, flags); } static void dump_pq_desc_dbg(struct ioat2_dma_chan *ioat, struct ioat_ring_ent *desc, struct ioat_ring_ent *ext) { struct device *dev = to_dev(&ioat->base); struct ioat_pq_descriptor *pq = desc->pq; struct ioat_pq_ext_descriptor *pq_ex = ext ? ext->pq_ex : NULL; struct ioat_raw_descriptor *descs[] = { (void *) pq, (void *) pq_ex }; int src_cnt = src_cnt_to_sw(pq->ctl_f.src_cnt); int i; dev_dbg(dev, "desc[%d]: (%#llx->%#llx) flags: %#x" " sz: %#x ctl: %#x (op: %d int: %d compl: %d pq: '%s%s' src_cnt: %d)\n", desc_id(desc), (unsigned long long) desc->txd.phys, (unsigned long long) (pq_ex ? pq_ex->next : pq->next), desc->txd.flags, pq->size, pq->ctl, pq->ctl_f.op, pq->ctl_f.int_en, pq->ctl_f.compl_write, pq->ctl_f.p_disable ? "" : "p", pq->ctl_f.q_disable ? "" : "q", pq->ctl_f.src_cnt); for (i = 0; i < src_cnt; i++) dev_dbg(dev, "\tsrc[%d]: %#llx coef: %#x\n", i, (unsigned long long) pq_get_src(descs, i), pq->coef[i]); dev_dbg(dev, "\tP: %#llx\n", pq->p_addr); dev_dbg(dev, "\tQ: %#llx\n", pq->q_addr); } static struct dma_async_tx_descriptor * __ioat3_prep_pq_lock(struct dma_chan *c, enum sum_check_flags *result, const dma_addr_t *dst, const dma_addr_t *src, unsigned int src_cnt, const unsigned char *scf, size_t len, unsigned long flags) { struct ioat2_dma_chan *ioat = to_ioat2_chan(c); struct ioat_chan_common *chan = &ioat->base; struct ioat_ring_ent *compl_desc; struct ioat_ring_ent *desc; struct ioat_ring_ent *ext; size_t total_len = len; struct ioat_pq_descriptor *pq; struct ioat_pq_ext_descriptor *pq_ex = NULL; struct ioat_dma_descriptor *hw; u32 offset = 0; u8 op = result ? IOAT_OP_PQ_VAL : IOAT_OP_PQ; int i, s, idx, with_ext, num_descs; dev_dbg(to_dev(chan), "%s\n", __func__); /* the engine requires at least two sources (we provide * at least 1 implied source in the DMA_PREP_CONTINUE case) */ BUG_ON(src_cnt + dmaf_continue(flags) < 2); num_descs = ioat2_xferlen_to_descs(ioat, len); /* we need 2x the number of descriptors to cover greater than 3 * sources (we need 1 extra source in the q-only continuation * case and 3 extra sources in the p+q continuation case. */ if (src_cnt + dmaf_p_disabled_continue(flags) > 3 || (dmaf_continue(flags) && !dmaf_p_disabled_continue(flags))) { with_ext = 1; num_descs *= 2; } else with_ext = 0; /* completion writes from the raid engine may pass completion * writes from the legacy engine, so we need one extra null * (legacy) descriptor to ensure all completion writes arrive in * order. */ if (likely(num_descs) && ioat2_check_space_lock(ioat, num_descs+1) == 0) idx = ioat->head; else return NULL; i = 0; do { struct ioat_raw_descriptor *descs[2]; size_t xfer_size = min_t(size_t, len, 1 << ioat->xfercap_log); desc = ioat2_get_ring_ent(ioat, idx + i); pq = desc->pq; /* save a branch by unconditionally retrieving the * extended descriptor pq_set_src() knows to not write * to it in the single descriptor case */ ext = ioat2_get_ring_ent(ioat, idx + i + with_ext); pq_ex = ext->pq_ex; descs[0] = (struct ioat_raw_descriptor *) pq; descs[1] = (struct ioat_raw_descriptor *) pq_ex; for (s = 0; s < src_cnt; s++) pq_set_src(descs, src[s], offset, scf[s], s); /* see the comment for dma_maxpq in include/linux/dmaengine.h */ if (dmaf_p_disabled_continue(flags)) pq_set_src(descs, dst[1], offset, 1, s++); else if (dmaf_continue(flags)) { pq_set_src(descs, dst[0], offset, 0, s++); pq_set_src(descs, dst[1], offset, 1, s++); pq_set_src(descs, dst[1], offset, 0, s++); } pq->size = xfer_size; pq->p_addr = dst[0] + offset; pq->q_addr = dst[1] + offset; pq->ctl = 0; pq->ctl_f.op = op; pq->ctl_f.src_cnt = src_cnt_to_hw(s); pq->ctl_f.p_disable = !!(flags & DMA_PREP_PQ_DISABLE_P); pq->ctl_f.q_disable = !!(flags & DMA_PREP_PQ_DISABLE_Q); len -= xfer_size; offset += xfer_size; } while ((i += 1 + with_ext) < num_descs); /* last pq descriptor carries the unmap parameters and fence bit */ desc->txd.flags = flags; desc->len = total_len; if (result) desc->result = result; pq->ctl_f.fence = !!(flags & DMA_PREP_FENCE); dump_pq_desc_dbg(ioat, desc, ext); /* completion descriptor carries interrupt bit */ compl_desc = ioat2_get_ring_ent(ioat, idx + i); compl_desc->txd.flags = flags & DMA_PREP_INTERRUPT; hw = compl_desc->hw; hw->ctl = 0; hw->ctl_f.null = 1; hw->ctl_f.int_en = !!(flags & DMA_PREP_INTERRUPT); hw->ctl_f.compl_write = 1; hw->size = NULL_DESC_BUFFER_SIZE; dump_desc_dbg(ioat, compl_desc); /* we leave the channel locked to ensure in order submission */ return &compl_desc->txd; } static struct dma_async_tx_descriptor * ioat3_prep_pq(struct dma_chan *chan, dma_addr_t *dst, dma_addr_t *src, unsigned int src_cnt, const unsigned char *scf, size_t len, unsigned long flags) { /* specify valid address for disabled result */ if (flags & DMA_PREP_PQ_DISABLE_P) dst[0] = dst[1]; if (flags & DMA_PREP_PQ_DISABLE_Q) dst[1] = dst[0]; /* handle the single source multiply case from the raid6 * recovery path */ if ((flags & DMA_PREP_PQ_DISABLE_P) && src_cnt == 1) { dma_addr_t single_source[2]; unsigned char single_source_coef[2]; BUG_ON(flags & DMA_PREP_PQ_DISABLE_Q); single_source[0] = src[0]; single_source[1] = src[0]; single_source_coef[0] = scf[0]; single_source_coef[1] = 0; return __ioat3_prep_pq_lock(chan, NULL, dst, single_source, 2, single_source_coef, len, flags); } else return __ioat3_prep_pq_lock(chan, NULL, dst, src, src_cnt, scf, len, flags); } struct dma_async_tx_descriptor * ioat3_prep_pq_val(struct dma_chan *chan, dma_addr_t *pq, dma_addr_t *src, unsigned int src_cnt, const unsigned char *scf, size_t len, enum sum_check_flags *pqres, unsigned long flags) { /* specify valid address for disabled result */ if (flags & DMA_PREP_PQ_DISABLE_P) pq[0] = pq[1]; if (flags & DMA_PREP_PQ_DISABLE_Q) pq[1] = pq[0]; /* the cleanup routine only sets bits on validate failure, it * does not clear bits on validate success... so clear it here */ *pqres = 0; return __ioat3_prep_pq_lock(chan, pqres, pq, src, src_cnt, scf, len, flags); } static struct dma_async_tx_descriptor * ioat3_prep_pqxor(struct dma_chan *chan, dma_addr_t dst, dma_addr_t *src, unsigned int src_cnt, size_t len, unsigned long flags) { unsigned char scf[src_cnt]; dma_addr_t pq[2]; memset(scf, 0, src_cnt); pq[0] = dst; flags |= DMA_PREP_PQ_DISABLE_Q; pq[1] = dst; /* specify valid address for disabled result */ return __ioat3_prep_pq_lock(chan, NULL, pq, src, src_cnt, scf, len, flags); } struct dma_async_tx_descriptor * ioat3_prep_pqxor_val(struct dma_chan *chan, dma_addr_t *src, unsigned int src_cnt, size_t len, enum sum_check_flags *result, unsigned long flags) { unsigned char scf[src_cnt]; dma_addr_t pq[2]; /* the cleanup routine only sets bits on validate failure, it * does not clear bits on validate success... so clear it here */ *result = 0; memset(scf, 0, src_cnt); pq[0] = src[0]; flags |= DMA_PREP_PQ_DISABLE_Q; pq[1] = pq[0]; /* specify valid address for disabled result */ return __ioat3_prep_pq_lock(chan, result, pq, &src[1], src_cnt - 1, scf, len, flags); } static struct dma_async_tx_descriptor * ioat3_prep_interrupt_lock(struct dma_chan *c, unsigned long flags) { struct ioat2_dma_chan *ioat = to_ioat2_chan(c); struct ioat_ring_ent *desc; struct ioat_dma_descriptor *hw; if (ioat2_check_space_lock(ioat, 1) == 0) desc = ioat2_get_ring_ent(ioat, ioat->head); else return NULL; hw = desc->hw; hw->ctl = 0; hw->ctl_f.null = 1; hw->ctl_f.int_en = 1; hw->ctl_f.fence = !!(flags & DMA_PREP_FENCE); hw->ctl_f.compl_write = 1; hw->size = NULL_DESC_BUFFER_SIZE; hw->src_addr = 0; hw->dst_addr = 0; desc->txd.flags = flags; desc->len = 1; dump_desc_dbg(ioat, desc); /* we leave the channel locked to ensure in order submission */ return &desc->txd; } static void __devinit ioat3_dma_test_callback(void *dma_async_param) { struct completion *cmp = dma_async_param; complete(cmp); } #define IOAT_NUM_SRC_TEST 6 /* must be <= 8 */ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device) { int i, src_idx; struct page *dest; struct page *xor_srcs[IOAT_NUM_SRC_TEST]; struct page *xor_val_srcs[IOAT_NUM_SRC_TEST + 1]; dma_addr_t dma_srcs[IOAT_NUM_SRC_TEST + 1]; dma_addr_t dma_addr, dest_dma; struct dma_async_tx_descriptor *tx; struct dma_chan *dma_chan; dma_cookie_t cookie; u8 cmp_byte = 0; u32 cmp_word; u32 xor_val_result; int err = 0; struct completion cmp; unsigned long tmo; struct device *dev = &device->pdev->dev; struct dma_device *dma = &device->common; dev_dbg(dev, "%s\n", __func__); if (!dma_has_cap(DMA_XOR, dma->cap_mask)) return 0; for (src_idx = 0; src_idx < IOAT_NUM_SRC_TEST; src_idx++) { xor_srcs[src_idx] = alloc_page(GFP_KERNEL); if (!xor_srcs[src_idx]) { while (src_idx--) __free_page(xor_srcs[src_idx]); return -ENOMEM; } } dest = alloc_page(GFP_KERNEL); if (!dest) { while (src_idx--) __free_page(xor_srcs[src_idx]); return -ENOMEM; } /* Fill in src buffers */ for (src_idx = 0; src_idx < IOAT_NUM_SRC_TEST; src_idx++) { u8 *ptr = page_address(xor_srcs[src_idx]); for (i = 0; i < PAGE_SIZE; i++) ptr[i] = (1 << src_idx); } for (src_idx = 0; src_idx < IOAT_NUM_SRC_TEST; src_idx++) cmp_byte ^= (u8) (1 << src_idx); cmp_word = (cmp_byte << 24) | (cmp_byte << 16) | (cmp_byte << 8) | cmp_byte; memset(page_address(dest), 0, PAGE_SIZE); dma_chan = container_of(dma->channels.next, struct dma_chan, device_node); if (dma->device_alloc_chan_resources(dma_chan) < 1) { err = -ENODEV; goto out; } /* test xor */ dest_dma = dma_map_page(dev, dest, 0, PAGE_SIZE, DMA_FROM_DEVICE); for (i = 0; i < IOAT_NUM_SRC_TEST; i++) dma_srcs[i] = dma_map_page(dev, xor_srcs[i], 0, PAGE_SIZE, DMA_TO_DEVICE); tx = dma->device_prep_dma_xor(dma_chan, dest_dma, dma_srcs, IOAT_NUM_SRC_TEST, PAGE_SIZE, DMA_PREP_INTERRUPT); if (!tx) { dev_err(dev, "Self-test xor prep failed\n"); err = -ENODEV; goto free_resources; } async_tx_ack(tx); init_completion(&cmp); tx->callback = ioat3_dma_test_callback; tx->callback_param = &cmp; cookie = tx->tx_submit(tx); if (cookie < 0) { dev_err(dev, "Self-test xor setup failed\n"); err = -ENODEV; goto free_resources; } dma->device_issue_pending(dma_chan); tmo = wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)); if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) { dev_err(dev, "Self-test xor timed out\n"); err = -ENODEV; goto free_resources; } dma_sync_single_for_cpu(dev, dest_dma, PAGE_SIZE, DMA_FROM_DEVICE); for (i = 0; i < (PAGE_SIZE / sizeof(u32)); i++) { u32 *ptr = page_address(dest); if (ptr[i] != cmp_word) { dev_err(dev, "Self-test xor failed compare\n"); err = -ENODEV; goto free_resources; } } dma_sync_single_for_device(dev, dest_dma, PAGE_SIZE, DMA_TO_DEVICE); /* skip validate if the capability is not present */ if (!dma_has_cap(DMA_XOR_VAL, dma_chan->device->cap_mask)) goto free_resources; /* validate the sources with the destintation page */ for (i = 0; i < IOAT_NUM_SRC_TEST; i++) xor_val_srcs[i] = xor_srcs[i]; xor_val_srcs[i] = dest; xor_val_result = 1; for (i = 0; i < IOAT_NUM_SRC_TEST + 1; i++) dma_srcs[i] = dma_map_page(dev, xor_val_srcs[i], 0, PAGE_SIZE, DMA_TO_DEVICE); tx = dma->device_prep_dma_xor_val(dma_chan, dma_srcs, IOAT_NUM_SRC_TEST + 1, PAGE_SIZE, &xor_val_result, DMA_PREP_INTERRUPT); if (!tx) { dev_err(dev, "Self-test zero prep failed\n"); err = -ENODEV; goto free_resources; } async_tx_ack(tx); init_completion(&cmp); tx->callback = ioat3_dma_test_callback; tx->callback_param = &cmp; cookie = tx->tx_submit(tx); if (cookie < 0) { dev_err(dev, "Self-test zero setup failed\n"); err = -ENODEV; goto free_resources; } dma->device_issue_pending(dma_chan); tmo = wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)); if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) { dev_err(dev, "Self-test validate timed out\n"); err = -ENODEV; goto free_resources; } if (xor_val_result != 0) { dev_err(dev, "Self-test validate failed compare\n"); err = -ENODEV; goto free_resources; } /* skip memset if the capability is not present */ if (!dma_has_cap(DMA_MEMSET, dma_chan->device->cap_mask)) goto free_resources; /* test memset */ dma_addr = dma_map_page(dev, dest, 0, PAGE_SIZE, DMA_FROM_DEVICE); tx = dma->device_prep_dma_memset(dma_chan, dma_addr, 0, PAGE_SIZE, DMA_PREP_INTERRUPT); if (!tx) { dev_err(dev, "Self-test memset prep failed\n"); err = -ENODEV; goto free_resources; } async_tx_ack(tx); init_completion(&cmp); tx->callback = ioat3_dma_test_callback; tx->callback_param = &cmp; cookie = tx->tx_submit(tx); if (cookie < 0) { dev_err(dev, "Self-test memset setup failed\n"); err = -ENODEV; goto free_resources; } dma->device_issue_pending(dma_chan); tmo = wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)); if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) { dev_err(dev, "Self-test memset timed out\n"); err = -ENODEV; goto free_resources; } for (i = 0; i < PAGE_SIZE/sizeof(u32); i++) { u32 *ptr = page_address(dest); if (ptr[i]) { dev_err(dev, "Self-test memset failed compare\n"); err = -ENODEV; goto free_resources; } } /* test for non-zero parity sum */ xor_val_result = 0; for (i = 0; i < IOAT_NUM_SRC_TEST + 1; i++) dma_srcs[i] = dma_map_page(dev, xor_val_srcs[i], 0, PAGE_SIZE, DMA_TO_DEVICE); tx = dma->device_prep_dma_xor_val(dma_chan, dma_srcs, IOAT_NUM_SRC_TEST + 1, PAGE_SIZE, &xor_val_result, DMA_PREP_INTERRUPT); if (!tx) { dev_err(dev, "Self-test 2nd zero prep failed\n"); err = -ENODEV; goto free_resources; } async_tx_ack(tx); init_completion(&cmp); tx->callback = ioat3_dma_test_callback; tx->callback_param = &cmp; cookie = tx->tx_submit(tx); if (cookie < 0) { dev_err(dev, "Self-test 2nd zero setup failed\n"); err = -ENODEV; goto free_resources; } dma->device_issue_pending(dma_chan); tmo = wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)); if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) { dev_err(dev, "Self-test 2nd validate timed out\n"); err = -ENODEV; goto free_resources; } if (xor_val_result != SUM_CHECK_P_RESULT) { dev_err(dev, "Self-test validate failed compare\n"); err = -ENODEV; goto free_resources; } free_resources: dma->device_free_chan_resources(dma_chan); out: src_idx = IOAT_NUM_SRC_TEST; while (src_idx--) __free_page(xor_srcs[src_idx]); __free_page(dest); return err; } static int __devinit ioat3_dma_self_test(struct ioatdma_device *device) { int rc = ioat_dma_self_test(device); if (rc) return rc; rc = ioat_xor_val_self_test(device); if (rc) return rc; return 0; } static int ioat3_reset_hw(struct ioat_chan_common *chan) { /* throw away whatever the channel was doing and get it * initialized, with ioat3 specific workarounds */ struct ioatdma_device *device = chan->device; struct pci_dev *pdev = device->pdev; u32 chanerr; u16 dev_id; int err; ioat2_quiesce(chan, msecs_to_jiffies(100)); chanerr = readl(chan->reg_base + IOAT_CHANERR_OFFSET); writel(chanerr, chan->reg_base + IOAT_CHANERR_OFFSET); /* -= IOAT ver.3 workarounds =- */ /* Write CHANERRMSK_INT with 3E07h to mask out the errors * that can cause stability issues for IOAT ver.3, and clear any * pending errors */ pci_write_config_dword(pdev, IOAT_PCI_CHANERRMASK_INT_OFFSET, 0x3e07); err = pci_read_config_dword(pdev, IOAT_PCI_CHANERR_INT_OFFSET, &chanerr); if (err) { dev_err(&pdev->dev, "channel error register unreachable\n"); return err; } pci_write_config_dword(pdev, IOAT_PCI_CHANERR_INT_OFFSET, chanerr); /* Clear DMAUNCERRSTS Cfg-Reg Parity Error status bit * (workaround for spurious config parity error after restart) */ pci_read_config_word(pdev, IOAT_PCI_DEVICE_ID_OFFSET, &dev_id); if (dev_id == PCI_DEVICE_ID_INTEL_IOAT_TBG0) pci_write_config_dword(pdev, IOAT_PCI_DMAUNCERRSTS_OFFSET, 0x10); return ioat2_reset_sync(chan, msecs_to_jiffies(200)); } static bool is_jf_ioat(struct pci_dev *pdev) { switch (pdev->device) { case PCI_DEVICE_ID_INTEL_IOAT_JSF0: case PCI_DEVICE_ID_INTEL_IOAT_JSF1: case PCI_DEVICE_ID_INTEL_IOAT_JSF2: case PCI_DEVICE_ID_INTEL_IOAT_JSF3: case PCI_DEVICE_ID_INTEL_IOAT_JSF4: case PCI_DEVICE_ID_INTEL_IOAT_JSF5: case PCI_DEVICE_ID_INTEL_IOAT_JSF6: case PCI_DEVICE_ID_INTEL_IOAT_JSF7: case PCI_DEVICE_ID_INTEL_IOAT_JSF8: case PCI_DEVICE_ID_INTEL_IOAT_JSF9: return true; default: return false; } } static bool is_snb_ioat(struct pci_dev *pdev) { switch (pdev->device) { case PCI_DEVICE_ID_INTEL_IOAT_SNB0: case PCI_DEVICE_ID_INTEL_IOAT_SNB1: case PCI_DEVICE_ID_INTEL_IOAT_SNB2: case PCI_DEVICE_ID_INTEL_IOAT_SNB3: case PCI_DEVICE_ID_INTEL_IOAT_SNB4: case PCI_DEVICE_ID_INTEL_IOAT_SNB5: case PCI_DEVICE_ID_INTEL_IOAT_SNB6: case PCI_DEVICE_ID_INTEL_IOAT_SNB7: case PCI_DEVICE_ID_INTEL_IOAT_SNB8: case PCI_DEVICE_ID_INTEL_IOAT_SNB9: return true; default: return false; } } int __devinit ioat3_dma_probe(struct ioatdma_device *device, int dca) { struct pci_dev *pdev = device->pdev; int dca_en = system_has_dca_enabled(pdev); struct dma_device *dma; struct dma_chan *c; struct ioat_chan_common *chan; bool is_raid_device = false; int err; u32 cap; device->enumerate_channels = ioat2_enumerate_channels; device->reset_hw = ioat3_reset_hw; device->self_test = ioat3_dma_self_test; dma = &device->common; dma->device_prep_dma_memcpy = ioat2_dma_prep_memcpy_lock; dma->device_issue_pending = ioat2_issue_pending; dma->device_alloc_chan_resources = ioat2_alloc_chan_resources; dma->device_free_chan_resources = ioat2_free_chan_resources; if (is_jf_ioat(pdev) || is_snb_ioat(pdev)) dma->copy_align = 6; dma_cap_set(DMA_INTERRUPT, dma->cap_mask); dma->device_prep_dma_interrupt = ioat3_prep_interrupt_lock; cap = readl(device->reg_base + IOAT_DMA_CAP_OFFSET); /* dca is incompatible with raid operations */ if (dca_en && (cap & (IOAT_CAP_XOR|IOAT_CAP_PQ))) cap &= ~(IOAT_CAP_XOR|IOAT_CAP_PQ); if (cap & IOAT_CAP_XOR) { is_raid_device = true; dma->max_xor = 8; dma->xor_align = 6; dma_cap_set(DMA_XOR, dma->cap_mask); dma->device_prep_dma_xor = ioat3_prep_xor; dma_cap_set(DMA_XOR_VAL, dma->cap_mask); dma->device_prep_dma_xor_val = ioat3_prep_xor_val; } if (cap & IOAT_CAP_PQ) { is_raid_device = true; dma_set_maxpq(dma, 8, 0); dma->pq_align = 6; dma_cap_set(DMA_PQ, dma->cap_mask); dma->device_prep_dma_pq = ioat3_prep_pq; dma_cap_set(DMA_PQ_VAL, dma->cap_mask); dma->device_prep_dma_pq_val = ioat3_prep_pq_val; if (!(cap & IOAT_CAP_XOR)) { dma->max_xor = 8; dma->xor_align = 6; dma_cap_set(DMA_XOR, dma->cap_mask); dma->device_prep_dma_xor = ioat3_prep_pqxor; dma_cap_set(DMA_XOR_VAL, dma->cap_mask); dma->device_prep_dma_xor_val = ioat3_prep_pqxor_val; } } if (is_raid_device && (cap & IOAT_CAP_FILL_BLOCK)) { dma_cap_set(DMA_MEMSET, dma->cap_mask); dma->device_prep_dma_memset = ioat3_prep_memset_lock; } if (is_raid_device) { dma->device_tx_status = ioat3_tx_status; device->cleanup_fn = ioat3_cleanup_event; device->timer_fn = ioat3_timer_event; } else { dma->device_tx_status = ioat_dma_tx_status; device->cleanup_fn = ioat2_cleanup_event; device->timer_fn = ioat2_timer_event; } #ifdef CONFIG_ASYNC_TX_DISABLE_PQ_VAL_DMA dma_cap_clear(DMA_PQ_VAL, dma->cap_mask); dma->device_prep_dma_pq_val = NULL; #endif #ifdef CONFIG_ASYNC_TX_DISABLE_XOR_VAL_DMA dma_cap_clear(DMA_XOR_VAL, dma->cap_mask); dma->device_prep_dma_xor_val = NULL; #endif err = ioat_probe(device); if (err) return err; ioat_set_tcp_copy_break(262144); list_for_each_entry(c, &dma->channels, device_node) { chan = to_chan_common(c); writel(IOAT_DMA_DCA_ANY_CPU, chan->reg_base + IOAT_DCACTRL_OFFSET); } err = ioat_register(device); if (err) return err; ioat_kobject_add(device, &ioat2_ktype); if (dca) device->dca = ioat3_dca_init(pdev, device->reg_base); return 0; }
gpl-2.0
EloYGomeZ/android-kenel-3.4.0
drivers/isdn/hisax/isar.c
4984
51614
/* $Id: isar.c,v 1.22.2.6 2004/02/11 13:21:34 keil Exp $ * * isar.c ISAR (Siemens PSB 7110) specific routines * * Author Karsten Keil (keil@isdn4linux.de) * * This file is (c) under GNU General Public License * */ #include <linux/init.h> #include "hisax.h" #include "isar.h" #include "isdnl1.h" #include <linux/interrupt.h> #include <linux/slab.h> #define DBG_LOADFIRM 0 #define DUMP_MBOXFRAME 2 #define DLE 0x10 #define ETX 0x03 #define FAXMODCNT 13 static const u_char faxmodulation[] = {3, 24, 48, 72, 73, 74, 96, 97, 98, 121, 122, 145, 146}; static u_int modmask = 0x1fff; static int frm_extra_delay = 2; static int para_TOA = 6; static const u_char *FC1_CMD[] = {"FAE", "FTS", "FRS", "FTM", "FRM", "FTH", "FRH", "CTRL"}; static void isar_setup(struct IsdnCardState *cs); static void isar_pump_cmd(struct BCState *bcs, u_char cmd, u_char para); static void ll_deliver_faxstat(struct BCState *bcs, u_char status); static inline int waitforHIA(struct IsdnCardState *cs, int timeout) { while ((cs->BC_Read_Reg(cs, 0, ISAR_HIA) & 1) && timeout) { udelay(1); timeout--; } if (!timeout) printk(KERN_WARNING "HiSax: ISAR waitforHIA timeout\n"); return (timeout); } static int sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len, u_char *msg) { int i; if (!waitforHIA(cs, 4000)) return (0); #if DUMP_MBOXFRAME if (cs->debug & L1_DEB_HSCX) debugl1(cs, "sendmsg(%02x,%02x,%d)", his, creg, len); #endif cs->BC_Write_Reg(cs, 0, ISAR_CTRL_H, creg); cs->BC_Write_Reg(cs, 0, ISAR_CTRL_L, len); cs->BC_Write_Reg(cs, 0, ISAR_WADR, 0); if (msg && len) { cs->BC_Write_Reg(cs, 1, ISAR_MBOX, msg[0]); for (i = 1; i < len; i++) cs->BC_Write_Reg(cs, 2, ISAR_MBOX, msg[i]); #if DUMP_MBOXFRAME > 1 if (cs->debug & L1_DEB_HSCX_FIFO) { char tmp[256], *t; i = len; while (i > 0) { t = tmp; t += sprintf(t, "sendmbox cnt %d", len); QuickHex(t, &msg[len-i], (i > 64) ? 64 : i); debugl1(cs, tmp); i -= 64; } } #endif } cs->BC_Write_Reg(cs, 1, ISAR_HIS, his); waitforHIA(cs, 10000); return (1); } /* Call only with IRQ disabled !!! */ static inline void rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg) { int i; cs->BC_Write_Reg(cs, 1, ISAR_RADR, 0); if (msg && ireg->clsb) { msg[0] = cs->BC_Read_Reg(cs, 1, ISAR_MBOX); for (i = 1; i < ireg->clsb; i++) msg[i] = cs->BC_Read_Reg(cs, 2, ISAR_MBOX); #if DUMP_MBOXFRAME > 1 if (cs->debug & L1_DEB_HSCX_FIFO) { char tmp[256], *t; i = ireg->clsb; while (i > 0) { t = tmp; t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb); QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i); debugl1(cs, tmp); i -= 64; } } #endif } cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); } /* Call only with IRQ disabled !!! */ static inline void get_irq_infos(struct IsdnCardState *cs, struct isar_reg *ireg) { ireg->iis = cs->BC_Read_Reg(cs, 1, ISAR_IIS); ireg->cmsb = cs->BC_Read_Reg(cs, 1, ISAR_CTRL_H); ireg->clsb = cs->BC_Read_Reg(cs, 1, ISAR_CTRL_L); #if DUMP_MBOXFRAME if (cs->debug & L1_DEB_HSCX) debugl1(cs, "irq_stat(%02x,%02x,%d)", ireg->iis, ireg->cmsb, ireg->clsb); #endif } static int waitrecmsg(struct IsdnCardState *cs, u_char *len, u_char *msg, int maxdelay) { int timeout = 0; struct isar_reg *ir = cs->bcs[0].hw.isar.reg; while ((!(cs->BC_Read_Reg(cs, 0, ISAR_IRQBIT) & ISAR_IRQSTA)) && (timeout++ < maxdelay)) udelay(1); if (timeout > maxdelay) { printk(KERN_WARNING"isar recmsg IRQSTA timeout\n"); return (0); } get_irq_infos(cs, ir); rcv_mbox(cs, ir, msg); *len = ir->clsb; return (1); } int ISARVersion(struct IsdnCardState *cs, char *s) { int ver; u_char msg[] = ISAR_MSG_HWVER; u_char tmp[64]; u_char len; u_long flags; int debug; cs->cardmsg(cs, CARD_RESET, NULL); spin_lock_irqsave(&cs->lock, flags); /* disable ISAR IRQ */ cs->BC_Write_Reg(cs, 0, ISAR_IRQBIT, 0); debug = cs->debug; cs->debug &= ~(L1_DEB_HSCX | L1_DEB_HSCX_FIFO); if (!sendmsg(cs, ISAR_HIS_VNR, 0, 3, msg)) { spin_unlock_irqrestore(&cs->lock, flags); return (-1); } if (!waitrecmsg(cs, &len, tmp, 100000)) { spin_unlock_irqrestore(&cs->lock, flags); return (-2); } cs->debug = debug; if (cs->bcs[0].hw.isar.reg->iis == ISAR_IIS_VNR) { if (len == 1) { ver = tmp[0] & 0xf; printk(KERN_INFO "%s ISAR version %d\n", s, ver); } else ver = -3; } else ver = -4; spin_unlock_irqrestore(&cs->lock, flags); return (ver); } static int isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) { int cfu_ret, ret, size, cnt, debug; u_char len, nom, noc; u_short sadr, left, *sp; u_char __user *p = buf; u_char *msg, *tmpmsg, *mp, tmp[64]; u_long flags; struct isar_reg *ireg = cs->bcs[0].hw.isar.reg; struct {u_short sadr; u_short len; u_short d_key; } blk_head; #define BLK_HEAD_SIZE 6 if (1 != (ret = ISARVersion(cs, "Testing"))) { printk(KERN_ERR"isar_load_firmware wrong isar version %d\n", ret); return (1); } debug = cs->debug; #if DBG_LOADFIRM < 2 cs->debug &= ~(L1_DEB_HSCX | L1_DEB_HSCX_FIFO); #endif cfu_ret = copy_from_user(&size, p, sizeof(int)); if (cfu_ret) { printk(KERN_ERR "isar_load_firmware copy_from_user ret %d\n", cfu_ret); return -EFAULT; } p += sizeof(int); printk(KERN_DEBUG"isar_load_firmware size: %d\n", size); cnt = 0; /* disable ISAR IRQ */ cs->BC_Write_Reg(cs, 0, ISAR_IRQBIT, 0); if (!(msg = kmalloc(256, GFP_KERNEL))) { printk(KERN_ERR"isar_load_firmware no buffer\n"); return (1); } if (!(tmpmsg = kmalloc(256, GFP_KERNEL))) { printk(KERN_ERR"isar_load_firmware no tmp buffer\n"); kfree(msg); return (1); } spin_lock_irqsave(&cs->lock, flags); /* disable ISAR IRQ */ cs->BC_Write_Reg(cs, 0, ISAR_IRQBIT, 0); spin_unlock_irqrestore(&cs->lock, flags); while (cnt < size) { if ((ret = copy_from_user(&blk_head, p, BLK_HEAD_SIZE))) { printk(KERN_ERR"isar_load_firmware copy_from_user ret %d\n", ret); goto reterror; } #ifdef __BIG_ENDIAN sadr = (blk_head.sadr & 0xff) * 256 + blk_head.sadr / 256; blk_head.sadr = sadr; sadr = (blk_head.len & 0xff) * 256 + blk_head.len / 256; blk_head.len = sadr; sadr = (blk_head.d_key & 0xff) * 256 + blk_head.d_key / 256; blk_head.d_key = sadr; #endif /* __BIG_ENDIAN */ cnt += BLK_HEAD_SIZE; p += BLK_HEAD_SIZE; printk(KERN_DEBUG"isar firmware block (%#x,%5d,%#x)\n", blk_head.sadr, blk_head.len, blk_head.d_key & 0xff); sadr = blk_head.sadr; left = blk_head.len; spin_lock_irqsave(&cs->lock, flags); if (!sendmsg(cs, ISAR_HIS_DKEY, blk_head.d_key & 0xff, 0, NULL)) { printk(KERN_ERR"isar sendmsg dkey failed\n"); ret = 1; goto reterr_unlock; } if (!waitrecmsg(cs, &len, tmp, 100000)) { printk(KERN_ERR"isar waitrecmsg dkey failed\n"); ret = 1; goto reterr_unlock; } if ((ireg->iis != ISAR_IIS_DKEY) || ireg->cmsb || len) { printk(KERN_ERR"isar wrong dkey response (%x,%x,%x)\n", ireg->iis, ireg->cmsb, len); ret = 1; goto reterr_unlock; } spin_unlock_irqrestore(&cs->lock, flags); while (left > 0) { if (left > 126) noc = 126; else noc = left; nom = 2 * noc; mp = msg; *mp++ = sadr / 256; *mp++ = sadr % 256; left -= noc; *mp++ = noc; if ((ret = copy_from_user(tmpmsg, p, nom))) { printk(KERN_ERR"isar_load_firmware copy_from_user ret %d\n", ret); goto reterror; } p += nom; cnt += nom; nom += 3; sp = (u_short *)tmpmsg; #if DBG_LOADFIRM printk(KERN_DEBUG"isar: load %3d words at %04x left %d\n", noc, sadr, left); #endif sadr += noc; while (noc) { #ifdef __BIG_ENDIAN *mp++ = *sp % 256; *mp++ = *sp / 256; #else *mp++ = *sp / 256; *mp++ = *sp % 256; #endif /* __BIG_ENDIAN */ sp++; noc--; } spin_lock_irqsave(&cs->lock, flags); if (!sendmsg(cs, ISAR_HIS_FIRM, 0, nom, msg)) { printk(KERN_ERR"isar sendmsg prog failed\n"); ret = 1; goto reterr_unlock; } if (!waitrecmsg(cs, &len, tmp, 100000)) { printk(KERN_ERR"isar waitrecmsg prog failed\n"); ret = 1; goto reterr_unlock; } if ((ireg->iis != ISAR_IIS_FIRM) || ireg->cmsb || len) { printk(KERN_ERR"isar wrong prog response (%x,%x,%x)\n", ireg->iis, ireg->cmsb, len); ret = 1; goto reterr_unlock; } spin_unlock_irqrestore(&cs->lock, flags); } printk(KERN_DEBUG"isar firmware block %5d words loaded\n", blk_head.len); } /* 10ms delay */ cnt = 10; while (cnt--) udelay(1000); msg[0] = 0xff; msg[1] = 0xfe; ireg->bstat = 0; spin_lock_irqsave(&cs->lock, flags); if (!sendmsg(cs, ISAR_HIS_STDSP, 0, 2, msg)) { printk(KERN_ERR"isar sendmsg start dsp failed\n"); ret = 1; goto reterr_unlock; } if (!waitrecmsg(cs, &len, tmp, 100000)) { printk(KERN_ERR"isar waitrecmsg start dsp failed\n"); ret = 1; goto reterr_unlock; } if ((ireg->iis != ISAR_IIS_STDSP) || ireg->cmsb || len) { printk(KERN_ERR"isar wrong start dsp response (%x,%x,%x)\n", ireg->iis, ireg->cmsb, len); ret = 1; goto reterr_unlock; } else printk(KERN_DEBUG"isar start dsp success\n"); /* NORMAL mode entered */ /* Enable IRQs of ISAR */ cs->BC_Write_Reg(cs, 0, ISAR_IRQBIT, ISAR_IRQSTA); spin_unlock_irqrestore(&cs->lock, flags); cnt = 1000; /* max 1s */ while ((!ireg->bstat) && cnt) { udelay(1000); cnt--; } if (!cnt) { printk(KERN_ERR"isar no general status event received\n"); ret = 1; goto reterror; } else { printk(KERN_DEBUG"isar general status event %x\n", ireg->bstat); } /* 10ms delay */ cnt = 10; while (cnt--) udelay(1000); spin_lock_irqsave(&cs->lock, flags); ireg->iis = 0; if (!sendmsg(cs, ISAR_HIS_DIAG, ISAR_CTRL_STST, 0, NULL)) { printk(KERN_ERR"isar sendmsg self tst failed\n"); ret = 1; goto reterr_unlock; } cnt = 10000; /* max 100 ms */ spin_unlock_irqrestore(&cs->lock, flags); while ((ireg->iis != ISAR_IIS_DIAG) && cnt) { udelay(10); cnt--; } udelay(1000); if (!cnt) { printk(KERN_ERR"isar no self tst response\n"); ret = 1; goto reterror; } if ((ireg->cmsb == ISAR_CTRL_STST) && (ireg->clsb == 1) && (ireg->par[0] == 0)) { printk(KERN_DEBUG"isar selftest OK\n"); } else { printk(KERN_DEBUG"isar selftest not OK %x/%x/%x\n", ireg->cmsb, ireg->clsb, ireg->par[0]); ret = 1; goto reterror; } spin_lock_irqsave(&cs->lock, flags); ireg->iis = 0; if (!sendmsg(cs, ISAR_HIS_DIAG, ISAR_CTRL_SWVER, 0, NULL)) { printk(KERN_ERR"isar RQST SVN failed\n"); ret = 1; goto reterr_unlock; } spin_unlock_irqrestore(&cs->lock, flags); cnt = 30000; /* max 300 ms */ while ((ireg->iis != ISAR_IIS_DIAG) && cnt) { udelay(10); cnt--; } udelay(1000); if (!cnt) { printk(KERN_ERR"isar no SVN response\n"); ret = 1; goto reterror; } else { if ((ireg->cmsb == ISAR_CTRL_SWVER) && (ireg->clsb == 1)) printk(KERN_DEBUG"isar software version %#x\n", ireg->par[0]); else { printk(KERN_ERR"isar wrong swver response (%x,%x) cnt(%d)\n", ireg->cmsb, ireg->clsb, cnt); ret = 1; goto reterror; } } spin_lock_irqsave(&cs->lock, flags); cs->debug = debug; isar_setup(cs); ret = 0; reterr_unlock: spin_unlock_irqrestore(&cs->lock, flags); reterror: cs->debug = debug; if (ret) /* disable ISAR IRQ */ cs->BC_Write_Reg(cs, 0, ISAR_IRQBIT, 0); kfree(msg); kfree(tmpmsg); return (ret); } #define B_LL_NOCARRIER 8 #define B_LL_CONNECT 9 #define B_LL_OK 10 static void isar_bh(struct work_struct *work) { struct BCState *bcs = container_of(work, struct BCState, tqueue); BChannel_bh(work); if (test_and_clear_bit(B_LL_NOCARRIER, &bcs->event)) ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_NOCARR); if (test_and_clear_bit(B_LL_CONNECT, &bcs->event)) ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); if (test_and_clear_bit(B_LL_OK, &bcs->event)) ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_OK); } static void send_DLE_ETX(struct BCState *bcs) { u_char dleetx[2] = {DLE, ETX}; struct sk_buff *skb; if ((skb = dev_alloc_skb(2))) { memcpy(skb_put(skb, 2), dleetx, 2); skb_queue_tail(&bcs->rqueue, skb); schedule_event(bcs, B_RCVBUFREADY); } else { printk(KERN_WARNING "HiSax: skb out of memory\n"); } } static inline int dle_count(unsigned char *buf, int len) { int count = 0; while (len--) if (*buf++ == DLE) count++; return count; } static inline void insert_dle(unsigned char *dest, unsigned char *src, int count) { /* <DLE> in input stream have to be flagged as <DLE><DLE> */ while (count--) { *dest++ = *src; if (*src++ == DLE) *dest++ = DLE; } } static void isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs) { u_char *ptr; struct sk_buff *skb; struct isar_reg *ireg = bcs->hw.isar.reg; if (!ireg->clsb) { debugl1(cs, "isar zero len frame"); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); return; } switch (bcs->mode) { case L1_MODE_NULL: debugl1(cs, "isar mode 0 spurious IIS_RDATA %x/%x/%x", ireg->iis, ireg->cmsb, ireg->clsb); printk(KERN_WARNING"isar mode 0 spurious IIS_RDATA %x/%x/%x\n", ireg->iis, ireg->cmsb, ireg->clsb); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); break; case L1_MODE_TRANS: case L1_MODE_V32: if ((skb = dev_alloc_skb(ireg->clsb))) { rcv_mbox(cs, ireg, (u_char *)skb_put(skb, ireg->clsb)); skb_queue_tail(&bcs->rqueue, skb); schedule_event(bcs, B_RCVBUFREADY); } else { printk(KERN_WARNING "HiSax: skb out of memory\n"); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); } break; case L1_MODE_HDLC: if ((bcs->hw.isar.rcvidx + ireg->clsb) > HSCX_BUFMAX) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar_rcv_frame: incoming packet too large"); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); bcs->hw.isar.rcvidx = 0; } else if (ireg->cmsb & HDLC_ERROR) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar frame error %x len %d", ireg->cmsb, ireg->clsb); #ifdef ERROR_STATISTIC if (ireg->cmsb & HDLC_ERR_RER) bcs->err_inv++; if (ireg->cmsb & HDLC_ERR_CER) bcs->err_crc++; #endif bcs->hw.isar.rcvidx = 0; cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); } else { if (ireg->cmsb & HDLC_FSD) bcs->hw.isar.rcvidx = 0; ptr = bcs->hw.isar.rcvbuf + bcs->hw.isar.rcvidx; bcs->hw.isar.rcvidx += ireg->clsb; rcv_mbox(cs, ireg, ptr); if (ireg->cmsb & HDLC_FED) { if (bcs->hw.isar.rcvidx < 3) { /* last 2 bytes are the FCS */ if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar frame to short %d", bcs->hw.isar.rcvidx); } else if (!(skb = dev_alloc_skb(bcs->hw.isar.rcvidx - 2))) { printk(KERN_WARNING "ISAR: receive out of memory\n"); } else { memcpy(skb_put(skb, bcs->hw.isar.rcvidx - 2), bcs->hw.isar.rcvbuf, bcs->hw.isar.rcvidx - 2); skb_queue_tail(&bcs->rqueue, skb); schedule_event(bcs, B_RCVBUFREADY); } bcs->hw.isar.rcvidx = 0; } } break; case L1_MODE_FAX: if (bcs->hw.isar.state != STFAX_ACTIV) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar_rcv_frame: not ACTIV"); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); bcs->hw.isar.rcvidx = 0; break; } if (bcs->hw.isar.cmd == PCTRL_CMD_FRM) { rcv_mbox(cs, ireg, bcs->hw.isar.rcvbuf); bcs->hw.isar.rcvidx = ireg->clsb + dle_count(bcs->hw.isar.rcvbuf, ireg->clsb); if (cs->debug & L1_DEB_HSCX) debugl1(cs, "isar_rcv_frame: raw(%d) dle(%d)", ireg->clsb, bcs->hw.isar.rcvidx); if ((skb = dev_alloc_skb(bcs->hw.isar.rcvidx))) { insert_dle((u_char *)skb_put(skb, bcs->hw.isar.rcvidx), bcs->hw.isar.rcvbuf, ireg->clsb); skb_queue_tail(&bcs->rqueue, skb); schedule_event(bcs, B_RCVBUFREADY); if (ireg->cmsb & SART_NMD) { /* ABORT */ if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar_rcv_frame: no more data"); bcs->hw.isar.rcvidx = 0; send_DLE_ETX(bcs); sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, 0, NULL); bcs->hw.isar.state = STFAX_ESCAPE; schedule_event(bcs, B_LL_NOCARRIER); } } else { printk(KERN_WARNING "HiSax: skb out of memory\n"); } break; } if (bcs->hw.isar.cmd != PCTRL_CMD_FRH) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar_rcv_frame: unknown fax mode %x", bcs->hw.isar.cmd); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); bcs->hw.isar.rcvidx = 0; break; } /* PCTRL_CMD_FRH */ if ((bcs->hw.isar.rcvidx + ireg->clsb) > HSCX_BUFMAX) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar_rcv_frame: incoming packet too large"); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); bcs->hw.isar.rcvidx = 0; } else if (ireg->cmsb & HDLC_ERROR) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar frame error %x len %d", ireg->cmsb, ireg->clsb); bcs->hw.isar.rcvidx = 0; cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); } else { if (ireg->cmsb & HDLC_FSD) { bcs->hw.isar.rcvidx = 0; } ptr = bcs->hw.isar.rcvbuf + bcs->hw.isar.rcvidx; bcs->hw.isar.rcvidx += ireg->clsb; rcv_mbox(cs, ireg, ptr); if (ireg->cmsb & HDLC_FED) { int len = bcs->hw.isar.rcvidx + dle_count(bcs->hw.isar.rcvbuf, bcs->hw.isar.rcvidx); if (bcs->hw.isar.rcvidx < 3) { /* last 2 bytes are the FCS */ if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar frame to short %d", bcs->hw.isar.rcvidx); printk(KERN_WARNING "ISAR: frame to short %d\n", bcs->hw.isar.rcvidx); } else if (!(skb = dev_alloc_skb(len))) { printk(KERN_WARNING "ISAR: receive out of memory\n"); } else { insert_dle((u_char *)skb_put(skb, len), bcs->hw.isar.rcvbuf, bcs->hw.isar.rcvidx); skb_queue_tail(&bcs->rqueue, skb); schedule_event(bcs, B_RCVBUFREADY); send_DLE_ETX(bcs); schedule_event(bcs, B_LL_OK); test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); } bcs->hw.isar.rcvidx = 0; } } if (ireg->cmsb & SART_NMD) { /* ABORT */ if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar_rcv_frame: no more data"); bcs->hw.isar.rcvidx = 0; sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, 0, NULL); bcs->hw.isar.state = STFAX_ESCAPE; if (test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag)) { send_DLE_ETX(bcs); schedule_event(bcs, B_LL_NOCARRIER); } } break; default: printk(KERN_ERR"isar_rcv_frame mode (%x)error\n", bcs->mode); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); break; } } void isar_fill_fifo(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; int count; u_char msb; u_char *ptr; if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) debugl1(cs, "isar_fill_fifo"); if (!bcs->tx_skb) return; if (bcs->tx_skb->len <= 0) return; if (!(bcs->hw.isar.reg->bstat & (bcs->hw.isar.dpath == 1 ? BSTAT_RDM1 : BSTAT_RDM2))) return; if (bcs->tx_skb->len > bcs->hw.isar.mml) { msb = 0; count = bcs->hw.isar.mml; } else { count = bcs->tx_skb->len; msb = HDLC_FED; } ptr = bcs->tx_skb->data; if (!bcs->hw.isar.txcnt) { msb |= HDLC_FST; if ((bcs->mode == L1_MODE_FAX) && (bcs->hw.isar.cmd == PCTRL_CMD_FTH)) { if (bcs->tx_skb->len > 1) { if ((ptr[0] == 0xff) && (ptr[1] == 0x13)) /* last frame */ test_and_set_bit(BC_FLG_LASTDATA, &bcs->Flag); } } } skb_pull(bcs->tx_skb, count); bcs->tx_cnt -= count; bcs->hw.isar.txcnt += count; switch (bcs->mode) { case L1_MODE_NULL: printk(KERN_ERR"isar_fill_fifo wrong mode 0\n"); break; case L1_MODE_TRANS: case L1_MODE_V32: sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, 0, count, ptr); break; case L1_MODE_HDLC: sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, msb, count, ptr); break; case L1_MODE_FAX: if (bcs->hw.isar.state != STFAX_ACTIV) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar_fill_fifo: not ACTIV"); } else if (bcs->hw.isar.cmd == PCTRL_CMD_FTH) { sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, msb, count, ptr); } else if (bcs->hw.isar.cmd == PCTRL_CMD_FTM) { sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, 0, count, ptr); } else { if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar_fill_fifo: not FTH/FTM"); } break; default: if (cs->debug) debugl1(cs, "isar_fill_fifo mode(%x) error", bcs->mode); printk(KERN_ERR"isar_fill_fifo mode(%x) error\n", bcs->mode); break; } } static inline struct BCState *sel_bcs_isar(struct IsdnCardState *cs, u_char dpath) { if ((!dpath) || (dpath == 3)) return (NULL); if (cs->bcs[0].hw.isar.dpath == dpath) return (&cs->bcs[0]); if (cs->bcs[1].hw.isar.dpath == dpath) return (&cs->bcs[1]); return (NULL); } static void send_frames(struct BCState *bcs) { if (bcs->tx_skb) { if (bcs->tx_skb->len) { isar_fill_fifo(bcs); return; } else { if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.isar.txcnt; spin_unlock_irqrestore(&bcs->aclock, flags); schedule_event(bcs, B_ACKPENDING); } if (bcs->mode == L1_MODE_FAX) { if (bcs->hw.isar.cmd == PCTRL_CMD_FTH) { if (test_bit(BC_FLG_LASTDATA, &bcs->Flag)) { test_and_set_bit(BC_FLG_NMD_DATA, &bcs->Flag); } } else if (bcs->hw.isar.cmd == PCTRL_CMD_FTM) { if (test_bit(BC_FLG_DLEETX, &bcs->Flag)) { test_and_set_bit(BC_FLG_LASTDATA, &bcs->Flag); test_and_set_bit(BC_FLG_NMD_DATA, &bcs->Flag); } } } dev_kfree_skb_any(bcs->tx_skb); bcs->hw.isar.txcnt = 0; bcs->tx_skb = NULL; } } if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) { bcs->hw.isar.txcnt = 0; test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); isar_fill_fifo(bcs); } else { if (test_and_clear_bit(BC_FLG_DLEETX, &bcs->Flag)) { if (test_and_clear_bit(BC_FLG_LASTDATA, &bcs->Flag)) { if (test_and_clear_bit(BC_FLG_NMD_DATA, &bcs->Flag)) { u_char dummy = 0; sendmsg(bcs->cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, 0x01, 1, &dummy); } test_and_set_bit(BC_FLG_LL_OK, &bcs->Flag); } else { schedule_event(bcs, B_LL_CONNECT); } } test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); schedule_event(bcs, B_XMTBUFREADY); } } static inline void check_send(struct IsdnCardState *cs, u_char rdm) { struct BCState *bcs; if (rdm & BSTAT_RDM1) { if ((bcs = sel_bcs_isar(cs, 1))) { if (bcs->mode) { send_frames(bcs); } } } if (rdm & BSTAT_RDM2) { if ((bcs = sel_bcs_isar(cs, 2))) { if (bcs->mode) { send_frames(bcs); } } } } static const char *dmril[] = {"NO SPEED", "1200/75", "NODEF2", "75/1200", "NODEF4", "300", "600", "1200", "2400", "4800", "7200", "9600nt", "9600t", "12000", "14400", "WRONG"}; static const char *dmrim[] = {"NO MOD", "NO DEF", "V32/V32b", "V22", "V21", "Bell103", "V23", "Bell202", "V17", "V29", "V27ter"}; static void isar_pump_status_rsp(struct BCState *bcs, struct isar_reg *ireg) { struct IsdnCardState *cs = bcs->cs; u_char ril = ireg->par[0]; u_char rim; if (!test_and_clear_bit(ISAR_RATE_REQ, &bcs->hw.isar.reg->Flags)) return; if (ril > 14) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "wrong pstrsp ril=%d", ril); ril = 15; } switch (ireg->par[1]) { case 0: rim = 0; break; case 0x20: rim = 2; break; case 0x40: rim = 3; break; case 0x41: rim = 4; break; case 0x51: rim = 5; break; case 0x61: rim = 6; break; case 0x71: rim = 7; break; case 0x82: rim = 8; break; case 0x92: rim = 9; break; case 0xa2: rim = 10; break; default: rim = 1; break; } sprintf(bcs->hw.isar.conmsg, "%s %s", dmril[ril], dmrim[rim]); bcs->conmsg = bcs->hw.isar.conmsg; if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump strsp %s", bcs->conmsg); } static void isar_pump_statev_modem(struct BCState *bcs, u_char devt) { struct IsdnCardState *cs = bcs->cs; u_char dps = SET_DPS(bcs->hw.isar.dpath); switch (devt) { case PSEV_10MS_TIMER: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev TIMER"); break; case PSEV_CON_ON: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev CONNECT"); l1_msg_b(bcs->st, PH_ACTIVATE | REQUEST, NULL); break; case PSEV_CON_OFF: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev NO CONNECT"); sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); l1_msg_b(bcs->st, PH_DEACTIVATE | REQUEST, NULL); break; case PSEV_V24_OFF: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev V24 OFF"); break; case PSEV_CTS_ON: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev CTS ON"); break; case PSEV_CTS_OFF: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev CTS OFF"); break; case PSEV_DCD_ON: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev CARRIER ON"); test_and_set_bit(ISAR_RATE_REQ, &bcs->hw.isar.reg->Flags); sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); break; case PSEV_DCD_OFF: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev CARRIER OFF"); break; case PSEV_DSR_ON: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev DSR ON"); break; case PSEV_DSR_OFF: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev DSR_OFF"); break; case PSEV_REM_RET: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev REMOTE RETRAIN"); break; case PSEV_REM_REN: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev REMOTE RENEGOTIATE"); break; case PSEV_GSTN_CLR: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev GSTN CLEAR"); break; default: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "unknown pump stev %x", devt); break; } } static void ll_deliver_faxstat(struct BCState *bcs, u_char status) { isdn_ctrl ic; struct Channel *chanp = (struct Channel *) bcs->st->lli.userdata; if (bcs->cs->debug & L1_DEB_HSCX) debugl1(bcs->cs, "HL->LL FAXIND %x", status); ic.driver = bcs->cs->myid; ic.command = ISDN_STAT_FAXIND; ic.arg = chanp->chan; ic.parm.aux.cmd = status; bcs->cs->iif.statcallb(&ic); } static void isar_pump_statev_fax(struct BCState *bcs, u_char devt) { struct IsdnCardState *cs = bcs->cs; u_char dps = SET_DPS(bcs->hw.isar.dpath); u_char p1; switch (devt) { case PSEV_10MS_TIMER: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev TIMER"); break; case PSEV_RSP_READY: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev RSP_READY"); bcs->hw.isar.state = STFAX_READY; l1_msg_b(bcs->st, PH_ACTIVATE | REQUEST, NULL); if (test_bit(BC_FLG_ORIG, &bcs->Flag)) { isar_pump_cmd(bcs, ISDN_FAX_CLASS1_FRH, 3); } else { isar_pump_cmd(bcs, ISDN_FAX_CLASS1_FTH, 3); } break; case PSEV_LINE_TX_H: if (bcs->hw.isar.state == STFAX_LINE) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev LINE_TX_H"); bcs->hw.isar.state = STFAX_CONT; sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); } else { if (cs->debug & L1_DEB_WARN) debugl1(cs, "pump stev LINE_TX_H wrong st %x", bcs->hw.isar.state); } break; case PSEV_LINE_RX_H: if (bcs->hw.isar.state == STFAX_LINE) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev LINE_RX_H"); bcs->hw.isar.state = STFAX_CONT; sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); } else { if (cs->debug & L1_DEB_WARN) debugl1(cs, "pump stev LINE_RX_H wrong st %x", bcs->hw.isar.state); } break; case PSEV_LINE_TX_B: if (bcs->hw.isar.state == STFAX_LINE) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev LINE_TX_B"); bcs->hw.isar.state = STFAX_CONT; sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); } else { if (cs->debug & L1_DEB_WARN) debugl1(cs, "pump stev LINE_TX_B wrong st %x", bcs->hw.isar.state); } break; case PSEV_LINE_RX_B: if (bcs->hw.isar.state == STFAX_LINE) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev LINE_RX_B"); bcs->hw.isar.state = STFAX_CONT; sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); } else { if (cs->debug & L1_DEB_WARN) debugl1(cs, "pump stev LINE_RX_B wrong st %x", bcs->hw.isar.state); } break; case PSEV_RSP_CONN: if (bcs->hw.isar.state == STFAX_CONT) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev RSP_CONN"); bcs->hw.isar.state = STFAX_ACTIV; test_and_set_bit(ISAR_RATE_REQ, &bcs->hw.isar.reg->Flags); sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); if (bcs->hw.isar.cmd == PCTRL_CMD_FTH) { /* 1s Flags before data */ if (test_and_set_bit(BC_FLG_FTI_RUN, &bcs->Flag)) del_timer(&bcs->hw.isar.ftimer); /* 1000 ms */ bcs->hw.isar.ftimer.expires = jiffies + ((1000 * HZ) / 1000); test_and_set_bit(BC_FLG_LL_CONN, &bcs->Flag); add_timer(&bcs->hw.isar.ftimer); } else { schedule_event(bcs, B_LL_CONNECT); } } else { if (cs->debug & L1_DEB_WARN) debugl1(cs, "pump stev RSP_CONN wrong st %x", bcs->hw.isar.state); } break; case PSEV_FLAGS_DET: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev FLAGS_DET"); break; case PSEV_RSP_DISC: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev RSP_DISC"); if (bcs->hw.isar.state == STFAX_ESCAPE) { p1 = 5; switch (bcs->hw.isar.newcmd) { case 0: bcs->hw.isar.state = STFAX_READY; break; case PCTRL_CMD_FTM: p1 = 2; case PCTRL_CMD_FTH: sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_SILON, 1, &p1); bcs->hw.isar.state = STFAX_SILDET; break; case PCTRL_CMD_FRM: if (frm_extra_delay) mdelay(frm_extra_delay); case PCTRL_CMD_FRH: p1 = bcs->hw.isar.mod = bcs->hw.isar.newmod; bcs->hw.isar.newmod = 0; bcs->hw.isar.cmd = bcs->hw.isar.newcmd; bcs->hw.isar.newcmd = 0; sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, bcs->hw.isar.cmd, 1, &p1); bcs->hw.isar.state = STFAX_LINE; bcs->hw.isar.try_mod = 3; break; default: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "RSP_DISC unknown newcmd %x", bcs->hw.isar.newcmd); break; } } else if (bcs->hw.isar.state == STFAX_ACTIV) { if (test_and_clear_bit(BC_FLG_LL_OK, &bcs->Flag)) { schedule_event(bcs, B_LL_OK); } else if (bcs->hw.isar.cmd == PCTRL_CMD_FRM) { send_DLE_ETX(bcs); schedule_event(bcs, B_LL_NOCARRIER); } else { ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_FCERROR); } bcs->hw.isar.state = STFAX_READY; } else { bcs->hw.isar.state = STFAX_READY; ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_FCERROR); } break; case PSEV_RSP_SILDET: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev RSP_SILDET"); if (bcs->hw.isar.state == STFAX_SILDET) { p1 = bcs->hw.isar.mod = bcs->hw.isar.newmod; bcs->hw.isar.newmod = 0; bcs->hw.isar.cmd = bcs->hw.isar.newcmd; bcs->hw.isar.newcmd = 0; sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, bcs->hw.isar.cmd, 1, &p1); bcs->hw.isar.state = STFAX_LINE; bcs->hw.isar.try_mod = 3; } break; case PSEV_RSP_SILOFF: if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev RSP_SILOFF"); break; case PSEV_RSP_FCERR: if (bcs->hw.isar.state == STFAX_LINE) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev RSP_FCERR try %d", bcs->hw.isar.try_mod); if (bcs->hw.isar.try_mod--) { sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, bcs->hw.isar.cmd, 1, &bcs->hw.isar.mod); break; } } if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev RSP_FCERR"); bcs->hw.isar.state = STFAX_ESCAPE; sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, 0, NULL); ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_FCERROR); break; default: break; } } static char debbuf[128]; void isar_int_main(struct IsdnCardState *cs) { struct isar_reg *ireg = cs->bcs[0].hw.isar.reg; struct BCState *bcs; get_irq_infos(cs, ireg); switch (ireg->iis & ISAR_IIS_MSCMSD) { case ISAR_IIS_RDATA: if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { isar_rcv_frame(cs, bcs); } else { debugl1(cs, "isar spurious IIS_RDATA %x/%x/%x", ireg->iis, ireg->cmsb, ireg->clsb); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); } break; case ISAR_IIS_GSTEV: cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); ireg->bstat |= ireg->cmsb; check_send(cs, ireg->cmsb); break; case ISAR_IIS_BSTEV: #ifdef ERROR_STATISTIC if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { if (ireg->cmsb == BSTEV_TBO) bcs->err_tx++; if (ireg->cmsb == BSTEV_RBO) bcs->err_rdo++; } #endif if (cs->debug & L1_DEB_WARN) debugl1(cs, "Buffer STEV dpath%d msb(%x)", ireg->iis >> 6, ireg->cmsb); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); break; case ISAR_IIS_PSTEV: if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { rcv_mbox(cs, ireg, (u_char *)ireg->par); if (bcs->mode == L1_MODE_V32) { isar_pump_statev_modem(bcs, ireg->cmsb); } else if (bcs->mode == L1_MODE_FAX) { isar_pump_statev_fax(bcs, ireg->cmsb); } else if (ireg->cmsb == PSEV_10MS_TIMER) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump stev TIMER"); } else { if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar IIS_PSTEV pmode %d stat %x", bcs->mode, ireg->cmsb); } } else { debugl1(cs, "isar spurious IIS_PSTEV %x/%x/%x", ireg->iis, ireg->cmsb, ireg->clsb); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); } break; case ISAR_IIS_PSTRSP: if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { rcv_mbox(cs, ireg, (u_char *)ireg->par); isar_pump_status_rsp(bcs, ireg); } else { debugl1(cs, "isar spurious IIS_PSTRSP %x/%x/%x", ireg->iis, ireg->cmsb, ireg->clsb); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); } break; case ISAR_IIS_DIAG: case ISAR_IIS_BSTRSP: case ISAR_IIS_IOM2RSP: rcv_mbox(cs, ireg, (u_char *)ireg->par); if ((cs->debug & (L1_DEB_HSCX | L1_DEB_HSCX_FIFO)) == L1_DEB_HSCX) { u_char *tp = debbuf; tp += sprintf(debbuf, "msg iis(%x) msb(%x)", ireg->iis, ireg->cmsb); QuickHex(tp, (u_char *)ireg->par, ireg->clsb); debugl1(cs, debbuf); } break; case ISAR_IIS_INVMSG: rcv_mbox(cs, ireg, debbuf); if (cs->debug & L1_DEB_WARN) debugl1(cs, "invalid msg his:%x", ireg->cmsb); break; default: rcv_mbox(cs, ireg, debbuf); if (cs->debug & L1_DEB_WARN) debugl1(cs, "unhandled msg iis(%x) ctrl(%x/%x)", ireg->iis, ireg->cmsb, ireg->clsb); break; } } static void ftimer_handler(struct BCState *bcs) { if (bcs->cs->debug) debugl1(bcs->cs, "ftimer flags %04lx", bcs->Flag); test_and_clear_bit(BC_FLG_FTI_RUN, &bcs->Flag); if (test_and_clear_bit(BC_FLG_LL_CONN, &bcs->Flag)) { schedule_event(bcs, B_LL_CONNECT); } if (test_and_clear_bit(BC_FLG_FTI_FTS, &bcs->Flag)) { schedule_event(bcs, B_LL_OK); } } static void setup_pump(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; u_char dps = SET_DPS(bcs->hw.isar.dpath); u_char ctrl, param[6]; switch (bcs->mode) { case L1_MODE_NULL: case L1_MODE_TRANS: case L1_MODE_HDLC: sendmsg(cs, dps | ISAR_HIS_PUMPCFG, PMOD_BYPASS, 0, NULL); break; case L1_MODE_V32: ctrl = PMOD_DATAMODEM; if (test_bit(BC_FLG_ORIG, &bcs->Flag)) { ctrl |= PCTRL_ORIG; param[5] = PV32P6_CTN; } else { param[5] = PV32P6_ATN; } param[0] = para_TOA; /* 6 db */ param[1] = PV32P2_V23R | PV32P2_V22A | PV32P2_V22B | PV32P2_V22C | PV32P2_V21 | PV32P2_BEL; param[2] = PV32P3_AMOD | PV32P3_V32B | PV32P3_V23B; param[3] = PV32P4_UT144; param[4] = PV32P5_UT144; sendmsg(cs, dps | ISAR_HIS_PUMPCFG, ctrl, 6, param); break; case L1_MODE_FAX: ctrl = PMOD_FAX; if (test_bit(BC_FLG_ORIG, &bcs->Flag)) { ctrl |= PCTRL_ORIG; param[1] = PFAXP2_CTN; } else { param[1] = PFAXP2_ATN; } param[0] = para_TOA; /* 6 db */ sendmsg(cs, dps | ISAR_HIS_PUMPCFG, ctrl, 2, param); bcs->hw.isar.state = STFAX_NULL; bcs->hw.isar.newcmd = 0; bcs->hw.isar.newmod = 0; test_and_set_bit(BC_FLG_FTI_RUN, &bcs->Flag); break; } udelay(1000); sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); udelay(1000); } static void setup_sart(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; u_char dps = SET_DPS(bcs->hw.isar.dpath); u_char ctrl, param[2]; switch (bcs->mode) { case L1_MODE_NULL: sendmsg(cs, dps | ISAR_HIS_SARTCFG, SMODE_DISABLE, 0, NULL); break; case L1_MODE_TRANS: sendmsg(cs, dps | ISAR_HIS_SARTCFG, SMODE_BINARY, 2, "\0\0"); break; case L1_MODE_HDLC: param[0] = 0; sendmsg(cs, dps | ISAR_HIS_SARTCFG, SMODE_HDLC, 1, param); break; case L1_MODE_V32: ctrl = SMODE_V14 | SCTRL_HDMC_BOTH; param[0] = S_P1_CHS_8; param[1] = S_P2_BFT_DEF; sendmsg(cs, dps | ISAR_HIS_SARTCFG, ctrl, 2, param); break; case L1_MODE_FAX: /* SART must not configured with FAX */ break; } udelay(1000); sendmsg(cs, dps | ISAR_HIS_BSTREQ, 0, 0, NULL); udelay(1000); } static void setup_iom2(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; u_char dps = SET_DPS(bcs->hw.isar.dpath); u_char cmsb = IOM_CTRL_ENA, msg[5] = {IOM_P1_TXD, 0, 0, 0, 0}; if (bcs->channel) msg[1] = msg[3] = 1; switch (bcs->mode) { case L1_MODE_NULL: cmsb = 0; /* dummy slot */ msg[1] = msg[3] = bcs->hw.isar.dpath + 2; break; case L1_MODE_TRANS: case L1_MODE_HDLC: break; case L1_MODE_V32: case L1_MODE_FAX: cmsb |= IOM_CTRL_ALAW | IOM_CTRL_RCV; break; } sendmsg(cs, dps | ISAR_HIS_IOM2CFG, cmsb, 5, msg); udelay(1000); sendmsg(cs, dps | ISAR_HIS_IOM2REQ, 0, 0, NULL); udelay(1000); } static int modeisar(struct BCState *bcs, int mode, int bc) { struct IsdnCardState *cs = bcs->cs; /* Here we are selecting the best datapath for requested mode */ if (bcs->mode == L1_MODE_NULL) { /* New Setup */ bcs->channel = bc; switch (mode) { case L1_MODE_NULL: /* init */ if (!bcs->hw.isar.dpath) /* no init for dpath 0 */ return (0); break; case L1_MODE_TRANS: case L1_MODE_HDLC: /* best is datapath 2 */ if (!test_and_set_bit(ISAR_DP2_USE, &bcs->hw.isar.reg->Flags)) bcs->hw.isar.dpath = 2; else if (!test_and_set_bit(ISAR_DP1_USE, &bcs->hw.isar.reg->Flags)) bcs->hw.isar.dpath = 1; else { printk(KERN_WARNING"isar modeisar both pathes in use\n"); return (1); } break; case L1_MODE_V32: case L1_MODE_FAX: /* only datapath 1 */ if (!test_and_set_bit(ISAR_DP1_USE, &bcs->hw.isar.reg->Flags)) bcs->hw.isar.dpath = 1; else { printk(KERN_WARNING"isar modeisar analog functions only with DP1\n"); debugl1(cs, "isar modeisar analog functions only with DP1"); return (1); } break; } } if (cs->debug & L1_DEB_HSCX) debugl1(cs, "isar dp%d mode %d->%d ichan %d", bcs->hw.isar.dpath, bcs->mode, mode, bc); bcs->mode = mode; setup_pump(bcs); setup_iom2(bcs); setup_sart(bcs); if (bcs->mode == L1_MODE_NULL) { /* Clear resources */ if (bcs->hw.isar.dpath == 1) test_and_clear_bit(ISAR_DP1_USE, &bcs->hw.isar.reg->Flags); else if (bcs->hw.isar.dpath == 2) test_and_clear_bit(ISAR_DP2_USE, &bcs->hw.isar.reg->Flags); bcs->hw.isar.dpath = 0; } return (0); } static void isar_pump_cmd(struct BCState *bcs, u_char cmd, u_char para) { struct IsdnCardState *cs = bcs->cs; u_char dps = SET_DPS(bcs->hw.isar.dpath); u_char ctrl = 0, nom = 0, p1 = 0; switch (cmd) { case ISDN_FAX_CLASS1_FTM: test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); if (bcs->hw.isar.state == STFAX_READY) { p1 = para; ctrl = PCTRL_CMD_FTM; nom = 1; bcs->hw.isar.state = STFAX_LINE; bcs->hw.isar.cmd = ctrl; bcs->hw.isar.mod = para; bcs->hw.isar.newmod = 0; bcs->hw.isar.newcmd = 0; bcs->hw.isar.try_mod = 3; } else if ((bcs->hw.isar.state == STFAX_ACTIV) && (bcs->hw.isar.cmd == PCTRL_CMD_FTM) && (bcs->hw.isar.mod == para)) { ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); } else { bcs->hw.isar.newmod = para; bcs->hw.isar.newcmd = PCTRL_CMD_FTM; nom = 0; ctrl = PCTRL_CMD_ESC; bcs->hw.isar.state = STFAX_ESCAPE; } break; case ISDN_FAX_CLASS1_FTH: test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); if (bcs->hw.isar.state == STFAX_READY) { p1 = para; ctrl = PCTRL_CMD_FTH; nom = 1; bcs->hw.isar.state = STFAX_LINE; bcs->hw.isar.cmd = ctrl; bcs->hw.isar.mod = para; bcs->hw.isar.newmod = 0; bcs->hw.isar.newcmd = 0; bcs->hw.isar.try_mod = 3; } else if ((bcs->hw.isar.state == STFAX_ACTIV) && (bcs->hw.isar.cmd == PCTRL_CMD_FTH) && (bcs->hw.isar.mod == para)) { ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); } else { bcs->hw.isar.newmod = para; bcs->hw.isar.newcmd = PCTRL_CMD_FTH; nom = 0; ctrl = PCTRL_CMD_ESC; bcs->hw.isar.state = STFAX_ESCAPE; } break; case ISDN_FAX_CLASS1_FRM: test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); if (bcs->hw.isar.state == STFAX_READY) { p1 = para; ctrl = PCTRL_CMD_FRM; nom = 1; bcs->hw.isar.state = STFAX_LINE; bcs->hw.isar.cmd = ctrl; bcs->hw.isar.mod = para; bcs->hw.isar.newmod = 0; bcs->hw.isar.newcmd = 0; bcs->hw.isar.try_mod = 3; } else if ((bcs->hw.isar.state == STFAX_ACTIV) && (bcs->hw.isar.cmd == PCTRL_CMD_FRM) && (bcs->hw.isar.mod == para)) { ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); } else { bcs->hw.isar.newmod = para; bcs->hw.isar.newcmd = PCTRL_CMD_FRM; nom = 0; ctrl = PCTRL_CMD_ESC; bcs->hw.isar.state = STFAX_ESCAPE; } break; case ISDN_FAX_CLASS1_FRH: test_and_set_bit(BC_FLG_FRH_WAIT, &bcs->Flag); if (bcs->hw.isar.state == STFAX_READY) { p1 = para; ctrl = PCTRL_CMD_FRH; nom = 1; bcs->hw.isar.state = STFAX_LINE; bcs->hw.isar.cmd = ctrl; bcs->hw.isar.mod = para; bcs->hw.isar.newmod = 0; bcs->hw.isar.newcmd = 0; bcs->hw.isar.try_mod = 3; } else if ((bcs->hw.isar.state == STFAX_ACTIV) && (bcs->hw.isar.cmd == PCTRL_CMD_FRH) && (bcs->hw.isar.mod == para)) { ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); } else { bcs->hw.isar.newmod = para; bcs->hw.isar.newcmd = PCTRL_CMD_FRH; nom = 0; ctrl = PCTRL_CMD_ESC; bcs->hw.isar.state = STFAX_ESCAPE; } break; case ISDN_FAXPUMP_HALT: bcs->hw.isar.state = STFAX_NULL; nom = 0; ctrl = PCTRL_CMD_HALT; break; } if (ctrl) sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, ctrl, nom, &p1); } static void isar_setup(struct IsdnCardState *cs) { u_char msg; int i; /* Dpath 1, 2 */ msg = 61; for (i = 0; i < 2; i++) { /* Buffer Config */ sendmsg(cs, (i ? ISAR_HIS_DPS2 : ISAR_HIS_DPS1) | ISAR_HIS_P12CFG, 4, 1, &msg); cs->bcs[i].hw.isar.mml = msg; cs->bcs[i].mode = 0; cs->bcs[i].hw.isar.dpath = i + 1; modeisar(&cs->bcs[i], 0, 0); INIT_WORK(&cs->bcs[i].tqueue, isar_bh); } } static void isar_l2l1(struct PStack *st, int pr, void *arg) { struct BCState *bcs = st->l1.bcs; struct sk_buff *skb = arg; int ret; u_long flags; switch (pr) { case (PH_DATA | REQUEST): spin_lock_irqsave(&bcs->cs->lock, flags); if (bcs->tx_skb) { skb_queue_tail(&bcs->squeue, skb); } else { bcs->tx_skb = skb; test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); if (bcs->cs->debug & L1_DEB_HSCX) debugl1(bcs->cs, "DRQ set BC_FLG_BUSY"); bcs->hw.isar.txcnt = 0; bcs->cs->BC_Send_Data(bcs); } spin_unlock_irqrestore(&bcs->cs->lock, flags); break; case (PH_PULL | INDICATION): spin_lock_irqsave(&bcs->cs->lock, flags); if (bcs->tx_skb) { printk(KERN_WARNING "isar_l2l1: this shouldn't happen\n"); } else { test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); if (bcs->cs->debug & L1_DEB_HSCX) debugl1(bcs->cs, "PUI set BC_FLG_BUSY"); bcs->tx_skb = skb; bcs->hw.isar.txcnt = 0; bcs->cs->BC_Send_Data(bcs); } spin_unlock_irqrestore(&bcs->cs->lock, flags); break; case (PH_PULL | REQUEST): if (!bcs->tx_skb) { test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); } else test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); break; case (PH_ACTIVATE | REQUEST): spin_lock_irqsave(&bcs->cs->lock, flags); test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); bcs->hw.isar.conmsg[0] = 0; if (test_bit(FLG_ORIG, &st->l2.flag)) test_and_set_bit(BC_FLG_ORIG, &bcs->Flag); else test_and_clear_bit(BC_FLG_ORIG, &bcs->Flag); switch (st->l1.mode) { case L1_MODE_TRANS: case L1_MODE_HDLC: ret = modeisar(bcs, st->l1.mode, st->l1.bc); spin_unlock_irqrestore(&bcs->cs->lock, flags); if (ret) l1_msg_b(st, PH_DEACTIVATE | REQUEST, arg); else l1_msg_b(st, PH_ACTIVATE | REQUEST, arg); break; case L1_MODE_V32: case L1_MODE_FAX: ret = modeisar(bcs, st->l1.mode, st->l1.bc); spin_unlock_irqrestore(&bcs->cs->lock, flags); if (ret) l1_msg_b(st, PH_DEACTIVATE | REQUEST, arg); break; default: spin_unlock_irqrestore(&bcs->cs->lock, flags); break; } break; case (PH_DEACTIVATE | REQUEST): l1_msg_b(st, pr, arg); break; case (PH_DEACTIVATE | CONFIRM): spin_lock_irqsave(&bcs->cs->lock, flags); switch (st->l1.mode) { case L1_MODE_TRANS: case L1_MODE_HDLC: case L1_MODE_V32: break; case L1_MODE_FAX: isar_pump_cmd(bcs, ISDN_FAXPUMP_HALT, 0); break; } test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); if (bcs->cs->debug & L1_DEB_HSCX) debugl1(bcs->cs, "PDAC clear BC_FLG_BUSY"); modeisar(bcs, 0, st->l1.bc); spin_unlock_irqrestore(&bcs->cs->lock, flags); st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); break; } } static void close_isarstate(struct BCState *bcs) { modeisar(bcs, 0, bcs->channel); if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { kfree(bcs->hw.isar.rcvbuf); bcs->hw.isar.rcvbuf = NULL; skb_queue_purge(&bcs->rqueue); skb_queue_purge(&bcs->squeue); if (bcs->tx_skb) { dev_kfree_skb_any(bcs->tx_skb); bcs->tx_skb = NULL; test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); if (bcs->cs->debug & L1_DEB_HSCX) debugl1(bcs->cs, "closeisar clear BC_FLG_BUSY"); } } del_timer(&bcs->hw.isar.ftimer); } static int open_isarstate(struct IsdnCardState *cs, struct BCState *bcs) { if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { if (!(bcs->hw.isar.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) { printk(KERN_WARNING "HiSax: No memory for isar.rcvbuf\n"); return (1); } skb_queue_head_init(&bcs->rqueue); skb_queue_head_init(&bcs->squeue); } bcs->tx_skb = NULL; test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); if (cs->debug & L1_DEB_HSCX) debugl1(cs, "openisar clear BC_FLG_BUSY"); bcs->event = 0; bcs->hw.isar.rcvidx = 0; bcs->tx_cnt = 0; return (0); } static int setstack_isar(struct PStack *st, struct BCState *bcs) { bcs->channel = st->l1.bc; if (open_isarstate(st->l1.hardware, bcs)) return (-1); st->l1.bcs = bcs; st->l2.l2l1 = isar_l2l1; setstack_manager(st); bcs->st = st; setstack_l1_B(st); return (0); } int isar_auxcmd(struct IsdnCardState *cs, isdn_ctrl *ic) { u_long adr; int features, i; struct BCState *bcs; if (cs->debug & L1_DEB_HSCX) debugl1(cs, "isar_auxcmd cmd/ch %x/%ld", ic->command, ic->arg); switch (ic->command) { case (ISDN_CMD_FAXCMD): bcs = cs->channel[ic->arg].bcs; if (cs->debug & L1_DEB_HSCX) debugl1(cs, "isar_auxcmd cmd/subcmd %d/%d", ic->parm.aux.cmd, ic->parm.aux.subcmd); switch (ic->parm.aux.cmd) { case ISDN_FAX_CLASS1_CTRL: if (ic->parm.aux.subcmd == ETX) test_and_set_bit(BC_FLG_DLEETX, &bcs->Flag); break; case ISDN_FAX_CLASS1_FTS: if (ic->parm.aux.subcmd == AT_QUERY) { ic->command = ISDN_STAT_FAXIND; ic->parm.aux.cmd = ISDN_FAX_CLASS1_OK; cs->iif.statcallb(ic); return (0); } else if (ic->parm.aux.subcmd == AT_EQ_QUERY) { strcpy(ic->parm.aux.para, "0-255"); ic->command = ISDN_STAT_FAXIND; ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; cs->iif.statcallb(ic); return (0); } else if (ic->parm.aux.subcmd == AT_EQ_VALUE) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "isar_auxcmd %s=%d", FC1_CMD[ic->parm.aux.cmd], ic->parm.aux.para[0]); if (bcs->hw.isar.state == STFAX_READY) { if (!ic->parm.aux.para[0]) { ic->command = ISDN_STAT_FAXIND; ic->parm.aux.cmd = ISDN_FAX_CLASS1_OK; cs->iif.statcallb(ic); return (0); } if (!test_and_set_bit(BC_FLG_FTI_RUN, &bcs->Flag)) { /* n*10 ms */ bcs->hw.isar.ftimer.expires = jiffies + ((ic->parm.aux.para[0] * 10 * HZ) / 1000); test_and_set_bit(BC_FLG_FTI_FTS, &bcs->Flag); add_timer(&bcs->hw.isar.ftimer); return (0); } else { if (cs->debug) debugl1(cs, "isar FTS=%d and FTI busy", ic->parm.aux.para[0]); } } else { if (cs->debug) debugl1(cs, "isar FTS=%d and isar.state not ready(%x)", ic->parm.aux.para[0], bcs->hw.isar.state); } ic->command = ISDN_STAT_FAXIND; ic->parm.aux.cmd = ISDN_FAX_CLASS1_ERROR; cs->iif.statcallb(ic); } break; case ISDN_FAX_CLASS1_FRM: case ISDN_FAX_CLASS1_FRH: case ISDN_FAX_CLASS1_FTM: case ISDN_FAX_CLASS1_FTH: if (ic->parm.aux.subcmd == AT_QUERY) { sprintf(ic->parm.aux.para, "%d", bcs->hw.isar.mod); ic->command = ISDN_STAT_FAXIND; ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; cs->iif.statcallb(ic); return (0); } else if (ic->parm.aux.subcmd == AT_EQ_QUERY) { char *p = ic->parm.aux.para; for (i = 0; i < FAXMODCNT; i++) if ((1 << i) & modmask) p += sprintf(p, "%d,", faxmodulation[i]); p--; *p = 0; ic->command = ISDN_STAT_FAXIND; ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; cs->iif.statcallb(ic); return (0); } else if (ic->parm.aux.subcmd == AT_EQ_VALUE) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "isar_auxcmd %s=%d", FC1_CMD[ic->parm.aux.cmd], ic->parm.aux.para[0]); for (i = 0; i < FAXMODCNT; i++) if (faxmodulation[i] == ic->parm.aux.para[0]) break; if ((i < FAXMODCNT) && ((1 << i) & modmask) && test_bit(BC_FLG_INIT, &bcs->Flag)) { isar_pump_cmd(bcs, ic->parm.aux.cmd, ic->parm.aux.para[0]); return (0); } } /* wrong modulation or not activ */ /* fall through */ default: ic->command = ISDN_STAT_FAXIND; ic->parm.aux.cmd = ISDN_FAX_CLASS1_ERROR; cs->iif.statcallb(ic); } break; case (ISDN_CMD_IOCTL): switch (ic->arg) { case 9: /* load firmware */ features = ISDN_FEATURE_L2_MODEM | ISDN_FEATURE_L2_FAX | ISDN_FEATURE_L3_FCLASS1; memcpy(&adr, ic->parm.num, sizeof(ulong)); if (isar_load_firmware(cs, (u_char __user *)adr)) return (1); else ll_run(cs, features); break; case 20: features = *(unsigned int *) ic->parm.num; printk(KERN_DEBUG "HiSax: max modulation old(%04x) new(%04x)\n", modmask, features); modmask = features; break; case 21: features = *(unsigned int *) ic->parm.num; printk(KERN_DEBUG "HiSax: FRM extra delay old(%d) new(%d) ms\n", frm_extra_delay, features); if (features >= 0) frm_extra_delay = features; break; case 22: features = *(unsigned int *) ic->parm.num; printk(KERN_DEBUG "HiSax: TOA old(%d) new(%d) db\n", para_TOA, features); if (features >= 0 && features < 32) para_TOA = features; break; default: printk(KERN_DEBUG "HiSax: invalid ioctl %d\n", (int) ic->arg); return (-EINVAL); } break; default: return (-EINVAL); } return (0); } void initisar(struct IsdnCardState *cs) { cs->bcs[0].BC_SetStack = setstack_isar; cs->bcs[1].BC_SetStack = setstack_isar; cs->bcs[0].BC_Close = close_isarstate; cs->bcs[1].BC_Close = close_isarstate; cs->bcs[0].hw.isar.ftimer.function = (void *) ftimer_handler; cs->bcs[0].hw.isar.ftimer.data = (long) &cs->bcs[0]; init_timer(&cs->bcs[0].hw.isar.ftimer); cs->bcs[1].hw.isar.ftimer.function = (void *) ftimer_handler; cs->bcs[1].hw.isar.ftimer.data = (long) &cs->bcs[1]; init_timer(&cs->bcs[1].hw.isar.ftimer); }
gpl-2.0
TeamExodus/kernel_samsung_msm8930-common
drivers/scsi/gvp11.c
5240
10806
#include <linux/types.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/zorro.h> #include <linux/module.h> #include <asm/page.h> #include <asm/pgtable.h> #include <asm/amigaints.h> #include <asm/amigahw.h> #include "scsi.h" #include "wd33c93.h" #include "gvp11.h" #define CHECK_WD33C93 struct gvp11_hostdata { struct WD33C93_hostdata wh; struct gvp11_scsiregs *regs; }; static irqreturn_t gvp11_intr(int irq, void *data) { struct Scsi_Host *instance = data; struct gvp11_hostdata *hdata = shost_priv(instance); unsigned int status = hdata->regs->CNTR; unsigned long flags; if (!(status & GVP11_DMAC_INT_PENDING)) return IRQ_NONE; spin_lock_irqsave(instance->host_lock, flags); wd33c93_intr(instance); spin_unlock_irqrestore(instance->host_lock, flags); return IRQ_HANDLED; } static int gvp11_xfer_mask = 0; void gvp11_setup(char *str, int *ints) { gvp11_xfer_mask = ints[1]; } static int dma_setup(struct scsi_cmnd *cmd, int dir_in) { struct Scsi_Host *instance = cmd->device->host; struct gvp11_hostdata *hdata = shost_priv(instance); struct WD33C93_hostdata *wh = &hdata->wh; struct gvp11_scsiregs *regs = hdata->regs; unsigned short cntr = GVP11_DMAC_INT_ENABLE; unsigned long addr = virt_to_bus(cmd->SCp.ptr); int bank_mask; static int scsi_alloc_out_of_range = 0; /* use bounce buffer if the physical address is bad */ if (addr & wh->dma_xfer_mask) { wh->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff; if (!scsi_alloc_out_of_range) { wh->dma_bounce_buffer = kmalloc(wh->dma_bounce_len, GFP_KERNEL); wh->dma_buffer_pool = BUF_SCSI_ALLOCED; } if (scsi_alloc_out_of_range || !wh->dma_bounce_buffer) { wh->dma_bounce_buffer = amiga_chip_alloc(wh->dma_bounce_len, "GVP II SCSI Bounce Buffer"); if (!wh->dma_bounce_buffer) { wh->dma_bounce_len = 0; return 1; } wh->dma_buffer_pool = BUF_CHIP_ALLOCED; } /* check if the address of the bounce buffer is OK */ addr = virt_to_bus(wh->dma_bounce_buffer); if (addr & wh->dma_xfer_mask) { /* fall back to Chip RAM if address out of range */ if (wh->dma_buffer_pool == BUF_SCSI_ALLOCED) { kfree(wh->dma_bounce_buffer); scsi_alloc_out_of_range = 1; } else { amiga_chip_free(wh->dma_bounce_buffer); } wh->dma_bounce_buffer = amiga_chip_alloc(wh->dma_bounce_len, "GVP II SCSI Bounce Buffer"); if (!wh->dma_bounce_buffer) { wh->dma_bounce_len = 0; return 1; } addr = virt_to_bus(wh->dma_bounce_buffer); wh->dma_buffer_pool = BUF_CHIP_ALLOCED; } if (!dir_in) { /* copy to bounce buffer for a write */ memcpy(wh->dma_bounce_buffer, cmd->SCp.ptr, cmd->SCp.this_residual); } } /* setup dma direction */ if (!dir_in) cntr |= GVP11_DMAC_DIR_WRITE; wh->dma_dir = dir_in; regs->CNTR = cntr; /* setup DMA *physical* address */ regs->ACR = addr; if (dir_in) { /* invalidate any cache */ cache_clear(addr, cmd->SCp.this_residual); } else { /* push any dirty cache */ cache_push(addr, cmd->SCp.this_residual); } bank_mask = (~wh->dma_xfer_mask >> 18) & 0x01c0; if (bank_mask) regs->BANK = bank_mask & (addr >> 18); /* start DMA */ regs->ST_DMA = 1; /* return success */ return 0; } static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, int status) { struct gvp11_hostdata *hdata = shost_priv(instance); struct WD33C93_hostdata *wh = &hdata->wh; struct gvp11_scsiregs *regs = hdata->regs; /* stop DMA */ regs->SP_DMA = 1; /* remove write bit from CONTROL bits */ regs->CNTR = GVP11_DMAC_INT_ENABLE; /* copy from a bounce buffer, if necessary */ if (status && wh->dma_bounce_buffer) { if (wh->dma_dir && SCpnt) memcpy(SCpnt->SCp.ptr, wh->dma_bounce_buffer, SCpnt->SCp.this_residual); if (wh->dma_buffer_pool == BUF_SCSI_ALLOCED) kfree(wh->dma_bounce_buffer); else amiga_chip_free(wh->dma_bounce_buffer); wh->dma_bounce_buffer = NULL; wh->dma_bounce_len = 0; } } static int gvp11_bus_reset(struct scsi_cmnd *cmd) { struct Scsi_Host *instance = cmd->device->host; /* FIXME perform bus-specific reset */ /* FIXME 2: shouldn't we no-op this function (return FAILED), and fall back to host reset function, wd33c93_host_reset ? */ spin_lock_irq(instance->host_lock); wd33c93_host_reset(cmd); spin_unlock_irq(instance->host_lock); return SUCCESS; } static struct scsi_host_template gvp11_scsi_template = { .module = THIS_MODULE, .name = "GVP Series II SCSI", .proc_info = wd33c93_proc_info, .proc_name = "GVP11", .queuecommand = wd33c93_queuecommand, .eh_abort_handler = wd33c93_abort, .eh_bus_reset_handler = gvp11_bus_reset, .eh_host_reset_handler = wd33c93_host_reset, .can_queue = CAN_QUEUE, .this_id = 7, .sg_tablesize = SG_ALL, .cmd_per_lun = CMD_PER_LUN, .use_clustering = DISABLE_CLUSTERING }; static int __devinit check_wd33c93(struct gvp11_scsiregs *regs) { #ifdef CHECK_WD33C93 volatile unsigned char *sasr_3393, *scmd_3393; unsigned char save_sasr; unsigned char q, qq; /* * These darn GVP boards are a problem - it can be tough to tell * whether or not they include a SCSI controller. This is the * ultimate Yet-Another-GVP-Detection-Hack in that it actually * probes for a WD33c93 chip: If we find one, it's extremely * likely that this card supports SCSI, regardless of Product_ * Code, Board_Size, etc. */ /* Get pointers to the presumed register locations and save contents */ sasr_3393 = &regs->SASR; scmd_3393 = &regs->SCMD; save_sasr = *sasr_3393; /* First test the AuxStatus Reg */ q = *sasr_3393; /* read it */ if (q & 0x08) /* bit 3 should always be clear */ return -ENODEV; *sasr_3393 = WD_AUXILIARY_STATUS; /* setup indirect address */ if (*sasr_3393 == WD_AUXILIARY_STATUS) { /* shouldn't retain the write */ *sasr_3393 = save_sasr; /* Oops - restore this byte */ return -ENODEV; } if (*sasr_3393 != q) { /* should still read the same */ *sasr_3393 = save_sasr; /* Oops - restore this byte */ return -ENODEV; } if (*scmd_3393 != q) /* and so should the image at 0x1f */ return -ENODEV; /* * Ok, we probably have a wd33c93, but let's check a few other places * for good measure. Make sure that this works for both 'A and 'B * chip versions. */ *sasr_3393 = WD_SCSI_STATUS; q = *scmd_3393; *sasr_3393 = WD_SCSI_STATUS; *scmd_3393 = ~q; *sasr_3393 = WD_SCSI_STATUS; qq = *scmd_3393; *sasr_3393 = WD_SCSI_STATUS; *scmd_3393 = q; if (qq != q) /* should be read only */ return -ENODEV; *sasr_3393 = 0x1e; /* this register is unimplemented */ q = *scmd_3393; *sasr_3393 = 0x1e; *scmd_3393 = ~q; *sasr_3393 = 0x1e; qq = *scmd_3393; *sasr_3393 = 0x1e; *scmd_3393 = q; if (qq != q || qq != 0xff) /* should be read only, all 1's */ return -ENODEV; *sasr_3393 = WD_TIMEOUT_PERIOD; q = *scmd_3393; *sasr_3393 = WD_TIMEOUT_PERIOD; *scmd_3393 = ~q; *sasr_3393 = WD_TIMEOUT_PERIOD; qq = *scmd_3393; *sasr_3393 = WD_TIMEOUT_PERIOD; *scmd_3393 = q; if (qq != (~q & 0xff)) /* should be read/write */ return -ENODEV; #endif /* CHECK_WD33C93 */ return 0; } static int __devinit gvp11_probe(struct zorro_dev *z, const struct zorro_device_id *ent) { struct Scsi_Host *instance; unsigned long address; int error; unsigned int epc; unsigned int default_dma_xfer_mask; struct gvp11_hostdata *hdata; struct gvp11_scsiregs *regs; wd33c93_regs wdregs; default_dma_xfer_mask = ent->driver_data; /* * Rumors state that some GVP ram boards use the same product * code as the SCSI controllers. Therefore if the board-size * is not 64KB we assume it is a ram board and bail out. */ if (zorro_resource_len(z) != 0x10000) return -ENODEV; address = z->resource.start; if (!request_mem_region(address, 256, "wd33c93")) return -EBUSY; regs = (struct gvp11_scsiregs *)(ZTWO_VADDR(address)); error = check_wd33c93(regs); if (error) goto fail_check_or_alloc; instance = scsi_host_alloc(&gvp11_scsi_template, sizeof(struct gvp11_hostdata)); if (!instance) { error = -ENOMEM; goto fail_check_or_alloc; } instance->irq = IRQ_AMIGA_PORTS; instance->unique_id = z->slotaddr; regs->secret2 = 1; regs->secret1 = 0; regs->secret3 = 15; while (regs->CNTR & GVP11_DMAC_BUSY) ; regs->CNTR = 0; regs->BANK = 0; wdregs.SASR = &regs->SASR; wdregs.SCMD = &regs->SCMD; hdata = shost_priv(instance); if (gvp11_xfer_mask) hdata->wh.dma_xfer_mask = gvp11_xfer_mask; else hdata->wh.dma_xfer_mask = default_dma_xfer_mask; hdata->wh.no_sync = 0xff; hdata->wh.fast = 0; hdata->wh.dma_mode = CTRL_DMA; hdata->regs = regs; /* * Check for 14MHz SCSI clock */ epc = *(unsigned short *)(ZTWO_VADDR(address) + 0x8000); wd33c93_init(instance, wdregs, dma_setup, dma_stop, (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10 : WD33C93_FS_12_15); error = request_irq(IRQ_AMIGA_PORTS, gvp11_intr, IRQF_SHARED, "GVP11 SCSI", instance); if (error) goto fail_irq; regs->CNTR = GVP11_DMAC_INT_ENABLE; error = scsi_add_host(instance, NULL); if (error) goto fail_host; zorro_set_drvdata(z, instance); scsi_scan_host(instance); return 0; fail_host: free_irq(IRQ_AMIGA_PORTS, instance); fail_irq: scsi_host_put(instance); fail_check_or_alloc: release_mem_region(address, 256); return error; } static void __devexit gvp11_remove(struct zorro_dev *z) { struct Scsi_Host *instance = zorro_get_drvdata(z); struct gvp11_hostdata *hdata = shost_priv(instance); hdata->regs->CNTR = 0; scsi_remove_host(instance); free_irq(IRQ_AMIGA_PORTS, instance); scsi_host_put(instance); release_mem_region(z->resource.start, 256); } /* * This should (hopefully) be the correct way to identify * all the different GVP SCSI controllers (except for the * SERIES I though). */ static struct zorro_device_id gvp11_zorro_tbl[] __devinitdata = { { ZORRO_PROD_GVP_COMBO_030_R3_SCSI, ~0x00ffffff }, { ZORRO_PROD_GVP_SERIES_II, ~0x00ffffff }, { ZORRO_PROD_GVP_GFORCE_030_SCSI, ~0x01ffffff }, { ZORRO_PROD_GVP_A530_SCSI, ~0x01ffffff }, { ZORRO_PROD_GVP_COMBO_030_R4_SCSI, ~0x01ffffff }, { ZORRO_PROD_GVP_A1291, ~0x07ffffff }, { ZORRO_PROD_GVP_GFORCE_040_SCSI_1, ~0x07ffffff }, { 0 } }; MODULE_DEVICE_TABLE(zorro, gvp11_zorro_tbl); static struct zorro_driver gvp11_driver = { .name = "gvp11", .id_table = gvp11_zorro_tbl, .probe = gvp11_probe, .remove = __devexit_p(gvp11_remove), }; static int __init gvp11_init(void) { return zorro_register_driver(&gvp11_driver); } module_init(gvp11_init); static void __exit gvp11_exit(void) { zorro_unregister_driver(&gvp11_driver); } module_exit(gvp11_exit); MODULE_DESCRIPTION("GVP Series II SCSI"); MODULE_LICENSE("GPL");
gpl-2.0
vl197602/htc_msm8960
drivers/net/hamradio/dmascc.c
5752
37761
/* * Driver for high-speed SCC boards (those with DMA support) * Copyright (C) 1997-2000 Klaus Kudielka * * S5SCC/DMA support by Janko Koleznik S52HI * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <linux/module.h> #include <linux/bitops.h> #include <linux/delay.h> #include <linux/errno.h> #include <linux/if_arp.h> #include <linux/in.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/kernel.h> #include <linux/mm.h> #include <linux/netdevice.h> #include <linux/slab.h> #include <linux/rtnetlink.h> #include <linux/sockios.h> #include <linux/workqueue.h> #include <linux/atomic.h> #include <asm/dma.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/uaccess.h> #include <net/ax25.h> #include "z8530.h" /* Number of buffers per channel */ #define NUM_TX_BUF 2 /* NUM_TX_BUF >= 1 (min. 2 recommended) */ #define NUM_RX_BUF 6 /* NUM_RX_BUF >= 1 (min. 2 recommended) */ #define BUF_SIZE 1576 /* BUF_SIZE >= mtu + hard_header_len */ /* Cards supported */ #define HW_PI { "Ottawa PI", 0x300, 0x20, 0x10, 8, \ 0, 8, 1843200, 3686400 } #define HW_PI2 { "Ottawa PI2", 0x300, 0x20, 0x10, 8, \ 0, 8, 3686400, 7372800 } #define HW_TWIN { "Gracilis PackeTwin", 0x200, 0x10, 0x10, 32, \ 0, 4, 6144000, 6144000 } #define HW_S5 { "S5SCC/DMA", 0x200, 0x10, 0x10, 32, \ 0, 8, 4915200, 9830400 } #define HARDWARE { HW_PI, HW_PI2, HW_TWIN, HW_S5 } #define TMR_0_HZ 25600 /* Frequency of timer 0 */ #define TYPE_PI 0 #define TYPE_PI2 1 #define TYPE_TWIN 2 #define TYPE_S5 3 #define NUM_TYPES 4 #define MAX_NUM_DEVS 32 /* SCC chips supported */ #define Z8530 0 #define Z85C30 1 #define Z85230 2 #define CHIPNAMES { "Z8530", "Z85C30", "Z85230" } /* I/O registers */ /* 8530 registers relative to card base */ #define SCCB_CMD 0x00 #define SCCB_DATA 0x01 #define SCCA_CMD 0x02 #define SCCA_DATA 0x03 /* 8253/8254 registers relative to card base */ #define TMR_CNT0 0x00 #define TMR_CNT1 0x01 #define TMR_CNT2 0x02 #define TMR_CTRL 0x03 /* Additional PI/PI2 registers relative to card base */ #define PI_DREQ_MASK 0x04 /* Additional PackeTwin registers relative to card base */ #define TWIN_INT_REG 0x08 #define TWIN_CLR_TMR1 0x09 #define TWIN_CLR_TMR2 0x0a #define TWIN_SPARE_1 0x0b #define TWIN_DMA_CFG 0x08 #define TWIN_SERIAL_CFG 0x09 #define TWIN_DMA_CLR_FF 0x0a #define TWIN_SPARE_2 0x0b /* PackeTwin I/O register values */ /* INT_REG */ #define TWIN_SCC_MSK 0x01 #define TWIN_TMR1_MSK 0x02 #define TWIN_TMR2_MSK 0x04 #define TWIN_INT_MSK 0x07 /* SERIAL_CFG */ #define TWIN_DTRA_ON 0x01 #define TWIN_DTRB_ON 0x02 #define TWIN_EXTCLKA 0x04 #define TWIN_EXTCLKB 0x08 #define TWIN_LOOPA_ON 0x10 #define TWIN_LOOPB_ON 0x20 #define TWIN_EI 0x80 /* DMA_CFG */ #define TWIN_DMA_HDX_T1 0x08 #define TWIN_DMA_HDX_R1 0x0a #define TWIN_DMA_HDX_T3 0x14 #define TWIN_DMA_HDX_R3 0x16 #define TWIN_DMA_FDX_T3R1 0x1b #define TWIN_DMA_FDX_T1R3 0x1d /* Status values */ #define IDLE 0 #define TX_HEAD 1 #define TX_DATA 2 #define TX_PAUSE 3 #define TX_TAIL 4 #define RTS_OFF 5 #define WAIT 6 #define DCD_ON 7 #define RX_ON 8 #define DCD_OFF 9 /* Ioctls */ #define SIOCGSCCPARAM SIOCDEVPRIVATE #define SIOCSSCCPARAM (SIOCDEVPRIVATE+1) /* Data types */ struct scc_param { int pclk_hz; /* frequency of BRG input (don't change) */ int brg_tc; /* BRG terminal count; BRG disabled if < 0 */ int nrzi; /* 0 (nrz), 1 (nrzi) */ int clocks; /* see dmascc_cfg documentation */ int txdelay; /* [1/TMR_0_HZ] */ int txtimeout; /* [1/HZ] */ int txtail; /* [1/TMR_0_HZ] */ int waittime; /* [1/TMR_0_HZ] */ int slottime; /* [1/TMR_0_HZ] */ int persist; /* 1 ... 256 */ int dma; /* -1 (disable), 0, 1, 3 */ int txpause; /* [1/TMR_0_HZ] */ int rtsoff; /* [1/TMR_0_HZ] */ int dcdon; /* [1/TMR_0_HZ] */ int dcdoff; /* [1/TMR_0_HZ] */ }; struct scc_hardware { char *name; int io_region; int io_delta; int io_size; int num_devs; int scc_offset; int tmr_offset; int tmr_hz; int pclk_hz; }; struct scc_priv { int type; int chip; struct net_device *dev; struct scc_info *info; int channel; int card_base, scc_cmd, scc_data; int tmr_cnt, tmr_ctrl, tmr_mode; struct scc_param param; char rx_buf[NUM_RX_BUF][BUF_SIZE]; int rx_len[NUM_RX_BUF]; int rx_ptr; struct work_struct rx_work; int rx_head, rx_tail, rx_count; int rx_over; char tx_buf[NUM_TX_BUF][BUF_SIZE]; int tx_len[NUM_TX_BUF]; int tx_ptr; int tx_head, tx_tail, tx_count; int state; unsigned long tx_start; int rr0; spinlock_t *register_lock; /* Per scc_info */ spinlock_t ring_lock; }; struct scc_info { int irq_used; int twin_serial_cfg; struct net_device *dev[2]; struct scc_priv priv[2]; struct scc_info *next; spinlock_t register_lock; /* Per device register lock */ }; /* Function declarations */ static int setup_adapter(int card_base, int type, int n) __init; static void write_scc(struct scc_priv *priv, int reg, int val); static void write_scc_data(struct scc_priv *priv, int val, int fast); static int read_scc(struct scc_priv *priv, int reg); static int read_scc_data(struct scc_priv *priv); static int scc_open(struct net_device *dev); static int scc_close(struct net_device *dev); static int scc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); static int scc_send_packet(struct sk_buff *skb, struct net_device *dev); static int scc_set_mac_address(struct net_device *dev, void *sa); static inline void tx_on(struct scc_priv *priv); static inline void rx_on(struct scc_priv *priv); static inline void rx_off(struct scc_priv *priv); static void start_timer(struct scc_priv *priv, int t, int r15); static inline unsigned char random(void); static inline void z8530_isr(struct scc_info *info); static irqreturn_t scc_isr(int irq, void *dev_id); static void rx_isr(struct scc_priv *priv); static void special_condition(struct scc_priv *priv, int rc); static void rx_bh(struct work_struct *); static void tx_isr(struct scc_priv *priv); static void es_isr(struct scc_priv *priv); static void tm_isr(struct scc_priv *priv); /* Initialization variables */ static int io[MAX_NUM_DEVS] __initdata = { 0, }; /* Beware! hw[] is also used in dmascc_exit(). */ static struct scc_hardware hw[NUM_TYPES] = HARDWARE; /* Global variables */ static struct scc_info *first; static unsigned long rand; MODULE_AUTHOR("Klaus Kudielka"); MODULE_DESCRIPTION("Driver for high-speed SCC boards"); module_param_array(io, int, NULL, 0); MODULE_LICENSE("GPL"); static void __exit dmascc_exit(void) { int i; struct scc_info *info; while (first) { info = first; /* Unregister devices */ for (i = 0; i < 2; i++) unregister_netdev(info->dev[i]); /* Reset board */ if (info->priv[0].type == TYPE_TWIN) outb(0, info->dev[0]->base_addr + TWIN_SERIAL_CFG); write_scc(&info->priv[0], R9, FHWRES); release_region(info->dev[0]->base_addr, hw[info->priv[0].type].io_size); for (i = 0; i < 2; i++) free_netdev(info->dev[i]); /* Free memory */ first = info->next; kfree(info); } } static int __init dmascc_init(void) { int h, i, j, n; int base[MAX_NUM_DEVS], tcmd[MAX_NUM_DEVS], t0[MAX_NUM_DEVS], t1[MAX_NUM_DEVS]; unsigned t_val; unsigned long time, start[MAX_NUM_DEVS], delay[MAX_NUM_DEVS], counting[MAX_NUM_DEVS]; /* Initialize random number generator */ rand = jiffies; /* Cards found = 0 */ n = 0; /* Warning message */ if (!io[0]) printk(KERN_INFO "dmascc: autoprobing (dangerous)\n"); /* Run autodetection for each card type */ for (h = 0; h < NUM_TYPES; h++) { if (io[0]) { /* User-specified I/O address regions */ for (i = 0; i < hw[h].num_devs; i++) base[i] = 0; for (i = 0; i < MAX_NUM_DEVS && io[i]; i++) { j = (io[i] - hw[h].io_region) / hw[h].io_delta; if (j >= 0 && j < hw[h].num_devs && hw[h].io_region + j * hw[h].io_delta == io[i]) { base[j] = io[i]; } } } else { /* Default I/O address regions */ for (i = 0; i < hw[h].num_devs; i++) { base[i] = hw[h].io_region + i * hw[h].io_delta; } } /* Check valid I/O address regions */ for (i = 0; i < hw[h].num_devs; i++) if (base[i]) { if (!request_region (base[i], hw[h].io_size, "dmascc")) base[i] = 0; else { tcmd[i] = base[i] + hw[h].tmr_offset + TMR_CTRL; t0[i] = base[i] + hw[h].tmr_offset + TMR_CNT0; t1[i] = base[i] + hw[h].tmr_offset + TMR_CNT1; } } /* Start timers */ for (i = 0; i < hw[h].num_devs; i++) if (base[i]) { /* Timer 0: LSB+MSB, Mode 3, TMR_0_HZ */ outb(0x36, tcmd[i]); outb((hw[h].tmr_hz / TMR_0_HZ) & 0xFF, t0[i]); outb((hw[h].tmr_hz / TMR_0_HZ) >> 8, t0[i]); /* Timer 1: LSB+MSB, Mode 0, HZ/10 */ outb(0x70, tcmd[i]); outb((TMR_0_HZ / HZ * 10) & 0xFF, t1[i]); outb((TMR_0_HZ / HZ * 10) >> 8, t1[i]); start[i] = jiffies; delay[i] = 0; counting[i] = 1; /* Timer 2: LSB+MSB, Mode 0 */ outb(0xb0, tcmd[i]); } time = jiffies; /* Wait until counter registers are loaded */ udelay(2000000 / TMR_0_HZ); /* Timing loop */ while (jiffies - time < 13) { for (i = 0; i < hw[h].num_devs; i++) if (base[i] && counting[i]) { /* Read back Timer 1: latch; read LSB; read MSB */ outb(0x40, tcmd[i]); t_val = inb(t1[i]) + (inb(t1[i]) << 8); /* Also check whether counter did wrap */ if (t_val == 0 || t_val > TMR_0_HZ / HZ * 10) counting[i] = 0; delay[i] = jiffies - start[i]; } } /* Evaluate measurements */ for (i = 0; i < hw[h].num_devs; i++) if (base[i]) { if ((delay[i] >= 9 && delay[i] <= 11) && /* Ok, we have found an adapter */ (setup_adapter(base[i], h, n) == 0)) n++; else release_region(base[i], hw[h].io_size); } } /* NUM_TYPES */ /* If any adapter was successfully initialized, return ok */ if (n) return 0; /* If no adapter found, return error */ printk(KERN_INFO "dmascc: no adapters found\n"); return -EIO; } module_init(dmascc_init); module_exit(dmascc_exit); static void __init dev_setup(struct net_device *dev) { dev->type = ARPHRD_AX25; dev->hard_header_len = AX25_MAX_HEADER_LEN; dev->mtu = 1500; dev->addr_len = AX25_ADDR_LEN; dev->tx_queue_len = 64; memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN); } static const struct net_device_ops scc_netdev_ops = { .ndo_open = scc_open, .ndo_stop = scc_close, .ndo_start_xmit = scc_send_packet, .ndo_do_ioctl = scc_ioctl, .ndo_set_mac_address = scc_set_mac_address, }; static int __init setup_adapter(int card_base, int type, int n) { int i, irq, chip; struct scc_info *info; struct net_device *dev; struct scc_priv *priv; unsigned long time; unsigned int irqs; int tmr_base = card_base + hw[type].tmr_offset; int scc_base = card_base + hw[type].scc_offset; char *chipnames[] = CHIPNAMES; /* Initialize what is necessary for write_scc and write_scc_data */ info = kzalloc(sizeof(struct scc_info), GFP_KERNEL | GFP_DMA); if (!info) { printk(KERN_ERR "dmascc: " "could not allocate memory for %s at %#3x\n", hw[type].name, card_base); goto out; } info->dev[0] = alloc_netdev(0, "", dev_setup); if (!info->dev[0]) { printk(KERN_ERR "dmascc: " "could not allocate memory for %s at %#3x\n", hw[type].name, card_base); goto out1; } info->dev[1] = alloc_netdev(0, "", dev_setup); if (!info->dev[1]) { printk(KERN_ERR "dmascc: " "could not allocate memory for %s at %#3x\n", hw[type].name, card_base); goto out2; } spin_lock_init(&info->register_lock); priv = &info->priv[0]; priv->type = type; priv->card_base = card_base; priv->scc_cmd = scc_base + SCCA_CMD; priv->scc_data = scc_base + SCCA_DATA; priv->register_lock = &info->register_lock; /* Reset SCC */ write_scc(priv, R9, FHWRES | MIE | NV); /* Determine type of chip by enabling SDLC/HDLC enhancements */ write_scc(priv, R15, SHDLCE); if (!read_scc(priv, R15)) { /* WR7' not present. This is an ordinary Z8530 SCC. */ chip = Z8530; } else { /* Put one character in TX FIFO */ write_scc_data(priv, 0, 0); if (read_scc(priv, R0) & Tx_BUF_EMP) { /* TX FIFO not full. This is a Z85230 ESCC with a 4-byte FIFO. */ chip = Z85230; } else { /* TX FIFO full. This is a Z85C30 SCC with a 1-byte FIFO. */ chip = Z85C30; } } write_scc(priv, R15, 0); /* Start IRQ auto-detection */ irqs = probe_irq_on(); /* Enable interrupts */ if (type == TYPE_TWIN) { outb(0, card_base + TWIN_DMA_CFG); inb(card_base + TWIN_CLR_TMR1); inb(card_base + TWIN_CLR_TMR2); info->twin_serial_cfg = TWIN_EI; outb(info->twin_serial_cfg, card_base + TWIN_SERIAL_CFG); } else { write_scc(priv, R15, CTSIE); write_scc(priv, R0, RES_EXT_INT); write_scc(priv, R1, EXT_INT_ENAB); } /* Start timer */ outb(1, tmr_base + TMR_CNT1); outb(0, tmr_base + TMR_CNT1); /* Wait and detect IRQ */ time = jiffies; while (jiffies - time < 2 + HZ / TMR_0_HZ); irq = probe_irq_off(irqs); /* Clear pending interrupt, disable interrupts */ if (type == TYPE_TWIN) { inb(card_base + TWIN_CLR_TMR1); } else { write_scc(priv, R1, 0); write_scc(priv, R15, 0); write_scc(priv, R0, RES_EXT_INT); } if (irq <= 0) { printk(KERN_ERR "dmascc: could not find irq of %s at %#3x (irq=%d)\n", hw[type].name, card_base, irq); goto out3; } /* Set up data structures */ for (i = 0; i < 2; i++) { dev = info->dev[i]; priv = &info->priv[i]; priv->type = type; priv->chip = chip; priv->dev = dev; priv->info = info; priv->channel = i; spin_lock_init(&priv->ring_lock); priv->register_lock = &info->register_lock; priv->card_base = card_base; priv->scc_cmd = scc_base + (i ? SCCB_CMD : SCCA_CMD); priv->scc_data = scc_base + (i ? SCCB_DATA : SCCA_DATA); priv->tmr_cnt = tmr_base + (i ? TMR_CNT2 : TMR_CNT1); priv->tmr_ctrl = tmr_base + TMR_CTRL; priv->tmr_mode = i ? 0xb0 : 0x70; priv->param.pclk_hz = hw[type].pclk_hz; priv->param.brg_tc = -1; priv->param.clocks = TCTRxCP | RCRTxCP; priv->param.persist = 256; priv->param.dma = -1; INIT_WORK(&priv->rx_work, rx_bh); dev->ml_priv = priv; sprintf(dev->name, "dmascc%i", 2 * n + i); dev->base_addr = card_base; dev->irq = irq; dev->netdev_ops = &scc_netdev_ops; dev->header_ops = &ax25_header_ops; } if (register_netdev(info->dev[0])) { printk(KERN_ERR "dmascc: could not register %s\n", info->dev[0]->name); goto out3; } if (register_netdev(info->dev[1])) { printk(KERN_ERR "dmascc: could not register %s\n", info->dev[1]->name); goto out4; } info->next = first; first = info; printk(KERN_INFO "dmascc: found %s (%s) at %#3x, irq %d\n", hw[type].name, chipnames[chip], card_base, irq); return 0; out4: unregister_netdev(info->dev[0]); out3: if (info->priv[0].type == TYPE_TWIN) outb(0, info->dev[0]->base_addr + TWIN_SERIAL_CFG); write_scc(&info->priv[0], R9, FHWRES); free_netdev(info->dev[1]); out2: free_netdev(info->dev[0]); out1: kfree(info); out: return -1; } /* Driver functions */ static void write_scc(struct scc_priv *priv, int reg, int val) { unsigned long flags; switch (priv->type) { case TYPE_S5: if (reg) outb(reg, priv->scc_cmd); outb(val, priv->scc_cmd); return; case TYPE_TWIN: if (reg) outb_p(reg, priv->scc_cmd); outb_p(val, priv->scc_cmd); return; default: spin_lock_irqsave(priv->register_lock, flags); outb_p(0, priv->card_base + PI_DREQ_MASK); if (reg) outb_p(reg, priv->scc_cmd); outb_p(val, priv->scc_cmd); outb(1, priv->card_base + PI_DREQ_MASK); spin_unlock_irqrestore(priv->register_lock, flags); return; } } static void write_scc_data(struct scc_priv *priv, int val, int fast) { unsigned long flags; switch (priv->type) { case TYPE_S5: outb(val, priv->scc_data); return; case TYPE_TWIN: outb_p(val, priv->scc_data); return; default: if (fast) outb_p(val, priv->scc_data); else { spin_lock_irqsave(priv->register_lock, flags); outb_p(0, priv->card_base + PI_DREQ_MASK); outb_p(val, priv->scc_data); outb(1, priv->card_base + PI_DREQ_MASK); spin_unlock_irqrestore(priv->register_lock, flags); } return; } } static int read_scc(struct scc_priv *priv, int reg) { int rc; unsigned long flags; switch (priv->type) { case TYPE_S5: if (reg) outb(reg, priv->scc_cmd); return inb(priv->scc_cmd); case TYPE_TWIN: if (reg) outb_p(reg, priv->scc_cmd); return inb_p(priv->scc_cmd); default: spin_lock_irqsave(priv->register_lock, flags); outb_p(0, priv->card_base + PI_DREQ_MASK); if (reg) outb_p(reg, priv->scc_cmd); rc = inb_p(priv->scc_cmd); outb(1, priv->card_base + PI_DREQ_MASK); spin_unlock_irqrestore(priv->register_lock, flags); return rc; } } static int read_scc_data(struct scc_priv *priv) { int rc; unsigned long flags; switch (priv->type) { case TYPE_S5: return inb(priv->scc_data); case TYPE_TWIN: return inb_p(priv->scc_data); default: spin_lock_irqsave(priv->register_lock, flags); outb_p(0, priv->card_base + PI_DREQ_MASK); rc = inb_p(priv->scc_data); outb(1, priv->card_base + PI_DREQ_MASK); spin_unlock_irqrestore(priv->register_lock, flags); return rc; } } static int scc_open(struct net_device *dev) { struct scc_priv *priv = dev->ml_priv; struct scc_info *info = priv->info; int card_base = priv->card_base; /* Request IRQ if not already used by other channel */ if (!info->irq_used) { if (request_irq(dev->irq, scc_isr, 0, "dmascc", info)) { return -EAGAIN; } } info->irq_used++; /* Request DMA if required */ if (priv->param.dma >= 0) { if (request_dma(priv->param.dma, "dmascc")) { if (--info->irq_used == 0) free_irq(dev->irq, info); return -EAGAIN; } else { unsigned long flags = claim_dma_lock(); clear_dma_ff(priv->param.dma); release_dma_lock(flags); } } /* Initialize local variables */ priv->rx_ptr = 0; priv->rx_over = 0; priv->rx_head = priv->rx_tail = priv->rx_count = 0; priv->state = IDLE; priv->tx_head = priv->tx_tail = priv->tx_count = 0; priv->tx_ptr = 0; /* Reset channel */ write_scc(priv, R9, (priv->channel ? CHRB : CHRA) | MIE | NV); /* X1 clock, SDLC mode */ write_scc(priv, R4, SDLC | X1CLK); /* DMA */ write_scc(priv, R1, EXT_INT_ENAB | WT_FN_RDYFN); /* 8 bit RX char, RX disable */ write_scc(priv, R3, Rx8); /* 8 bit TX char, TX disable */ write_scc(priv, R5, Tx8); /* SDLC address field */ write_scc(priv, R6, 0); /* SDLC flag */ write_scc(priv, R7, FLAG); switch (priv->chip) { case Z85C30: /* Select WR7' */ write_scc(priv, R15, SHDLCE); /* Auto EOM reset */ write_scc(priv, R7, AUTOEOM); write_scc(priv, R15, 0); break; case Z85230: /* Select WR7' */ write_scc(priv, R15, SHDLCE); /* The following bits are set (see 2.5.2.1): - Automatic EOM reset - Interrupt request if RX FIFO is half full This bit should be ignored in DMA mode (according to the documentation), but actually isn't. The receiver doesn't work if it is set. Thus, we have to clear it in DMA mode. - Interrupt/DMA request if TX FIFO is completely empty a) If set, the ESCC behaves as if it had no TX FIFO (Z85C30 compatibility). b) If cleared, DMA requests may follow each other very quickly, filling up the TX FIFO. Advantage: TX works even in case of high bus latency. Disadvantage: Edge-triggered DMA request circuitry may miss a request. No more data is delivered, resulting in a TX FIFO underrun. Both PI2 and S5SCC/DMA seem to work fine with TXFIFOE cleared. The PackeTwin doesn't. I don't know about the PI, but let's assume it behaves like the PI2. */ if (priv->param.dma >= 0) { if (priv->type == TYPE_TWIN) write_scc(priv, R7, AUTOEOM | TXFIFOE); else write_scc(priv, R7, AUTOEOM); } else { write_scc(priv, R7, AUTOEOM | RXFIFOH); } write_scc(priv, R15, 0); break; } /* Preset CRC, NRZ(I) encoding */ write_scc(priv, R10, CRCPS | (priv->param.nrzi ? NRZI : NRZ)); /* Configure baud rate generator */ if (priv->param.brg_tc >= 0) { /* Program BR generator */ write_scc(priv, R12, priv->param.brg_tc & 0xFF); write_scc(priv, R13, (priv->param.brg_tc >> 8) & 0xFF); /* BRG source = SYS CLK; enable BRG; DTR REQ function (required by PackeTwin, not connected on the PI2); set DPLL source to BRG */ write_scc(priv, R14, SSBR | DTRREQ | BRSRC | BRENABL); /* Enable DPLL */ write_scc(priv, R14, SEARCH | DTRREQ | BRSRC | BRENABL); } else { /* Disable BR generator */ write_scc(priv, R14, DTRREQ | BRSRC); } /* Configure clocks */ if (priv->type == TYPE_TWIN) { /* Disable external TX clock receiver */ outb((info->twin_serial_cfg &= ~(priv->channel ? TWIN_EXTCLKB : TWIN_EXTCLKA)), card_base + TWIN_SERIAL_CFG); } write_scc(priv, R11, priv->param.clocks); if ((priv->type == TYPE_TWIN) && !(priv->param.clocks & TRxCOI)) { /* Enable external TX clock receiver */ outb((info->twin_serial_cfg |= (priv->channel ? TWIN_EXTCLKB : TWIN_EXTCLKA)), card_base + TWIN_SERIAL_CFG); } /* Configure PackeTwin */ if (priv->type == TYPE_TWIN) { /* Assert DTR, enable interrupts */ outb((info->twin_serial_cfg |= TWIN_EI | (priv->channel ? TWIN_DTRB_ON : TWIN_DTRA_ON)), card_base + TWIN_SERIAL_CFG); } /* Read current status */ priv->rr0 = read_scc(priv, R0); /* Enable DCD interrupt */ write_scc(priv, R15, DCDIE); netif_start_queue(dev); return 0; } static int scc_close(struct net_device *dev) { struct scc_priv *priv = dev->ml_priv; struct scc_info *info = priv->info; int card_base = priv->card_base; netif_stop_queue(dev); if (priv->type == TYPE_TWIN) { /* Drop DTR */ outb((info->twin_serial_cfg &= (priv->channel ? ~TWIN_DTRB_ON : ~TWIN_DTRA_ON)), card_base + TWIN_SERIAL_CFG); } /* Reset channel, free DMA and IRQ */ write_scc(priv, R9, (priv->channel ? CHRB : CHRA) | MIE | NV); if (priv->param.dma >= 0) { if (priv->type == TYPE_TWIN) outb(0, card_base + TWIN_DMA_CFG); free_dma(priv->param.dma); } if (--info->irq_used == 0) free_irq(dev->irq, info); return 0; } static int scc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { struct scc_priv *priv = dev->ml_priv; switch (cmd) { case SIOCGSCCPARAM: if (copy_to_user (ifr->ifr_data, &priv->param, sizeof(struct scc_param))) return -EFAULT; return 0; case SIOCSSCCPARAM: if (!capable(CAP_NET_ADMIN)) return -EPERM; if (netif_running(dev)) return -EAGAIN; if (copy_from_user (&priv->param, ifr->ifr_data, sizeof(struct scc_param))) return -EFAULT; return 0; default: return -EINVAL; } } static int scc_send_packet(struct sk_buff *skb, struct net_device *dev) { struct scc_priv *priv = dev->ml_priv; unsigned long flags; int i; /* Temporarily stop the scheduler feeding us packets */ netif_stop_queue(dev); /* Transfer data to DMA buffer */ i = priv->tx_head; skb_copy_from_linear_data_offset(skb, 1, priv->tx_buf[i], skb->len - 1); priv->tx_len[i] = skb->len - 1; /* Clear interrupts while we touch our circular buffers */ spin_lock_irqsave(&priv->ring_lock, flags); /* Move the ring buffer's head */ priv->tx_head = (i + 1) % NUM_TX_BUF; priv->tx_count++; /* If we just filled up the last buffer, leave queue stopped. The higher layers must wait until we have a DMA buffer to accept the data. */ if (priv->tx_count < NUM_TX_BUF) netif_wake_queue(dev); /* Set new TX state */ if (priv->state == IDLE) { /* Assert RTS, start timer */ priv->state = TX_HEAD; priv->tx_start = jiffies; write_scc(priv, R5, TxCRC_ENAB | RTS | TxENAB | Tx8); write_scc(priv, R15, 0); start_timer(priv, priv->param.txdelay, 0); } /* Turn interrupts back on and free buffer */ spin_unlock_irqrestore(&priv->ring_lock, flags); dev_kfree_skb(skb); return NETDEV_TX_OK; } static int scc_set_mac_address(struct net_device *dev, void *sa) { memcpy(dev->dev_addr, ((struct sockaddr *) sa)->sa_data, dev->addr_len); return 0; } static inline void tx_on(struct scc_priv *priv) { int i, n; unsigned long flags; if (priv->param.dma >= 0) { n = (priv->chip == Z85230) ? 3 : 1; /* Program DMA controller */ flags = claim_dma_lock(); set_dma_mode(priv->param.dma, DMA_MODE_WRITE); set_dma_addr(priv->param.dma, (int) priv->tx_buf[priv->tx_tail] + n); set_dma_count(priv->param.dma, priv->tx_len[priv->tx_tail] - n); release_dma_lock(flags); /* Enable TX underrun interrupt */ write_scc(priv, R15, TxUIE); /* Configure DREQ */ if (priv->type == TYPE_TWIN) outb((priv->param.dma == 1) ? TWIN_DMA_HDX_T1 : TWIN_DMA_HDX_T3, priv->card_base + TWIN_DMA_CFG); else write_scc(priv, R1, EXT_INT_ENAB | WT_FN_RDYFN | WT_RDY_ENAB); /* Write first byte(s) */ spin_lock_irqsave(priv->register_lock, flags); for (i = 0; i < n; i++) write_scc_data(priv, priv->tx_buf[priv->tx_tail][i], 1); enable_dma(priv->param.dma); spin_unlock_irqrestore(priv->register_lock, flags); } else { write_scc(priv, R15, TxUIE); write_scc(priv, R1, EXT_INT_ENAB | WT_FN_RDYFN | TxINT_ENAB); tx_isr(priv); } /* Reset EOM latch if we do not have the AUTOEOM feature */ if (priv->chip == Z8530) write_scc(priv, R0, RES_EOM_L); } static inline void rx_on(struct scc_priv *priv) { unsigned long flags; /* Clear RX FIFO */ while (read_scc(priv, R0) & Rx_CH_AV) read_scc_data(priv); priv->rx_over = 0; if (priv->param.dma >= 0) { /* Program DMA controller */ flags = claim_dma_lock(); set_dma_mode(priv->param.dma, DMA_MODE_READ); set_dma_addr(priv->param.dma, (int) priv->rx_buf[priv->rx_head]); set_dma_count(priv->param.dma, BUF_SIZE); release_dma_lock(flags); enable_dma(priv->param.dma); /* Configure PackeTwin DMA */ if (priv->type == TYPE_TWIN) { outb((priv->param.dma == 1) ? TWIN_DMA_HDX_R1 : TWIN_DMA_HDX_R3, priv->card_base + TWIN_DMA_CFG); } /* Sp. cond. intr. only, ext int enable, RX DMA enable */ write_scc(priv, R1, EXT_INT_ENAB | INT_ERR_Rx | WT_RDY_RT | WT_FN_RDYFN | WT_RDY_ENAB); } else { /* Reset current frame */ priv->rx_ptr = 0; /* Intr. on all Rx characters and Sp. cond., ext int enable */ write_scc(priv, R1, EXT_INT_ENAB | INT_ALL_Rx | WT_RDY_RT | WT_FN_RDYFN); } write_scc(priv, R0, ERR_RES); write_scc(priv, R3, RxENABLE | Rx8 | RxCRC_ENAB); } static inline void rx_off(struct scc_priv *priv) { /* Disable receiver */ write_scc(priv, R3, Rx8); /* Disable DREQ / RX interrupt */ if (priv->param.dma >= 0 && priv->type == TYPE_TWIN) outb(0, priv->card_base + TWIN_DMA_CFG); else write_scc(priv, R1, EXT_INT_ENAB | WT_FN_RDYFN); /* Disable DMA */ if (priv->param.dma >= 0) disable_dma(priv->param.dma); } static void start_timer(struct scc_priv *priv, int t, int r15) { outb(priv->tmr_mode, priv->tmr_ctrl); if (t == 0) { tm_isr(priv); } else if (t > 0) { outb(t & 0xFF, priv->tmr_cnt); outb((t >> 8) & 0xFF, priv->tmr_cnt); if (priv->type != TYPE_TWIN) { write_scc(priv, R15, r15 | CTSIE); priv->rr0 |= CTS; } } } static inline unsigned char random(void) { /* See "Numerical Recipes in C", second edition, p. 284 */ rand = rand * 1664525L + 1013904223L; return (unsigned char) (rand >> 24); } static inline void z8530_isr(struct scc_info *info) { int is, i = 100; while ((is = read_scc(&info->priv[0], R3)) && i--) { if (is & CHARxIP) { rx_isr(&info->priv[0]); } else if (is & CHATxIP) { tx_isr(&info->priv[0]); } else if (is & CHAEXT) { es_isr(&info->priv[0]); } else if (is & CHBRxIP) { rx_isr(&info->priv[1]); } else if (is & CHBTxIP) { tx_isr(&info->priv[1]); } else { es_isr(&info->priv[1]); } write_scc(&info->priv[0], R0, RES_H_IUS); i++; } if (i < 0) { printk(KERN_ERR "dmascc: stuck in ISR with RR3=0x%02x.\n", is); } /* Ok, no interrupts pending from this 8530. The INT line should be inactive now. */ } static irqreturn_t scc_isr(int irq, void *dev_id) { struct scc_info *info = dev_id; spin_lock(info->priv[0].register_lock); /* At this point interrupts are enabled, and the interrupt under service is already acknowledged, but masked off. Interrupt processing: We loop until we know that the IRQ line is low. If another positive edge occurs afterwards during the ISR, another interrupt will be triggered by the interrupt controller as soon as the IRQ level is enabled again (see asm/irq.h). Bottom-half handlers will be processed after scc_isr(). This is important, since we only have small ringbuffers and want new data to be fetched/delivered immediately. */ if (info->priv[0].type == TYPE_TWIN) { int is, card_base = info->priv[0].card_base; while ((is = ~inb(card_base + TWIN_INT_REG)) & TWIN_INT_MSK) { if (is & TWIN_SCC_MSK) { z8530_isr(info); } else if (is & TWIN_TMR1_MSK) { inb(card_base + TWIN_CLR_TMR1); tm_isr(&info->priv[0]); } else { inb(card_base + TWIN_CLR_TMR2); tm_isr(&info->priv[1]); } } } else z8530_isr(info); spin_unlock(info->priv[0].register_lock); return IRQ_HANDLED; } static void rx_isr(struct scc_priv *priv) { if (priv->param.dma >= 0) { /* Check special condition and perform error reset. See 2.4.7.5. */ special_condition(priv, read_scc(priv, R1)); write_scc(priv, R0, ERR_RES); } else { /* Check special condition for each character. Error reset not necessary. Same algorithm for SCC and ESCC. See 2.4.7.1 and 2.4.7.4. */ int rc; while (read_scc(priv, R0) & Rx_CH_AV) { rc = read_scc(priv, R1); if (priv->rx_ptr < BUF_SIZE) priv->rx_buf[priv->rx_head][priv-> rx_ptr++] = read_scc_data(priv); else { priv->rx_over = 2; read_scc_data(priv); } special_condition(priv, rc); } } } static void special_condition(struct scc_priv *priv, int rc) { int cb; unsigned long flags; /* See Figure 2-15. Only overrun and EOF need to be checked. */ if (rc & Rx_OVR) { /* Receiver overrun */ priv->rx_over = 1; if (priv->param.dma < 0) write_scc(priv, R0, ERR_RES); } else if (rc & END_FR) { /* End of frame. Get byte count */ if (priv->param.dma >= 0) { flags = claim_dma_lock(); cb = BUF_SIZE - get_dma_residue(priv->param.dma) - 2; release_dma_lock(flags); } else { cb = priv->rx_ptr - 2; } if (priv->rx_over) { /* We had an overrun */ priv->dev->stats.rx_errors++; if (priv->rx_over == 2) priv->dev->stats.rx_length_errors++; else priv->dev->stats.rx_fifo_errors++; priv->rx_over = 0; } else if (rc & CRC_ERR) { /* Count invalid CRC only if packet length >= minimum */ if (cb >= 15) { priv->dev->stats.rx_errors++; priv->dev->stats.rx_crc_errors++; } } else { if (cb >= 15) { if (priv->rx_count < NUM_RX_BUF - 1) { /* Put good frame in FIFO */ priv->rx_len[priv->rx_head] = cb; priv->rx_head = (priv->rx_head + 1) % NUM_RX_BUF; priv->rx_count++; schedule_work(&priv->rx_work); } else { priv->dev->stats.rx_errors++; priv->dev->stats.rx_over_errors++; } } } /* Get ready for new frame */ if (priv->param.dma >= 0) { flags = claim_dma_lock(); set_dma_addr(priv->param.dma, (int) priv->rx_buf[priv->rx_head]); set_dma_count(priv->param.dma, BUF_SIZE); release_dma_lock(flags); } else { priv->rx_ptr = 0; } } } static void rx_bh(struct work_struct *ugli_api) { struct scc_priv *priv = container_of(ugli_api, struct scc_priv, rx_work); int i = priv->rx_tail; int cb; unsigned long flags; struct sk_buff *skb; unsigned char *data; spin_lock_irqsave(&priv->ring_lock, flags); while (priv->rx_count) { spin_unlock_irqrestore(&priv->ring_lock, flags); cb = priv->rx_len[i]; /* Allocate buffer */ skb = dev_alloc_skb(cb + 1); if (skb == NULL) { /* Drop packet */ priv->dev->stats.rx_dropped++; } else { /* Fill buffer */ data = skb_put(skb, cb + 1); data[0] = 0; memcpy(&data[1], priv->rx_buf[i], cb); skb->protocol = ax25_type_trans(skb, priv->dev); netif_rx(skb); priv->dev->stats.rx_packets++; priv->dev->stats.rx_bytes += cb; } spin_lock_irqsave(&priv->ring_lock, flags); /* Move tail */ priv->rx_tail = i = (i + 1) % NUM_RX_BUF; priv->rx_count--; } spin_unlock_irqrestore(&priv->ring_lock, flags); } static void tx_isr(struct scc_priv *priv) { int i = priv->tx_tail, p = priv->tx_ptr; /* Suspend TX interrupts if we don't want to send anything. See Figure 2-22. */ if (p == priv->tx_len[i]) { write_scc(priv, R0, RES_Tx_P); return; } /* Write characters */ while ((read_scc(priv, R0) & Tx_BUF_EMP) && p < priv->tx_len[i]) { write_scc_data(priv, priv->tx_buf[i][p++], 0); } /* Reset EOM latch of Z8530 */ if (!priv->tx_ptr && p && priv->chip == Z8530) write_scc(priv, R0, RES_EOM_L); priv->tx_ptr = p; } static void es_isr(struct scc_priv *priv) { int i, rr0, drr0, res; unsigned long flags; /* Read status, reset interrupt bit (open latches) */ rr0 = read_scc(priv, R0); write_scc(priv, R0, RES_EXT_INT); drr0 = priv->rr0 ^ rr0; priv->rr0 = rr0; /* Transmit underrun (2.4.9.6). We can't check the TxEOM flag, since it might have already been cleared again by AUTOEOM. */ if (priv->state == TX_DATA) { /* Get remaining bytes */ i = priv->tx_tail; if (priv->param.dma >= 0) { disable_dma(priv->param.dma); flags = claim_dma_lock(); res = get_dma_residue(priv->param.dma); release_dma_lock(flags); } else { res = priv->tx_len[i] - priv->tx_ptr; priv->tx_ptr = 0; } /* Disable DREQ / TX interrupt */ if (priv->param.dma >= 0 && priv->type == TYPE_TWIN) outb(0, priv->card_base + TWIN_DMA_CFG); else write_scc(priv, R1, EXT_INT_ENAB | WT_FN_RDYFN); if (res) { /* Update packet statistics */ priv->dev->stats.tx_errors++; priv->dev->stats.tx_fifo_errors++; /* Other underrun interrupts may already be waiting */ write_scc(priv, R0, RES_EXT_INT); write_scc(priv, R0, RES_EXT_INT); } else { /* Update packet statistics */ priv->dev->stats.tx_packets++; priv->dev->stats.tx_bytes += priv->tx_len[i]; /* Remove frame from FIFO */ priv->tx_tail = (i + 1) % NUM_TX_BUF; priv->tx_count--; /* Inform upper layers */ netif_wake_queue(priv->dev); } /* Switch state */ write_scc(priv, R15, 0); if (priv->tx_count && (jiffies - priv->tx_start) < priv->param.txtimeout) { priv->state = TX_PAUSE; start_timer(priv, priv->param.txpause, 0); } else { priv->state = TX_TAIL; start_timer(priv, priv->param.txtail, 0); } } /* DCD transition */ if (drr0 & DCD) { if (rr0 & DCD) { switch (priv->state) { case IDLE: case WAIT: priv->state = DCD_ON; write_scc(priv, R15, 0); start_timer(priv, priv->param.dcdon, 0); } } else { switch (priv->state) { case RX_ON: rx_off(priv); priv->state = DCD_OFF; write_scc(priv, R15, 0); start_timer(priv, priv->param.dcdoff, 0); } } } /* CTS transition */ if ((drr0 & CTS) && (~rr0 & CTS) && priv->type != TYPE_TWIN) tm_isr(priv); } static void tm_isr(struct scc_priv *priv) { switch (priv->state) { case TX_HEAD: case TX_PAUSE: tx_on(priv); priv->state = TX_DATA; break; case TX_TAIL: write_scc(priv, R5, TxCRC_ENAB | Tx8); priv->state = RTS_OFF; if (priv->type != TYPE_TWIN) write_scc(priv, R15, 0); start_timer(priv, priv->param.rtsoff, 0); break; case RTS_OFF: write_scc(priv, R15, DCDIE); priv->rr0 = read_scc(priv, R0); if (priv->rr0 & DCD) { priv->dev->stats.collisions++; rx_on(priv); priv->state = RX_ON; } else { priv->state = WAIT; start_timer(priv, priv->param.waittime, DCDIE); } break; case WAIT: if (priv->tx_count) { priv->state = TX_HEAD; priv->tx_start = jiffies; write_scc(priv, R5, TxCRC_ENAB | RTS | TxENAB | Tx8); write_scc(priv, R15, 0); start_timer(priv, priv->param.txdelay, 0); } else { priv->state = IDLE; if (priv->type != TYPE_TWIN) write_scc(priv, R15, DCDIE); } break; case DCD_ON: case DCD_OFF: write_scc(priv, R15, DCDIE); priv->rr0 = read_scc(priv, R0); if (priv->rr0 & DCD) { rx_on(priv); priv->state = RX_ON; } else { priv->state = WAIT; start_timer(priv, random() / priv->param.persist * priv->param.slottime, DCDIE); } break; } }
gpl-2.0
fideoman/Alucard-Kernel-jfltexx
drivers/acpi/event.c
7544
6992
/* * event.c - exporting ACPI events via procfs * * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * */ #include <linux/spinlock.h> #include <linux/export.h> #include <linux/proc_fs.h> #include <linux/init.h> #include <linux/poll.h> #include <linux/gfp.h> #include <acpi/acpi_drivers.h> #include <net/netlink.h> #include <net/genetlink.h> #include "internal.h" #define _COMPONENT ACPI_SYSTEM_COMPONENT ACPI_MODULE_NAME("event"); #ifdef CONFIG_ACPI_PROC_EVENT /* Global vars for handling event proc entry */ static DEFINE_SPINLOCK(acpi_system_event_lock); int event_is_open = 0; extern struct list_head acpi_bus_event_list; extern wait_queue_head_t acpi_bus_event_queue; static int acpi_system_open_event(struct inode *inode, struct file *file) { spin_lock_irq(&acpi_system_event_lock); if (event_is_open) goto out_busy; event_is_open = 1; spin_unlock_irq(&acpi_system_event_lock); return 0; out_busy: spin_unlock_irq(&acpi_system_event_lock); return -EBUSY; } static ssize_t acpi_system_read_event(struct file *file, char __user * buffer, size_t count, loff_t * ppos) { int result = 0; struct acpi_bus_event event; static char str[ACPI_MAX_STRING]; static int chars_remaining = 0; static char *ptr; if (!chars_remaining) { memset(&event, 0, sizeof(struct acpi_bus_event)); if ((file->f_flags & O_NONBLOCK) && (list_empty(&acpi_bus_event_list))) return -EAGAIN; result = acpi_bus_receive_event(&event); if (result) return result; chars_remaining = sprintf(str, "%s %s %08x %08x\n", event.device_class ? event. device_class : "<unknown>", event.bus_id ? event. bus_id : "<unknown>", event.type, event.data); ptr = str; } if (chars_remaining < count) { count = chars_remaining; } if (copy_to_user(buffer, ptr, count)) return -EFAULT; *ppos += count; chars_remaining -= count; ptr += count; return count; } static int acpi_system_close_event(struct inode *inode, struct file *file) { spin_lock_irq(&acpi_system_event_lock); event_is_open = 0; spin_unlock_irq(&acpi_system_event_lock); return 0; } static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait) { poll_wait(file, &acpi_bus_event_queue, wait); if (!list_empty(&acpi_bus_event_list)) return POLLIN | POLLRDNORM; return 0; } static const struct file_operations acpi_system_event_ops = { .owner = THIS_MODULE, .open = acpi_system_open_event, .read = acpi_system_read_event, .release = acpi_system_close_event, .poll = acpi_system_poll_event, .llseek = default_llseek, }; #endif /* CONFIG_ACPI_PROC_EVENT */ /* ACPI notifier chain */ static BLOCKING_NOTIFIER_HEAD(acpi_chain_head); int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data) { struct acpi_bus_event event; strcpy(event.device_class, dev->pnp.device_class); strcpy(event.bus_id, dev->pnp.bus_id); event.type = type; event.data = data; return (blocking_notifier_call_chain(&acpi_chain_head, 0, (void *)&event) == NOTIFY_BAD) ? -EINVAL : 0; } EXPORT_SYMBOL(acpi_notifier_call_chain); int register_acpi_notifier(struct notifier_block *nb) { return blocking_notifier_chain_register(&acpi_chain_head, nb); } EXPORT_SYMBOL(register_acpi_notifier); int unregister_acpi_notifier(struct notifier_block *nb) { return blocking_notifier_chain_unregister(&acpi_chain_head, nb); } EXPORT_SYMBOL(unregister_acpi_notifier); #ifdef CONFIG_NET static unsigned int acpi_event_seqnum; struct acpi_genl_event { acpi_device_class device_class; char bus_id[15]; u32 type; u32 data; }; /* attributes of acpi_genl_family */ enum { ACPI_GENL_ATTR_UNSPEC, ACPI_GENL_ATTR_EVENT, /* ACPI event info needed by user space */ __ACPI_GENL_ATTR_MAX, }; #define ACPI_GENL_ATTR_MAX (__ACPI_GENL_ATTR_MAX - 1) /* commands supported by the acpi_genl_family */ enum { ACPI_GENL_CMD_UNSPEC, ACPI_GENL_CMD_EVENT, /* kernel->user notifications for ACPI events */ __ACPI_GENL_CMD_MAX, }; #define ACPI_GENL_CMD_MAX (__ACPI_GENL_CMD_MAX - 1) #define ACPI_GENL_FAMILY_NAME "acpi_event" #define ACPI_GENL_VERSION 0x01 #define ACPI_GENL_MCAST_GROUP_NAME "acpi_mc_group" static struct genl_family acpi_event_genl_family = { .id = GENL_ID_GENERATE, .name = ACPI_GENL_FAMILY_NAME, .version = ACPI_GENL_VERSION, .maxattr = ACPI_GENL_ATTR_MAX, }; static struct genl_multicast_group acpi_event_mcgrp = { .name = ACPI_GENL_MCAST_GROUP_NAME, }; int acpi_bus_generate_netlink_event(const char *device_class, const char *bus_id, u8 type, int data) { struct sk_buff *skb; struct nlattr *attr; struct acpi_genl_event *event; void *msg_header; int size; int result; /* allocate memory */ size = nla_total_size(sizeof(struct acpi_genl_event)) + nla_total_size(0); skb = genlmsg_new(size, GFP_ATOMIC); if (!skb) return -ENOMEM; /* add the genetlink message header */ msg_header = genlmsg_put(skb, 0, acpi_event_seqnum++, &acpi_event_genl_family, 0, ACPI_GENL_CMD_EVENT); if (!msg_header) { nlmsg_free(skb); return -ENOMEM; } /* fill the data */ attr = nla_reserve(skb, ACPI_GENL_ATTR_EVENT, sizeof(struct acpi_genl_event)); if (!attr) { nlmsg_free(skb); return -EINVAL; } event = nla_data(attr); if (!event) { nlmsg_free(skb); return -EINVAL; } memset(event, 0, sizeof(struct acpi_genl_event)); strcpy(event->device_class, device_class); strcpy(event->bus_id, bus_id); event->type = type; event->data = data; /* send multicast genetlink message */ result = genlmsg_end(skb, msg_header); if (result < 0) { nlmsg_free(skb); return result; } genlmsg_multicast(skb, 0, acpi_event_mcgrp.id, GFP_ATOMIC); return 0; } EXPORT_SYMBOL(acpi_bus_generate_netlink_event); static int acpi_event_genetlink_init(void) { int result; result = genl_register_family(&acpi_event_genl_family); if (result) return result; result = genl_register_mc_group(&acpi_event_genl_family, &acpi_event_mcgrp); if (result) genl_unregister_family(&acpi_event_genl_family); return result; } #else int acpi_bus_generate_netlink_event(const char *device_class, const char *bus_id, u8 type, int data) { return 0; } EXPORT_SYMBOL(acpi_bus_generate_netlink_event); static int acpi_event_genetlink_init(void) { return -ENODEV; } #endif static int __init acpi_event_init(void) { #ifdef CONFIG_ACPI_PROC_EVENT struct proc_dir_entry *entry; #endif int error = 0; if (acpi_disabled) return 0; /* create genetlink for acpi event */ error = acpi_event_genetlink_init(); if (error) printk(KERN_WARNING PREFIX "Failed to create genetlink family for ACPI event\n"); #ifdef CONFIG_ACPI_PROC_EVENT /* 'event' [R] */ entry = proc_create("event", S_IRUSR, acpi_root_dir, &acpi_system_event_ops); if (!entry) return -ENODEV; #endif return 0; } fs_initcall(acpi_event_init);
gpl-2.0