repo_name
string
path
string
copies
string
size
string
content
string
license
string
TheTypoMaster/yotrino-linux-kernel
drivers/gpu/drm/nouveau/core/engine/device/nv04.c
2230
3646
/* * Copyright 2012 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. * * Authors: Ben Skeggs */ #include <subdev/bios.h> #include <subdev/bus.h> #include <subdev/i2c.h> #include <subdev/clock.h> #include <subdev/devinit.h> #include <subdev/mc.h> #include <subdev/timer.h> #include <subdev/fb.h> #include <subdev/instmem.h> #include <subdev/vm.h> #include <engine/device.h> #include <engine/dmaobj.h> #include <engine/fifo.h> #include <engine/software.h> #include <engine/graph.h> #include <engine/disp.h> int nv04_identify(struct nouveau_device *device) { switch (device->chipset) { case 0x04: device->cname = "NV04"; device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; device->oclass[NVDEV_SUBDEV_I2C ] = &nv04_i2c_oclass; device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv04_clock_oclass; device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv04_devinit_oclass; device->oclass[NVDEV_SUBDEV_MC ] = &nv04_mc_oclass; device->oclass[NVDEV_SUBDEV_BUS ] = &nv04_bus_oclass; device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; device->oclass[NVDEV_SUBDEV_FB ] = &nv04_fb_oclass; device->oclass[NVDEV_SUBDEV_INSTMEM] = &nv04_instmem_oclass; device->oclass[NVDEV_SUBDEV_VM ] = &nv04_vmmgr_oclass; device->oclass[NVDEV_ENGINE_DMAOBJ ] = &nv04_dmaeng_oclass; device->oclass[NVDEV_ENGINE_FIFO ] = &nv04_fifo_oclass; device->oclass[NVDEV_ENGINE_SW ] = &nv04_software_oclass; device->oclass[NVDEV_ENGINE_GR ] = &nv04_graph_oclass; device->oclass[NVDEV_ENGINE_DISP ] = &nv04_disp_oclass; break; case 0x05: device->cname = "NV05"; device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; device->oclass[NVDEV_SUBDEV_I2C ] = &nv04_i2c_oclass; device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv04_clock_oclass; device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv05_devinit_oclass; device->oclass[NVDEV_SUBDEV_MC ] = &nv04_mc_oclass; device->oclass[NVDEV_SUBDEV_BUS ] = &nv04_bus_oclass; device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; device->oclass[NVDEV_SUBDEV_FB ] = &nv04_fb_oclass; device->oclass[NVDEV_SUBDEV_INSTMEM] = &nv04_instmem_oclass; device->oclass[NVDEV_SUBDEV_VM ] = &nv04_vmmgr_oclass; device->oclass[NVDEV_ENGINE_DMAOBJ ] = &nv04_dmaeng_oclass; device->oclass[NVDEV_ENGINE_FIFO ] = &nv04_fifo_oclass; device->oclass[NVDEV_ENGINE_SW ] = &nv04_software_oclass; device->oclass[NVDEV_ENGINE_GR ] = &nv04_graph_oclass; device->oclass[NVDEV_ENGINE_DISP ] = &nv04_disp_oclass; break; default: nv_fatal(device, "unknown RIVA chipset\n"); return -EINVAL; } return 0; }
gpl-2.0
NooNameR/k3_bravo
arch/x86/kernel/rtc.c
2486
6442
/* * RTC related functions */ #include <linux/platform_device.h> #include <linux/mc146818rtc.h> #include <linux/acpi.h> #include <linux/bcd.h> #include <linux/pnp.h> #include <linux/of.h> #include <asm/vsyscall.h> #include <asm/x86_init.h> #include <asm/time.h> #ifdef CONFIG_X86_32 /* * This is a special lock that is owned by the CPU and holds the index * register we are working with. It is required for NMI access to the * CMOS/RTC registers. See include/asm-i386/mc146818rtc.h for details. */ volatile unsigned long cmos_lock; EXPORT_SYMBOL(cmos_lock); #endif /* CONFIG_X86_32 */ /* For two digit years assume time is always after that */ #define CMOS_YEARS_OFFS 2000 DEFINE_SPINLOCK(rtc_lock); EXPORT_SYMBOL(rtc_lock); /* * In order to set the CMOS clock precisely, set_rtc_mmss has to be * called 500 ms after the second nowtime has started, because when * nowtime is written into the registers of the CMOS clock, it will * jump to the next second precisely 500 ms later. Check the Motorola * MC146818A or Dallas DS12887 data sheet for details. * * BUG: This routine does not handle hour overflow properly; it just * sets the minutes. Usually you'll only notice that after reboot! */ int mach_set_rtc_mmss(unsigned long nowtime) { int real_seconds, real_minutes, cmos_minutes; unsigned char save_control, save_freq_select; int retval = 0; /* tell the clock it's being set */ save_control = CMOS_READ(RTC_CONTROL); CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL); /* stop and reset prescaler */ save_freq_select = CMOS_READ(RTC_FREQ_SELECT); CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); cmos_minutes = CMOS_READ(RTC_MINUTES); if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) cmos_minutes = bcd2bin(cmos_minutes); /* * since we're only adjusting minutes and seconds, * don't interfere with hour overflow. This avoids * messing with unknown time zones but requires your * RTC not to be off by more than 15 minutes */ real_seconds = nowtime % 60; real_minutes = nowtime / 60; /* correct for half hour time zone */ if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1) real_minutes += 30; real_minutes %= 60; if (abs(real_minutes - cmos_minutes) < 30) { if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { real_seconds = bin2bcd(real_seconds); real_minutes = bin2bcd(real_minutes); } CMOS_WRITE(real_seconds, RTC_SECONDS); CMOS_WRITE(real_minutes, RTC_MINUTES); } else { printk_once(KERN_NOTICE "set_rtc_mmss: can't update from %d to %d\n", cmos_minutes, real_minutes); retval = -1; } /* The following flags have to be released exactly in this order, * otherwise the DS12887 (popular MC146818A clone with integrated * battery and quartz) will not reset the oscillator and will not * update precisely 500 ms later. You won't find this mentioned in * the Dallas Semiconductor data sheets, but who believes data * sheets anyway ... -- Markus Kuhn */ CMOS_WRITE(save_control, RTC_CONTROL); CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); return retval; } unsigned long mach_get_cmos_time(void) { unsigned int status, year, mon, day, hour, min, sec, century = 0; /* * If UIP is clear, then we have >= 244 microseconds before * RTC registers will be updated. Spec sheet says that this * is the reliable way to read RTC - registers. If UIP is set * then the register access might be invalid. */ while ((CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)) cpu_relax(); sec = CMOS_READ(RTC_SECONDS); min = CMOS_READ(RTC_MINUTES); hour = CMOS_READ(RTC_HOURS); day = CMOS_READ(RTC_DAY_OF_MONTH); mon = CMOS_READ(RTC_MONTH); year = CMOS_READ(RTC_YEAR); #ifdef CONFIG_ACPI if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && acpi_gbl_FADT.century) century = CMOS_READ(acpi_gbl_FADT.century); #endif status = CMOS_READ(RTC_CONTROL); WARN_ON_ONCE(RTC_ALWAYS_BCD && (status & RTC_DM_BINARY)); if (RTC_ALWAYS_BCD || !(status & RTC_DM_BINARY)) { sec = bcd2bin(sec); min = bcd2bin(min); hour = bcd2bin(hour); day = bcd2bin(day); mon = bcd2bin(mon); year = bcd2bin(year); } if (century) { century = bcd2bin(century); year += century * 100; printk(KERN_INFO "Extended CMOS year: %d\n", century * 100); } else year += CMOS_YEARS_OFFS; return mktime(year, mon, day, hour, min, sec); } /* Routines for accessing the CMOS RAM/RTC. */ unsigned char rtc_cmos_read(unsigned char addr) { unsigned char val; lock_cmos_prefix(addr); outb(addr, RTC_PORT(0)); val = inb(RTC_PORT(1)); lock_cmos_suffix(addr); return val; } EXPORT_SYMBOL(rtc_cmos_read); void rtc_cmos_write(unsigned char val, unsigned char addr) { lock_cmos_prefix(addr); outb(addr, RTC_PORT(0)); outb(val, RTC_PORT(1)); lock_cmos_suffix(addr); } EXPORT_SYMBOL(rtc_cmos_write); int update_persistent_clock(struct timespec now) { unsigned long flags; int retval; spin_lock_irqsave(&rtc_lock, flags); retval = x86_platform.set_wallclock(now.tv_sec); spin_unlock_irqrestore(&rtc_lock, flags); return retval; } /* not static: needed by APM */ void read_persistent_clock(struct timespec *ts) { unsigned long retval, flags; spin_lock_irqsave(&rtc_lock, flags); retval = x86_platform.get_wallclock(); spin_unlock_irqrestore(&rtc_lock, flags); ts->tv_sec = retval; ts->tv_nsec = 0; } unsigned long long native_read_tsc(void) { return __native_read_tsc(); } EXPORT_SYMBOL(native_read_tsc); static struct resource rtc_resources[] = { [0] = { .start = RTC_PORT(0), .end = RTC_PORT(1), .flags = IORESOURCE_IO, }, [1] = { .start = RTC_IRQ, .end = RTC_IRQ, .flags = IORESOURCE_IRQ, } }; static struct platform_device rtc_device = { .name = "rtc_cmos", .id = -1, .resource = rtc_resources, .num_resources = ARRAY_SIZE(rtc_resources), }; static __init int add_rtc_cmos(void) { #ifdef CONFIG_PNP static const char *ids[] __initconst = { "PNP0b00", "PNP0b01", "PNP0b02", }; struct pnp_dev *dev; struct pnp_id *id; int i; pnp_for_each_dev(dev) { for (id = dev->id; id; id = id->next) { for (i = 0; i < ARRAY_SIZE(ids); i++) { if (compare_pnp_id(id, ids[i]) != 0) return 0; } } } #endif if (of_have_populated_dt()) return 0; platform_device_register(&rtc_device); dev_info(&rtc_device.dev, "registered platform RTC device (no PNP device found)\n"); return 0; } device_initcall(add_rtc_cmos);
gpl-2.0
flar2/xoom-ElementalX
drivers/media/video/tw9910.c
2742
24525
/* * tw9910 Video Driver * * Copyright (C) 2008 Renesas Solutions Corp. * Kuninori Morimoto <morimoto.kuninori@renesas.com> * * Based on ov772x driver, * * Copyright (C) 2008 Kuninori Morimoto <morimoto.kuninori@renesas.com> * Copyright 2006-7 Jonathan Corbet <corbet@lwn.net> * Copyright (C) 2008 Magnus Damm * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/init.h> #include <linux/module.h> #include <linux/i2c.h> #include <linux/slab.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/videodev2.h> #include <media/v4l2-chip-ident.h> #include <media/v4l2-subdev.h> #include <media/soc_camera.h> #include <media/tw9910.h> #define GET_ID(val) ((val & 0xF8) >> 3) #define GET_REV(val) (val & 0x07) /* * register offset */ #define ID 0x00 /* Product ID Code Register */ #define STATUS1 0x01 /* Chip Status Register I */ #define INFORM 0x02 /* Input Format */ #define OPFORM 0x03 /* Output Format Control Register */ #define DLYCTR 0x04 /* Hysteresis and HSYNC Delay Control */ #define OUTCTR1 0x05 /* Output Control I */ #define ACNTL1 0x06 /* Analog Control Register 1 */ #define CROP_HI 0x07 /* Cropping Register, High */ #define VDELAY_LO 0x08 /* Vertical Delay Register, Low */ #define VACTIVE_LO 0x09 /* Vertical Active Register, Low */ #define HDELAY_LO 0x0A /* Horizontal Delay Register, Low */ #define HACTIVE_LO 0x0B /* Horizontal Active Register, Low */ #define CNTRL1 0x0C /* Control Register I */ #define VSCALE_LO 0x0D /* Vertical Scaling Register, Low */ #define SCALE_HI 0x0E /* Scaling Register, High */ #define HSCALE_LO 0x0F /* Horizontal Scaling Register, Low */ #define BRIGHT 0x10 /* BRIGHTNESS Control Register */ #define CONTRAST 0x11 /* CONTRAST Control Register */ #define SHARPNESS 0x12 /* SHARPNESS Control Register I */ #define SAT_U 0x13 /* Chroma (U) Gain Register */ #define SAT_V 0x14 /* Chroma (V) Gain Register */ #define HUE 0x15 /* Hue Control Register */ #define CORING1 0x17 #define CORING2 0x18 /* Coring and IF compensation */ #define VBICNTL 0x19 /* VBI Control Register */ #define ACNTL2 0x1A /* Analog Control 2 */ #define OUTCTR2 0x1B /* Output Control 2 */ #define SDT 0x1C /* Standard Selection */ #define SDTR 0x1D /* Standard Recognition */ #define TEST 0x1F /* Test Control Register */ #define CLMPG 0x20 /* Clamping Gain */ #define IAGC 0x21 /* Individual AGC Gain */ #define AGCGAIN 0x22 /* AGC Gain */ #define PEAKWT 0x23 /* White Peak Threshold */ #define CLMPL 0x24 /* Clamp level */ #define SYNCT 0x25 /* Sync Amplitude */ #define MISSCNT 0x26 /* Sync Miss Count Register */ #define PCLAMP 0x27 /* Clamp Position Register */ #define VCNTL1 0x28 /* Vertical Control I */ #define VCNTL2 0x29 /* Vertical Control II */ #define CKILL 0x2A /* Color Killer Level Control */ #define COMB 0x2B /* Comb Filter Control */ #define LDLY 0x2C /* Luma Delay and H Filter Control */ #define MISC1 0x2D /* Miscellaneous Control I */ #define LOOP 0x2E /* LOOP Control Register */ #define MISC2 0x2F /* Miscellaneous Control II */ #define MVSN 0x30 /* Macrovision Detection */ #define STATUS2 0x31 /* Chip STATUS II */ #define HFREF 0x32 /* H monitor */ #define CLMD 0x33 /* CLAMP MODE */ #define IDCNTL 0x34 /* ID Detection Control */ #define CLCNTL1 0x35 /* Clamp Control I */ #define ANAPLLCTL 0x4C #define VBIMIN 0x4D #define HSLOWCTL 0x4E #define WSS3 0x4F #define FILLDATA 0x50 #define SDID 0x51 #define DID 0x52 #define WSS1 0x53 #define WSS2 0x54 #define VVBI 0x55 #define LCTL6 0x56 #define LCTL7 0x57 #define LCTL8 0x58 #define LCTL9 0x59 #define LCTL10 0x5A #define LCTL11 0x5B #define LCTL12 0x5C #define LCTL13 0x5D #define LCTL14 0x5E #define LCTL15 0x5F #define LCTL16 0x60 #define LCTL17 0x61 #define LCTL18 0x62 #define LCTL19 0x63 #define LCTL20 0x64 #define LCTL21 0x65 #define LCTL22 0x66 #define LCTL23 0x67 #define LCTL24 0x68 #define LCTL25 0x69 #define LCTL26 0x6A #define HSBEGIN 0x6B #define HSEND 0x6C #define OVSDLY 0x6D #define OVSEND 0x6E #define VBIDELAY 0x6F /* * register detail */ /* INFORM */ #define FC27_ON 0x40 /* 1 : Input crystal clock frequency is 27MHz */ #define FC27_FF 0x00 /* 0 : Square pixel mode. */ /* Must use 24.54MHz for 60Hz field rate */ /* source or 29.5MHz for 50Hz field rate */ #define IFSEL_S 0x10 /* 01 : S-video decoding */ #define IFSEL_C 0x00 /* 00 : Composite video decoding */ /* Y input video selection */ #define YSEL_M0 0x00 /* 00 : Mux0 selected */ #define YSEL_M1 0x04 /* 01 : Mux1 selected */ #define YSEL_M2 0x08 /* 10 : Mux2 selected */ #define YSEL_M3 0x10 /* 11 : Mux3 selected */ /* OPFORM */ #define MODE 0x80 /* 0 : CCIR601 compatible YCrCb 4:2:2 format */ /* 1 : ITU-R-656 compatible data sequence format */ #define LEN 0x40 /* 0 : 8-bit YCrCb 4:2:2 output format */ /* 1 : 16-bit YCrCb 4:2:2 output format.*/ #define LLCMODE 0x20 /* 1 : LLC output mode. */ /* 0 : free-run output mode */ #define AINC 0x10 /* Serial interface auto-indexing control */ /* 0 : auto-increment */ /* 1 : non-auto */ #define VSCTL 0x08 /* 1 : Vertical out ctrl by DVALID */ /* 0 : Vertical out ctrl by HACTIVE and DVALID */ #define OEN_TRI_SEL_MASK 0x07 #define OEN_TRI_SEL_ALL_ON 0x00 /* Enable output for Rev0/Rev1 */ #define OEN_TRI_SEL_ALL_OFF_r0 0x06 /* All tri-stated for Rev0 */ #define OEN_TRI_SEL_ALL_OFF_r1 0x07 /* All tri-stated for Rev1 */ /* OUTCTR1 */ #define VSP_LO 0x00 /* 0 : VS pin output polarity is active low */ #define VSP_HI 0x80 /* 1 : VS pin output polarity is active high. */ /* VS pin output control */ #define VSSL_VSYNC 0x00 /* 0 : VSYNC */ #define VSSL_VACT 0x10 /* 1 : VACT */ #define VSSL_FIELD 0x20 /* 2 : FIELD */ #define VSSL_VVALID 0x30 /* 3 : VVALID */ #define VSSL_ZERO 0x70 /* 7 : 0 */ #define HSP_LOW 0x00 /* 0 : HS pin output polarity is active low */ #define HSP_HI 0x08 /* 1 : HS pin output polarity is active high.*/ /* HS pin output control */ #define HSSL_HACT 0x00 /* 0 : HACT */ #define HSSL_HSYNC 0x01 /* 1 : HSYNC */ #define HSSL_DVALID 0x02 /* 2 : DVALID */ #define HSSL_HLOCK 0x03 /* 3 : HLOCK */ #define HSSL_ASYNCW 0x04 /* 4 : ASYNCW */ #define HSSL_ZERO 0x07 /* 7 : 0 */ /* ACNTL1 */ #define SRESET 0x80 /* resets the device to its default state * but all register content remain unchanged. * This bit is self-resetting. */ #define ACNTL1_PDN_MASK 0x0e #define CLK_PDN 0x08 /* system clock power down */ #define Y_PDN 0x04 /* Luma ADC power down */ #define C_PDN 0x02 /* Chroma ADC power down */ /* ACNTL2 */ #define ACNTL2_PDN_MASK 0x40 #define PLL_PDN 0x40 /* PLL power down */ /* VBICNTL */ /* RTSEL : control the real time signal output from the MPOUT pin */ #define RTSEL_MASK 0x07 #define RTSEL_VLOSS 0x00 /* 0000 = Video loss */ #define RTSEL_HLOCK 0x01 /* 0001 = H-lock */ #define RTSEL_SLOCK 0x02 /* 0010 = S-lock */ #define RTSEL_VLOCK 0x03 /* 0011 = V-lock */ #define RTSEL_MONO 0x04 /* 0100 = MONO */ #define RTSEL_DET50 0x05 /* 0101 = DET50 */ #define RTSEL_FIELD 0x06 /* 0110 = FIELD */ #define RTSEL_RTCO 0x07 /* 0111 = RTCO ( Real Time Control ) */ /* * structure */ struct regval_list { unsigned char reg_num; unsigned char value; }; struct tw9910_scale_ctrl { char *name; unsigned short width; unsigned short height; u16 hscale; u16 vscale; }; struct tw9910_cropping_ctrl { u16 vdelay; u16 vactive; u16 hdelay; u16 hactive; }; struct tw9910_hsync_ctrl { u16 start; u16 end; }; struct tw9910_priv { struct v4l2_subdev subdev; struct tw9910_video_info *info; const struct tw9910_scale_ctrl *scale; u32 revision; }; static const struct tw9910_scale_ctrl tw9910_ntsc_scales[] = { { .name = "NTSC SQ", .width = 640, .height = 480, .hscale = 0x0100, .vscale = 0x0100, }, { .name = "NTSC CCIR601", .width = 720, .height = 480, .hscale = 0x0100, .vscale = 0x0100, }, { .name = "NTSC SQ (CIF)", .width = 320, .height = 240, .hscale = 0x0200, .vscale = 0x0200, }, { .name = "NTSC CCIR601 (CIF)", .width = 360, .height = 240, .hscale = 0x0200, .vscale = 0x0200, }, { .name = "NTSC SQ (QCIF)", .width = 160, .height = 120, .hscale = 0x0400, .vscale = 0x0400, }, { .name = "NTSC CCIR601 (QCIF)", .width = 180, .height = 120, .hscale = 0x0400, .vscale = 0x0400, }, }; static const struct tw9910_scale_ctrl tw9910_pal_scales[] = { { .name = "PAL SQ", .width = 768, .height = 576, .hscale = 0x0100, .vscale = 0x0100, }, { .name = "PAL CCIR601", .width = 720, .height = 576, .hscale = 0x0100, .vscale = 0x0100, }, { .name = "PAL SQ (CIF)", .width = 384, .height = 288, .hscale = 0x0200, .vscale = 0x0200, }, { .name = "PAL CCIR601 (CIF)", .width = 360, .height = 288, .hscale = 0x0200, .vscale = 0x0200, }, { .name = "PAL SQ (QCIF)", .width = 192, .height = 144, .hscale = 0x0400, .vscale = 0x0400, }, { .name = "PAL CCIR601 (QCIF)", .width = 180, .height = 144, .hscale = 0x0400, .vscale = 0x0400, }, }; static const struct tw9910_hsync_ctrl tw9910_hsync_ctrl = { .start = 0x0260, .end = 0x0300, }; /* * general function */ static struct tw9910_priv *to_tw9910(const struct i2c_client *client) { return container_of(i2c_get_clientdata(client), struct tw9910_priv, subdev); } static int tw9910_mask_set(struct i2c_client *client, u8 command, u8 mask, u8 set) { s32 val = i2c_smbus_read_byte_data(client, command); if (val < 0) return val; val &= ~mask; val |= set & mask; return i2c_smbus_write_byte_data(client, command, val); } static int tw9910_set_scale(struct i2c_client *client, const struct tw9910_scale_ctrl *scale) { int ret; ret = i2c_smbus_write_byte_data(client, SCALE_HI, (scale->vscale & 0x0F00) >> 4 | (scale->hscale & 0x0F00) >> 8); if (ret < 0) return ret; ret = i2c_smbus_write_byte_data(client, HSCALE_LO, scale->hscale & 0x00FF); if (ret < 0) return ret; ret = i2c_smbus_write_byte_data(client, VSCALE_LO, scale->vscale & 0x00FF); return ret; } static int tw9910_set_hsync(struct i2c_client *client, const struct tw9910_hsync_ctrl *hsync) { struct tw9910_priv *priv = to_tw9910(client); int ret; /* bit 10 - 3 */ ret = i2c_smbus_write_byte_data(client, HSBEGIN, (hsync->start & 0x07F8) >> 3); if (ret < 0) return ret; /* bit 10 - 3 */ ret = i2c_smbus_write_byte_data(client, HSEND, (hsync->end & 0x07F8) >> 3); if (ret < 0) return ret; /* So far only revisions 0 and 1 have been seen */ /* bit 2 - 0 */ if (1 == priv->revision) ret = tw9910_mask_set(client, HSLOWCTL, 0x77, (hsync->start & 0x0007) << 4 | (hsync->end & 0x0007)); return ret; } static void tw9910_reset(struct i2c_client *client) { tw9910_mask_set(client, ACNTL1, SRESET, SRESET); msleep(1); } static int tw9910_power(struct i2c_client *client, int enable) { int ret; u8 acntl1; u8 acntl2; if (enable) { acntl1 = 0; acntl2 = 0; } else { acntl1 = CLK_PDN | Y_PDN | C_PDN; acntl2 = PLL_PDN; } ret = tw9910_mask_set(client, ACNTL1, ACNTL1_PDN_MASK, acntl1); if (ret < 0) return ret; return tw9910_mask_set(client, ACNTL2, ACNTL2_PDN_MASK, acntl2); } static const struct tw9910_scale_ctrl* tw9910_select_norm(struct soc_camera_device *icd, u32 width, u32 height) { const struct tw9910_scale_ctrl *scale; const struct tw9910_scale_ctrl *ret = NULL; v4l2_std_id norm = icd->vdev->current_norm; __u32 diff = 0xffffffff, tmp; int size, i; if (norm & V4L2_STD_NTSC) { scale = tw9910_ntsc_scales; size = ARRAY_SIZE(tw9910_ntsc_scales); } else if (norm & V4L2_STD_PAL) { scale = tw9910_pal_scales; size = ARRAY_SIZE(tw9910_pal_scales); } else { return NULL; } for (i = 0; i < size; i++) { tmp = abs(width - scale[i].width) + abs(height - scale[i].height); if (tmp < diff) { diff = tmp; ret = scale + i; } } return ret; } /* * soc_camera_ops function */ static int tw9910_s_stream(struct v4l2_subdev *sd, int enable) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct tw9910_priv *priv = to_tw9910(client); u8 val; int ret; if (!enable) { switch (priv->revision) { case 0: val = OEN_TRI_SEL_ALL_OFF_r0; break; case 1: val = OEN_TRI_SEL_ALL_OFF_r1; break; default: dev_err(&client->dev, "un-supported revision\n"); return -EINVAL; } } else { val = OEN_TRI_SEL_ALL_ON; if (!priv->scale) { dev_err(&client->dev, "norm select error\n"); return -EPERM; } dev_dbg(&client->dev, "%s %dx%d\n", priv->scale->name, priv->scale->width, priv->scale->height); } ret = tw9910_mask_set(client, OPFORM, OEN_TRI_SEL_MASK, val); if (ret < 0) return ret; return tw9910_power(client, enable); } static int tw9910_set_bus_param(struct soc_camera_device *icd, unsigned long flags) { struct v4l2_subdev *sd = soc_camera_to_subdev(icd); struct i2c_client *client = v4l2_get_subdevdata(sd); u8 val = VSSL_VVALID | HSSL_DVALID; /* * set OUTCTR1 * * We use VVALID and DVALID signals to control VSYNC and HSYNC * outputs, in this mode their polarity is inverted. */ if (flags & SOCAM_HSYNC_ACTIVE_LOW) val |= HSP_HI; if (flags & SOCAM_VSYNC_ACTIVE_LOW) val |= VSP_HI; return i2c_smbus_write_byte_data(client, OUTCTR1, val); } static unsigned long tw9910_query_bus_param(struct soc_camera_device *icd) { struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); struct tw9910_priv *priv = to_tw9910(client); struct soc_camera_link *icl = to_soc_camera_link(icd); unsigned long flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_MASTER | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW | SOCAM_HSYNC_ACTIVE_LOW | SOCAM_DATA_ACTIVE_HIGH | priv->info->buswidth; return soc_camera_apply_sensor_flags(icl, flags); } static int tw9910_s_std(struct v4l2_subdev *sd, v4l2_std_id norm) { int ret = -EINVAL; if (norm & (V4L2_STD_NTSC | V4L2_STD_PAL)) ret = 0; return ret; } static int tw9910_enum_input(struct soc_camera_device *icd, struct v4l2_input *inp) { inp->type = V4L2_INPUT_TYPE_TUNER; inp->std = V4L2_STD_UNKNOWN; strcpy(inp->name, "Video"); return 0; } static int tw9910_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct tw9910_priv *priv = to_tw9910(client); id->ident = V4L2_IDENT_TW9910; id->revision = priv->revision; return 0; } #ifdef CONFIG_VIDEO_ADV_DEBUG static int tw9910_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { struct i2c_client *client = v4l2_get_subdevdata(sd); int ret; if (reg->reg > 0xff) return -EINVAL; ret = i2c_smbus_read_byte_data(client, reg->reg); if (ret < 0) return ret; /* * ret = int * reg->val = __u64 */ reg->val = (__u64)ret; return 0; } static int tw9910_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { struct i2c_client *client = v4l2_get_subdevdata(sd); if (reg->reg > 0xff || reg->val > 0xff) return -EINVAL; return i2c_smbus_write_byte_data(client, reg->reg, reg->val); } #endif static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) { struct v4l2_rect *rect = &a->c; struct i2c_client *client = v4l2_get_subdevdata(sd); struct tw9910_priv *priv = to_tw9910(client); struct soc_camera_device *icd = client->dev.platform_data; int ret = -EINVAL; u8 val; /* * select suitable norm */ priv->scale = tw9910_select_norm(icd, rect->width, rect->height); if (!priv->scale) goto tw9910_set_fmt_error; /* * reset hardware */ tw9910_reset(client); /* * set bus width */ val = 0x00; if (SOCAM_DATAWIDTH_16 == priv->info->buswidth) val = LEN; ret = tw9910_mask_set(client, OPFORM, LEN, val); if (ret < 0) goto tw9910_set_fmt_error; /* * select MPOUT behavior */ switch (priv->info->mpout) { case TW9910_MPO_VLOSS: val = RTSEL_VLOSS; break; case TW9910_MPO_HLOCK: val = RTSEL_HLOCK; break; case TW9910_MPO_SLOCK: val = RTSEL_SLOCK; break; case TW9910_MPO_VLOCK: val = RTSEL_VLOCK; break; case TW9910_MPO_MONO: val = RTSEL_MONO; break; case TW9910_MPO_DET50: val = RTSEL_DET50; break; case TW9910_MPO_FIELD: val = RTSEL_FIELD; break; case TW9910_MPO_RTCO: val = RTSEL_RTCO; break; default: val = 0; } ret = tw9910_mask_set(client, VBICNTL, RTSEL_MASK, val); if (ret < 0) goto tw9910_set_fmt_error; /* * set scale */ ret = tw9910_set_scale(client, priv->scale); if (ret < 0) goto tw9910_set_fmt_error; /* * set hsync */ ret = tw9910_set_hsync(client, &tw9910_hsync_ctrl); if (ret < 0) goto tw9910_set_fmt_error; rect->width = priv->scale->width; rect->height = priv->scale->height; rect->left = 0; rect->top = 0; return ret; tw9910_set_fmt_error: tw9910_reset(client); priv->scale = NULL; return ret; } static int tw9910_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct tw9910_priv *priv = to_tw9910(client); if (!priv->scale) { int ret; struct v4l2_crop crop = { .c = { .left = 0, .top = 0, .width = 640, .height = 480, }, }; ret = tw9910_s_crop(sd, &crop); if (ret < 0) return ret; } a->c.left = 0; a->c.top = 0; a->c.width = priv->scale->width; a->c.height = priv->scale->height; a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; return 0; } static int tw9910_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) { a->bounds.left = 0; a->bounds.top = 0; a->bounds.width = 768; a->bounds.height = 576; a->defrect.left = 0; a->defrect.top = 0; a->defrect.width = 640; a->defrect.height = 480; a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; a->pixelaspect.numerator = 1; a->pixelaspect.denominator = 1; return 0; } static int tw9910_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct tw9910_priv *priv = to_tw9910(client); if (!priv->scale) { int ret; struct v4l2_crop crop = { .c = { .left = 0, .top = 0, .width = 640, .height = 480, }, }; ret = tw9910_s_crop(sd, &crop); if (ret < 0) return ret; } mf->width = priv->scale->width; mf->height = priv->scale->height; mf->code = V4L2_MBUS_FMT_UYVY8_2X8; mf->colorspace = V4L2_COLORSPACE_JPEG; mf->field = V4L2_FIELD_INTERLACED_BT; return 0; } static int tw9910_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct tw9910_priv *priv = to_tw9910(client); /* See tw9910_s_crop() - no proper cropping support */ struct v4l2_crop a = { .c = { .left = 0, .top = 0, .width = mf->width, .height = mf->height, }, }; int ret; WARN_ON(mf->field != V4L2_FIELD_ANY && mf->field != V4L2_FIELD_INTERLACED_BT); /* * check color format */ if (mf->code != V4L2_MBUS_FMT_UYVY8_2X8) return -EINVAL; mf->colorspace = V4L2_COLORSPACE_JPEG; ret = tw9910_s_crop(sd, &a); if (!ret) { mf->width = priv->scale->width; mf->height = priv->scale->height; } return ret; } static int tw9910_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_device *icd = client->dev.platform_data; const struct tw9910_scale_ctrl *scale; if (V4L2_FIELD_ANY == mf->field) { mf->field = V4L2_FIELD_INTERLACED_BT; } else if (V4L2_FIELD_INTERLACED_BT != mf->field) { dev_err(&client->dev, "Field type %d invalid.\n", mf->field); return -EINVAL; } mf->code = V4L2_MBUS_FMT_UYVY8_2X8; mf->colorspace = V4L2_COLORSPACE_JPEG; /* * select suitable norm */ scale = tw9910_select_norm(icd, mf->width, mf->height); if (!scale) return -EINVAL; mf->width = scale->width; mf->height = scale->height; return 0; } static int tw9910_video_probe(struct soc_camera_device *icd, struct i2c_client *client) { struct tw9910_priv *priv = to_tw9910(client); s32 id; /* * We must have a parent by now. And it cannot be a wrong one. * So this entire test is completely redundant. */ if (!icd->dev.parent || to_soc_camera_host(icd->dev.parent)->nr != icd->iface) return -ENODEV; /* * tw9910 only use 8 or 16 bit bus width */ if (SOCAM_DATAWIDTH_16 != priv->info->buswidth && SOCAM_DATAWIDTH_8 != priv->info->buswidth) { dev_err(&client->dev, "bus width error\n"); return -ENODEV; } /* * check and show Product ID * So far only revisions 0 and 1 have been seen */ id = i2c_smbus_read_byte_data(client, ID); priv->revision = GET_REV(id); id = GET_ID(id); if (0x0B != id || 0x01 < priv->revision) { dev_err(&client->dev, "Product ID error %x:%x\n", id, priv->revision); return -ENODEV; } dev_info(&client->dev, "tw9910 Product ID %0x:%0x\n", id, priv->revision); icd->vdev->tvnorms = V4L2_STD_NTSC | V4L2_STD_PAL; icd->vdev->current_norm = V4L2_STD_NTSC; return 0; } static struct soc_camera_ops tw9910_ops = { .set_bus_param = tw9910_set_bus_param, .query_bus_param = tw9910_query_bus_param, .enum_input = tw9910_enum_input, }; static struct v4l2_subdev_core_ops tw9910_subdev_core_ops = { .g_chip_ident = tw9910_g_chip_ident, .s_std = tw9910_s_std, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = tw9910_g_register, .s_register = tw9910_s_register, #endif }; static int tw9910_enum_fmt(struct v4l2_subdev *sd, unsigned int index, enum v4l2_mbus_pixelcode *code) { if (index) return -EINVAL; *code = V4L2_MBUS_FMT_UYVY8_2X8; return 0; } static struct v4l2_subdev_video_ops tw9910_subdev_video_ops = { .s_stream = tw9910_s_stream, .g_mbus_fmt = tw9910_g_fmt, .s_mbus_fmt = tw9910_s_fmt, .try_mbus_fmt = tw9910_try_fmt, .cropcap = tw9910_cropcap, .g_crop = tw9910_g_crop, .s_crop = tw9910_s_crop, .enum_mbus_fmt = tw9910_enum_fmt, }; static struct v4l2_subdev_ops tw9910_subdev_ops = { .core = &tw9910_subdev_core_ops, .video = &tw9910_subdev_video_ops, }; /* * i2c_driver function */ static int tw9910_probe(struct i2c_client *client, const struct i2c_device_id *did) { struct tw9910_priv *priv; struct tw9910_video_info *info; struct soc_camera_device *icd = client->dev.platform_data; struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct soc_camera_link *icl; int ret; if (!icd) { dev_err(&client->dev, "TW9910: missing soc-camera data!\n"); return -EINVAL; } icl = to_soc_camera_link(icd); if (!icl || !icl->priv) return -EINVAL; info = icl->priv; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { dev_err(&client->dev, "I2C-Adapter doesn't support " "I2C_FUNC_SMBUS_BYTE_DATA\n"); return -EIO; } priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; priv->info = info; v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops); icd->ops = &tw9910_ops; icd->iface = icl->bus_id; ret = tw9910_video_probe(icd, client); if (ret) { icd->ops = NULL; kfree(priv); } return ret; } static int tw9910_remove(struct i2c_client *client) { struct tw9910_priv *priv = to_tw9910(client); struct soc_camera_device *icd = client->dev.platform_data; icd->ops = NULL; kfree(priv); return 0; } static const struct i2c_device_id tw9910_id[] = { { "tw9910", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, tw9910_id); static struct i2c_driver tw9910_i2c_driver = { .driver = { .name = "tw9910", }, .probe = tw9910_probe, .remove = tw9910_remove, .id_table = tw9910_id, }; /* * module function */ static int __init tw9910_module_init(void) { return i2c_add_driver(&tw9910_i2c_driver); } static void __exit tw9910_module_exit(void) { i2c_del_driver(&tw9910_i2c_driver); } module_init(tw9910_module_init); module_exit(tw9910_module_exit); MODULE_DESCRIPTION("SoC Camera driver for tw9910"); MODULE_AUTHOR("Kuninori Morimoto"); MODULE_LICENSE("GPL v2");
gpl-2.0
seltaeb/n7100-jb-samsung
drivers/xen/xenfs/privcmd.c
3254
8414
/****************************************************************************** * privcmd.c * * Interface to privileged domain-0 commands. * * Copyright (c) 2002-2004, K A Fraser, B Dragovic */ #include <linux/kernel.h> #include <linux/sched.h> #include <linux/slab.h> #include <linux/string.h> #include <linux/errno.h> #include <linux/mm.h> #include <linux/mman.h> #include <linux/uaccess.h> #include <linux/swap.h> #include <linux/highmem.h> #include <linux/pagemap.h> #include <linux/seq_file.h> #include <asm/pgalloc.h> #include <asm/pgtable.h> #include <asm/tlb.h> #include <asm/xen/hypervisor.h> #include <asm/xen/hypercall.h> #include <xen/xen.h> #include <xen/privcmd.h> #include <xen/interface/xen.h> #include <xen/features.h> #include <xen/page.h> #include <xen/xen-ops.h> #ifndef HAVE_ARCH_PRIVCMD_MMAP static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma); #endif static long privcmd_ioctl_hypercall(void __user *udata) { struct privcmd_hypercall hypercall; long ret; if (copy_from_user(&hypercall, udata, sizeof(hypercall))) return -EFAULT; ret = privcmd_call(hypercall.op, hypercall.arg[0], hypercall.arg[1], hypercall.arg[2], hypercall.arg[3], hypercall.arg[4]); return ret; } static void free_page_list(struct list_head *pages) { struct page *p, *n; list_for_each_entry_safe(p, n, pages, lru) __free_page(p); INIT_LIST_HEAD(pages); } /* * Given an array of items in userspace, return a list of pages * containing the data. If copying fails, either because of memory * allocation failure or a problem reading user memory, return an * error code; its up to the caller to dispose of any partial list. */ static int gather_array(struct list_head *pagelist, unsigned nelem, size_t size, void __user *data) { unsigned pageidx; void *pagedata; int ret; if (size > PAGE_SIZE) return 0; pageidx = PAGE_SIZE; pagedata = NULL; /* quiet, gcc */ while (nelem--) { if (pageidx > PAGE_SIZE-size) { struct page *page = alloc_page(GFP_KERNEL); ret = -ENOMEM; if (page == NULL) goto fail; pagedata = page_address(page); list_add_tail(&page->lru, pagelist); pageidx = 0; } ret = -EFAULT; if (copy_from_user(pagedata + pageidx, data, size)) goto fail; data += size; pageidx += size; } ret = 0; fail: return ret; } /* * Call function "fn" on each element of the array fragmented * over a list of pages. */ static int traverse_pages(unsigned nelem, size_t size, struct list_head *pos, int (*fn)(void *data, void *state), void *state) { void *pagedata; unsigned pageidx; int ret = 0; BUG_ON(size > PAGE_SIZE); pageidx = PAGE_SIZE; pagedata = NULL; /* hush, gcc */ while (nelem--) { if (pageidx > PAGE_SIZE-size) { struct page *page; pos = pos->next; page = list_entry(pos, struct page, lru); pagedata = page_address(page); pageidx = 0; } ret = (*fn)(pagedata + pageidx, state); if (ret) break; pageidx += size; } return ret; } struct mmap_mfn_state { unsigned long va; struct vm_area_struct *vma; domid_t domain; }; static int mmap_mfn_range(void *data, void *state) { struct privcmd_mmap_entry *msg = data; struct mmap_mfn_state *st = state; struct vm_area_struct *vma = st->vma; int rc; /* Do not allow range to wrap the address space. */ if ((msg->npages > (LONG_MAX >> PAGE_SHIFT)) || ((unsigned long)(msg->npages << PAGE_SHIFT) >= -st->va)) return -EINVAL; /* Range chunks must be contiguous in va space. */ if ((msg->va != st->va) || ((msg->va+(msg->npages<<PAGE_SHIFT)) > vma->vm_end)) return -EINVAL; rc = xen_remap_domain_mfn_range(vma, msg->va & PAGE_MASK, msg->mfn, msg->npages, vma->vm_page_prot, st->domain); if (rc < 0) return rc; st->va += msg->npages << PAGE_SHIFT; return 0; } static long privcmd_ioctl_mmap(void __user *udata) { struct privcmd_mmap mmapcmd; struct mm_struct *mm = current->mm; struct vm_area_struct *vma; int rc; LIST_HEAD(pagelist); struct mmap_mfn_state state; if (!xen_initial_domain()) return -EPERM; if (copy_from_user(&mmapcmd, udata, sizeof(mmapcmd))) return -EFAULT; rc = gather_array(&pagelist, mmapcmd.num, sizeof(struct privcmd_mmap_entry), mmapcmd.entry); if (rc || list_empty(&pagelist)) goto out; down_write(&mm->mmap_sem); { struct page *page = list_first_entry(&pagelist, struct page, lru); struct privcmd_mmap_entry *msg = page_address(page); vma = find_vma(mm, msg->va); rc = -EINVAL; if (!vma || (msg->va != vma->vm_start) || !privcmd_enforce_singleshot_mapping(vma)) goto out_up; } state.va = vma->vm_start; state.vma = vma; state.domain = mmapcmd.dom; rc = traverse_pages(mmapcmd.num, sizeof(struct privcmd_mmap_entry), &pagelist, mmap_mfn_range, &state); out_up: up_write(&mm->mmap_sem); out: free_page_list(&pagelist); return rc; } struct mmap_batch_state { domid_t domain; unsigned long va; struct vm_area_struct *vma; int err; xen_pfn_t __user *user; }; static int mmap_batch_fn(void *data, void *state) { xen_pfn_t *mfnp = data; struct mmap_batch_state *st = state; if (xen_remap_domain_mfn_range(st->vma, st->va & PAGE_MASK, *mfnp, 1, st->vma->vm_page_prot, st->domain) < 0) { *mfnp |= 0xf0000000U; st->err++; } st->va += PAGE_SIZE; return 0; } static int mmap_return_errors(void *data, void *state) { xen_pfn_t *mfnp = data; struct mmap_batch_state *st = state; return put_user(*mfnp, st->user++); } static struct vm_operations_struct privcmd_vm_ops; static long privcmd_ioctl_mmap_batch(void __user *udata) { int ret; struct privcmd_mmapbatch m; struct mm_struct *mm = current->mm; struct vm_area_struct *vma; unsigned long nr_pages; LIST_HEAD(pagelist); struct mmap_batch_state state; if (!xen_initial_domain()) return -EPERM; if (copy_from_user(&m, udata, sizeof(m))) return -EFAULT; nr_pages = m.num; if ((m.num <= 0) || (nr_pages > (LONG_MAX >> PAGE_SHIFT))) return -EINVAL; ret = gather_array(&pagelist, m.num, sizeof(xen_pfn_t), m.arr); if (ret || list_empty(&pagelist)) goto out; down_write(&mm->mmap_sem); vma = find_vma(mm, m.addr); ret = -EINVAL; if (!vma || vma->vm_ops != &privcmd_vm_ops || (m.addr != vma->vm_start) || ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) || !privcmd_enforce_singleshot_mapping(vma)) { up_write(&mm->mmap_sem); goto out; } state.domain = m.dom; state.vma = vma; state.va = m.addr; state.err = 0; ret = traverse_pages(m.num, sizeof(xen_pfn_t), &pagelist, mmap_batch_fn, &state); up_write(&mm->mmap_sem); if (state.err > 0) { state.user = m.arr; ret = traverse_pages(m.num, sizeof(xen_pfn_t), &pagelist, mmap_return_errors, &state); } out: free_page_list(&pagelist); return ret; } static long privcmd_ioctl(struct file *file, unsigned int cmd, unsigned long data) { int ret = -ENOSYS; void __user *udata = (void __user *) data; switch (cmd) { case IOCTL_PRIVCMD_HYPERCALL: ret = privcmd_ioctl_hypercall(udata); break; case IOCTL_PRIVCMD_MMAP: ret = privcmd_ioctl_mmap(udata); break; case IOCTL_PRIVCMD_MMAPBATCH: ret = privcmd_ioctl_mmap_batch(udata); break; default: ret = -EINVAL; break; } return ret; } #ifndef HAVE_ARCH_PRIVCMD_MMAP static int privcmd_fault(struct vm_area_struct *vma, struct vm_fault *vmf) { printk(KERN_DEBUG "privcmd_fault: vma=%p %lx-%lx, pgoff=%lx, uv=%p\n", vma, vma->vm_start, vma->vm_end, vmf->pgoff, vmf->virtual_address); return VM_FAULT_SIGBUS; } static struct vm_operations_struct privcmd_vm_ops = { .fault = privcmd_fault }; static int privcmd_mmap(struct file *file, struct vm_area_struct *vma) { /* Unsupported for auto-translate guests. */ if (xen_feature(XENFEAT_auto_translated_physmap)) return -ENOSYS; /* DONTCOPY is essential for Xen because copy_page_range doesn't know * how to recreate these mappings */ vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY | VM_PFNMAP; vma->vm_ops = &privcmd_vm_ops; vma->vm_private_data = NULL; return 0; } static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma) { return (xchg(&vma->vm_private_data, (void *)1) == NULL); } #endif const struct file_operations privcmd_file_ops = { .unlocked_ioctl = privcmd_ioctl, .mmap = privcmd_mmap, };
gpl-2.0
m-stein/linux
drivers/net/wireless/ath/ath9k/eeprom.c
3254
15079
/* * Copyright (c) 2008-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 "hw.h" void ath9k_hw_analog_shift_regwrite(struct ath_hw *ah, u32 reg, u32 val) { REG_WRITE(ah, reg, val); if (ah->config.analog_shiftreg) udelay(100); } void ath9k_hw_analog_shift_rmw(struct ath_hw *ah, u32 reg, u32 mask, u32 shift, u32 val) { u32 regVal; regVal = REG_READ(ah, reg) & ~mask; regVal |= (val << shift) & mask; REG_WRITE(ah, reg, regVal); if (ah->config.analog_shiftreg) udelay(100); } int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight, int16_t targetLeft, int16_t targetRight) { int16_t rv; if (srcRight == srcLeft) { rv = targetLeft; } else { rv = (int16_t) (((target - srcLeft) * targetRight + (srcRight - target) * targetLeft) / (srcRight - srcLeft)); } return rv; } bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, u16 *indexL, u16 *indexR) { u16 i; if (target <= pList[0]) { *indexL = *indexR = 0; return true; } if (target >= pList[listSize - 1]) { *indexL = *indexR = (u16) (listSize - 1); return true; } for (i = 0; i < listSize - 1; i++) { if (pList[i] == target) { *indexL = *indexR = i; return true; } if (target < pList[i + 1]) { *indexL = i; *indexR = (u16) (i + 1); return false; } } return false; } void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data, int eep_start_loc, int size) { int i = 0, j, addr; u32 addrdata[8]; u32 data[8]; for (addr = 0; addr < size; addr++) { addrdata[i] = AR5416_EEPROM_OFFSET + ((addr + eep_start_loc) << AR5416_EEPROM_S); i++; if (i == 8) { REG_READ_MULTI(ah, addrdata, data, i); for (j = 0; j < i; j++) { *eep_data = data[j]; eep_data++; } i = 0; } } if (i != 0) { REG_READ_MULTI(ah, addrdata, data, i); for (j = 0; j < i; j++) { *eep_data = data[j]; eep_data++; } } } static bool ath9k_hw_nvram_read_blob(struct ath_hw *ah, u32 off, u16 *data) { u16 *blob_data; if (off * sizeof(u16) > ah->eeprom_blob->size) return false; blob_data = (u16 *)ah->eeprom_blob->data; *data = blob_data[off]; return true; } bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data) { struct ath_common *common = ath9k_hw_common(ah); bool ret; if (ah->eeprom_blob) ret = ath9k_hw_nvram_read_blob(ah, off, data); else ret = common->bus_ops->eeprom_read(common, off, data); if (!ret) ath_dbg(common, EEPROM, "unable to read eeprom region at offset %u\n", off); return ret; } void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList, u8 *pVpdList, u16 numIntercepts, u8 *pRetVpdList) { u16 i, k; u8 currPwr = pwrMin; u16 idxL = 0, idxR = 0; for (i = 0; i <= (pwrMax - pwrMin) / 2; i++) { ath9k_hw_get_lower_upper_index(currPwr, pPwrList, numIntercepts, &(idxL), &(idxR)); if (idxR < 1) idxR = 1; if (idxL == numIntercepts - 1) idxL = (u16) (numIntercepts - 2); if (pPwrList[idxL] == pPwrList[idxR]) k = pVpdList[idxL]; else k = (u16)(((currPwr - pPwrList[idxL]) * pVpdList[idxR] + (pPwrList[idxR] - currPwr) * pVpdList[idxL]) / (pPwrList[idxR] - pPwrList[idxL])); pRetVpdList[i] = (u8) k; currPwr += 2; } } void ath9k_hw_get_legacy_target_powers(struct ath_hw *ah, struct ath9k_channel *chan, struct cal_target_power_leg *powInfo, u16 numChannels, struct cal_target_power_leg *pNewPower, u16 numRates, bool isExtTarget) { struct chan_centers centers; u16 clo, chi; int i; int matchIndex = -1, lowIndex = -1; u16 freq; ath9k_hw_get_channel_centers(ah, chan, &centers); freq = (isExtTarget) ? centers.ext_center : centers.ctl_center; if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel, IS_CHAN_2GHZ(chan))) { matchIndex = 0; } else { for (i = 0; (i < numChannels) && (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) { if (freq == ath9k_hw_fbin2freq(powInfo[i].bChannel, IS_CHAN_2GHZ(chan))) { matchIndex = i; break; } else if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel, IS_CHAN_2GHZ(chan)) && i > 0 && freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel, IS_CHAN_2GHZ(chan))) { lowIndex = i - 1; break; } } if ((matchIndex == -1) && (lowIndex == -1)) matchIndex = i - 1; } if (matchIndex != -1) { *pNewPower = powInfo[matchIndex]; } else { clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel, IS_CHAN_2GHZ(chan)); chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel, IS_CHAN_2GHZ(chan)); for (i = 0; i < numRates; i++) { pNewPower->tPow2x[i] = (u8)ath9k_hw_interpolate(freq, clo, chi, powInfo[lowIndex].tPow2x[i], powInfo[lowIndex + 1].tPow2x[i]); } } } void ath9k_hw_get_target_powers(struct ath_hw *ah, struct ath9k_channel *chan, struct cal_target_power_ht *powInfo, u16 numChannels, struct cal_target_power_ht *pNewPower, u16 numRates, bool isHt40Target) { struct chan_centers centers; u16 clo, chi; int i; int matchIndex = -1, lowIndex = -1; u16 freq; ath9k_hw_get_channel_centers(ah, chan, &centers); freq = isHt40Target ? centers.synth_center : centers.ctl_center; if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel, IS_CHAN_2GHZ(chan))) { matchIndex = 0; } else { for (i = 0; (i < numChannels) && (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) { if (freq == ath9k_hw_fbin2freq(powInfo[i].bChannel, IS_CHAN_2GHZ(chan))) { matchIndex = i; break; } else if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel, IS_CHAN_2GHZ(chan)) && i > 0 && freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel, IS_CHAN_2GHZ(chan))) { lowIndex = i - 1; break; } } if ((matchIndex == -1) && (lowIndex == -1)) matchIndex = i - 1; } if (matchIndex != -1) { *pNewPower = powInfo[matchIndex]; } else { clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel, IS_CHAN_2GHZ(chan)); chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel, IS_CHAN_2GHZ(chan)); for (i = 0; i < numRates; i++) { pNewPower->tPow2x[i] = (u8)ath9k_hw_interpolate(freq, clo, chi, powInfo[lowIndex].tPow2x[i], powInfo[lowIndex + 1].tPow2x[i]); } } } u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower, bool is2GHz, int num_band_edges) { u16 twiceMaxEdgePower = MAX_RATE_POWER; int i; for (i = 0; (i < num_band_edges) && (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED); i++) { if (freq == ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, is2GHz)) { twiceMaxEdgePower = CTL_EDGE_TPOWER(pRdEdgesPower[i].ctl); break; } else if ((i > 0) && (freq < ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, is2GHz))) { if (ath9k_hw_fbin2freq(pRdEdgesPower[i - 1].bChannel, is2GHz) < freq && CTL_EDGE_FLAGS(pRdEdgesPower[i - 1].ctl)) { twiceMaxEdgePower = CTL_EDGE_TPOWER(pRdEdgesPower[i - 1].ctl); } break; } } return twiceMaxEdgePower; } u16 ath9k_hw_get_scaled_power(struct ath_hw *ah, u16 power_limit, u8 antenna_reduction) { u16 reduction = antenna_reduction; /* * Reduce scaled Power by number of chains active * to get the per chain tx power level. */ switch (ar5416_get_ntxchains(ah->txchainmask)) { case 1: break; case 2: reduction += POWER_CORRECTION_FOR_TWO_CHAIN; break; case 3: reduction += POWER_CORRECTION_FOR_THREE_CHAIN; break; } if (power_limit > reduction) power_limit -= reduction; else power_limit = 0; return power_limit; } void ath9k_hw_update_regulatory_maxpower(struct ath_hw *ah) { struct ath_common *common = ath9k_hw_common(ah); struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); switch (ar5416_get_ntxchains(ah->txchainmask)) { case 1: break; case 2: regulatory->max_power_level += POWER_CORRECTION_FOR_TWO_CHAIN; break; case 3: regulatory->max_power_level += POWER_CORRECTION_FOR_THREE_CHAIN; break; default: ath_dbg(common, EEPROM, "Invalid chainmask configuration\n"); break; } } void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah, struct ath9k_channel *chan, void *pRawDataSet, u8 *bChans, u16 availPiers, u16 tPdGainOverlap, u16 *pPdGainBoundaries, u8 *pPDADCValues, u16 numXpdGains) { int i, j, k; int16_t ss; u16 idxL = 0, idxR = 0, numPiers; static u8 vpdTableL[AR5416_NUM_PD_GAINS] [AR5416_MAX_PWR_RANGE_IN_HALF_DB]; static u8 vpdTableR[AR5416_NUM_PD_GAINS] [AR5416_MAX_PWR_RANGE_IN_HALF_DB]; static u8 vpdTableI[AR5416_NUM_PD_GAINS] [AR5416_MAX_PWR_RANGE_IN_HALF_DB]; u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR; u8 minPwrT4[AR5416_NUM_PD_GAINS]; u8 maxPwrT4[AR5416_NUM_PD_GAINS]; int16_t vpdStep; int16_t tmpVal; u16 sizeCurrVpdTable, maxIndex, tgtIndex; bool match; int16_t minDelta = 0; struct chan_centers centers; int pdgain_boundary_default; struct cal_data_per_freq *data_def = pRawDataSet; struct cal_data_per_freq_4k *data_4k = pRawDataSet; struct cal_data_per_freq_ar9287 *data_9287 = pRawDataSet; bool eeprom_4k = AR_SREV_9285(ah) || AR_SREV_9271(ah); int intercepts; if (AR_SREV_9287(ah)) intercepts = AR9287_PD_GAIN_ICEPTS; else intercepts = AR5416_PD_GAIN_ICEPTS; memset(&minPwrT4, 0, AR5416_NUM_PD_GAINS); ath9k_hw_get_channel_centers(ah, chan, &centers); for (numPiers = 0; numPiers < availPiers; numPiers++) { if (bChans[numPiers] == AR5416_BCHAN_UNUSED) break; } match = ath9k_hw_get_lower_upper_index((u8)FREQ2FBIN(centers.synth_center, IS_CHAN_2GHZ(chan)), bChans, numPiers, &idxL, &idxR); if (match) { if (AR_SREV_9287(ah)) { /* FIXME: array overrun? */ for (i = 0; i < numXpdGains; i++) { minPwrT4[i] = data_9287[idxL].pwrPdg[i][0]; maxPwrT4[i] = data_9287[idxL].pwrPdg[i][4]; ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i], data_9287[idxL].pwrPdg[i], data_9287[idxL].vpdPdg[i], intercepts, vpdTableI[i]); } } else if (eeprom_4k) { for (i = 0; i < numXpdGains; i++) { minPwrT4[i] = data_4k[idxL].pwrPdg[i][0]; maxPwrT4[i] = data_4k[idxL].pwrPdg[i][4]; ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i], data_4k[idxL].pwrPdg[i], data_4k[idxL].vpdPdg[i], intercepts, vpdTableI[i]); } } else { for (i = 0; i < numXpdGains; i++) { minPwrT4[i] = data_def[idxL].pwrPdg[i][0]; maxPwrT4[i] = data_def[idxL].pwrPdg[i][4]; ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i], data_def[idxL].pwrPdg[i], data_def[idxL].vpdPdg[i], intercepts, vpdTableI[i]); } } } else { for (i = 0; i < numXpdGains; i++) { if (AR_SREV_9287(ah)) { pVpdL = data_9287[idxL].vpdPdg[i]; pPwrL = data_9287[idxL].pwrPdg[i]; pVpdR = data_9287[idxR].vpdPdg[i]; pPwrR = data_9287[idxR].pwrPdg[i]; } else if (eeprom_4k) { pVpdL = data_4k[idxL].vpdPdg[i]; pPwrL = data_4k[idxL].pwrPdg[i]; pVpdR = data_4k[idxR].vpdPdg[i]; pPwrR = data_4k[idxR].pwrPdg[i]; } else { pVpdL = data_def[idxL].vpdPdg[i]; pPwrL = data_def[idxL].pwrPdg[i]; pVpdR = data_def[idxR].vpdPdg[i]; pPwrR = data_def[idxR].pwrPdg[i]; } minPwrT4[i] = max(pPwrL[0], pPwrR[0]); maxPwrT4[i] = min(pPwrL[intercepts - 1], pPwrR[intercepts - 1]); ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i], pPwrL, pVpdL, intercepts, vpdTableL[i]); ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i], pPwrR, pVpdR, intercepts, vpdTableR[i]); for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) { vpdTableI[i][j] = (u8)(ath9k_hw_interpolate((u16) FREQ2FBIN(centers. synth_center, IS_CHAN_2GHZ (chan)), bChans[idxL], bChans[idxR], vpdTableL[i][j], vpdTableR[i][j])); } } } k = 0; for (i = 0; i < numXpdGains; i++) { if (i == (numXpdGains - 1)) pPdGainBoundaries[i] = (u16)(maxPwrT4[i] / 2); else pPdGainBoundaries[i] = (u16)((maxPwrT4[i] + minPwrT4[i + 1]) / 4); pPdGainBoundaries[i] = min((u16)MAX_RATE_POWER, pPdGainBoundaries[i]); minDelta = 0; if (i == 0) { if (AR_SREV_9280_20_OR_LATER(ah)) ss = (int16_t)(0 - (minPwrT4[i] / 2)); else ss = 0; } else { ss = (int16_t)((pPdGainBoundaries[i - 1] - (minPwrT4[i] / 2)) - tPdGainOverlap + 1 + minDelta); } vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]); vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep); while ((ss < 0) && (k < (AR5416_NUM_PDADC_VALUES - 1))) { tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep); pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal); ss++; } sizeCurrVpdTable = (u8) ((maxPwrT4[i] - minPwrT4[i]) / 2 + 1); tgtIndex = (u8)(pPdGainBoundaries[i] + tPdGainOverlap - (minPwrT4[i] / 2)); maxIndex = (tgtIndex < sizeCurrVpdTable) ? tgtIndex : sizeCurrVpdTable; while ((ss < maxIndex) && (k < (AR5416_NUM_PDADC_VALUES - 1))) { pPDADCValues[k++] = vpdTableI[i][ss++]; } vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] - vpdTableI[i][sizeCurrVpdTable - 2]); vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep); if (tgtIndex >= maxIndex) { while ((ss <= tgtIndex) && (k < (AR5416_NUM_PDADC_VALUES - 1))) { tmpVal = (int16_t)((vpdTableI[i][sizeCurrVpdTable - 1] + (ss - maxIndex + 1) * vpdStep)); pPDADCValues[k++] = (u8)((tmpVal > 255) ? 255 : tmpVal); ss++; } } } if (eeprom_4k) pdgain_boundary_default = 58; else pdgain_boundary_default = pPdGainBoundaries[i - 1]; while (i < AR5416_PD_GAINS_IN_MASK) { pPdGainBoundaries[i] = pdgain_boundary_default; i++; } while (k < AR5416_NUM_PDADC_VALUES) { pPDADCValues[k] = pPDADCValues[k - 1]; k++; } } int ath9k_hw_eeprom_init(struct ath_hw *ah) { int status; if (AR_SREV_9300_20_OR_LATER(ah)) ah->eep_ops = &eep_ar9300_ops; else if (AR_SREV_9287(ah)) { ah->eep_ops = &eep_ar9287_ops; } else if (AR_SREV_9285(ah) || AR_SREV_9271(ah)) { ah->eep_ops = &eep_4k_ops; } else { ah->eep_ops = &eep_def_ops; } if (!ah->eep_ops->fill_eeprom(ah)) return -EIO; status = ah->eep_ops->check_eeprom(ah); return status; }
gpl-2.0
remicks/android_kernel_lge_hammerhead
tools/perf/builtin-sched.c
4790
44868
#include "builtin.h" #include "perf.h" #include "util/util.h" #include "util/evlist.h" #include "util/cache.h" #include "util/evsel.h" #include "util/symbol.h" #include "util/thread.h" #include "util/header.h" #include "util/session.h" #include "util/tool.h" #include "util/parse-options.h" #include "util/trace-event.h" #include "util/debug.h" #include <sys/prctl.h> #include <sys/resource.h> #include <semaphore.h> #include <pthread.h> #include <math.h> static const char *input_name; static char default_sort_order[] = "avg, max, switch, runtime"; static const char *sort_order = default_sort_order; static int profile_cpu = -1; #define PR_SET_NAME 15 /* Set process name */ #define MAX_CPUS 4096 static u64 run_measurement_overhead; static u64 sleep_measurement_overhead; #define COMM_LEN 20 #define SYM_LEN 129 #define MAX_PID 65536 static unsigned long nr_tasks; struct sched_atom; struct task_desc { unsigned long nr; unsigned long pid; char comm[COMM_LEN]; unsigned long nr_events; unsigned long curr_event; struct sched_atom **atoms; pthread_t thread; sem_t sleep_sem; sem_t ready_for_work; sem_t work_done_sem; u64 cpu_usage; }; enum sched_event_type { SCHED_EVENT_RUN, SCHED_EVENT_SLEEP, SCHED_EVENT_WAKEUP, SCHED_EVENT_MIGRATION, }; struct sched_atom { enum sched_event_type type; int specific_wait; u64 timestamp; u64 duration; unsigned long nr; sem_t *wait_sem; struct task_desc *wakee; }; static struct task_desc *pid_to_task[MAX_PID]; static struct task_desc **tasks; static pthread_mutex_t start_work_mutex = PTHREAD_MUTEX_INITIALIZER; static u64 start_time; static pthread_mutex_t work_done_wait_mutex = PTHREAD_MUTEX_INITIALIZER; static unsigned long nr_run_events; static unsigned long nr_sleep_events; static unsigned long nr_wakeup_events; static unsigned long nr_sleep_corrections; static unsigned long nr_run_events_optimized; static unsigned long targetless_wakeups; static unsigned long multitarget_wakeups; static u64 cpu_usage; static u64 runavg_cpu_usage; static u64 parent_cpu_usage; static u64 runavg_parent_cpu_usage; static unsigned long nr_runs; static u64 sum_runtime; static u64 sum_fluct; static u64 run_avg; static unsigned int replay_repeat = 10; static unsigned long nr_timestamps; static unsigned long nr_unordered_timestamps; static unsigned long nr_state_machine_bugs; static unsigned long nr_context_switch_bugs; static unsigned long nr_events; static unsigned long nr_lost_chunks; static unsigned long nr_lost_events; #define TASK_STATE_TO_CHAR_STR "RSDTtZX" enum thread_state { THREAD_SLEEPING = 0, THREAD_WAIT_CPU, THREAD_SCHED_IN, THREAD_IGNORE }; struct work_atom { struct list_head list; enum thread_state state; u64 sched_out_time; u64 wake_up_time; u64 sched_in_time; u64 runtime; }; struct work_atoms { struct list_head work_list; struct thread *thread; struct rb_node node; u64 max_lat; u64 max_lat_at; u64 total_lat; u64 nb_atoms; u64 total_runtime; }; typedef int (*sort_fn_t)(struct work_atoms *, struct work_atoms *); static struct rb_root atom_root, sorted_atom_root; static u64 all_runtime; static u64 all_count; static u64 get_nsecs(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return ts.tv_sec * 1000000000ULL + ts.tv_nsec; } static void burn_nsecs(u64 nsecs) { u64 T0 = get_nsecs(), T1; do { T1 = get_nsecs(); } while (T1 + run_measurement_overhead < T0 + nsecs); } static void sleep_nsecs(u64 nsecs) { struct timespec ts; ts.tv_nsec = nsecs % 999999999; ts.tv_sec = nsecs / 999999999; nanosleep(&ts, NULL); } static void calibrate_run_measurement_overhead(void) { u64 T0, T1, delta, min_delta = 1000000000ULL; int i; for (i = 0; i < 10; i++) { T0 = get_nsecs(); burn_nsecs(0); T1 = get_nsecs(); delta = T1-T0; min_delta = min(min_delta, delta); } run_measurement_overhead = min_delta; printf("run measurement overhead: %" PRIu64 " nsecs\n", min_delta); } static void calibrate_sleep_measurement_overhead(void) { u64 T0, T1, delta, min_delta = 1000000000ULL; int i; for (i = 0; i < 10; i++) { T0 = get_nsecs(); sleep_nsecs(10000); T1 = get_nsecs(); delta = T1-T0; min_delta = min(min_delta, delta); } min_delta -= 10000; sleep_measurement_overhead = min_delta; printf("sleep measurement overhead: %" PRIu64 " nsecs\n", min_delta); } static struct sched_atom * get_new_event(struct task_desc *task, u64 timestamp) { struct sched_atom *event = zalloc(sizeof(*event)); unsigned long idx = task->nr_events; size_t size; event->timestamp = timestamp; event->nr = idx; task->nr_events++; size = sizeof(struct sched_atom *) * task->nr_events; task->atoms = realloc(task->atoms, size); BUG_ON(!task->atoms); task->atoms[idx] = event; return event; } static struct sched_atom *last_event(struct task_desc *task) { if (!task->nr_events) return NULL; return task->atoms[task->nr_events - 1]; } static void add_sched_event_run(struct task_desc *task, u64 timestamp, u64 duration) { struct sched_atom *event, *curr_event = last_event(task); /* * optimize an existing RUN event by merging this one * to it: */ if (curr_event && curr_event->type == SCHED_EVENT_RUN) { nr_run_events_optimized++; curr_event->duration += duration; return; } event = get_new_event(task, timestamp); event->type = SCHED_EVENT_RUN; event->duration = duration; nr_run_events++; } static void add_sched_event_wakeup(struct task_desc *task, u64 timestamp, struct task_desc *wakee) { struct sched_atom *event, *wakee_event; event = get_new_event(task, timestamp); event->type = SCHED_EVENT_WAKEUP; event->wakee = wakee; wakee_event = last_event(wakee); if (!wakee_event || wakee_event->type != SCHED_EVENT_SLEEP) { targetless_wakeups++; return; } if (wakee_event->wait_sem) { multitarget_wakeups++; return; } wakee_event->wait_sem = zalloc(sizeof(*wakee_event->wait_sem)); sem_init(wakee_event->wait_sem, 0, 0); wakee_event->specific_wait = 1; event->wait_sem = wakee_event->wait_sem; nr_wakeup_events++; } static void add_sched_event_sleep(struct task_desc *task, u64 timestamp, u64 task_state __used) { struct sched_atom *event = get_new_event(task, timestamp); event->type = SCHED_EVENT_SLEEP; nr_sleep_events++; } static struct task_desc *register_pid(unsigned long pid, const char *comm) { struct task_desc *task; BUG_ON(pid >= MAX_PID); task = pid_to_task[pid]; if (task) return task; task = zalloc(sizeof(*task)); task->pid = pid; task->nr = nr_tasks; strcpy(task->comm, comm); /* * every task starts in sleeping state - this gets ignored * if there's no wakeup pointing to this sleep state: */ add_sched_event_sleep(task, 0, 0); pid_to_task[pid] = task; nr_tasks++; tasks = realloc(tasks, nr_tasks*sizeof(struct task_task *)); BUG_ON(!tasks); tasks[task->nr] = task; if (verbose) printf("registered task #%ld, PID %ld (%s)\n", nr_tasks, pid, comm); return task; } static void print_task_traces(void) { struct task_desc *task; unsigned long i; for (i = 0; i < nr_tasks; i++) { task = tasks[i]; printf("task %6ld (%20s:%10ld), nr_events: %ld\n", task->nr, task->comm, task->pid, task->nr_events); } } static void add_cross_task_wakeups(void) { struct task_desc *task1, *task2; unsigned long i, j; for (i = 0; i < nr_tasks; i++) { task1 = tasks[i]; j = i + 1; if (j == nr_tasks) j = 0; task2 = tasks[j]; add_sched_event_wakeup(task1, 0, task2); } } static void process_sched_event(struct task_desc *this_task __used, struct sched_atom *atom) { int ret = 0; switch (atom->type) { case SCHED_EVENT_RUN: burn_nsecs(atom->duration); break; case SCHED_EVENT_SLEEP: if (atom->wait_sem) ret = sem_wait(atom->wait_sem); BUG_ON(ret); break; case SCHED_EVENT_WAKEUP: if (atom->wait_sem) ret = sem_post(atom->wait_sem); BUG_ON(ret); break; case SCHED_EVENT_MIGRATION: break; default: BUG_ON(1); } } static u64 get_cpu_usage_nsec_parent(void) { struct rusage ru; u64 sum; int err; err = getrusage(RUSAGE_SELF, &ru); BUG_ON(err); sum = ru.ru_utime.tv_sec*1e9 + ru.ru_utime.tv_usec*1e3; sum += ru.ru_stime.tv_sec*1e9 + ru.ru_stime.tv_usec*1e3; return sum; } static int self_open_counters(void) { struct perf_event_attr attr; int fd; memset(&attr, 0, sizeof(attr)); attr.type = PERF_TYPE_SOFTWARE; attr.config = PERF_COUNT_SW_TASK_CLOCK; fd = sys_perf_event_open(&attr, 0, -1, -1, 0); if (fd < 0) die("Error: sys_perf_event_open() syscall returned" "with %d (%s)\n", fd, strerror(errno)); return fd; } static u64 get_cpu_usage_nsec_self(int fd) { u64 runtime; int ret; ret = read(fd, &runtime, sizeof(runtime)); BUG_ON(ret != sizeof(runtime)); return runtime; } static void *thread_func(void *ctx) { struct task_desc *this_task = ctx; u64 cpu_usage_0, cpu_usage_1; unsigned long i, ret; char comm2[22]; int fd; sprintf(comm2, ":%s", this_task->comm); prctl(PR_SET_NAME, comm2); fd = self_open_counters(); again: ret = sem_post(&this_task->ready_for_work); BUG_ON(ret); ret = pthread_mutex_lock(&start_work_mutex); BUG_ON(ret); ret = pthread_mutex_unlock(&start_work_mutex); BUG_ON(ret); cpu_usage_0 = get_cpu_usage_nsec_self(fd); for (i = 0; i < this_task->nr_events; i++) { this_task->curr_event = i; process_sched_event(this_task, this_task->atoms[i]); } cpu_usage_1 = get_cpu_usage_nsec_self(fd); this_task->cpu_usage = cpu_usage_1 - cpu_usage_0; ret = sem_post(&this_task->work_done_sem); BUG_ON(ret); ret = pthread_mutex_lock(&work_done_wait_mutex); BUG_ON(ret); ret = pthread_mutex_unlock(&work_done_wait_mutex); BUG_ON(ret); goto again; } static void create_tasks(void) { struct task_desc *task; pthread_attr_t attr; unsigned long i; int err; err = pthread_attr_init(&attr); BUG_ON(err); err = pthread_attr_setstacksize(&attr, (size_t) max(16 * 1024, PTHREAD_STACK_MIN)); BUG_ON(err); err = pthread_mutex_lock(&start_work_mutex); BUG_ON(err); err = pthread_mutex_lock(&work_done_wait_mutex); BUG_ON(err); for (i = 0; i < nr_tasks; i++) { task = tasks[i]; sem_init(&task->sleep_sem, 0, 0); sem_init(&task->ready_for_work, 0, 0); sem_init(&task->work_done_sem, 0, 0); task->curr_event = 0; err = pthread_create(&task->thread, &attr, thread_func, task); BUG_ON(err); } } static void wait_for_tasks(void) { u64 cpu_usage_0, cpu_usage_1; struct task_desc *task; unsigned long i, ret; start_time = get_nsecs(); cpu_usage = 0; pthread_mutex_unlock(&work_done_wait_mutex); for (i = 0; i < nr_tasks; i++) { task = tasks[i]; ret = sem_wait(&task->ready_for_work); BUG_ON(ret); sem_init(&task->ready_for_work, 0, 0); } ret = pthread_mutex_lock(&work_done_wait_mutex); BUG_ON(ret); cpu_usage_0 = get_cpu_usage_nsec_parent(); pthread_mutex_unlock(&start_work_mutex); for (i = 0; i < nr_tasks; i++) { task = tasks[i]; ret = sem_wait(&task->work_done_sem); BUG_ON(ret); sem_init(&task->work_done_sem, 0, 0); cpu_usage += task->cpu_usage; task->cpu_usage = 0; } cpu_usage_1 = get_cpu_usage_nsec_parent(); if (!runavg_cpu_usage) runavg_cpu_usage = cpu_usage; runavg_cpu_usage = (runavg_cpu_usage*9 + cpu_usage)/10; parent_cpu_usage = cpu_usage_1 - cpu_usage_0; if (!runavg_parent_cpu_usage) runavg_parent_cpu_usage = parent_cpu_usage; runavg_parent_cpu_usage = (runavg_parent_cpu_usage*9 + parent_cpu_usage)/10; ret = pthread_mutex_lock(&start_work_mutex); BUG_ON(ret); for (i = 0; i < nr_tasks; i++) { task = tasks[i]; sem_init(&task->sleep_sem, 0, 0); task->curr_event = 0; } } static void run_one_test(void) { u64 T0, T1, delta, avg_delta, fluct; T0 = get_nsecs(); wait_for_tasks(); T1 = get_nsecs(); delta = T1 - T0; sum_runtime += delta; nr_runs++; avg_delta = sum_runtime / nr_runs; if (delta < avg_delta) fluct = avg_delta - delta; else fluct = delta - avg_delta; sum_fluct += fluct; if (!run_avg) run_avg = delta; run_avg = (run_avg*9 + delta)/10; printf("#%-3ld: %0.3f, ", nr_runs, (double)delta/1000000.0); printf("ravg: %0.2f, ", (double)run_avg/1e6); printf("cpu: %0.2f / %0.2f", (double)cpu_usage/1e6, (double)runavg_cpu_usage/1e6); #if 0 /* * rusage statistics done by the parent, these are less * accurate than the sum_exec_runtime based statistics: */ printf(" [%0.2f / %0.2f]", (double)parent_cpu_usage/1e6, (double)runavg_parent_cpu_usage/1e6); #endif printf("\n"); if (nr_sleep_corrections) printf(" (%ld sleep corrections)\n", nr_sleep_corrections); nr_sleep_corrections = 0; } static void test_calibrations(void) { u64 T0, T1; T0 = get_nsecs(); burn_nsecs(1e6); T1 = get_nsecs(); printf("the run test took %" PRIu64 " nsecs\n", T1 - T0); T0 = get_nsecs(); sleep_nsecs(1e6); T1 = get_nsecs(); printf("the sleep test took %" PRIu64 " nsecs\n", T1 - T0); } #define FILL_FIELD(ptr, field, event, data) \ ptr.field = (typeof(ptr.field)) raw_field_value(event, #field, data) #define FILL_ARRAY(ptr, array, event, data) \ do { \ void *__array = raw_field_ptr(event, #array, data); \ memcpy(ptr.array, __array, sizeof(ptr.array)); \ } while(0) #define FILL_COMMON_FIELDS(ptr, event, data) \ do { \ FILL_FIELD(ptr, common_type, event, data); \ FILL_FIELD(ptr, common_flags, event, data); \ FILL_FIELD(ptr, common_preempt_count, event, data); \ FILL_FIELD(ptr, common_pid, event, data); \ FILL_FIELD(ptr, common_tgid, event, data); \ } while (0) struct trace_switch_event { u32 size; u16 common_type; u8 common_flags; u8 common_preempt_count; u32 common_pid; u32 common_tgid; char prev_comm[16]; u32 prev_pid; u32 prev_prio; u64 prev_state; char next_comm[16]; u32 next_pid; u32 next_prio; }; struct trace_runtime_event { u32 size; u16 common_type; u8 common_flags; u8 common_preempt_count; u32 common_pid; u32 common_tgid; char comm[16]; u32 pid; u64 runtime; u64 vruntime; }; struct trace_wakeup_event { u32 size; u16 common_type; u8 common_flags; u8 common_preempt_count; u32 common_pid; u32 common_tgid; char comm[16]; u32 pid; u32 prio; u32 success; u32 cpu; }; struct trace_fork_event { u32 size; u16 common_type; u8 common_flags; u8 common_preempt_count; u32 common_pid; u32 common_tgid; char parent_comm[16]; u32 parent_pid; char child_comm[16]; u32 child_pid; }; struct trace_migrate_task_event { u32 size; u16 common_type; u8 common_flags; u8 common_preempt_count; u32 common_pid; u32 common_tgid; char comm[16]; u32 pid; u32 prio; u32 cpu; }; struct trace_sched_handler { void (*switch_event)(struct trace_switch_event *, struct machine *, struct event *, int cpu, u64 timestamp, struct thread *thread); void (*runtime_event)(struct trace_runtime_event *, struct machine *, struct event *, int cpu, u64 timestamp, struct thread *thread); void (*wakeup_event)(struct trace_wakeup_event *, struct machine *, struct event *, int cpu, u64 timestamp, struct thread *thread); void (*fork_event)(struct trace_fork_event *, struct event *, int cpu, u64 timestamp, struct thread *thread); void (*migrate_task_event)(struct trace_migrate_task_event *, struct machine *machine, struct event *, int cpu, u64 timestamp, struct thread *thread); }; static void replay_wakeup_event(struct trace_wakeup_event *wakeup_event, struct machine *machine __used, struct event *event, int cpu __used, u64 timestamp __used, struct thread *thread __used) { struct task_desc *waker, *wakee; if (verbose) { printf("sched_wakeup event %p\n", event); printf(" ... pid %d woke up %s/%d\n", wakeup_event->common_pid, wakeup_event->comm, wakeup_event->pid); } waker = register_pid(wakeup_event->common_pid, "<unknown>"); wakee = register_pid(wakeup_event->pid, wakeup_event->comm); add_sched_event_wakeup(waker, timestamp, wakee); } static u64 cpu_last_switched[MAX_CPUS]; static void replay_switch_event(struct trace_switch_event *switch_event, struct machine *machine __used, struct event *event, int cpu, u64 timestamp, struct thread *thread __used) { struct task_desc *prev, __used *next; u64 timestamp0; s64 delta; if (verbose) printf("sched_switch event %p\n", event); if (cpu >= MAX_CPUS || cpu < 0) return; timestamp0 = cpu_last_switched[cpu]; if (timestamp0) delta = timestamp - timestamp0; else delta = 0; if (delta < 0) die("hm, delta: %" PRIu64 " < 0 ?\n", delta); if (verbose) { printf(" ... switch from %s/%d to %s/%d [ran %" PRIu64 " nsecs]\n", switch_event->prev_comm, switch_event->prev_pid, switch_event->next_comm, switch_event->next_pid, delta); } prev = register_pid(switch_event->prev_pid, switch_event->prev_comm); next = register_pid(switch_event->next_pid, switch_event->next_comm); cpu_last_switched[cpu] = timestamp; add_sched_event_run(prev, timestamp, delta); add_sched_event_sleep(prev, timestamp, switch_event->prev_state); } static void replay_fork_event(struct trace_fork_event *fork_event, struct event *event, int cpu __used, u64 timestamp __used, struct thread *thread __used) { if (verbose) { printf("sched_fork event %p\n", event); printf("... parent: %s/%d\n", fork_event->parent_comm, fork_event->parent_pid); printf("... child: %s/%d\n", fork_event->child_comm, fork_event->child_pid); } register_pid(fork_event->parent_pid, fork_event->parent_comm); register_pid(fork_event->child_pid, fork_event->child_comm); } static struct trace_sched_handler replay_ops = { .wakeup_event = replay_wakeup_event, .switch_event = replay_switch_event, .fork_event = replay_fork_event, }; struct sort_dimension { const char *name; sort_fn_t cmp; struct list_head list; }; static LIST_HEAD(cmp_pid); static int thread_lat_cmp(struct list_head *list, struct work_atoms *l, struct work_atoms *r) { struct sort_dimension *sort; int ret = 0; BUG_ON(list_empty(list)); list_for_each_entry(sort, list, list) { ret = sort->cmp(l, r); if (ret) return ret; } return ret; } static struct work_atoms * thread_atoms_search(struct rb_root *root, struct thread *thread, struct list_head *sort_list) { struct rb_node *node = root->rb_node; struct work_atoms key = { .thread = thread }; while (node) { struct work_atoms *atoms; int cmp; atoms = container_of(node, struct work_atoms, node); cmp = thread_lat_cmp(sort_list, &key, atoms); if (cmp > 0) node = node->rb_left; else if (cmp < 0) node = node->rb_right; else { BUG_ON(thread != atoms->thread); return atoms; } } return NULL; } static void __thread_latency_insert(struct rb_root *root, struct work_atoms *data, struct list_head *sort_list) { struct rb_node **new = &(root->rb_node), *parent = NULL; while (*new) { struct work_atoms *this; int cmp; this = container_of(*new, struct work_atoms, node); parent = *new; cmp = thread_lat_cmp(sort_list, data, this); if (cmp > 0) new = &((*new)->rb_left); else new = &((*new)->rb_right); } rb_link_node(&data->node, parent, new); rb_insert_color(&data->node, root); } static void thread_atoms_insert(struct thread *thread) { struct work_atoms *atoms = zalloc(sizeof(*atoms)); if (!atoms) die("No memory"); atoms->thread = thread; INIT_LIST_HEAD(&atoms->work_list); __thread_latency_insert(&atom_root, atoms, &cmp_pid); } static void latency_fork_event(struct trace_fork_event *fork_event __used, struct event *event __used, int cpu __used, u64 timestamp __used, struct thread *thread __used) { /* should insert the newcomer */ } __used static char sched_out_state(struct trace_switch_event *switch_event) { const char *str = TASK_STATE_TO_CHAR_STR; return str[switch_event->prev_state]; } static void add_sched_out_event(struct work_atoms *atoms, char run_state, u64 timestamp) { struct work_atom *atom = zalloc(sizeof(*atom)); if (!atom) die("Non memory"); atom->sched_out_time = timestamp; if (run_state == 'R') { atom->state = THREAD_WAIT_CPU; atom->wake_up_time = atom->sched_out_time; } list_add_tail(&atom->list, &atoms->work_list); } static void add_runtime_event(struct work_atoms *atoms, u64 delta, u64 timestamp __used) { struct work_atom *atom; BUG_ON(list_empty(&atoms->work_list)); atom = list_entry(atoms->work_list.prev, struct work_atom, list); atom->runtime += delta; atoms->total_runtime += delta; } static void add_sched_in_event(struct work_atoms *atoms, u64 timestamp) { struct work_atom *atom; u64 delta; if (list_empty(&atoms->work_list)) return; atom = list_entry(atoms->work_list.prev, struct work_atom, list); if (atom->state != THREAD_WAIT_CPU) return; if (timestamp < atom->wake_up_time) { atom->state = THREAD_IGNORE; return; } atom->state = THREAD_SCHED_IN; atom->sched_in_time = timestamp; delta = atom->sched_in_time - atom->wake_up_time; atoms->total_lat += delta; if (delta > atoms->max_lat) { atoms->max_lat = delta; atoms->max_lat_at = timestamp; } atoms->nb_atoms++; } static void latency_switch_event(struct trace_switch_event *switch_event, struct machine *machine, struct event *event __used, int cpu, u64 timestamp, struct thread *thread __used) { struct work_atoms *out_events, *in_events; struct thread *sched_out, *sched_in; u64 timestamp0; s64 delta; BUG_ON(cpu >= MAX_CPUS || cpu < 0); timestamp0 = cpu_last_switched[cpu]; cpu_last_switched[cpu] = timestamp; if (timestamp0) delta = timestamp - timestamp0; else delta = 0; if (delta < 0) die("hm, delta: %" PRIu64 " < 0 ?\n", delta); sched_out = machine__findnew_thread(machine, switch_event->prev_pid); sched_in = machine__findnew_thread(machine, switch_event->next_pid); out_events = thread_atoms_search(&atom_root, sched_out, &cmp_pid); if (!out_events) { thread_atoms_insert(sched_out); out_events = thread_atoms_search(&atom_root, sched_out, &cmp_pid); if (!out_events) die("out-event: Internal tree error"); } add_sched_out_event(out_events, sched_out_state(switch_event), timestamp); in_events = thread_atoms_search(&atom_root, sched_in, &cmp_pid); if (!in_events) { thread_atoms_insert(sched_in); in_events = thread_atoms_search(&atom_root, sched_in, &cmp_pid); if (!in_events) die("in-event: Internal tree error"); /* * Take came in we have not heard about yet, * add in an initial atom in runnable state: */ add_sched_out_event(in_events, 'R', timestamp); } add_sched_in_event(in_events, timestamp); } static void latency_runtime_event(struct trace_runtime_event *runtime_event, struct machine *machine, struct event *event __used, int cpu, u64 timestamp, struct thread *this_thread __used) { struct thread *thread = machine__findnew_thread(machine, runtime_event->pid); struct work_atoms *atoms = thread_atoms_search(&atom_root, thread, &cmp_pid); BUG_ON(cpu >= MAX_CPUS || cpu < 0); if (!atoms) { thread_atoms_insert(thread); atoms = thread_atoms_search(&atom_root, thread, &cmp_pid); if (!atoms) die("in-event: Internal tree error"); add_sched_out_event(atoms, 'R', timestamp); } add_runtime_event(atoms, runtime_event->runtime, timestamp); } static void latency_wakeup_event(struct trace_wakeup_event *wakeup_event, struct machine *machine, struct event *__event __used, int cpu __used, u64 timestamp, struct thread *thread __used) { struct work_atoms *atoms; struct work_atom *atom; struct thread *wakee; /* Note for later, it may be interesting to observe the failing cases */ if (!wakeup_event->success) return; wakee = machine__findnew_thread(machine, wakeup_event->pid); atoms = thread_atoms_search(&atom_root, wakee, &cmp_pid); if (!atoms) { thread_atoms_insert(wakee); atoms = thread_atoms_search(&atom_root, wakee, &cmp_pid); if (!atoms) die("wakeup-event: Internal tree error"); add_sched_out_event(atoms, 'S', timestamp); } BUG_ON(list_empty(&atoms->work_list)); atom = list_entry(atoms->work_list.prev, struct work_atom, list); /* * You WILL be missing events if you've recorded only * one CPU, or are only looking at only one, so don't * make useless noise. */ if (profile_cpu == -1 && atom->state != THREAD_SLEEPING) nr_state_machine_bugs++; nr_timestamps++; if (atom->sched_out_time > timestamp) { nr_unordered_timestamps++; return; } atom->state = THREAD_WAIT_CPU; atom->wake_up_time = timestamp; } static void latency_migrate_task_event(struct trace_migrate_task_event *migrate_task_event, struct machine *machine, struct event *__event __used, int cpu __used, u64 timestamp, struct thread *thread __used) { struct work_atoms *atoms; struct work_atom *atom; struct thread *migrant; /* * Only need to worry about migration when profiling one CPU. */ if (profile_cpu == -1) return; migrant = machine__findnew_thread(machine, migrate_task_event->pid); atoms = thread_atoms_search(&atom_root, migrant, &cmp_pid); if (!atoms) { thread_atoms_insert(migrant); register_pid(migrant->pid, migrant->comm); atoms = thread_atoms_search(&atom_root, migrant, &cmp_pid); if (!atoms) die("migration-event: Internal tree error"); add_sched_out_event(atoms, 'R', timestamp); } BUG_ON(list_empty(&atoms->work_list)); atom = list_entry(atoms->work_list.prev, struct work_atom, list); atom->sched_in_time = atom->sched_out_time = atom->wake_up_time = timestamp; nr_timestamps++; if (atom->sched_out_time > timestamp) nr_unordered_timestamps++; } static struct trace_sched_handler lat_ops = { .wakeup_event = latency_wakeup_event, .switch_event = latency_switch_event, .runtime_event = latency_runtime_event, .fork_event = latency_fork_event, .migrate_task_event = latency_migrate_task_event, }; static void output_lat_thread(struct work_atoms *work_list) { int i; int ret; u64 avg; if (!work_list->nb_atoms) return; /* * Ignore idle threads: */ if (!strcmp(work_list->thread->comm, "swapper")) return; all_runtime += work_list->total_runtime; all_count += work_list->nb_atoms; ret = printf(" %s:%d ", work_list->thread->comm, work_list->thread->pid); for (i = 0; i < 24 - ret; i++) printf(" "); avg = work_list->total_lat / work_list->nb_atoms; printf("|%11.3f ms |%9" PRIu64 " | avg:%9.3f ms | max:%9.3f ms | max at: %9.6f s\n", (double)work_list->total_runtime / 1e6, work_list->nb_atoms, (double)avg / 1e6, (double)work_list->max_lat / 1e6, (double)work_list->max_lat_at / 1e9); } static int pid_cmp(struct work_atoms *l, struct work_atoms *r) { if (l->thread->pid < r->thread->pid) return -1; if (l->thread->pid > r->thread->pid) return 1; return 0; } static struct sort_dimension pid_sort_dimension = { .name = "pid", .cmp = pid_cmp, }; static int avg_cmp(struct work_atoms *l, struct work_atoms *r) { u64 avgl, avgr; if (!l->nb_atoms) return -1; if (!r->nb_atoms) return 1; avgl = l->total_lat / l->nb_atoms; avgr = r->total_lat / r->nb_atoms; if (avgl < avgr) return -1; if (avgl > avgr) return 1; return 0; } static struct sort_dimension avg_sort_dimension = { .name = "avg", .cmp = avg_cmp, }; static int max_cmp(struct work_atoms *l, struct work_atoms *r) { if (l->max_lat < r->max_lat) return -1; if (l->max_lat > r->max_lat) return 1; return 0; } static struct sort_dimension max_sort_dimension = { .name = "max", .cmp = max_cmp, }; static int switch_cmp(struct work_atoms *l, struct work_atoms *r) { if (l->nb_atoms < r->nb_atoms) return -1; if (l->nb_atoms > r->nb_atoms) return 1; return 0; } static struct sort_dimension switch_sort_dimension = { .name = "switch", .cmp = switch_cmp, }; static int runtime_cmp(struct work_atoms *l, struct work_atoms *r) { if (l->total_runtime < r->total_runtime) return -1; if (l->total_runtime > r->total_runtime) return 1; return 0; } static struct sort_dimension runtime_sort_dimension = { .name = "runtime", .cmp = runtime_cmp, }; static struct sort_dimension *available_sorts[] = { &pid_sort_dimension, &avg_sort_dimension, &max_sort_dimension, &switch_sort_dimension, &runtime_sort_dimension, }; #define NB_AVAILABLE_SORTS (int)(sizeof(available_sorts) / sizeof(struct sort_dimension *)) static LIST_HEAD(sort_list); static int sort_dimension__add(const char *tok, struct list_head *list) { int i; for (i = 0; i < NB_AVAILABLE_SORTS; i++) { if (!strcmp(available_sorts[i]->name, tok)) { list_add_tail(&available_sorts[i]->list, list); return 0; } } return -1; } static void setup_sorting(void); static void sort_lat(void) { struct rb_node *node; for (;;) { struct work_atoms *data; node = rb_first(&atom_root); if (!node) break; rb_erase(node, &atom_root); data = rb_entry(node, struct work_atoms, node); __thread_latency_insert(&sorted_atom_root, data, &sort_list); } } static struct trace_sched_handler *trace_handler; static void process_sched_wakeup_event(struct perf_tool *tool __used, struct event *event, struct perf_sample *sample, struct machine *machine, struct thread *thread) { void *data = sample->raw_data; struct trace_wakeup_event wakeup_event; FILL_COMMON_FIELDS(wakeup_event, event, data); FILL_ARRAY(wakeup_event, comm, event, data); FILL_FIELD(wakeup_event, pid, event, data); FILL_FIELD(wakeup_event, prio, event, data); FILL_FIELD(wakeup_event, success, event, data); FILL_FIELD(wakeup_event, cpu, event, data); if (trace_handler->wakeup_event) trace_handler->wakeup_event(&wakeup_event, machine, event, sample->cpu, sample->time, thread); } /* * Track the current task - that way we can know whether there's any * weird events, such as a task being switched away that is not current. */ static int max_cpu; static u32 curr_pid[MAX_CPUS] = { [0 ... MAX_CPUS-1] = -1 }; static struct thread *curr_thread[MAX_CPUS]; static char next_shortname1 = 'A'; static char next_shortname2 = '0'; static void map_switch_event(struct trace_switch_event *switch_event, struct machine *machine, struct event *event __used, int this_cpu, u64 timestamp, struct thread *thread __used) { struct thread *sched_out __used, *sched_in; int new_shortname; u64 timestamp0; s64 delta; int cpu; BUG_ON(this_cpu >= MAX_CPUS || this_cpu < 0); if (this_cpu > max_cpu) max_cpu = this_cpu; timestamp0 = cpu_last_switched[this_cpu]; cpu_last_switched[this_cpu] = timestamp; if (timestamp0) delta = timestamp - timestamp0; else delta = 0; if (delta < 0) die("hm, delta: %" PRIu64 " < 0 ?\n", delta); sched_out = machine__findnew_thread(machine, switch_event->prev_pid); sched_in = machine__findnew_thread(machine, switch_event->next_pid); curr_thread[this_cpu] = sched_in; printf(" "); new_shortname = 0; if (!sched_in->shortname[0]) { sched_in->shortname[0] = next_shortname1; sched_in->shortname[1] = next_shortname2; if (next_shortname1 < 'Z') { next_shortname1++; } else { next_shortname1='A'; if (next_shortname2 < '9') { next_shortname2++; } else { next_shortname2='0'; } } new_shortname = 1; } for (cpu = 0; cpu <= max_cpu; cpu++) { if (cpu != this_cpu) printf(" "); else printf("*"); if (curr_thread[cpu]) { if (curr_thread[cpu]->pid) printf("%2s ", curr_thread[cpu]->shortname); else printf(". "); } else printf(" "); } printf(" %12.6f secs ", (double)timestamp/1e9); if (new_shortname) { printf("%s => %s:%d\n", sched_in->shortname, sched_in->comm, sched_in->pid); } else { printf("\n"); } } static void process_sched_switch_event(struct perf_tool *tool __used, struct event *event, struct perf_sample *sample, struct machine *machine, struct thread *thread) { int this_cpu = sample->cpu; void *data = sample->raw_data; struct trace_switch_event switch_event; FILL_COMMON_FIELDS(switch_event, event, data); FILL_ARRAY(switch_event, prev_comm, event, data); FILL_FIELD(switch_event, prev_pid, event, data); FILL_FIELD(switch_event, prev_prio, event, data); FILL_FIELD(switch_event, prev_state, event, data); FILL_ARRAY(switch_event, next_comm, event, data); FILL_FIELD(switch_event, next_pid, event, data); FILL_FIELD(switch_event, next_prio, event, data); if (curr_pid[this_cpu] != (u32)-1) { /* * Are we trying to switch away a PID that is * not current? */ if (curr_pid[this_cpu] != switch_event.prev_pid) nr_context_switch_bugs++; } if (trace_handler->switch_event) trace_handler->switch_event(&switch_event, machine, event, this_cpu, sample->time, thread); curr_pid[this_cpu] = switch_event.next_pid; } static void process_sched_runtime_event(struct perf_tool *tool __used, struct event *event, struct perf_sample *sample, struct machine *machine, struct thread *thread) { void *data = sample->raw_data; struct trace_runtime_event runtime_event; FILL_ARRAY(runtime_event, comm, event, data); FILL_FIELD(runtime_event, pid, event, data); FILL_FIELD(runtime_event, runtime, event, data); FILL_FIELD(runtime_event, vruntime, event, data); if (trace_handler->runtime_event) trace_handler->runtime_event(&runtime_event, machine, event, sample->cpu, sample->time, thread); } static void process_sched_fork_event(struct perf_tool *tool __used, struct event *event, struct perf_sample *sample, struct machine *machine __used, struct thread *thread) { void *data = sample->raw_data; struct trace_fork_event fork_event; FILL_COMMON_FIELDS(fork_event, event, data); FILL_ARRAY(fork_event, parent_comm, event, data); FILL_FIELD(fork_event, parent_pid, event, data); FILL_ARRAY(fork_event, child_comm, event, data); FILL_FIELD(fork_event, child_pid, event, data); if (trace_handler->fork_event) trace_handler->fork_event(&fork_event, event, sample->cpu, sample->time, thread); } static void process_sched_exit_event(struct perf_tool *tool __used, struct event *event, struct perf_sample *sample __used, struct machine *machine __used, struct thread *thread __used) { if (verbose) printf("sched_exit event %p\n", event); } static void process_sched_migrate_task_event(struct perf_tool *tool __used, struct event *event, struct perf_sample *sample, struct machine *machine, struct thread *thread) { void *data = sample->raw_data; struct trace_migrate_task_event migrate_task_event; FILL_COMMON_FIELDS(migrate_task_event, event, data); FILL_ARRAY(migrate_task_event, comm, event, data); FILL_FIELD(migrate_task_event, pid, event, data); FILL_FIELD(migrate_task_event, prio, event, data); FILL_FIELD(migrate_task_event, cpu, event, data); if (trace_handler->migrate_task_event) trace_handler->migrate_task_event(&migrate_task_event, machine, event, sample->cpu, sample->time, thread); } typedef void (*tracepoint_handler)(struct perf_tool *tool, struct event *event, struct perf_sample *sample, struct machine *machine, struct thread *thread); static int perf_sched__process_tracepoint_sample(struct perf_tool *tool, union perf_event *event __used, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine) { struct thread *thread = machine__findnew_thread(machine, sample->pid); if (thread == NULL) { pr_debug("problem processing %s event, skipping it.\n", evsel->name); return -1; } evsel->hists.stats.total_period += sample->period; hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); if (evsel->handler.func != NULL) { tracepoint_handler f = evsel->handler.func; if (evsel->handler.data == NULL) evsel->handler.data = trace_find_event(evsel->attr.config); f(tool, evsel->handler.data, sample, machine, thread); } return 0; } static struct perf_tool perf_sched = { .sample = perf_sched__process_tracepoint_sample, .comm = perf_event__process_comm, .lost = perf_event__process_lost, .fork = perf_event__process_task, .ordered_samples = true, }; static void read_events(bool destroy, struct perf_session **psession) { int err = -EINVAL; const struct perf_evsel_str_handler handlers[] = { { "sched:sched_switch", process_sched_switch_event, }, { "sched:sched_stat_runtime", process_sched_runtime_event, }, { "sched:sched_wakeup", process_sched_wakeup_event, }, { "sched:sched_wakeup_new", process_sched_wakeup_event, }, { "sched:sched_process_fork", process_sched_fork_event, }, { "sched:sched_process_exit", process_sched_exit_event, }, { "sched:sched_migrate_task", process_sched_migrate_task_event, }, }; struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0, false, &perf_sched); if (session == NULL) die("No Memory"); err = perf_evlist__set_tracepoints_handlers_array(session->evlist, handlers); assert(err == 0); if (perf_session__has_traces(session, "record -R")) { err = perf_session__process_events(session, &perf_sched); if (err) die("Failed to process events, error %d", err); nr_events = session->hists.stats.nr_events[0]; nr_lost_events = session->hists.stats.total_lost; nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST]; } if (destroy) perf_session__delete(session); if (psession) *psession = session; } static void print_bad_events(void) { if (nr_unordered_timestamps && nr_timestamps) { printf(" INFO: %.3f%% unordered timestamps (%ld out of %ld)\n", (double)nr_unordered_timestamps/(double)nr_timestamps*100.0, nr_unordered_timestamps, nr_timestamps); } if (nr_lost_events && nr_events) { printf(" INFO: %.3f%% lost events (%ld out of %ld, in %ld chunks)\n", (double)nr_lost_events/(double)nr_events*100.0, nr_lost_events, nr_events, nr_lost_chunks); } if (nr_state_machine_bugs && nr_timestamps) { printf(" INFO: %.3f%% state machine bugs (%ld out of %ld)", (double)nr_state_machine_bugs/(double)nr_timestamps*100.0, nr_state_machine_bugs, nr_timestamps); if (nr_lost_events) printf(" (due to lost events?)"); printf("\n"); } if (nr_context_switch_bugs && nr_timestamps) { printf(" INFO: %.3f%% context switch bugs (%ld out of %ld)", (double)nr_context_switch_bugs/(double)nr_timestamps*100.0, nr_context_switch_bugs, nr_timestamps); if (nr_lost_events) printf(" (due to lost events?)"); printf("\n"); } } static void __cmd_lat(void) { struct rb_node *next; struct perf_session *session; setup_pager(); read_events(false, &session); sort_lat(); printf("\n ---------------------------------------------------------------------------------------------------------------\n"); printf(" Task | Runtime ms | Switches | Average delay ms | Maximum delay ms | Maximum delay at |\n"); printf(" ---------------------------------------------------------------------------------------------------------------\n"); next = rb_first(&sorted_atom_root); while (next) { struct work_atoms *work_list; work_list = rb_entry(next, struct work_atoms, node); output_lat_thread(work_list); next = rb_next(next); } printf(" -----------------------------------------------------------------------------------------\n"); printf(" TOTAL: |%11.3f ms |%9" PRIu64 " |\n", (double)all_runtime/1e6, all_count); printf(" ---------------------------------------------------\n"); print_bad_events(); printf("\n"); perf_session__delete(session); } static struct trace_sched_handler map_ops = { .wakeup_event = NULL, .switch_event = map_switch_event, .runtime_event = NULL, .fork_event = NULL, }; static void __cmd_map(void) { max_cpu = sysconf(_SC_NPROCESSORS_CONF); setup_pager(); read_events(true, NULL); print_bad_events(); } static void __cmd_replay(void) { unsigned long i; calibrate_run_measurement_overhead(); calibrate_sleep_measurement_overhead(); test_calibrations(); read_events(true, NULL); printf("nr_run_events: %ld\n", nr_run_events); printf("nr_sleep_events: %ld\n", nr_sleep_events); printf("nr_wakeup_events: %ld\n", nr_wakeup_events); if (targetless_wakeups) printf("target-less wakeups: %ld\n", targetless_wakeups); if (multitarget_wakeups) printf("multi-target wakeups: %ld\n", multitarget_wakeups); if (nr_run_events_optimized) printf("run atoms optimized: %ld\n", nr_run_events_optimized); print_task_traces(); add_cross_task_wakeups(); create_tasks(); printf("------------------------------------------------------------\n"); for (i = 0; i < replay_repeat; i++) run_one_test(); } static const char * const sched_usage[] = { "perf sched [<options>] {record|latency|map|replay|script}", NULL }; static const struct option sched_options[] = { OPT_STRING('i', "input", &input_name, "file", "input file name"), OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), OPT_END() }; static const char * const latency_usage[] = { "perf sched latency [<options>]", NULL }; static const struct option latency_options[] = { OPT_STRING('s', "sort", &sort_order, "key[,key2...]", "sort by key(s): runtime, switch, avg, max"), OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), OPT_INTEGER('C', "CPU", &profile_cpu, "CPU to profile on"), OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), OPT_END() }; static const char * const replay_usage[] = { "perf sched replay [<options>]", NULL }; static const struct option replay_options[] = { OPT_UINTEGER('r', "repeat", &replay_repeat, "repeat the workload replay N times (-1: infinite)"), OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), OPT_END() }; static void setup_sorting(void) { char *tmp, *tok, *str = strdup(sort_order); for (tok = strtok_r(str, ", ", &tmp); tok; tok = strtok_r(NULL, ", ", &tmp)) { if (sort_dimension__add(tok, &sort_list) < 0) { error("Unknown --sort key: `%s'", tok); usage_with_options(latency_usage, latency_options); } } free(str); sort_dimension__add("pid", &cmp_pid); } static const char *record_args[] = { "record", "-a", "-R", "-f", "-m", "1024", "-c", "1", "-e", "sched:sched_switch", "-e", "sched:sched_stat_wait", "-e", "sched:sched_stat_sleep", "-e", "sched:sched_stat_iowait", "-e", "sched:sched_stat_runtime", "-e", "sched:sched_process_exit", "-e", "sched:sched_process_fork", "-e", "sched:sched_wakeup", "-e", "sched:sched_migrate_task", }; static int __cmd_record(int argc, const char **argv) { unsigned int rec_argc, i, j; const char **rec_argv; rec_argc = ARRAY_SIZE(record_args) + argc - 1; rec_argv = calloc(rec_argc + 1, sizeof(char *)); if (rec_argv == NULL) return -ENOMEM; for (i = 0; i < ARRAY_SIZE(record_args); i++) rec_argv[i] = strdup(record_args[i]); for (j = 1; j < (unsigned int)argc; j++, i++) rec_argv[i] = argv[j]; BUG_ON(i != rec_argc); return cmd_record(i, rec_argv, NULL); } int cmd_sched(int argc, const char **argv, const char *prefix __used) { argc = parse_options(argc, argv, sched_options, sched_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) usage_with_options(sched_usage, sched_options); /* * Aliased to 'perf script' for now: */ if (!strcmp(argv[0], "script")) return cmd_script(argc, argv, prefix); symbol__init(); if (!strncmp(argv[0], "rec", 3)) { return __cmd_record(argc, argv); } else if (!strncmp(argv[0], "lat", 3)) { trace_handler = &lat_ops; if (argc > 1) { argc = parse_options(argc, argv, latency_options, latency_usage, 0); if (argc) usage_with_options(latency_usage, latency_options); } setup_sorting(); __cmd_lat(); } else if (!strcmp(argv[0], "map")) { trace_handler = &map_ops; setup_sorting(); __cmd_map(); } else if (!strncmp(argv[0], "rep", 3)) { trace_handler = &replay_ops; if (argc) { argc = parse_options(argc, argv, replay_options, replay_usage, 0); if (argc) usage_with_options(replay_usage, replay_options); } __cmd_replay(); } else { usage_with_options(sched_usage, sched_options); } return 0; }
gpl-2.0
ibm-research/fusedos-linux
drivers/net/wireless/orinoco/orinoco_cs.c
5814
14251
/* orinoco_cs.c (formerly known as dldwd_cs.c) * * A driver for "Hermes" chipset based PCMCIA wireless adaptors, such * as the Lucent WavelanIEEE/Orinoco cards and their OEM (Cabletron/ * EnteraSys RoamAbout 802.11, ELSA Airlancer, Melco Buffalo and others). * It should also be usable on various Prism II based cards such as the * Linksys, D-Link and Farallon Skyline. It should also work on Symbol * cards such as the 3Com AirConnect and Ericsson WLAN. * * Copyright notice & release notes in file main.c */ #define DRIVER_NAME "orinoco_cs" #define PFX DRIVER_NAME ": " #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/delay.h> #include <pcmcia/cistpl.h> #include <pcmcia/cisreg.h> #include <pcmcia/ds.h> #include "orinoco.h" /********************************************************************/ /* Module stuff */ /********************************************************************/ MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>"); MODULE_DESCRIPTION("Driver for PCMCIA Lucent Orinoco," " Prism II based and similar wireless cards"); MODULE_LICENSE("Dual MPL/GPL"); /* Module parameters */ /* Some D-Link cards have buggy CIS. They do work at 5v properly, but * don't have any CIS entry for it. This workaround it... */ static int ignore_cis_vcc; /* = 0 */ module_param(ignore_cis_vcc, int, 0); MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket"); /********************************************************************/ /* Data structures */ /********************************************************************/ /* PCMCIA specific device information (goes in the card field of * struct orinoco_private */ struct orinoco_pccard { struct pcmcia_device *p_dev; /* Used to handle hard reset */ /* yuck, we need this hack to work around the insanity of the * PCMCIA layer */ unsigned long hard_reset_in_progress; }; /********************************************************************/ /* Function prototypes */ /********************************************************************/ static int orinoco_cs_config(struct pcmcia_device *link); static void orinoco_cs_release(struct pcmcia_device *link); static void orinoco_cs_detach(struct pcmcia_device *p_dev); /********************************************************************/ /* Device methods */ /********************************************************************/ static int orinoco_cs_hard_reset(struct orinoco_private *priv) { struct orinoco_pccard *card = priv->card; struct pcmcia_device *link = card->p_dev; int err; /* We need atomic ops here, because we're not holding the lock */ set_bit(0, &card->hard_reset_in_progress); err = pcmcia_reset_card(link->socket); if (err) return err; msleep(100); clear_bit(0, &card->hard_reset_in_progress); return 0; } /********************************************************************/ /* PCMCIA stuff */ /********************************************************************/ static int orinoco_cs_probe(struct pcmcia_device *link) { struct orinoco_private *priv; struct orinoco_pccard *card; priv = alloc_orinocodev(sizeof(*card), &link->dev, orinoco_cs_hard_reset, NULL); if (!priv) return -ENOMEM; card = priv->card; /* Link both structures together */ card->p_dev = link; link->priv = priv; return orinoco_cs_config(link); } /* orinoco_cs_attach */ static void orinoco_cs_detach(struct pcmcia_device *link) { struct orinoco_private *priv = link->priv; orinoco_if_del(priv); orinoco_cs_release(link); free_orinocodev(priv); } /* orinoco_cs_detach */ static int orinoco_cs_config_check(struct pcmcia_device *p_dev, void *priv_data) { if (p_dev->config_index == 0) return -EINVAL; return pcmcia_request_io(p_dev); }; static int orinoco_cs_config(struct pcmcia_device *link) { struct orinoco_private *priv = link->priv; struct hermes *hw = &priv->hw; int ret; void __iomem *mem; link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC | CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; if (ignore_cis_vcc) link->config_flags &= ~CONF_AUTO_CHECK_VCC; ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL); if (ret) { if (!ignore_cis_vcc) printk(KERN_ERR PFX "GetNextTuple(): No matching " "CIS configuration. Maybe you need the " "ignore_cis_vcc=1 parameter.\n"); goto failed; } mem = ioport_map(link->resource[0]->start, resource_size(link->resource[0])); if (!mem) goto failed; /* We initialize the hermes structure before completing PCMCIA * configuration just in case the interrupt handler gets * called. */ hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING); ret = pcmcia_request_irq(link, orinoco_interrupt); if (ret) goto failed; ret = pcmcia_enable_device(link); if (ret) goto failed; /* Initialise the main driver */ if (orinoco_init(priv) != 0) { printk(KERN_ERR PFX "orinoco_init() failed\n"); goto failed; } /* Register an interface with the stack */ if (orinoco_if_add(priv, link->resource[0]->start, link->irq, NULL) != 0) { printk(KERN_ERR PFX "orinoco_if_add() failed\n"); goto failed; } return 0; failed: orinoco_cs_release(link); return -ENODEV; } /* orinoco_cs_config */ static void orinoco_cs_release(struct pcmcia_device *link) { struct orinoco_private *priv = link->priv; unsigned long flags; /* We're committed to taking the device away now, so mark the * hardware as unavailable */ priv->hw.ops->lock_irqsave(&priv->lock, &flags); priv->hw_unavailable++; priv->hw.ops->unlock_irqrestore(&priv->lock, &flags); pcmcia_disable_device(link); if (priv->hw.iobase) ioport_unmap(priv->hw.iobase); } /* orinoco_cs_release */ static int orinoco_cs_suspend(struct pcmcia_device *link) { struct orinoco_private *priv = link->priv; struct orinoco_pccard *card = priv->card; /* This is probably racy, but I can't think of a better way, short of rewriting the PCMCIA layer to not suck :-( */ if (!test_bit(0, &card->hard_reset_in_progress)) orinoco_down(priv); return 0; } static int orinoco_cs_resume(struct pcmcia_device *link) { struct orinoco_private *priv = link->priv; struct orinoco_pccard *card = priv->card; int err = 0; if (!test_bit(0, &card->hard_reset_in_progress)) err = orinoco_up(priv); return err; } /********************************************************************/ /* Module initialization */ /********************************************************************/ static const struct pcmcia_device_id orinoco_cs_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), /* 3Com AirConnect PCI 777A */ PCMCIA_DEVICE_MANF_CARD(0x016b, 0x0001), /* Ericsson WLAN Card C11 */ PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a), /* Nortel Networks eMobility 802.11 Wireless Adapter */ PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), /* AirWay 802.11 Adapter (PCMCIA) */ PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), /* ARtem Onair */ PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0003), /* ARtem Onair Comcard 11 */ PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), /* Buffalo WLI-PCM-S11 */ PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), /* ASUS SpaceLink WL-100 */ PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002), /* SpeedStream SS1021 Wireless Adapter */ PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x3021), /* SpeedStream Wireless Adapter */ PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001), /* PLANEX RoadLannerWave GW-NS11H */ PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3), PCMCIA_DEVICE_PROD_ID12("Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio", 0x5cd01705, 0x4271660f), PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11B_CF_CARD_25", 0x78fc06ee, 0x45a50c1e), PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11b_PC_CARD_25", 0x78fc06ee, 0xdb9aa842), PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169), PCMCIA_DEVICE_PROD_ID12("BENQ", "AWL100 PCMCIA ADAPTER", 0x35dadc74, 0x01f7fedb), PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90), PCMCIA_DEVICE_PROD_ID12("D-Link Corporation", "D-Link DWL-650H 11Mbps WLAN Adapter", 0xef544d24, 0xcd8ea916), PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3), PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c), PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless 2011 LAN PC Card", 0x816cc815, 0x07f58077), PCMCIA_DEVICE_PROD_ID12("LeArtery", "SYNCBYAIR 11Mbps Wireless LAN PC Card", 0x7e3b326a, 0x49893e92), PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a), PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410), PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3), PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a), PCMCIA_DEVICE_PROD_ID12("Nortel Networks", "emobility 802.11 Wireless LAN PC Card", 0x2d617ea0, 0x88cd5767), PCMCIA_DEVICE_PROD_ID12("OTC", "Wireless AirEZY 2411-PCC WLAN Card", 0x4ac44287, 0x235a6bed), PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9), PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26), PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b), PCMCIA_DEVICE_PROD_ID12("Symbol Technologies", "LA4111 Spectrum24 Wireless LAN PC Card", 0x3f02b4d6, 0x3663cb0e), PCMCIA_DEVICE_MANF_CARD_PROD_ID3(0x0156, 0x0002, "Version 01.01", 0xd27deb1a), /* Lucent Orinoco */ #ifdef CONFIG_HERMES_PRISM /* Only entries that certainly identify Prism chipset */ PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), /* SonicWALL Long Range Wireless Card */ PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), /* Sohoware NCP110, Philips 802.11b */ PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0002), /* AnyPoint(TM) Wireless II PC Card */ PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), /* PROXIM RangeLAN-DS/LAN PC CARD */ PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), /* Compaq WL100 11 Mbps Wireless Adapter */ PCMCIA_DEVICE_MANF_CARD(0x01ff, 0x0008), /* Intermec MobileLAN 11Mbps 802.11b WLAN Card */ PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), /* Samsung SWL2000-N 11Mb/s WLAN Card */ PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), /* Linksys WPC11 Version 2.5 */ PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), /* Linksys WPC11 Version 3 */ PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), /* Compaq HNW-100 11 Mbps Wireless Adapter */ PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), /* Linksys WCF12 Wireless CompactFlash Card */ PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), /* Airvast WN-100 */ PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), /* Adaptec Ultra Wireless ANW-8030 */ PCMCIA_DEVICE_MANF_CARD(0xc001, 0x0008), /* CONTEC FLEXSCAN/FX-DDS110-PCC */ PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), /* Conceptronic CON11Cpro, EMTAC A2424i */ PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), /* Safeway 802.11b, ZCOMAX AirRunner/XI-300 */ PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), /* D-Link DCF660, Sandisk Connect SDWCFB-000 */ PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0), PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5), PCMCIA_DEVICE_PROD_ID12("Addtron", "AWP-100 Wireless PCMCIA", 0xe6ec52ce, 0x08649af2), PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 0x2decece3, 0x82067c18), PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3), PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", 0x54f7c49c, 0x15a75e5b), PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584), PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9), PCMCIA_DEVICE_PROD_ID12("corega_K.K.", "Wireless_LAN_PCCB-11", 0x29e33311, 0xee7a27ae), PCMCIA_DEVICE_PROD_ID12("Digital Data Communications", "WPC-0100", 0xfdd73470, 0xe0b6f146), PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac), PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab), PCMCIA_DEVICE_PROD_ID12(" ", "IEEE 802.11 Wireless LAN/PC Card", 0x3b6e20c8, 0xefccafe9), PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), PCMCIA_DEVICE_PROD_ID12("INTERSIL", "I-GATE 11M PC Card / PC Card plus", 0x74c5e40d, 0x8304ff77), PCMCIA_DEVICE_PROD_ID12("Intersil", "PRISM 2_5 PCMCIA ADAPTER", 0x4b801a17, 0x6345a0bf), PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", 0x0733cc81, 0x0c52f395), PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01), PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1), PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401 Wireless PC", "Card", 0xa37434e9, 0x9762e8f1), PCMCIA_DEVICE_PROD_ID12("OEM", "PRISM2 IEEE 802.11 PC-Card", 0xfea54c90, 0x48f2bdd6), PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264), PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-NS110", 0x209f40ab, 0x46263178), PCMCIA_DEVICE_PROD_ID12("SMC", "SMC2532W-B EliteConnect Wireless Adapter", 0xc4f8b18b, 0x196bd757), PCMCIA_DEVICE_PROD_ID12("SMC", "SMC2632W", 0xc4f8b18b, 0x474a1f2a), PCMCIA_DEVICE_PROD_ID12("ZoomAir 11Mbps High", "Rate wireless Networking", 0x273fe3db, 0x32a1eaee), PCMCIA_DEVICE_PROD_ID3("HFA3863", 0x355cb092), PCMCIA_DEVICE_PROD_ID3("ISL37100P", 0x630d52b2), PCMCIA_DEVICE_PROD_ID3("ISL37101P-10", 0xdd97a26b), PCMCIA_DEVICE_PROD_ID3("ISL37300P", 0xc9049a39), /* This may be Agere or Intersil Firmware */ PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), #endif PCMCIA_DEVICE_NULL, }; MODULE_DEVICE_TABLE(pcmcia, orinoco_cs_ids); static struct pcmcia_driver orinoco_driver = { .owner = THIS_MODULE, .name = DRIVER_NAME, .probe = orinoco_cs_probe, .remove = orinoco_cs_detach, .id_table = orinoco_cs_ids, .suspend = orinoco_cs_suspend, .resume = orinoco_cs_resume, }; static int __init init_orinoco_cs(void) { return pcmcia_register_driver(&orinoco_driver); } static void __exit exit_orinoco_cs(void) { pcmcia_unregister_driver(&orinoco_driver); } module_init(init_orinoco_cs); module_exit(exit_orinoco_cs);
gpl-2.0
Klozz/kernel_asus_grouper_kitkat
drivers/staging/winbond/mds.c
8118
17881
#include "mds_f.h" #include "mto.h" #include "wbhal.h" #include "wb35tx_f.h" unsigned char Mds_initial(struct wbsoft_priv *adapter) { struct wb35_mds *pMds = &adapter->Mds; pMds->TxPause = false; pMds->TxRTSThreshold = DEFAULT_RTSThreshold; pMds->TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; return hal_get_tx_buffer(&adapter->sHwData, &pMds->pTxBuffer); } static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *buffer) { struct T00_descriptor *pT00; struct T01_descriptor *pT01; u16 Duration, NextBodyLen, OffsetSize; u8 Rate, i; unsigned char CTS_on = false, RTS_on = false; struct T00_descriptor *pNextT00; u16 BodyLen = 0; unsigned char boGroupAddr = false; OffsetSize = pDes->FragmentThreshold + 32 + 3; OffsetSize &= ~0x03; Rate = pDes->TxRate >> 1; if (!Rate) Rate = 1; pT00 = (struct T00_descriptor *)buffer; pT01 = (struct T01_descriptor *)(buffer+4); pNextT00 = (struct T00_descriptor *)(buffer+OffsetSize); if (buffer[DOT_11_DA_OFFSET+8] & 0x1) /* +8 for USB hdr */ boGroupAddr = true; /****************************************** * Set RTS/CTS mechanism ******************************************/ if (!boGroupAddr) { /* NOTE : If the protection mode is enabled and the MSDU will be fragmented, * the tx rates of MPDUs will all be DSSS rates. So it will not use * CTS-to-self in this case. CTS-To-self will only be used when without * fragmentation. -- 20050112 */ BodyLen = (u16)pT00->T00_frame_length; /* include 802.11 header */ BodyLen += 4; /* CRC */ if (BodyLen >= CURRENT_RTS_THRESHOLD) RTS_on = true; /* Using RTS */ else { if (pT01->T01_modulation_type) { /* Is using OFDM */ if (CURRENT_PROTECT_MECHANISM) /* Is using protect */ CTS_on = true; /* Using CTS */ } } } if (RTS_on || CTS_on) { if (pT01->T01_modulation_type) { /* Is using OFDM */ /* CTS duration * 2 SIFS + DATA transmit time + 1 ACK * ACK Rate : 24 Mega bps * ACK frame length = 14 bytes */ Duration = 2*DEFAULT_SIFSTIME + 2*PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION + ((BodyLen*8 + 22 + Rate*4 - 1)/(Rate*4))*Tsym + ((112 + 22 + 95)/96)*Tsym; } else { /* DSSS */ /* CTS duration * 2 SIFS + DATA transmit time + 1 ACK * Rate : ?? Mega bps * ACK frame length = 14 bytes */ if (pT01->T01_plcp_header_length) /* long preamble */ Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME*2; else Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*2; Duration += (((BodyLen + 14)*8 + Rate-1) / Rate + DEFAULT_SIFSTIME*2); } if (RTS_on) { if (pT01->T01_modulation_type) { /* Is using OFDM */ /* CTS + 1 SIFS + CTS duration * CTS Rate : 24 Mega bps * CTS frame length = 14 bytes */ Duration += (DEFAULT_SIFSTIME + PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION + ((112 + 22 + 95)/96)*Tsym); } else { /* CTS + 1 SIFS + CTS duration * CTS Rate : ?? Mega bps * CTS frame length = 14 bytes */ if (pT01->T01_plcp_header_length) /* long preamble */ Duration += LONG_PREAMBLE_PLUS_PLCPHEADER_TIME; else Duration += SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME; Duration += (((112 + Rate-1) / Rate) + DEFAULT_SIFSTIME); } } /* Set the value into USB descriptor */ pT01->T01_add_rts = RTS_on ? 1 : 0; pT01->T01_add_cts = CTS_on ? 1 : 0; pT01->T01_rts_cts_duration = Duration; } /****************************************** * Fill the more fragment descriptor ******************************************/ if (boGroupAddr) Duration = 0; else { for (i = pDes->FragmentCount-1; i > 0; i--) { NextBodyLen = (u16)pNextT00->T00_frame_length; NextBodyLen += 4; /* CRC */ if (pT01->T01_modulation_type) { /* OFDM * data transmit time + 3 SIFS + 2 ACK * Rate : ??Mega bps * ACK frame length = 14 bytes, tx rate = 24M */ Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION * 3; Duration += (((NextBodyLen*8 + 22 + Rate*4 - 1)/(Rate*4)) * Tsym + (((2*14)*8 + 22 + 95)/96)*Tsym + DEFAULT_SIFSTIME*3); } else { /* DSSS * data transmit time + 2 ACK + 3 SIFS * Rate : ??Mega bps * ACK frame length = 14 bytes * TODO : */ if (pT01->T01_plcp_header_length) /* long preamble */ Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME*3; else Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*3; Duration += (((NextBodyLen + (2*14))*8 + Rate-1) / Rate + DEFAULT_SIFSTIME*3); } ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */ /* ----20061009 add by anson's endian */ pNextT00->value = cpu_to_le32(pNextT00->value); pT01->value = cpu_to_le32(pT01->value); /* ----end 20061009 add by anson's endian */ buffer += OffsetSize; pT01 = (struct T01_descriptor *)(buffer+4); if (i != 1) /* The last fragment will not have the next fragment */ pNextT00 = (struct T00_descriptor *)(buffer+OffsetSize); } /******************************************* * Fill the last fragment descriptor *******************************************/ if (pT01->T01_modulation_type) { /* OFDM * 1 SIFS + 1 ACK * Rate : 24 Mega bps * ACK frame length = 14 bytes */ Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION; /* The Tx rate of ACK use 24M */ Duration += (((112 + 22 + 95)/96)*Tsym + DEFAULT_SIFSTIME); } else { /* DSSS * 1 ACK + 1 SIFS * Rate : ?? Mega bps * ACK frame length = 14 bytes(112 bits) */ if (pT01->T01_plcp_header_length) /* long preamble */ Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME; else Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME; Duration += ((112 + Rate-1)/Rate + DEFAULT_SIFSTIME); } } ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */ pT00->value = cpu_to_le32(pT00->value); pT01->value = cpu_to_le32(pT01->value); /* --end 20061009 add */ } /* The function return the 4n size of usb pk */ static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer) { struct T00_descriptor *pT00; struct wb35_mds *pMds = &adapter->Mds; u8 *buffer; u8 *src_buffer; u8 *pctmp; u16 Size = 0; u16 SizeLeft, CopySize, CopyLeft, stmp; u8 buf_index, FragmentCount = 0; /* Copy fragment body */ buffer = TargetBuffer; /* shift 8B usb + 24B 802.11 */ SizeLeft = pDes->buffer_total_size; buf_index = pDes->buffer_start_index; pT00 = (struct T00_descriptor *)buffer; while (SizeLeft) { pT00 = (struct T00_descriptor *)buffer; CopySize = SizeLeft; if (SizeLeft > pDes->FragmentThreshold) { CopySize = pDes->FragmentThreshold; pT00->T00_frame_length = 24 + CopySize; /* Set USB length */ } else pT00->T00_frame_length = 24 + SizeLeft; /* Set USB length */ SizeLeft -= CopySize; /* 1 Byte operation */ pctmp = (u8 *)(buffer + 8 + DOT_11_SEQUENCE_OFFSET); *pctmp &= 0xf0; *pctmp |= FragmentCount; /* 931130.5.m */ if (!FragmentCount) pT00->T00_first_mpdu = 1; buffer += 32; /* 8B usb + 24B 802.11 header */ Size += 32; /* Copy into buffer */ stmp = CopySize + 3; stmp &= ~0x03; /* 4n Alignment */ Size += stmp; /* Current 4n offset of mpdu */ while (CopySize) { /* Copy body */ src_buffer = pDes->buffer_address[buf_index]; CopyLeft = CopySize; if (CopySize >= pDes->buffer_size[buf_index]) { CopyLeft = pDes->buffer_size[buf_index]; /* Get the next buffer of descriptor */ buf_index++; buf_index %= MAX_DESCRIPTOR_BUFFER_INDEX; } else { u8 *pctmp = pDes->buffer_address[buf_index]; pctmp += CopySize; pDes->buffer_address[buf_index] = pctmp; pDes->buffer_size[buf_index] -= CopySize; } memcpy(buffer, src_buffer, CopyLeft); buffer += CopyLeft; CopySize -= CopyLeft; } /* 931130.5.n */ if (pMds->MicAdd) { if (!SizeLeft) { pMds->MicWriteAddress[pMds->MicWriteIndex] = buffer - pMds->MicAdd; pMds->MicWriteSize[pMds->MicWriteIndex] = pMds->MicAdd; pMds->MicAdd = 0; } else if (SizeLeft < 8) { /* 931130.5.p */ pMds->MicAdd = SizeLeft; pMds->MicWriteAddress[pMds->MicWriteIndex] = buffer - (8 - SizeLeft); pMds->MicWriteSize[pMds->MicWriteIndex] = 8 - SizeLeft; pMds->MicWriteIndex++; } } /* Does it need to generate the new header for next mpdu? */ if (SizeLeft) { buffer = TargetBuffer + Size; /* Get the next 4n start address */ memcpy(buffer, TargetBuffer, 32); /* Copy 8B USB +24B 802.11 */ pT00 = (struct T00_descriptor *)buffer; pT00->T00_first_mpdu = 0; } FragmentCount++; } pT00->T00_last_mpdu = 1; pT00->T00_IsLastMpdu = 1; buffer = (u8 *)pT00 + 8; /* +8 for USB hdr */ buffer[1] &= ~0x04; /* Clear more frag bit of 802.11 frame control */ pDes->FragmentCount = FragmentCount; /* Update the correct fragment number */ return Size; } static void Mds_HeaderCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer) { struct wb35_mds *pMds = &adapter->Mds; u8 *src_buffer = pDes->buffer_address[0]; /* 931130.5.g */ struct T00_descriptor *pT00; struct T01_descriptor *pT01; u16 stmp; u8 i, ctmp1, ctmp2, ctmpf; u16 FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD; stmp = pDes->buffer_total_size; /* * Set USB header 8 byte */ pT00 = (struct T00_descriptor *)TargetBuffer; TargetBuffer += 4; pT01 = (struct T01_descriptor *)TargetBuffer; TargetBuffer += 4; pT00->value = 0; /* Clear */ pT01->value = 0; /* Clear */ pT00->T00_tx_packet_id = pDes->Descriptor_ID; /* Set packet ID */ pT00->T00_header_length = 24; /* Set header length */ pT01->T01_retry_abort_ebable = 1; /* 921013 931130.5.h */ /* Key ID setup */ pT01->T01_wep_id = 0; FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; /* Do not fragment */ /* Copy full data, the 1'st buffer contain all the data 931130.5.j */ memcpy(TargetBuffer, src_buffer, DOT_11_MAC_HEADER_SIZE); /* Copy header */ pDes->buffer_address[0] = src_buffer + DOT_11_MAC_HEADER_SIZE; pDes->buffer_total_size -= DOT_11_MAC_HEADER_SIZE; pDes->buffer_size[0] = pDes->buffer_total_size; /* Set fragment threshold */ FragmentThreshold -= (DOT_11_MAC_HEADER_SIZE + 4); pDes->FragmentThreshold = FragmentThreshold; /* Set more frag bit */ TargetBuffer[1] |= 0x04; /* Set more frag bit */ /* * Set tx rate */ stmp = *(u16 *)(TargetBuffer+30); /* 2n alignment address */ /* Use basic rate */ ctmp1 = ctmpf = CURRENT_TX_RATE_FOR_MNG; pDes->TxRate = ctmp1; pr_debug("Tx rate =%x\n", ctmp1); pT01->T01_modulation_type = (ctmp1%3) ? 0 : 1; for (i = 0; i < 2; i++) { if (i == 1) ctmp1 = ctmpf; pMds->TxRate[pDes->Descriptor_ID][i] = ctmp1; /* backup the ta rate and fall back rate */ if (ctmp1 == 108) ctmp2 = 7; else if (ctmp1 == 96) ctmp2 = 6; /* Rate convert for USB */ else if (ctmp1 == 72) ctmp2 = 5; else if (ctmp1 == 48) ctmp2 = 4; else if (ctmp1 == 36) ctmp2 = 3; else if (ctmp1 == 24) ctmp2 = 2; else if (ctmp1 == 18) ctmp2 = 1; else if (ctmp1 == 12) ctmp2 = 0; else if (ctmp1 == 22) ctmp2 = 3; else if (ctmp1 == 11) ctmp2 = 2; else if (ctmp1 == 4) ctmp2 = 1; else ctmp2 = 0; /* if( ctmp1 == 2 ) or default */ if (i == 0) pT01->T01_transmit_rate = ctmp2; else pT01->T01_fall_back_rate = ctmp2; } /* * Set preamble type */ if ((pT01->T01_modulation_type == 0) && (pT01->T01_transmit_rate == 0)) /* RATE_1M */ pDes->PreambleMode = WLAN_PREAMBLE_TYPE_LONG; else pDes->PreambleMode = CURRENT_PREAMBLE_MODE; pT01->T01_plcp_header_length = pDes->PreambleMode; /* Set preamble */ } static void MLME_GetNextPacket(struct wbsoft_priv *adapter, struct wb35_descriptor *desc) { desc->InternalUsed = desc->buffer_start_index + desc->buffer_number; desc->InternalUsed %= MAX_DESCRIPTOR_BUFFER_INDEX; desc->buffer_address[desc->InternalUsed] = adapter->sMlmeFrame.pMMPDU; desc->buffer_size[desc->InternalUsed] = adapter->sMlmeFrame.len; desc->buffer_total_size += adapter->sMlmeFrame.len; desc->buffer_number++; desc->Type = adapter->sMlmeFrame.DataType; } static void MLMEfreeMMPDUBuffer(struct wbsoft_priv *adapter, s8 *pData) { int i; /* Reclaim the data buffer */ for (i = 0; i < MAX_NUM_TX_MMPDU; i++) { if (pData == (s8 *)&(adapter->sMlmeFrame.TxMMPDU[i])) break; } if (adapter->sMlmeFrame.TxMMPDUInUse[i]) adapter->sMlmeFrame.TxMMPDUInUse[i] = false; else { /* Something wrong PD43 Add debug code here??? */ } } static void MLME_SendComplete(struct wbsoft_priv *adapter, u8 PacketID, unsigned char SendOK) { /* Reclaim the data buffer */ adapter->sMlmeFrame.len = 0; MLMEfreeMMPDUBuffer(adapter, adapter->sMlmeFrame.pMMPDU); /* Return resource */ adapter->sMlmeFrame.IsInUsed = PACKET_FREE_TO_USE; } void Mds_Tx(struct wbsoft_priv *adapter) { struct hw_data *pHwData = &adapter->sHwData; struct wb35_mds *pMds = &adapter->Mds; struct wb35_descriptor TxDes; struct wb35_descriptor *pTxDes = &TxDes; u8 *XmitBufAddress; u16 XmitBufSize, PacketSize, stmp, CurrentSize, FragmentThreshold; u8 FillIndex, TxDesIndex, FragmentCount, FillCount; unsigned char BufferFilled = false; if (pMds->TxPause) return; if (!hal_driver_init_OK(pHwData)) return; /* Only one thread can be run here */ if (atomic_inc_return(&pMds->TxThreadCount) != 1) goto cleanup; /* Start to fill the data */ do { FillIndex = pMds->TxFillIndex; if (pMds->TxOwner[FillIndex]) { /* Is owned by software 0:Yes 1:No */ pr_debug("[Mds_Tx] Tx Owner is H/W.\n"); break; } XmitBufAddress = pMds->pTxBuffer + (MAX_USB_TX_BUFFER * FillIndex); /* Get buffer */ XmitBufSize = 0; FillCount = 0; do { PacketSize = adapter->sMlmeFrame.len; if (!PacketSize) break; /* For Check the buffer resource */ FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD; /* 931130.5.b */ FragmentCount = PacketSize/FragmentThreshold + 1; stmp = PacketSize + FragmentCount*32 + 8; /* 931130.5.c 8:MIC */ if ((XmitBufSize + stmp) >= MAX_USB_TX_BUFFER) { printk("[Mds_Tx] Excess max tx buffer.\n"); break; /* buffer is not enough */ } /* * Start transmitting */ BufferFilled = true; /* Leaves first u8 intact */ memset((u8 *)pTxDes + 1, 0, sizeof(struct wb35_descriptor) - 1); TxDesIndex = pMds->TxDesIndex; /* Get the current ID */ pTxDes->Descriptor_ID = TxDesIndex; pMds->TxDesFrom[TxDesIndex] = 2; /* Storing the information of source coming from */ pMds->TxDesIndex++; pMds->TxDesIndex %= MAX_USB_TX_DESCRIPTOR; MLME_GetNextPacket(adapter, pTxDes); /* Copy header. 8byte USB + 24byte 802.11Hdr. Set TxRate, Preamble type */ Mds_HeaderCopy(adapter, pTxDes, XmitBufAddress); /* For speed up Key setting */ if (pTxDes->EapFix) { pr_debug("35: EPA 4th frame detected. Size = %d\n", PacketSize); pHwData->IsKeyPreSet = 1; } /* Copy (fragment) frame body, and set USB, 802.11 hdr flag */ CurrentSize = Mds_BodyCopy(adapter, pTxDes, XmitBufAddress); /* Set RTS/CTS and Normal duration field into buffer */ Mds_DurationSet(adapter, pTxDes, XmitBufAddress); /* Shift to the next address */ XmitBufSize += CurrentSize; XmitBufAddress += CurrentSize; /* Get packet to transmit completed, 1:TESTSTA 2:MLME 3: Ndis data */ MLME_SendComplete(adapter, 0, true); /* Software TSC count 20060214 */ pMds->TxTsc++; if (pMds->TxTsc == 0) pMds->TxTsc_2++; FillCount++; /* 20060928 */ } while (HAL_USB_MODE_BURST(pHwData)); /* End of multiple MSDU copy loop. false = single true = multiple sending */ /* Move to the next one, if necessary */ if (BufferFilled) { /* size setting */ pMds->TxBufferSize[FillIndex] = XmitBufSize; /* 20060928 set Tx count */ pMds->TxCountInBuffer[FillIndex] = FillCount; /* Set owner flag */ pMds->TxOwner[FillIndex] = 1; pMds->TxFillIndex++; pMds->TxFillIndex %= MAX_USB_TX_BUFFER_NUMBER; BufferFilled = false; } else break; if (!PacketSize) /* No more pk for transmitting */ break; } while (true); /* * Start to send by lower module */ if (!pHwData->IsKeyPreSet) Wb35Tx_start(adapter); cleanup: atomic_dec(&pMds->TxThreadCount); } void Mds_SendComplete(struct wbsoft_priv *adapter, struct T02_descriptor *pT02) { struct wb35_mds *pMds = &adapter->Mds; struct hw_data *pHwData = &adapter->sHwData; u8 PacketId = (u8)pT02->T02_Tx_PktID; unsigned char SendOK = true; u8 RetryCount, TxRate; if (pT02->T02_IgnoreResult) /* Don't care the result */ return; if (pT02->T02_IsLastMpdu) { /* TODO: DTO -- get the retry count and fragment count */ /* Tx rate */ TxRate = pMds->TxRate[PacketId][0]; RetryCount = (u8)pT02->T02_MPDU_Cnt; if (pT02->value & FLAG_ERROR_TX_MASK) { SendOK = false; if (pT02->T02_transmit_abort || pT02->T02_out_of_MaxTxMSDULiftTime) { /* retry error */ pHwData->dto_tx_retry_count += (RetryCount+1); /* [for tx debug] */ if (RetryCount < 7) pHwData->tx_retry_count[RetryCount] += RetryCount; else pHwData->tx_retry_count[7] += RetryCount; pr_debug("dto_tx_retry_count =%d\n", pHwData->dto_tx_retry_count); MTO_SetTxCount(adapter, TxRate, RetryCount); } pHwData->dto_tx_frag_count += (RetryCount+1); /* [for tx debug] */ if (pT02->T02_transmit_abort_due_to_TBTT) pHwData->tx_TBTT_start_count++; if (pT02->T02_transmit_without_encryption_due_to_wep_on_false) pHwData->tx_WepOn_false_count++; if (pT02->T02_discard_due_to_null_wep_key) pHwData->tx_Null_key_count++; } else { if (pT02->T02_effective_transmission_rate) pHwData->tx_ETR_count++; MTO_SetTxCount(adapter, TxRate, RetryCount); } /* Clear send result buffer */ pMds->TxResult[PacketId] = 0; } else pMds->TxResult[PacketId] |= ((u16)(pT02->value & 0x0ffff)); }
gpl-2.0
JoinTheRealms/TF700-dualboot-stockbased
drivers/staging/winbond/mds.c
8118
17881
#include "mds_f.h" #include "mto.h" #include "wbhal.h" #include "wb35tx_f.h" unsigned char Mds_initial(struct wbsoft_priv *adapter) { struct wb35_mds *pMds = &adapter->Mds; pMds->TxPause = false; pMds->TxRTSThreshold = DEFAULT_RTSThreshold; pMds->TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; return hal_get_tx_buffer(&adapter->sHwData, &pMds->pTxBuffer); } static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *buffer) { struct T00_descriptor *pT00; struct T01_descriptor *pT01; u16 Duration, NextBodyLen, OffsetSize; u8 Rate, i; unsigned char CTS_on = false, RTS_on = false; struct T00_descriptor *pNextT00; u16 BodyLen = 0; unsigned char boGroupAddr = false; OffsetSize = pDes->FragmentThreshold + 32 + 3; OffsetSize &= ~0x03; Rate = pDes->TxRate >> 1; if (!Rate) Rate = 1; pT00 = (struct T00_descriptor *)buffer; pT01 = (struct T01_descriptor *)(buffer+4); pNextT00 = (struct T00_descriptor *)(buffer+OffsetSize); if (buffer[DOT_11_DA_OFFSET+8] & 0x1) /* +8 for USB hdr */ boGroupAddr = true; /****************************************** * Set RTS/CTS mechanism ******************************************/ if (!boGroupAddr) { /* NOTE : If the protection mode is enabled and the MSDU will be fragmented, * the tx rates of MPDUs will all be DSSS rates. So it will not use * CTS-to-self in this case. CTS-To-self will only be used when without * fragmentation. -- 20050112 */ BodyLen = (u16)pT00->T00_frame_length; /* include 802.11 header */ BodyLen += 4; /* CRC */ if (BodyLen >= CURRENT_RTS_THRESHOLD) RTS_on = true; /* Using RTS */ else { if (pT01->T01_modulation_type) { /* Is using OFDM */ if (CURRENT_PROTECT_MECHANISM) /* Is using protect */ CTS_on = true; /* Using CTS */ } } } if (RTS_on || CTS_on) { if (pT01->T01_modulation_type) { /* Is using OFDM */ /* CTS duration * 2 SIFS + DATA transmit time + 1 ACK * ACK Rate : 24 Mega bps * ACK frame length = 14 bytes */ Duration = 2*DEFAULT_SIFSTIME + 2*PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION + ((BodyLen*8 + 22 + Rate*4 - 1)/(Rate*4))*Tsym + ((112 + 22 + 95)/96)*Tsym; } else { /* DSSS */ /* CTS duration * 2 SIFS + DATA transmit time + 1 ACK * Rate : ?? Mega bps * ACK frame length = 14 bytes */ if (pT01->T01_plcp_header_length) /* long preamble */ Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME*2; else Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*2; Duration += (((BodyLen + 14)*8 + Rate-1) / Rate + DEFAULT_SIFSTIME*2); } if (RTS_on) { if (pT01->T01_modulation_type) { /* Is using OFDM */ /* CTS + 1 SIFS + CTS duration * CTS Rate : 24 Mega bps * CTS frame length = 14 bytes */ Duration += (DEFAULT_SIFSTIME + PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION + ((112 + 22 + 95)/96)*Tsym); } else { /* CTS + 1 SIFS + CTS duration * CTS Rate : ?? Mega bps * CTS frame length = 14 bytes */ if (pT01->T01_plcp_header_length) /* long preamble */ Duration += LONG_PREAMBLE_PLUS_PLCPHEADER_TIME; else Duration += SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME; Duration += (((112 + Rate-1) / Rate) + DEFAULT_SIFSTIME); } } /* Set the value into USB descriptor */ pT01->T01_add_rts = RTS_on ? 1 : 0; pT01->T01_add_cts = CTS_on ? 1 : 0; pT01->T01_rts_cts_duration = Duration; } /****************************************** * Fill the more fragment descriptor ******************************************/ if (boGroupAddr) Duration = 0; else { for (i = pDes->FragmentCount-1; i > 0; i--) { NextBodyLen = (u16)pNextT00->T00_frame_length; NextBodyLen += 4; /* CRC */ if (pT01->T01_modulation_type) { /* OFDM * data transmit time + 3 SIFS + 2 ACK * Rate : ??Mega bps * ACK frame length = 14 bytes, tx rate = 24M */ Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION * 3; Duration += (((NextBodyLen*8 + 22 + Rate*4 - 1)/(Rate*4)) * Tsym + (((2*14)*8 + 22 + 95)/96)*Tsym + DEFAULT_SIFSTIME*3); } else { /* DSSS * data transmit time + 2 ACK + 3 SIFS * Rate : ??Mega bps * ACK frame length = 14 bytes * TODO : */ if (pT01->T01_plcp_header_length) /* long preamble */ Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME*3; else Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*3; Duration += (((NextBodyLen + (2*14))*8 + Rate-1) / Rate + DEFAULT_SIFSTIME*3); } ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */ /* ----20061009 add by anson's endian */ pNextT00->value = cpu_to_le32(pNextT00->value); pT01->value = cpu_to_le32(pT01->value); /* ----end 20061009 add by anson's endian */ buffer += OffsetSize; pT01 = (struct T01_descriptor *)(buffer+4); if (i != 1) /* The last fragment will not have the next fragment */ pNextT00 = (struct T00_descriptor *)(buffer+OffsetSize); } /******************************************* * Fill the last fragment descriptor *******************************************/ if (pT01->T01_modulation_type) { /* OFDM * 1 SIFS + 1 ACK * Rate : 24 Mega bps * ACK frame length = 14 bytes */ Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION; /* The Tx rate of ACK use 24M */ Duration += (((112 + 22 + 95)/96)*Tsym + DEFAULT_SIFSTIME); } else { /* DSSS * 1 ACK + 1 SIFS * Rate : ?? Mega bps * ACK frame length = 14 bytes(112 bits) */ if (pT01->T01_plcp_header_length) /* long preamble */ Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME; else Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME; Duration += ((112 + Rate-1)/Rate + DEFAULT_SIFSTIME); } } ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */ pT00->value = cpu_to_le32(pT00->value); pT01->value = cpu_to_le32(pT01->value); /* --end 20061009 add */ } /* The function return the 4n size of usb pk */ static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer) { struct T00_descriptor *pT00; struct wb35_mds *pMds = &adapter->Mds; u8 *buffer; u8 *src_buffer; u8 *pctmp; u16 Size = 0; u16 SizeLeft, CopySize, CopyLeft, stmp; u8 buf_index, FragmentCount = 0; /* Copy fragment body */ buffer = TargetBuffer; /* shift 8B usb + 24B 802.11 */ SizeLeft = pDes->buffer_total_size; buf_index = pDes->buffer_start_index; pT00 = (struct T00_descriptor *)buffer; while (SizeLeft) { pT00 = (struct T00_descriptor *)buffer; CopySize = SizeLeft; if (SizeLeft > pDes->FragmentThreshold) { CopySize = pDes->FragmentThreshold; pT00->T00_frame_length = 24 + CopySize; /* Set USB length */ } else pT00->T00_frame_length = 24 + SizeLeft; /* Set USB length */ SizeLeft -= CopySize; /* 1 Byte operation */ pctmp = (u8 *)(buffer + 8 + DOT_11_SEQUENCE_OFFSET); *pctmp &= 0xf0; *pctmp |= FragmentCount; /* 931130.5.m */ if (!FragmentCount) pT00->T00_first_mpdu = 1; buffer += 32; /* 8B usb + 24B 802.11 header */ Size += 32; /* Copy into buffer */ stmp = CopySize + 3; stmp &= ~0x03; /* 4n Alignment */ Size += stmp; /* Current 4n offset of mpdu */ while (CopySize) { /* Copy body */ src_buffer = pDes->buffer_address[buf_index]; CopyLeft = CopySize; if (CopySize >= pDes->buffer_size[buf_index]) { CopyLeft = pDes->buffer_size[buf_index]; /* Get the next buffer of descriptor */ buf_index++; buf_index %= MAX_DESCRIPTOR_BUFFER_INDEX; } else { u8 *pctmp = pDes->buffer_address[buf_index]; pctmp += CopySize; pDes->buffer_address[buf_index] = pctmp; pDes->buffer_size[buf_index] -= CopySize; } memcpy(buffer, src_buffer, CopyLeft); buffer += CopyLeft; CopySize -= CopyLeft; } /* 931130.5.n */ if (pMds->MicAdd) { if (!SizeLeft) { pMds->MicWriteAddress[pMds->MicWriteIndex] = buffer - pMds->MicAdd; pMds->MicWriteSize[pMds->MicWriteIndex] = pMds->MicAdd; pMds->MicAdd = 0; } else if (SizeLeft < 8) { /* 931130.5.p */ pMds->MicAdd = SizeLeft; pMds->MicWriteAddress[pMds->MicWriteIndex] = buffer - (8 - SizeLeft); pMds->MicWriteSize[pMds->MicWriteIndex] = 8 - SizeLeft; pMds->MicWriteIndex++; } } /* Does it need to generate the new header for next mpdu? */ if (SizeLeft) { buffer = TargetBuffer + Size; /* Get the next 4n start address */ memcpy(buffer, TargetBuffer, 32); /* Copy 8B USB +24B 802.11 */ pT00 = (struct T00_descriptor *)buffer; pT00->T00_first_mpdu = 0; } FragmentCount++; } pT00->T00_last_mpdu = 1; pT00->T00_IsLastMpdu = 1; buffer = (u8 *)pT00 + 8; /* +8 for USB hdr */ buffer[1] &= ~0x04; /* Clear more frag bit of 802.11 frame control */ pDes->FragmentCount = FragmentCount; /* Update the correct fragment number */ return Size; } static void Mds_HeaderCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer) { struct wb35_mds *pMds = &adapter->Mds; u8 *src_buffer = pDes->buffer_address[0]; /* 931130.5.g */ struct T00_descriptor *pT00; struct T01_descriptor *pT01; u16 stmp; u8 i, ctmp1, ctmp2, ctmpf; u16 FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD; stmp = pDes->buffer_total_size; /* * Set USB header 8 byte */ pT00 = (struct T00_descriptor *)TargetBuffer; TargetBuffer += 4; pT01 = (struct T01_descriptor *)TargetBuffer; TargetBuffer += 4; pT00->value = 0; /* Clear */ pT01->value = 0; /* Clear */ pT00->T00_tx_packet_id = pDes->Descriptor_ID; /* Set packet ID */ pT00->T00_header_length = 24; /* Set header length */ pT01->T01_retry_abort_ebable = 1; /* 921013 931130.5.h */ /* Key ID setup */ pT01->T01_wep_id = 0; FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; /* Do not fragment */ /* Copy full data, the 1'st buffer contain all the data 931130.5.j */ memcpy(TargetBuffer, src_buffer, DOT_11_MAC_HEADER_SIZE); /* Copy header */ pDes->buffer_address[0] = src_buffer + DOT_11_MAC_HEADER_SIZE; pDes->buffer_total_size -= DOT_11_MAC_HEADER_SIZE; pDes->buffer_size[0] = pDes->buffer_total_size; /* Set fragment threshold */ FragmentThreshold -= (DOT_11_MAC_HEADER_SIZE + 4); pDes->FragmentThreshold = FragmentThreshold; /* Set more frag bit */ TargetBuffer[1] |= 0x04; /* Set more frag bit */ /* * Set tx rate */ stmp = *(u16 *)(TargetBuffer+30); /* 2n alignment address */ /* Use basic rate */ ctmp1 = ctmpf = CURRENT_TX_RATE_FOR_MNG; pDes->TxRate = ctmp1; pr_debug("Tx rate =%x\n", ctmp1); pT01->T01_modulation_type = (ctmp1%3) ? 0 : 1; for (i = 0; i < 2; i++) { if (i == 1) ctmp1 = ctmpf; pMds->TxRate[pDes->Descriptor_ID][i] = ctmp1; /* backup the ta rate and fall back rate */ if (ctmp1 == 108) ctmp2 = 7; else if (ctmp1 == 96) ctmp2 = 6; /* Rate convert for USB */ else if (ctmp1 == 72) ctmp2 = 5; else if (ctmp1 == 48) ctmp2 = 4; else if (ctmp1 == 36) ctmp2 = 3; else if (ctmp1 == 24) ctmp2 = 2; else if (ctmp1 == 18) ctmp2 = 1; else if (ctmp1 == 12) ctmp2 = 0; else if (ctmp1 == 22) ctmp2 = 3; else if (ctmp1 == 11) ctmp2 = 2; else if (ctmp1 == 4) ctmp2 = 1; else ctmp2 = 0; /* if( ctmp1 == 2 ) or default */ if (i == 0) pT01->T01_transmit_rate = ctmp2; else pT01->T01_fall_back_rate = ctmp2; } /* * Set preamble type */ if ((pT01->T01_modulation_type == 0) && (pT01->T01_transmit_rate == 0)) /* RATE_1M */ pDes->PreambleMode = WLAN_PREAMBLE_TYPE_LONG; else pDes->PreambleMode = CURRENT_PREAMBLE_MODE; pT01->T01_plcp_header_length = pDes->PreambleMode; /* Set preamble */ } static void MLME_GetNextPacket(struct wbsoft_priv *adapter, struct wb35_descriptor *desc) { desc->InternalUsed = desc->buffer_start_index + desc->buffer_number; desc->InternalUsed %= MAX_DESCRIPTOR_BUFFER_INDEX; desc->buffer_address[desc->InternalUsed] = adapter->sMlmeFrame.pMMPDU; desc->buffer_size[desc->InternalUsed] = adapter->sMlmeFrame.len; desc->buffer_total_size += adapter->sMlmeFrame.len; desc->buffer_number++; desc->Type = adapter->sMlmeFrame.DataType; } static void MLMEfreeMMPDUBuffer(struct wbsoft_priv *adapter, s8 *pData) { int i; /* Reclaim the data buffer */ for (i = 0; i < MAX_NUM_TX_MMPDU; i++) { if (pData == (s8 *)&(adapter->sMlmeFrame.TxMMPDU[i])) break; } if (adapter->sMlmeFrame.TxMMPDUInUse[i]) adapter->sMlmeFrame.TxMMPDUInUse[i] = false; else { /* Something wrong PD43 Add debug code here??? */ } } static void MLME_SendComplete(struct wbsoft_priv *adapter, u8 PacketID, unsigned char SendOK) { /* Reclaim the data buffer */ adapter->sMlmeFrame.len = 0; MLMEfreeMMPDUBuffer(adapter, adapter->sMlmeFrame.pMMPDU); /* Return resource */ adapter->sMlmeFrame.IsInUsed = PACKET_FREE_TO_USE; } void Mds_Tx(struct wbsoft_priv *adapter) { struct hw_data *pHwData = &adapter->sHwData; struct wb35_mds *pMds = &adapter->Mds; struct wb35_descriptor TxDes; struct wb35_descriptor *pTxDes = &TxDes; u8 *XmitBufAddress; u16 XmitBufSize, PacketSize, stmp, CurrentSize, FragmentThreshold; u8 FillIndex, TxDesIndex, FragmentCount, FillCount; unsigned char BufferFilled = false; if (pMds->TxPause) return; if (!hal_driver_init_OK(pHwData)) return; /* Only one thread can be run here */ if (atomic_inc_return(&pMds->TxThreadCount) != 1) goto cleanup; /* Start to fill the data */ do { FillIndex = pMds->TxFillIndex; if (pMds->TxOwner[FillIndex]) { /* Is owned by software 0:Yes 1:No */ pr_debug("[Mds_Tx] Tx Owner is H/W.\n"); break; } XmitBufAddress = pMds->pTxBuffer + (MAX_USB_TX_BUFFER * FillIndex); /* Get buffer */ XmitBufSize = 0; FillCount = 0; do { PacketSize = adapter->sMlmeFrame.len; if (!PacketSize) break; /* For Check the buffer resource */ FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD; /* 931130.5.b */ FragmentCount = PacketSize/FragmentThreshold + 1; stmp = PacketSize + FragmentCount*32 + 8; /* 931130.5.c 8:MIC */ if ((XmitBufSize + stmp) >= MAX_USB_TX_BUFFER) { printk("[Mds_Tx] Excess max tx buffer.\n"); break; /* buffer is not enough */ } /* * Start transmitting */ BufferFilled = true; /* Leaves first u8 intact */ memset((u8 *)pTxDes + 1, 0, sizeof(struct wb35_descriptor) - 1); TxDesIndex = pMds->TxDesIndex; /* Get the current ID */ pTxDes->Descriptor_ID = TxDesIndex; pMds->TxDesFrom[TxDesIndex] = 2; /* Storing the information of source coming from */ pMds->TxDesIndex++; pMds->TxDesIndex %= MAX_USB_TX_DESCRIPTOR; MLME_GetNextPacket(adapter, pTxDes); /* Copy header. 8byte USB + 24byte 802.11Hdr. Set TxRate, Preamble type */ Mds_HeaderCopy(adapter, pTxDes, XmitBufAddress); /* For speed up Key setting */ if (pTxDes->EapFix) { pr_debug("35: EPA 4th frame detected. Size = %d\n", PacketSize); pHwData->IsKeyPreSet = 1; } /* Copy (fragment) frame body, and set USB, 802.11 hdr flag */ CurrentSize = Mds_BodyCopy(adapter, pTxDes, XmitBufAddress); /* Set RTS/CTS and Normal duration field into buffer */ Mds_DurationSet(adapter, pTxDes, XmitBufAddress); /* Shift to the next address */ XmitBufSize += CurrentSize; XmitBufAddress += CurrentSize; /* Get packet to transmit completed, 1:TESTSTA 2:MLME 3: Ndis data */ MLME_SendComplete(adapter, 0, true); /* Software TSC count 20060214 */ pMds->TxTsc++; if (pMds->TxTsc == 0) pMds->TxTsc_2++; FillCount++; /* 20060928 */ } while (HAL_USB_MODE_BURST(pHwData)); /* End of multiple MSDU copy loop. false = single true = multiple sending */ /* Move to the next one, if necessary */ if (BufferFilled) { /* size setting */ pMds->TxBufferSize[FillIndex] = XmitBufSize; /* 20060928 set Tx count */ pMds->TxCountInBuffer[FillIndex] = FillCount; /* Set owner flag */ pMds->TxOwner[FillIndex] = 1; pMds->TxFillIndex++; pMds->TxFillIndex %= MAX_USB_TX_BUFFER_NUMBER; BufferFilled = false; } else break; if (!PacketSize) /* No more pk for transmitting */ break; } while (true); /* * Start to send by lower module */ if (!pHwData->IsKeyPreSet) Wb35Tx_start(adapter); cleanup: atomic_dec(&pMds->TxThreadCount); } void Mds_SendComplete(struct wbsoft_priv *adapter, struct T02_descriptor *pT02) { struct wb35_mds *pMds = &adapter->Mds; struct hw_data *pHwData = &adapter->sHwData; u8 PacketId = (u8)pT02->T02_Tx_PktID; unsigned char SendOK = true; u8 RetryCount, TxRate; if (pT02->T02_IgnoreResult) /* Don't care the result */ return; if (pT02->T02_IsLastMpdu) { /* TODO: DTO -- get the retry count and fragment count */ /* Tx rate */ TxRate = pMds->TxRate[PacketId][0]; RetryCount = (u8)pT02->T02_MPDU_Cnt; if (pT02->value & FLAG_ERROR_TX_MASK) { SendOK = false; if (pT02->T02_transmit_abort || pT02->T02_out_of_MaxTxMSDULiftTime) { /* retry error */ pHwData->dto_tx_retry_count += (RetryCount+1); /* [for tx debug] */ if (RetryCount < 7) pHwData->tx_retry_count[RetryCount] += RetryCount; else pHwData->tx_retry_count[7] += RetryCount; pr_debug("dto_tx_retry_count =%d\n", pHwData->dto_tx_retry_count); MTO_SetTxCount(adapter, TxRate, RetryCount); } pHwData->dto_tx_frag_count += (RetryCount+1); /* [for tx debug] */ if (pT02->T02_transmit_abort_due_to_TBTT) pHwData->tx_TBTT_start_count++; if (pT02->T02_transmit_without_encryption_due_to_wep_on_false) pHwData->tx_WepOn_false_count++; if (pT02->T02_discard_due_to_null_wep_key) pHwData->tx_Null_key_count++; } else { if (pT02->T02_effective_transmission_rate) pHwData->tx_ETR_count++; MTO_SetTxCount(adapter, TxRate, RetryCount); } /* Clear send result buffer */ pMds->TxResult[PacketId] = 0; } else pMds->TxResult[PacketId] |= ((u16)(pT02->value & 0x0ffff)); }
gpl-2.0
arcardinal/kernel_lge_g3
drivers/net/ethernet/neterion/vxge/vxge-ethtool.c
8118
41400
/****************************************************************************** * This software may be used and distributed according to the terms of * the GNU General Public License (GPL), incorporated herein by reference. * Drivers based on or derived from this code fall under the GPL and must * retain the authorship, copyright and license notice. This file is not * a complete program and may only be used when the entire operating * system is licensed under the GPL. * See the file COPYING in this distribution for more information. * * vxge-ethtool.c: Driver for Exar Corp's X3100 Series 10GbE PCIe I/O * Virtualized Server Adapter. * Copyright(c) 2002-2010 Exar Corp. ******************************************************************************/ #include <linux/ethtool.h> #include <linux/slab.h> #include <linux/pci.h> #include <linux/etherdevice.h> #include "vxge-ethtool.h" /** * vxge_ethtool_sset - Sets different link parameters. * @dev: device pointer. * @info: pointer to the structure with parameters given by ethtool to set * link information. * * The function sets different link parameters provided by the user onto * the NIC. * Return value: * 0 on success. */ static int vxge_ethtool_sset(struct net_device *dev, struct ethtool_cmd *info) { /* We currently only support 10Gb/FULL */ if ((info->autoneg == AUTONEG_ENABLE) || (ethtool_cmd_speed(info) != SPEED_10000) || (info->duplex != DUPLEX_FULL)) return -EINVAL; return 0; } /** * vxge_ethtool_gset - Return link specific information. * @dev: device pointer. * @info: pointer to the structure with parameters given by ethtool * to return link information. * * Returns link specific information like speed, duplex etc.. to ethtool. * Return value : * return 0 on success. */ static int vxge_ethtool_gset(struct net_device *dev, struct ethtool_cmd *info) { info->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); info->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE); info->port = PORT_FIBRE; info->transceiver = XCVR_EXTERNAL; if (netif_carrier_ok(dev)) { ethtool_cmd_speed_set(info, SPEED_10000); info->duplex = DUPLEX_FULL; } else { ethtool_cmd_speed_set(info, -1); info->duplex = -1; } info->autoneg = AUTONEG_DISABLE; return 0; } /** * vxge_ethtool_gdrvinfo - Returns driver specific information. * @dev: device pointer. * @info: pointer to the structure with parameters given by ethtool to * return driver information. * * Returns driver specefic information like name, version etc.. to ethtool. */ static void vxge_ethtool_gdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct vxgedev *vdev = netdev_priv(dev); strlcpy(info->driver, VXGE_DRIVER_NAME, sizeof(VXGE_DRIVER_NAME)); strlcpy(info->version, DRV_VERSION, sizeof(DRV_VERSION)); strlcpy(info->fw_version, vdev->fw_version, VXGE_HW_FW_STRLEN); strlcpy(info->bus_info, pci_name(vdev->pdev), sizeof(info->bus_info)); info->regdump_len = sizeof(struct vxge_hw_vpath_reg) * vdev->no_of_vpath; info->n_stats = STAT_LEN; } /** * vxge_ethtool_gregs - dumps the entire space of Titan into the buffer. * @dev: device pointer. * @regs: pointer to the structure with parameters given by ethtool for * dumping the registers. * @reg_space: The input argumnet into which all the registers are dumped. * * Dumps the vpath register space of Titan NIC into the user given * buffer area. */ static void vxge_ethtool_gregs(struct net_device *dev, struct ethtool_regs *regs, void *space) { int index, offset; enum vxge_hw_status status; u64 reg; u64 *reg_space = (u64 *)space; struct vxgedev *vdev = netdev_priv(dev); struct __vxge_hw_device *hldev = vdev->devh; regs->len = sizeof(struct vxge_hw_vpath_reg) * vdev->no_of_vpath; regs->version = vdev->pdev->subsystem_device; for (index = 0; index < vdev->no_of_vpath; index++) { for (offset = 0; offset < sizeof(struct vxge_hw_vpath_reg); offset += 8) { status = vxge_hw_mgmt_reg_read(hldev, vxge_hw_mgmt_reg_type_vpath, vdev->vpaths[index].device_id, offset, &reg); if (status != VXGE_HW_OK) { vxge_debug_init(VXGE_ERR, "%s:%d Getting reg dump Failed", __func__, __LINE__); return; } *reg_space++ = reg; } } } /** * vxge_ethtool_idnic - To physically identify the nic on the system. * @dev : device pointer. * @state : requested LED state * * Used to physically identify the NIC on the system. * 0 on success */ static int vxge_ethtool_idnic(struct net_device *dev, enum ethtool_phys_id_state state) { struct vxgedev *vdev = netdev_priv(dev); struct __vxge_hw_device *hldev = vdev->devh; switch (state) { case ETHTOOL_ID_ACTIVE: vxge_hw_device_flick_link_led(hldev, VXGE_FLICKER_ON); break; case ETHTOOL_ID_INACTIVE: vxge_hw_device_flick_link_led(hldev, VXGE_FLICKER_OFF); break; default: return -EINVAL; } return 0; } /** * vxge_ethtool_getpause_data - Pause frame frame generation and reception. * @dev : device pointer. * @ep : pointer to the structure with pause parameters given by ethtool. * Description: * Returns the Pause frame generation and reception capability of the NIC. * Return value: * void */ static void vxge_ethtool_getpause_data(struct net_device *dev, struct ethtool_pauseparam *ep) { struct vxgedev *vdev = netdev_priv(dev); struct __vxge_hw_device *hldev = vdev->devh; vxge_hw_device_getpause_data(hldev, 0, &ep->tx_pause, &ep->rx_pause); } /** * vxge_ethtool_setpause_data - set/reset pause frame generation. * @dev : device pointer. * @ep : pointer to the structure with pause parameters given by ethtool. * Description: * It can be used to set or reset Pause frame generation or reception * support of the NIC. * Return value: * int, returns 0 on Success */ static int vxge_ethtool_setpause_data(struct net_device *dev, struct ethtool_pauseparam *ep) { struct vxgedev *vdev = netdev_priv(dev); struct __vxge_hw_device *hldev = vdev->devh; vxge_hw_device_setpause_data(hldev, 0, ep->tx_pause, ep->rx_pause); vdev->config.tx_pause_enable = ep->tx_pause; vdev->config.rx_pause_enable = ep->rx_pause; return 0; } static void vxge_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *estats, u64 *tmp_stats) { int j, k; enum vxge_hw_status status; enum vxge_hw_status swstatus; struct vxge_vpath *vpath = NULL; struct vxgedev *vdev = netdev_priv(dev); struct __vxge_hw_device *hldev = vdev->devh; struct vxge_hw_xmac_stats *xmac_stats; struct vxge_hw_device_stats_sw_info *sw_stats; struct vxge_hw_device_stats_hw_info *hw_stats; u64 *ptr = tmp_stats; memset(tmp_stats, 0, vxge_ethtool_get_sset_count(dev, ETH_SS_STATS) * sizeof(u64)); xmac_stats = kzalloc(sizeof(struct vxge_hw_xmac_stats), GFP_KERNEL); if (xmac_stats == NULL) { vxge_debug_init(VXGE_ERR, "%s : %d Memory Allocation failed for xmac_stats", __func__, __LINE__); return; } sw_stats = kzalloc(sizeof(struct vxge_hw_device_stats_sw_info), GFP_KERNEL); if (sw_stats == NULL) { kfree(xmac_stats); vxge_debug_init(VXGE_ERR, "%s : %d Memory Allocation failed for sw_stats", __func__, __LINE__); return; } hw_stats = kzalloc(sizeof(struct vxge_hw_device_stats_hw_info), GFP_KERNEL); if (hw_stats == NULL) { kfree(xmac_stats); kfree(sw_stats); vxge_debug_init(VXGE_ERR, "%s : %d Memory Allocation failed for hw_stats", __func__, __LINE__); return; } *ptr++ = 0; status = vxge_hw_device_xmac_stats_get(hldev, xmac_stats); if (status != VXGE_HW_OK) { if (status != VXGE_HW_ERR_PRIVILAGED_OPEARATION) { vxge_debug_init(VXGE_ERR, "%s : %d Failure in getting xmac stats", __func__, __LINE__); } } swstatus = vxge_hw_driver_stats_get(hldev, sw_stats); if (swstatus != VXGE_HW_OK) { vxge_debug_init(VXGE_ERR, "%s : %d Failure in getting sw stats", __func__, __LINE__); } status = vxge_hw_device_stats_get(hldev, hw_stats); if (status != VXGE_HW_OK) { vxge_debug_init(VXGE_ERR, "%s : %d hw_stats_get error", __func__, __LINE__); } for (k = 0; k < vdev->no_of_vpath; k++) { struct vxge_hw_vpath_stats_hw_info *vpath_info; vpath = &vdev->vpaths[k]; j = vpath->device_id; vpath_info = hw_stats->vpath_info[j]; if (!vpath_info) { memset(ptr, 0, (VXGE_HW_VPATH_TX_STATS_LEN + VXGE_HW_VPATH_RX_STATS_LEN) * sizeof(u64)); ptr += (VXGE_HW_VPATH_TX_STATS_LEN + VXGE_HW_VPATH_RX_STATS_LEN); continue; } *ptr++ = vpath_info->tx_stats.tx_ttl_eth_frms; *ptr++ = vpath_info->tx_stats.tx_ttl_eth_octets; *ptr++ = vpath_info->tx_stats.tx_data_octets; *ptr++ = vpath_info->tx_stats.tx_mcast_frms; *ptr++ = vpath_info->tx_stats.tx_bcast_frms; *ptr++ = vpath_info->tx_stats.tx_ucast_frms; *ptr++ = vpath_info->tx_stats.tx_tagged_frms; *ptr++ = vpath_info->tx_stats.tx_vld_ip; *ptr++ = vpath_info->tx_stats.tx_vld_ip_octets; *ptr++ = vpath_info->tx_stats.tx_icmp; *ptr++ = vpath_info->tx_stats.tx_tcp; *ptr++ = vpath_info->tx_stats.tx_rst_tcp; *ptr++ = vpath_info->tx_stats.tx_udp; *ptr++ = vpath_info->tx_stats.tx_unknown_protocol; *ptr++ = vpath_info->tx_stats.tx_lost_ip; *ptr++ = vpath_info->tx_stats.tx_parse_error; *ptr++ = vpath_info->tx_stats.tx_tcp_offload; *ptr++ = vpath_info->tx_stats.tx_retx_tcp_offload; *ptr++ = vpath_info->tx_stats.tx_lost_ip_offload; *ptr++ = vpath_info->rx_stats.rx_ttl_eth_frms; *ptr++ = vpath_info->rx_stats.rx_vld_frms; *ptr++ = vpath_info->rx_stats.rx_offload_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_eth_octets; *ptr++ = vpath_info->rx_stats.rx_data_octets; *ptr++ = vpath_info->rx_stats.rx_offload_octets; *ptr++ = vpath_info->rx_stats.rx_vld_mcast_frms; *ptr++ = vpath_info->rx_stats.rx_vld_bcast_frms; *ptr++ = vpath_info->rx_stats.rx_accepted_ucast_frms; *ptr++ = vpath_info->rx_stats.rx_accepted_nucast_frms; *ptr++ = vpath_info->rx_stats.rx_tagged_frms; *ptr++ = vpath_info->rx_stats.rx_long_frms; *ptr++ = vpath_info->rx_stats.rx_usized_frms; *ptr++ = vpath_info->rx_stats.rx_osized_frms; *ptr++ = vpath_info->rx_stats.rx_frag_frms; *ptr++ = vpath_info->rx_stats.rx_jabber_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_64_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_65_127_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_128_255_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_256_511_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_512_1023_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_1024_1518_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_1519_4095_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_4096_8191_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_8192_max_frms; *ptr++ = vpath_info->rx_stats.rx_ttl_gt_max_frms; *ptr++ = vpath_info->rx_stats.rx_ip; *ptr++ = vpath_info->rx_stats.rx_accepted_ip; *ptr++ = vpath_info->rx_stats.rx_ip_octets; *ptr++ = vpath_info->rx_stats.rx_err_ip; *ptr++ = vpath_info->rx_stats.rx_icmp; *ptr++ = vpath_info->rx_stats.rx_tcp; *ptr++ = vpath_info->rx_stats.rx_udp; *ptr++ = vpath_info->rx_stats.rx_err_tcp; *ptr++ = vpath_info->rx_stats.rx_lost_frms; *ptr++ = vpath_info->rx_stats.rx_lost_ip; *ptr++ = vpath_info->rx_stats.rx_lost_ip_offload; *ptr++ = vpath_info->rx_stats.rx_various_discard; *ptr++ = vpath_info->rx_stats.rx_sleep_discard; *ptr++ = vpath_info->rx_stats.rx_red_discard; *ptr++ = vpath_info->rx_stats.rx_queue_full_discard; *ptr++ = vpath_info->rx_stats.rx_mpa_ok_frms; } *ptr++ = 0; for (k = 0; k < vdev->max_config_port; k++) { *ptr++ = xmac_stats->aggr_stats[k].tx_frms; *ptr++ = xmac_stats->aggr_stats[k].tx_data_octets; *ptr++ = xmac_stats->aggr_stats[k].tx_mcast_frms; *ptr++ = xmac_stats->aggr_stats[k].tx_bcast_frms; *ptr++ = xmac_stats->aggr_stats[k].tx_discarded_frms; *ptr++ = xmac_stats->aggr_stats[k].tx_errored_frms; *ptr++ = xmac_stats->aggr_stats[k].rx_frms; *ptr++ = xmac_stats->aggr_stats[k].rx_data_octets; *ptr++ = xmac_stats->aggr_stats[k].rx_mcast_frms; *ptr++ = xmac_stats->aggr_stats[k].rx_bcast_frms; *ptr++ = xmac_stats->aggr_stats[k].rx_discarded_frms; *ptr++ = xmac_stats->aggr_stats[k].rx_errored_frms; *ptr++ = xmac_stats->aggr_stats[k].rx_unknown_slow_proto_frms; } *ptr++ = 0; for (k = 0; k < vdev->max_config_port; k++) { *ptr++ = xmac_stats->port_stats[k].tx_ttl_frms; *ptr++ = xmac_stats->port_stats[k].tx_ttl_octets; *ptr++ = xmac_stats->port_stats[k].tx_data_octets; *ptr++ = xmac_stats->port_stats[k].tx_mcast_frms; *ptr++ = xmac_stats->port_stats[k].tx_bcast_frms; *ptr++ = xmac_stats->port_stats[k].tx_ucast_frms; *ptr++ = xmac_stats->port_stats[k].tx_tagged_frms; *ptr++ = xmac_stats->port_stats[k].tx_vld_ip; *ptr++ = xmac_stats->port_stats[k].tx_vld_ip_octets; *ptr++ = xmac_stats->port_stats[k].tx_icmp; *ptr++ = xmac_stats->port_stats[k].tx_tcp; *ptr++ = xmac_stats->port_stats[k].tx_rst_tcp; *ptr++ = xmac_stats->port_stats[k].tx_udp; *ptr++ = xmac_stats->port_stats[k].tx_parse_error; *ptr++ = xmac_stats->port_stats[k].tx_unknown_protocol; *ptr++ = xmac_stats->port_stats[k].tx_pause_ctrl_frms; *ptr++ = xmac_stats->port_stats[k].tx_marker_pdu_frms; *ptr++ = xmac_stats->port_stats[k].tx_lacpdu_frms; *ptr++ = xmac_stats->port_stats[k].tx_drop_ip; *ptr++ = xmac_stats->port_stats[k].tx_marker_resp_pdu_frms; *ptr++ = xmac_stats->port_stats[k].tx_xgmii_char2_match; *ptr++ = xmac_stats->port_stats[k].tx_xgmii_char1_match; *ptr++ = xmac_stats->port_stats[k].tx_xgmii_column2_match; *ptr++ = xmac_stats->port_stats[k].tx_xgmii_column1_match; *ptr++ = xmac_stats->port_stats[k].tx_any_err_frms; *ptr++ = xmac_stats->port_stats[k].tx_drop_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_frms; *ptr++ = xmac_stats->port_stats[k].rx_vld_frms; *ptr++ = xmac_stats->port_stats[k].rx_offload_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_octets; *ptr++ = xmac_stats->port_stats[k].rx_data_octets; *ptr++ = xmac_stats->port_stats[k].rx_offload_octets; *ptr++ = xmac_stats->port_stats[k].rx_vld_mcast_frms; *ptr++ = xmac_stats->port_stats[k].rx_vld_bcast_frms; *ptr++ = xmac_stats->port_stats[k].rx_accepted_ucast_frms; *ptr++ = xmac_stats->port_stats[k].rx_accepted_nucast_frms; *ptr++ = xmac_stats->port_stats[k].rx_tagged_frms; *ptr++ = xmac_stats->port_stats[k].rx_long_frms; *ptr++ = xmac_stats->port_stats[k].rx_usized_frms; *ptr++ = xmac_stats->port_stats[k].rx_osized_frms; *ptr++ = xmac_stats->port_stats[k].rx_frag_frms; *ptr++ = xmac_stats->port_stats[k].rx_jabber_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_64_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_65_127_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_128_255_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_256_511_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_512_1023_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_1024_1518_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_1519_4095_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_4096_8191_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_8192_max_frms; *ptr++ = xmac_stats->port_stats[k].rx_ttl_gt_max_frms; *ptr++ = xmac_stats->port_stats[k].rx_ip; *ptr++ = xmac_stats->port_stats[k].rx_accepted_ip; *ptr++ = xmac_stats->port_stats[k].rx_ip_octets; *ptr++ = xmac_stats->port_stats[k].rx_err_ip; *ptr++ = xmac_stats->port_stats[k].rx_icmp; *ptr++ = xmac_stats->port_stats[k].rx_tcp; *ptr++ = xmac_stats->port_stats[k].rx_udp; *ptr++ = xmac_stats->port_stats[k].rx_err_tcp; *ptr++ = xmac_stats->port_stats[k].rx_pause_count; *ptr++ = xmac_stats->port_stats[k].rx_pause_ctrl_frms; *ptr++ = xmac_stats->port_stats[k].rx_unsup_ctrl_frms; *ptr++ = xmac_stats->port_stats[k].rx_fcs_err_frms; *ptr++ = xmac_stats->port_stats[k].rx_in_rng_len_err_frms; *ptr++ = xmac_stats->port_stats[k].rx_out_rng_len_err_frms; *ptr++ = xmac_stats->port_stats[k].rx_drop_frms; *ptr++ = xmac_stats->port_stats[k].rx_discarded_frms; *ptr++ = xmac_stats->port_stats[k].rx_drop_ip; *ptr++ = xmac_stats->port_stats[k].rx_drop_udp; *ptr++ = xmac_stats->port_stats[k].rx_marker_pdu_frms; *ptr++ = xmac_stats->port_stats[k].rx_lacpdu_frms; *ptr++ = xmac_stats->port_stats[k].rx_unknown_pdu_frms; *ptr++ = xmac_stats->port_stats[k].rx_marker_resp_pdu_frms; *ptr++ = xmac_stats->port_stats[k].rx_fcs_discard; *ptr++ = xmac_stats->port_stats[k].rx_illegal_pdu_frms; *ptr++ = xmac_stats->port_stats[k].rx_switch_discard; *ptr++ = xmac_stats->port_stats[k].rx_len_discard; *ptr++ = xmac_stats->port_stats[k].rx_rpa_discard; *ptr++ = xmac_stats->port_stats[k].rx_l2_mgmt_discard; *ptr++ = xmac_stats->port_stats[k].rx_rts_discard; *ptr++ = xmac_stats->port_stats[k].rx_trash_discard; *ptr++ = xmac_stats->port_stats[k].rx_buff_full_discard; *ptr++ = xmac_stats->port_stats[k].rx_red_discard; *ptr++ = xmac_stats->port_stats[k].rx_xgmii_ctrl_err_cnt; *ptr++ = xmac_stats->port_stats[k].rx_xgmii_data_err_cnt; *ptr++ = xmac_stats->port_stats[k].rx_xgmii_char1_match; *ptr++ = xmac_stats->port_stats[k].rx_xgmii_err_sym; *ptr++ = xmac_stats->port_stats[k].rx_xgmii_column1_match; *ptr++ = xmac_stats->port_stats[k].rx_xgmii_char2_match; *ptr++ = xmac_stats->port_stats[k].rx_local_fault; *ptr++ = xmac_stats->port_stats[k].rx_xgmii_column2_match; *ptr++ = xmac_stats->port_stats[k].rx_jettison; *ptr++ = xmac_stats->port_stats[k].rx_remote_fault; } *ptr++ = 0; for (k = 0; k < vdev->no_of_vpath; k++) { struct vxge_hw_vpath_stats_sw_info *vpath_info; vpath = &vdev->vpaths[k]; j = vpath->device_id; vpath_info = (struct vxge_hw_vpath_stats_sw_info *) &sw_stats->vpath_info[j]; *ptr++ = vpath_info->soft_reset_cnt; *ptr++ = vpath_info->error_stats.unknown_alarms; *ptr++ = vpath_info->error_stats.network_sustained_fault; *ptr++ = vpath_info->error_stats.network_sustained_ok; *ptr++ = vpath_info->error_stats.kdfcctl_fifo0_overwrite; *ptr++ = vpath_info->error_stats.kdfcctl_fifo0_poison; *ptr++ = vpath_info->error_stats.kdfcctl_fifo0_dma_error; *ptr++ = vpath_info->error_stats.dblgen_fifo0_overflow; *ptr++ = vpath_info->error_stats.statsb_pif_chain_error; *ptr++ = vpath_info->error_stats.statsb_drop_timeout; *ptr++ = vpath_info->error_stats.target_illegal_access; *ptr++ = vpath_info->error_stats.ini_serr_det; *ptr++ = vpath_info->error_stats.prc_ring_bumps; *ptr++ = vpath_info->error_stats.prc_rxdcm_sc_err; *ptr++ = vpath_info->error_stats.prc_rxdcm_sc_abort; *ptr++ = vpath_info->error_stats.prc_quanta_size_err; *ptr++ = vpath_info->ring_stats.common_stats.full_cnt; *ptr++ = vpath_info->ring_stats.common_stats.usage_cnt; *ptr++ = vpath_info->ring_stats.common_stats.usage_max; *ptr++ = vpath_info->ring_stats.common_stats. reserve_free_swaps_cnt; *ptr++ = vpath_info->ring_stats.common_stats.total_compl_cnt; for (j = 0; j < VXGE_HW_DTR_MAX_T_CODE; j++) *ptr++ = vpath_info->ring_stats.rxd_t_code_err_cnt[j]; *ptr++ = vpath_info->fifo_stats.common_stats.full_cnt; *ptr++ = vpath_info->fifo_stats.common_stats.usage_cnt; *ptr++ = vpath_info->fifo_stats.common_stats.usage_max; *ptr++ = vpath_info->fifo_stats.common_stats. reserve_free_swaps_cnt; *ptr++ = vpath_info->fifo_stats.common_stats.total_compl_cnt; *ptr++ = vpath_info->fifo_stats.total_posts; *ptr++ = vpath_info->fifo_stats.total_buffers; for (j = 0; j < VXGE_HW_DTR_MAX_T_CODE; j++) *ptr++ = vpath_info->fifo_stats.txd_t_code_err_cnt[j]; } *ptr++ = 0; for (k = 0; k < vdev->no_of_vpath; k++) { struct vxge_hw_vpath_stats_hw_info *vpath_info; vpath = &vdev->vpaths[k]; j = vpath->device_id; vpath_info = hw_stats->vpath_info[j]; if (!vpath_info) { memset(ptr, 0, VXGE_HW_VPATH_STATS_LEN * sizeof(u64)); ptr += VXGE_HW_VPATH_STATS_LEN; continue; } *ptr++ = vpath_info->ini_num_mwr_sent; *ptr++ = vpath_info->ini_num_mrd_sent; *ptr++ = vpath_info->ini_num_cpl_rcvd; *ptr++ = vpath_info->ini_num_mwr_byte_sent; *ptr++ = vpath_info->ini_num_cpl_byte_rcvd; *ptr++ = vpath_info->wrcrdtarb_xoff; *ptr++ = vpath_info->rdcrdtarb_xoff; *ptr++ = vpath_info->vpath_genstats_count0; *ptr++ = vpath_info->vpath_genstats_count1; *ptr++ = vpath_info->vpath_genstats_count2; *ptr++ = vpath_info->vpath_genstats_count3; *ptr++ = vpath_info->vpath_genstats_count4; *ptr++ = vpath_info->vpath_genstats_count5; *ptr++ = vpath_info->prog_event_vnum0; *ptr++ = vpath_info->prog_event_vnum1; *ptr++ = vpath_info->prog_event_vnum2; *ptr++ = vpath_info->prog_event_vnum3; *ptr++ = vpath_info->rx_multi_cast_frame_discard; *ptr++ = vpath_info->rx_frm_transferred; *ptr++ = vpath_info->rxd_returned; *ptr++ = vpath_info->rx_mpa_len_fail_frms; *ptr++ = vpath_info->rx_mpa_mrk_fail_frms; *ptr++ = vpath_info->rx_mpa_crc_fail_frms; *ptr++ = vpath_info->rx_permitted_frms; *ptr++ = vpath_info->rx_vp_reset_discarded_frms; *ptr++ = vpath_info->rx_wol_frms; *ptr++ = vpath_info->tx_vp_reset_discarded_frms; } *ptr++ = 0; *ptr++ = vdev->stats.vpaths_open; *ptr++ = vdev->stats.vpath_open_fail; *ptr++ = vdev->stats.link_up; *ptr++ = vdev->stats.link_down; for (k = 0; k < vdev->no_of_vpath; k++) { *ptr += vdev->vpaths[k].fifo.stats.tx_frms; *(ptr + 1) += vdev->vpaths[k].fifo.stats.tx_errors; *(ptr + 2) += vdev->vpaths[k].fifo.stats.tx_bytes; *(ptr + 3) += vdev->vpaths[k].fifo.stats.txd_not_free; *(ptr + 4) += vdev->vpaths[k].fifo.stats.txd_out_of_desc; *(ptr + 5) += vdev->vpaths[k].ring.stats.rx_frms; *(ptr + 6) += vdev->vpaths[k].ring.stats.rx_errors; *(ptr + 7) += vdev->vpaths[k].ring.stats.rx_bytes; *(ptr + 8) += vdev->vpaths[k].ring.stats.rx_mcast; *(ptr + 9) += vdev->vpaths[k].fifo.stats.pci_map_fail + vdev->vpaths[k].ring.stats.pci_map_fail; *(ptr + 10) += vdev->vpaths[k].ring.stats.skb_alloc_fail; } ptr += 12; kfree(xmac_stats); kfree(sw_stats); kfree(hw_stats); } static void vxge_ethtool_get_strings(struct net_device *dev, u32 stringset, u8 *data) { int stat_size = 0; int i, j; struct vxgedev *vdev = netdev_priv(dev); switch (stringset) { case ETH_SS_STATS: vxge_add_string("VPATH STATISTICS%s\t\t\t", &stat_size, data, ""); for (i = 0; i < vdev->no_of_vpath; i++) { vxge_add_string("tx_ttl_eth_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_ttl_eth_octects_%d\t\t", &stat_size, data, i); vxge_add_string("tx_data_octects_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_mcast_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_bcast_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_ucast_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_tagged_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_vld_ip_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_vld_ip_octects_%d\t\t", &stat_size, data, i); vxge_add_string("tx_icmp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("tx_tcp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("tx_rst_tcp_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_udp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("tx_unknown_proto_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_lost_ip_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_parse_error_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_tcp_offload_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_retx_tcp_offload_%d\t\t", &stat_size, data, i); vxge_add_string("tx_lost_ip_offload_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_eth_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_vld_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_offload_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_eth_octects_%d\t\t", &stat_size, data, i); vxge_add_string("rx_data_octects_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_offload_octects_%d\t\t", &stat_size, data, i); vxge_add_string("rx_vld_mcast_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_vld_bcast_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_accepted_ucast_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_accepted_nucast_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_tagged_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_long_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_usized_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_osized_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_frag_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_jabber_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_64_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_65_127_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_128_255_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_256_511_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_512_1023_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_1024_1518_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_1519_4095_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_4096_8191_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_8192_max_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_gt_max_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ip%d\t\t\t\t", &stat_size, data, i); vxge_add_string("rx_accepted_ip_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_ip_octects_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_err_ip_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_icmp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("rx_tcp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("rx_udp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("rx_err_tcp_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_lost_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_lost_ip_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_lost_ip_offload_%d\t\t", &stat_size, data, i); vxge_add_string("rx_various_discard_%d\t\t", &stat_size, data, i); vxge_add_string("rx_sleep_discard_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_red_discard_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_queue_full_discard_%d\t\t", &stat_size, data, i); vxge_add_string("rx_mpa_ok_frms_%d\t\t\t", &stat_size, data, i); } vxge_add_string("\nAGGR STATISTICS%s\t\t\t\t", &stat_size, data, ""); for (i = 0; i < vdev->max_config_port; i++) { vxge_add_string("tx_frms_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("tx_data_octects_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_mcast_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_bcast_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_discarded_frms_%d\t\t", &stat_size, data, i); vxge_add_string("tx_errored_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_frms_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("rx_data_octects_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_mcast_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_bcast_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_discarded_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_errored_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_unknown_slow_proto_frms_%d\t", &stat_size, data, i); } vxge_add_string("\nPORT STATISTICS%s\t\t\t\t", &stat_size, data, ""); for (i = 0; i < vdev->max_config_port; i++) { vxge_add_string("tx_ttl_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_ttl_octects_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_data_octects_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_mcast_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_bcast_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_ucast_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_tagged_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_vld_ip_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_vld_ip_octects_%d\t\t", &stat_size, data, i); vxge_add_string("tx_icmp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("tx_tcp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("tx_rst_tcp_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_udp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("tx_parse_error_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_unknown_protocol_%d\t\t", &stat_size, data, i); vxge_add_string("tx_pause_ctrl_frms_%d\t\t", &stat_size, data, i); vxge_add_string("tx_marker_pdu_frms_%d\t\t", &stat_size, data, i); vxge_add_string("tx_lacpdu_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_drop_ip_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_marker_resp_pdu_frms_%d\t\t", &stat_size, data, i); vxge_add_string("tx_xgmii_char2_match_%d\t\t", &stat_size, data, i); vxge_add_string("tx_xgmii_char1_match_%d\t\t", &stat_size, data, i); vxge_add_string("tx_xgmii_column2_match_%d\t\t", &stat_size, data, i); vxge_add_string("tx_xgmii_column1_match_%d\t\t", &stat_size, data, i); vxge_add_string("tx_any_err_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_drop_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_vld_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_offload_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_octects_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_data_octects_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_offload_octects_%d\t\t", &stat_size, data, i); vxge_add_string("rx_vld_mcast_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_vld_bcast_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_accepted_ucast_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_accepted_nucast_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_tagged_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_long_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_usized_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_osized_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_frag_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_jabber_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_64_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_65_127_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_128_255_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_256_511_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_512_1023_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_1024_1518_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_1519_4095_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_4096_8191_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_8192_max_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ttl_gt_max_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_ip_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("rx_accepted_ip_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_ip_octets_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_err_ip_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_icmp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("rx_tcp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("rx_udp_%d\t\t\t\t", &stat_size, data, i); vxge_add_string("rx_err_tcp_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_pause_count_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_pause_ctrl_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_unsup_ctrl_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_fcs_err_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_in_rng_len_err_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_out_rng_len_err_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_drop_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_discard_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_drop_ip_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_drop_udp_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_marker_pdu_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_lacpdu_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_unknown_pdu_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_marker_resp_pdu_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_fcs_discard_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_illegal_pdu_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_switch_discard_%d\t\t", &stat_size, data, i); vxge_add_string("rx_len_discard_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_rpa_discard_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_l2_mgmt_discard_%d\t\t", &stat_size, data, i); vxge_add_string("rx_rts_discard_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_trash_discard_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_buff_full_discard_%d\t\t", &stat_size, data, i); vxge_add_string("rx_red_discard_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_xgmii_ctrl_err_cnt_%d\t\t", &stat_size, data, i); vxge_add_string("rx_xgmii_data_err_cnt_%d\t\t", &stat_size, data, i); vxge_add_string("rx_xgmii_char1_match_%d\t\t", &stat_size, data, i); vxge_add_string("rx_xgmii_err_sym_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_xgmii_column1_match_%d\t\t", &stat_size, data, i); vxge_add_string("rx_xgmii_char2_match_%d\t\t", &stat_size, data, i); vxge_add_string("rx_local_fault_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_xgmii_column2_match_%d\t\t", &stat_size, data, i); vxge_add_string("rx_jettison_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_remote_fault_%d\t\t\t", &stat_size, data, i); } vxge_add_string("\n SOFTWARE STATISTICS%s\t\t\t", &stat_size, data, ""); for (i = 0; i < vdev->no_of_vpath; i++) { vxge_add_string("soft_reset_cnt_%d\t\t\t", &stat_size, data, i); vxge_add_string("unknown_alarms_%d\t\t\t", &stat_size, data, i); vxge_add_string("network_sustained_fault_%d\t\t", &stat_size, data, i); vxge_add_string("network_sustained_ok_%d\t\t", &stat_size, data, i); vxge_add_string("kdfcctl_fifo0_overwrite_%d\t\t", &stat_size, data, i); vxge_add_string("kdfcctl_fifo0_poison_%d\t\t", &stat_size, data, i); vxge_add_string("kdfcctl_fifo0_dma_error_%d\t\t", &stat_size, data, i); vxge_add_string("dblgen_fifo0_overflow_%d\t\t", &stat_size, data, i); vxge_add_string("statsb_pif_chain_error_%d\t\t", &stat_size, data, i); vxge_add_string("statsb_drop_timeout_%d\t\t", &stat_size, data, i); vxge_add_string("target_illegal_access_%d\t\t", &stat_size, data, i); vxge_add_string("ini_serr_det_%d\t\t\t", &stat_size, data, i); vxge_add_string("prc_ring_bumps_%d\t\t\t", &stat_size, data, i); vxge_add_string("prc_rxdcm_sc_err_%d\t\t\t", &stat_size, data, i); vxge_add_string("prc_rxdcm_sc_abort_%d\t\t", &stat_size, data, i); vxge_add_string("prc_quanta_size_err_%d\t\t", &stat_size, data, i); vxge_add_string("ring_full_cnt_%d\t\t\t", &stat_size, data, i); vxge_add_string("ring_usage_cnt_%d\t\t\t", &stat_size, data, i); vxge_add_string("ring_usage_max_%d\t\t\t", &stat_size, data, i); vxge_add_string("ring_reserve_free_swaps_cnt_%d\t", &stat_size, data, i); vxge_add_string("ring_total_compl_cnt_%d\t\t", &stat_size, data, i); for (j = 0; j < VXGE_HW_DTR_MAX_T_CODE; j++) vxge_add_string("rxd_t_code_err_cnt%d_%d\t\t", &stat_size, data, j, i); vxge_add_string("fifo_full_cnt_%d\t\t\t", &stat_size, data, i); vxge_add_string("fifo_usage_cnt_%d\t\t\t", &stat_size, data, i); vxge_add_string("fifo_usage_max_%d\t\t\t", &stat_size, data, i); vxge_add_string("fifo_reserve_free_swaps_cnt_%d\t", &stat_size, data, i); vxge_add_string("fifo_total_compl_cnt_%d\t\t", &stat_size, data, i); vxge_add_string("fifo_total_posts_%d\t\t\t", &stat_size, data, i); vxge_add_string("fifo_total_buffers_%d\t\t", &stat_size, data, i); for (j = 0; j < VXGE_HW_DTR_MAX_T_CODE; j++) vxge_add_string("txd_t_code_err_cnt%d_%d\t\t", &stat_size, data, j, i); } vxge_add_string("\n HARDWARE STATISTICS%s\t\t\t", &stat_size, data, ""); for (i = 0; i < vdev->no_of_vpath; i++) { vxge_add_string("ini_num_mwr_sent_%d\t\t\t", &stat_size, data, i); vxge_add_string("ini_num_mrd_sent_%d\t\t\t", &stat_size, data, i); vxge_add_string("ini_num_cpl_rcvd_%d\t\t\t", &stat_size, data, i); vxge_add_string("ini_num_mwr_byte_sent_%d\t\t", &stat_size, data, i); vxge_add_string("ini_num_cpl_byte_rcvd_%d\t\t", &stat_size, data, i); vxge_add_string("wrcrdtarb_xoff_%d\t\t\t", &stat_size, data, i); vxge_add_string("rdcrdtarb_xoff_%d\t\t\t", &stat_size, data, i); vxge_add_string("vpath_genstats_count0_%d\t\t", &stat_size, data, i); vxge_add_string("vpath_genstats_count1_%d\t\t", &stat_size, data, i); vxge_add_string("vpath_genstats_count2_%d\t\t", &stat_size, data, i); vxge_add_string("vpath_genstats_count3_%d\t\t", &stat_size, data, i); vxge_add_string("vpath_genstats_count4_%d\t\t", &stat_size, data, i); vxge_add_string("vpath_genstats_count5_%d\t\t", &stat_size, data, i); vxge_add_string("prog_event_vnum0_%d\t\t\t", &stat_size, data, i); vxge_add_string("prog_event_vnum1_%d\t\t\t", &stat_size, data, i); vxge_add_string("prog_event_vnum2_%d\t\t\t", &stat_size, data, i); vxge_add_string("prog_event_vnum3_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_multi_cast_frame_discard_%d\t", &stat_size, data, i); vxge_add_string("rx_frm_transferred_%d\t\t", &stat_size, data, i); vxge_add_string("rxd_returned_%d\t\t\t", &stat_size, data, i); vxge_add_string("rx_mpa_len_fail_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_mpa_mrk_fail_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_mpa_crc_fail_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_permitted_frms_%d\t\t", &stat_size, data, i); vxge_add_string("rx_vp_reset_discarded_frms_%d\t", &stat_size, data, i); vxge_add_string("rx_wol_frms_%d\t\t\t", &stat_size, data, i); vxge_add_string("tx_vp_reset_discarded_frms_%d\t", &stat_size, data, i); } memcpy(data + stat_size, &ethtool_driver_stats_keys, sizeof(ethtool_driver_stats_keys)); } } static int vxge_ethtool_get_regs_len(struct net_device *dev) { struct vxgedev *vdev = netdev_priv(dev); return sizeof(struct vxge_hw_vpath_reg) * vdev->no_of_vpath; } static int vxge_ethtool_get_sset_count(struct net_device *dev, int sset) { struct vxgedev *vdev = netdev_priv(dev); switch (sset) { case ETH_SS_STATS: return VXGE_TITLE_LEN + (vdev->no_of_vpath * VXGE_HW_VPATH_STATS_LEN) + (vdev->max_config_port * VXGE_HW_AGGR_STATS_LEN) + (vdev->max_config_port * VXGE_HW_PORT_STATS_LEN) + (vdev->no_of_vpath * VXGE_HW_VPATH_TX_STATS_LEN) + (vdev->no_of_vpath * VXGE_HW_VPATH_RX_STATS_LEN) + (vdev->no_of_vpath * VXGE_SW_STATS_LEN) + DRIVER_STAT_LEN; default: return -EOPNOTSUPP; } } static int vxge_fw_flash(struct net_device *dev, struct ethtool_flash *parms) { struct vxgedev *vdev = netdev_priv(dev); if (vdev->max_vpath_supported != VXGE_HW_MAX_VIRTUAL_PATHS) { printk(KERN_INFO "Single Function Mode is required to flash the" " firmware\n"); return -EINVAL; } if (netif_running(dev)) { printk(KERN_INFO "Interface %s must be down to flash the " "firmware\n", dev->name); return -EBUSY; } return vxge_fw_upgrade(vdev, parms->data, 1); } static const struct ethtool_ops vxge_ethtool_ops = { .get_settings = vxge_ethtool_gset, .set_settings = vxge_ethtool_sset, .get_drvinfo = vxge_ethtool_gdrvinfo, .get_regs_len = vxge_ethtool_get_regs_len, .get_regs = vxge_ethtool_gregs, .get_link = ethtool_op_get_link, .get_pauseparam = vxge_ethtool_getpause_data, .set_pauseparam = vxge_ethtool_setpause_data, .get_strings = vxge_ethtool_get_strings, .set_phys_id = vxge_ethtool_idnic, .get_sset_count = vxge_ethtool_get_sset_count, .get_ethtool_stats = vxge_get_ethtool_stats, .flash_device = vxge_fw_flash, }; void vxge_initialize_ethtool_ops(struct net_device *ndev) { SET_ETHTOOL_OPS(ndev, &vxge_ethtool_ops); }
gpl-2.0
trunghieuhust/android_sony_kernel_msm8260A
drivers/sfi/sfi_acpi.c
11702
6204
/* sfi_acpi.c Simple Firmware Interface - ACPI extensions */ /* 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) 2009 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License 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 LICENSE.GPL. BSD LICENSE Copyright(c) 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. */ #define KMSG_COMPONENT "SFI" #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt #include <linux/kernel.h> #include <acpi/acpi.h> #include <linux/sfi.h> #include "sfi_core.h" /* * SFI can access ACPI-defined tables via an optional ACPI XSDT. * * This allows re-use, and avoids re-definition, of standard tables. * For example, the "MCFG" table is defined by PCI, reserved by ACPI, * and is expected to be present many SFI-only systems. */ static struct acpi_table_xsdt *xsdt_va __read_mostly; #define XSDT_GET_NUM_ENTRIES(ptable, entry_type) \ ((ptable->header.length - sizeof(struct acpi_table_header)) / \ (sizeof(entry_type))) static inline struct sfi_table_header *acpi_to_sfi_th( struct acpi_table_header *th) { return (struct sfi_table_header *)th; } static inline struct acpi_table_header *sfi_to_acpi_th( struct sfi_table_header *th) { return (struct acpi_table_header *)th; } /* * sfi_acpi_parse_xsdt() * * Parse the ACPI XSDT for later access by sfi_acpi_table_parse(). */ static int __init sfi_acpi_parse_xsdt(struct sfi_table_header *th) { struct sfi_table_key key = SFI_ANY_KEY; int tbl_cnt, i; void *ret; xsdt_va = (struct acpi_table_xsdt *)th; tbl_cnt = XSDT_GET_NUM_ENTRIES(xsdt_va, u64); for (i = 0; i < tbl_cnt; i++) { ret = sfi_check_table(xsdt_va->table_offset_entry[i], &key); if (IS_ERR(ret)) { disable_sfi(); return -1; } } return 0; } int __init sfi_acpi_init(void) { struct sfi_table_key xsdt_key = { .sig = SFI_SIG_XSDT }; sfi_table_parse(SFI_SIG_XSDT, NULL, NULL, sfi_acpi_parse_xsdt); /* Only call the get_table to keep the table mapped */ xsdt_va = (struct acpi_table_xsdt *)sfi_get_table(&xsdt_key); return 0; } static struct acpi_table_header *sfi_acpi_get_table(struct sfi_table_key *key) { u32 tbl_cnt, i; void *ret; tbl_cnt = XSDT_GET_NUM_ENTRIES(xsdt_va, u64); for (i = 0; i < tbl_cnt; i++) { ret = sfi_check_table(xsdt_va->table_offset_entry[i], key); if (!IS_ERR(ret) && ret) return sfi_to_acpi_th(ret); } return NULL; } static void sfi_acpi_put_table(struct acpi_table_header *table) { sfi_put_table(acpi_to_sfi_th(table)); } /* * sfi_acpi_table_parse() * * Find specified table in XSDT, run handler on it and return its return value */ int sfi_acpi_table_parse(char *signature, char *oem_id, char *oem_table_id, int(*handler)(struct acpi_table_header *)) { struct acpi_table_header *table = NULL; struct sfi_table_key key; int ret = 0; if (sfi_disabled) return -1; key.sig = signature; key.oem_id = oem_id; key.oem_table_id = oem_table_id; table = sfi_acpi_get_table(&key); if (!table) return -EINVAL; ret = handler(table); sfi_acpi_put_table(table); return ret; } static ssize_t sfi_acpi_table_show(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t offset, size_t count) { struct sfi_table_attr *tbl_attr = container_of(bin_attr, struct sfi_table_attr, attr); struct acpi_table_header *th = NULL; struct sfi_table_key key; ssize_t cnt; key.sig = tbl_attr->name; key.oem_id = NULL; key.oem_table_id = NULL; th = sfi_acpi_get_table(&key); if (!th) return 0; cnt = memory_read_from_buffer(buf, count, &offset, th, th->length); sfi_acpi_put_table(th); return cnt; } void __init sfi_acpi_sysfs_init(void) { u32 tbl_cnt, i; struct sfi_table_attr *tbl_attr; tbl_cnt = XSDT_GET_NUM_ENTRIES(xsdt_va, u64); for (i = 0; i < tbl_cnt; i++) { tbl_attr = sfi_sysfs_install_table(xsdt_va->table_offset_entry[i]); tbl_attr->attr.read = sfi_acpi_table_show; } return; }
gpl-2.0
mekinik232/ambipi
lib/ffmpeg/libavcodec/qdm2_tablegen.c
183
1433
/* * Generate a header file for hardcoded QDM2 tables * * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> * * This file is part of FFmpeg. * * FFmpeg 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. * * FFmpeg 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 FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdlib.h> #define CONFIG_HARDCODED_TABLES 0 #include "qdm2_tablegen.h" #include "tableprint.h" int main(void) { softclip_table_init(); rnd_table_init(); init_noise_samples(); write_fileheader(); WRITE_ARRAY("static const", uint16_t, softclip_table); WRITE_ARRAY("static const", float, noise_table); WRITE_ARRAY("static const", float, noise_samples); WRITE_2D_ARRAY("static const", uint8_t, random_dequant_index); WRITE_2D_ARRAY("static const", uint8_t, random_dequant_type24); return 0; }
gpl-2.0
tcp209/kernel_samsung_epic4gtouch
sound/pci/cs5535audio/cs5535audio_pm.c
951
4019
/* * Power management for audio on multifunction CS5535 companion device * Copyright (C) Jaya Kumar * * 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/init.h> #include <linux/pci.h> #include <linux/delay.h> #include <sound/core.h> #include <sound/control.h> #include <sound/initval.h> #include <sound/asoundef.h> #include <sound/pcm.h> #include <sound/ac97_codec.h> #include "cs5535audio.h" static void snd_cs5535audio_stop_hardware(struct cs5535audio *cs5535au) { /* we depend on snd_ac97_suspend to tell the AC97 codec to shutdown. the amd spec suggests that the LNK_SHUTDOWN be done at the same time that the codec power-down is issued. instead, we do it just after rather than at the same time. excluding codec specific build_ops->suspend ac97 powerdown hits: 0x8000 EAPD 0x4000 Headphone amplifier 0x0300 ADC & DAC 0x0400 Analog Mixer powerdown (Vref on) I am not sure if this is the best that we can do. The remainder to be investigated are: - analog mixer (vref off) 0x0800 - AC-link powerdown 0x1000 - codec internal clock 0x2000 */ /* set LNK_SHUTDOWN to shutdown AC link */ cs_writel(cs5535au, ACC_CODEC_CNTL, ACC_CODEC_CNTL_LNK_SHUTDOWN); } int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state) { struct snd_card *card = pci_get_drvdata(pci); struct cs5535audio *cs5535au = card->private_data; int i; snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(cs5535au->pcm); snd_ac97_suspend(cs5535au->ac97); for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) { struct cs5535audio_dma *dma = &cs5535au->dmas[i]; if (dma && dma->substream) dma->saved_prd = dma->ops->read_prd(cs5535au); } /* save important regs, then disable aclink in hw */ snd_cs5535audio_stop_hardware(cs5535au); if (pci_save_state(pci)) { printk(KERN_ERR "cs5535audio: pci_save_state failed!\n"); return -EIO; } pci_disable_device(pci); pci_set_power_state(pci, pci_choose_state(pci, state)); return 0; } int snd_cs5535audio_resume(struct pci_dev *pci) { struct snd_card *card = pci_get_drvdata(pci); struct cs5535audio *cs5535au = card->private_data; u32 tmp; int timeout; int i; pci_set_power_state(pci, PCI_D0); if (pci_restore_state(pci) < 0) { printk(KERN_ERR "cs5535audio: pci_restore_state failed, " "disabling device\n"); snd_card_disconnect(card); return -EIO; } if (pci_enable_device(pci) < 0) { printk(KERN_ERR "cs5535audio: pci_enable_device failed, " "disabling device\n"); snd_card_disconnect(card); return -EIO; } pci_set_master(pci); /* set LNK_WRM_RST to reset AC link */ cs_writel(cs5535au, ACC_CODEC_CNTL, ACC_CODEC_CNTL_LNK_WRM_RST); timeout = 50; do { tmp = cs_readl(cs5535au, ACC_CODEC_STATUS); if (tmp & PRM_RDY_STS) break; udelay(1); } while (--timeout); if (!timeout) snd_printk(KERN_ERR "Failure getting AC Link ready\n"); /* set up rate regs, dma. actual initiation is done in trig */ for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) { struct cs5535audio_dma *dma = &cs5535au->dmas[i]; if (dma && dma->substream) { dma->substream->ops->prepare(dma->substream); dma->ops->setup_prd(cs5535au, dma->saved_prd); } } /* we depend on ac97 to perform the codec power up */ snd_ac97_resume(cs5535au->ac97); snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; }
gpl-2.0
houst0nn/android_kernel_lge_geeb
drivers/net/ethernet/3com/3c509.c
1207
42967
/* 3c509.c: A 3c509 EtherLink3 ethernet driver for linux. */ /* Written 1993-2000 by Donald Becker. Copyright 1994-2000 by Donald Becker. Copyright 1993 United States Government as represented by the Director, National Security Agency. This software may be used and distributed according to the terms of the GNU General Public License, incorporated herein by reference. This driver is for the 3Com EtherLinkIII series. The author may be reached as becker@scyld.com, or C/O Scyld Computing Corporation 410 Severn Ave., Suite 210 Annapolis MD 21403 Known limitations: Because of the way 3c509 ISA detection works it's difficult to predict a priori which of several ISA-mode cards will be detected first. This driver does not use predictive interrupt mode, resulting in higher packet latency but lower overhead. If interrupts are disabled for an unusually long time it could also result in missed packets, but in practice this rarely happens. FIXES: Alan Cox: Removed the 'Unexpected interrupt' bug. Michael Meskes: Upgraded to Donald Becker's version 1.07. Alan Cox: Increased the eeprom delay. Regardless of what the docs say some people definitely get problems with lower (but in card spec) delays v1.10 4/21/97 Fixed module code so that multiple cards may be detected, other cleanups. -djb Andrea Arcangeli: Upgraded to Donald Becker's version 1.12. Rick Payne: Fixed SMP race condition v1.13 9/8/97 Made 'max_interrupt_work' an insmod-settable variable -djb v1.14 10/15/97 Avoided waiting..discard message for fast machines -djb v1.15 1/31/98 Faster recovery for Tx errors. -djb v1.16 2/3/98 Different ID port handling to avoid sound cards. -djb v1.18 12Mar2001 Andrew Morton - Avoid bogus detect of 3c590's (Andrzej Krzysztofowicz) - Reviewed against 1.18 from scyld.com v1.18a 17Nov2001 Jeff Garzik <jgarzik@pobox.com> - ethtool support v1.18b 1Mar2002 Zwane Mwaikambo <zwane@commfireservices.com> - Power Management support v1.18c 1Mar2002 David Ruggiero <jdr@farfalle.com> - Full duplex support v1.19 16Oct2002 Zwane Mwaikambo <zwane@linuxpower.ca> - Additional ethtool features v1.19a 28Oct2002 Davud Ruggiero <jdr@farfalle.com> - Increase *read_eeprom udelay to workaround oops with 2 cards. v1.19b 08Nov2002 Marc Zyngier <maz@wild-wind.fr.eu.org> - Introduce driver model for EISA cards. v1.20 04Feb2008 Ondrej Zary <linux@rainbow-software.org> - convert to isa_driver and pnp_driver and some cleanups */ #define DRV_NAME "3c509" #define DRV_VERSION "1.20" #define DRV_RELDATE "04Feb2008" /* A few values that may be tweaked. */ /* Time in jiffies before concluding the transmitter is hung. */ #define TX_TIMEOUT (400*HZ/1000) #include <linux/module.h> #include <linux/mca.h> #include <linux/isa.h> #include <linux/pnp.h> #include <linux/string.h> #include <linux/interrupt.h> #include <linux/errno.h> #include <linux/in.h> #include <linux/ioport.h> #include <linux/init.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/pm.h> #include <linux/skbuff.h> #include <linux/delay.h> /* for udelay() */ #include <linux/spinlock.h> #include <linux/ethtool.h> #include <linux/device.h> #include <linux/eisa.h> #include <linux/bitops.h> #include <asm/uaccess.h> #include <asm/io.h> #include <asm/irq.h> static char version[] __devinitdata = DRV_NAME ".c:" DRV_VERSION " " DRV_RELDATE " becker@scyld.com\n"; #ifdef EL3_DEBUG static int el3_debug = EL3_DEBUG; #else static int el3_debug = 2; #endif /* Used to do a global count of all the cards in the system. Must be * a global variable so that the mca/eisa probe routines can increment * it */ static int el3_cards = 0; #define EL3_MAX_CARDS 8 /* To minimize the size of the driver source I only define operating constants if they are used several times. You'll need the manual anyway if you want to understand driver details. */ /* Offsets from base I/O address. */ #define EL3_DATA 0x00 #define EL3_CMD 0x0e #define EL3_STATUS 0x0e #define EEPROM_READ 0x80 #define EL3_IO_EXTENT 16 #define EL3WINDOW(win_num) outw(SelectWindow + (win_num), ioaddr + EL3_CMD) /* The top five bits written to EL3_CMD are a command, the lower 11 bits are the parameter, if applicable. */ enum c509cmd { TotalReset = 0<<11, SelectWindow = 1<<11, StartCoax = 2<<11, RxDisable = 3<<11, RxEnable = 4<<11, RxReset = 5<<11, RxDiscard = 8<<11, TxEnable = 9<<11, TxDisable = 10<<11, TxReset = 11<<11, FakeIntr = 12<<11, AckIntr = 13<<11, SetIntrEnb = 14<<11, SetStatusEnb = 15<<11, SetRxFilter = 16<<11, SetRxThreshold = 17<<11, SetTxThreshold = 18<<11, SetTxStart = 19<<11, StatsEnable = 21<<11, StatsDisable = 22<<11, StopCoax = 23<<11, PowerUp = 27<<11, PowerDown = 28<<11, PowerAuto = 29<<11}; enum c509status { IntLatch = 0x0001, AdapterFailure = 0x0002, TxComplete = 0x0004, TxAvailable = 0x0008, RxComplete = 0x0010, RxEarly = 0x0020, IntReq = 0x0040, StatsFull = 0x0080, CmdBusy = 0x1000, }; /* The SetRxFilter command accepts the following classes: */ enum RxFilter { RxStation = 1, RxMulticast = 2, RxBroadcast = 4, RxProm = 8 }; /* Register window 1 offsets, the window used in normal operation. */ #define TX_FIFO 0x00 #define RX_FIFO 0x00 #define RX_STATUS 0x08 #define TX_STATUS 0x0B #define TX_FREE 0x0C /* Remaining free bytes in Tx buffer. */ #define WN0_CONF_CTRL 0x04 /* Window 0: Configuration control register */ #define WN0_ADDR_CONF 0x06 /* Window 0: Address configuration register */ #define WN0_IRQ 0x08 /* Window 0: Set IRQ line in bits 12-15. */ #define WN4_MEDIA 0x0A /* Window 4: Various transcvr/media bits. */ #define MEDIA_TP 0x00C0 /* Enable link beat and jabber for 10baseT. */ #define WN4_NETDIAG 0x06 /* Window 4: Net diagnostic */ #define FD_ENABLE 0x8000 /* Enable full-duplex ("external loopback") */ /* * Must be a power of two (we use a binary and in the * circular queue) */ #define SKB_QUEUE_SIZE 64 enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_MCA, EL3_EISA }; struct el3_private { spinlock_t lock; /* skb send-queue */ int head, size; struct sk_buff *queue[SKB_QUEUE_SIZE]; enum el3_cardtype type; }; static int id_port; static int current_tag; static struct net_device *el3_devs[EL3_MAX_CARDS]; /* Parameters that may be passed into the module. */ static int debug = -1; static int irq[] = {-1, -1, -1, -1, -1, -1, -1, -1}; /* Maximum events (Rx packets, etc.) to handle at each interrupt. */ static int max_interrupt_work = 10; #ifdef CONFIG_PNP static int nopnp; #endif static int __devinit el3_common_init(struct net_device *dev); static void el3_common_remove(struct net_device *dev); static ushort id_read_eeprom(int index); static ushort read_eeprom(int ioaddr, int index); static int el3_open(struct net_device *dev); static netdev_tx_t el3_start_xmit(struct sk_buff *skb, struct net_device *dev); static irqreturn_t el3_interrupt(int irq, void *dev_id); static void update_stats(struct net_device *dev); static struct net_device_stats *el3_get_stats(struct net_device *dev); static int el3_rx(struct net_device *dev); static int el3_close(struct net_device *dev); static void set_multicast_list(struct net_device *dev); static void el3_tx_timeout (struct net_device *dev); static void el3_down(struct net_device *dev); static void el3_up(struct net_device *dev); static const struct ethtool_ops ethtool_ops; #ifdef CONFIG_PM static int el3_suspend(struct device *, pm_message_t); static int el3_resume(struct device *); #else #define el3_suspend NULL #define el3_resume NULL #endif /* generic device remove for all device types */ static int el3_device_remove (struct device *device); #ifdef CONFIG_NET_POLL_CONTROLLER static void el3_poll_controller(struct net_device *dev); #endif /* Return 0 on success, 1 on error, 2 when found already detected PnP card */ static int el3_isa_id_sequence(__be16 *phys_addr) { short lrs_state = 0xff; int i; /* ISA boards are detected by sending the ID sequence to the ID_PORT. We find cards past the first by setting the 'current_tag' on cards as they are found. Cards with their tag set will not respond to subsequent ID sequences. */ outb(0x00, id_port); outb(0x00, id_port); for (i = 0; i < 255; i++) { outb(lrs_state, id_port); lrs_state <<= 1; lrs_state = lrs_state & 0x100 ? lrs_state ^ 0xcf : lrs_state; } /* For the first probe, clear all board's tag registers. */ if (current_tag == 0) outb(0xd0, id_port); else /* Otherwise kill off already-found boards. */ outb(0xd8, id_port); if (id_read_eeprom(7) != 0x6d50) return 1; /* Read in EEPROM data, which does contention-select. Only the lowest address board will stay "on-line". 3Com got the byte order backwards. */ for (i = 0; i < 3; i++) phys_addr[i] = htons(id_read_eeprom(i)); #ifdef CONFIG_PNP if (!nopnp) { /* The ISA PnP 3c509 cards respond to the ID sequence too. This check is needed in order not to register them twice. */ for (i = 0; i < el3_cards; i++) { struct el3_private *lp = netdev_priv(el3_devs[i]); if (lp->type == EL3_PNP && !memcmp(phys_addr, el3_devs[i]->dev_addr, ETH_ALEN)) { if (el3_debug > 3) pr_debug("3c509 with address %02x %02x %02x %02x %02x %02x was found by ISAPnP\n", phys_addr[0] & 0xff, phys_addr[0] >> 8, phys_addr[1] & 0xff, phys_addr[1] >> 8, phys_addr[2] & 0xff, phys_addr[2] >> 8); /* Set the adaptor tag so that the next card can be found. */ outb(0xd0 + ++current_tag, id_port); return 2; } } } #endif /* CONFIG_PNP */ return 0; } static void __devinit el3_dev_fill(struct net_device *dev, __be16 *phys_addr, int ioaddr, int irq, int if_port, enum el3_cardtype type) { struct el3_private *lp = netdev_priv(dev); memcpy(dev->dev_addr, phys_addr, ETH_ALEN); dev->base_addr = ioaddr; dev->irq = irq; dev->if_port = if_port; lp->type = type; } static int __devinit el3_isa_match(struct device *pdev, unsigned int ndev) { struct net_device *dev; int ioaddr, isa_irq, if_port, err; unsigned int iobase; __be16 phys_addr[3]; while ((err = el3_isa_id_sequence(phys_addr)) == 2) ; /* Skip to next card when PnP card found */ if (err == 1) return 0; iobase = id_read_eeprom(8); if_port = iobase >> 14; ioaddr = 0x200 + ((iobase & 0x1f) << 4); if (irq[el3_cards] > 1 && irq[el3_cards] < 16) isa_irq = irq[el3_cards]; else isa_irq = id_read_eeprom(9) >> 12; dev = alloc_etherdev(sizeof(struct el3_private)); if (!dev) return -ENOMEM; SET_NETDEV_DEV(dev, pdev); netdev_boot_setup_check(dev); if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509-isa")) { free_netdev(dev); return 0; } /* Set the adaptor tag so that the next card can be found. */ outb(0xd0 + ++current_tag, id_port); /* Activate the adaptor at the EEPROM location. */ outb((ioaddr >> 4) | 0xe0, id_port); EL3WINDOW(0); if (inw(ioaddr) != 0x6d50) { free_netdev(dev); return 0; } /* Free the interrupt so that some other card can use it. */ outw(0x0f00, ioaddr + WN0_IRQ); el3_dev_fill(dev, phys_addr, ioaddr, isa_irq, if_port, EL3_ISA); dev_set_drvdata(pdev, dev); if (el3_common_init(dev)) { free_netdev(dev); return 0; } el3_devs[el3_cards++] = dev; return 1; } static int __devexit el3_isa_remove(struct device *pdev, unsigned int ndev) { el3_device_remove(pdev); dev_set_drvdata(pdev, NULL); return 0; } #ifdef CONFIG_PM static int el3_isa_suspend(struct device *dev, unsigned int n, pm_message_t state) { current_tag = 0; return el3_suspend(dev, state); } static int el3_isa_resume(struct device *dev, unsigned int n) { struct net_device *ndev = dev_get_drvdata(dev); int ioaddr = ndev->base_addr, err; __be16 phys_addr[3]; while ((err = el3_isa_id_sequence(phys_addr)) == 2) ; /* Skip to next card when PnP card found */ if (err == 1) return 0; /* Set the adaptor tag so that the next card can be found. */ outb(0xd0 + ++current_tag, id_port); /* Enable the card */ outb((ioaddr >> 4) | 0xe0, id_port); EL3WINDOW(0); if (inw(ioaddr) != 0x6d50) return 1; /* Free the interrupt so that some other card can use it. */ outw(0x0f00, ioaddr + WN0_IRQ); return el3_resume(dev); } #endif static struct isa_driver el3_isa_driver = { .match = el3_isa_match, .remove = __devexit_p(el3_isa_remove), #ifdef CONFIG_PM .suspend = el3_isa_suspend, .resume = el3_isa_resume, #endif .driver = { .name = "3c509" }, }; static int isa_registered; #ifdef CONFIG_PNP static struct pnp_device_id el3_pnp_ids[] = { { .id = "TCM5090" }, /* 3Com Etherlink III (TP) */ { .id = "TCM5091" }, /* 3Com Etherlink III */ { .id = "TCM5094" }, /* 3Com Etherlink III (combo) */ { .id = "TCM5095" }, /* 3Com Etherlink III (TPO) */ { .id = "TCM5098" }, /* 3Com Etherlink III (TPC) */ { .id = "PNP80f7" }, /* 3Com Etherlink III compatible */ { .id = "PNP80f8" }, /* 3Com Etherlink III compatible */ { .id = "" } }; MODULE_DEVICE_TABLE(pnp, el3_pnp_ids); static int __devinit el3_pnp_probe(struct pnp_dev *pdev, const struct pnp_device_id *id) { short i; int ioaddr, irq, if_port; __be16 phys_addr[3]; struct net_device *dev = NULL; int err; ioaddr = pnp_port_start(pdev, 0); if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509-pnp")) return -EBUSY; irq = pnp_irq(pdev, 0); EL3WINDOW(0); for (i = 0; i < 3; i++) phys_addr[i] = htons(read_eeprom(ioaddr, i)); if_port = read_eeprom(ioaddr, 8) >> 14; dev = alloc_etherdev(sizeof(struct el3_private)); if (!dev) { release_region(ioaddr, EL3_IO_EXTENT); return -ENOMEM; } SET_NETDEV_DEV(dev, &pdev->dev); netdev_boot_setup_check(dev); el3_dev_fill(dev, phys_addr, ioaddr, irq, if_port, EL3_PNP); pnp_set_drvdata(pdev, dev); err = el3_common_init(dev); if (err) { pnp_set_drvdata(pdev, NULL); free_netdev(dev); return err; } el3_devs[el3_cards++] = dev; return 0; } static void __devexit el3_pnp_remove(struct pnp_dev *pdev) { el3_common_remove(pnp_get_drvdata(pdev)); pnp_set_drvdata(pdev, NULL); } #ifdef CONFIG_PM static int el3_pnp_suspend(struct pnp_dev *pdev, pm_message_t state) { return el3_suspend(&pdev->dev, state); } static int el3_pnp_resume(struct pnp_dev *pdev) { return el3_resume(&pdev->dev); } #endif static struct pnp_driver el3_pnp_driver = { .name = "3c509", .id_table = el3_pnp_ids, .probe = el3_pnp_probe, .remove = __devexit_p(el3_pnp_remove), #ifdef CONFIG_PM .suspend = el3_pnp_suspend, .resume = el3_pnp_resume, #endif }; static int pnp_registered; #endif /* CONFIG_PNP */ #ifdef CONFIG_EISA static struct eisa_device_id el3_eisa_ids[] = { { "TCM5090" }, { "TCM5091" }, { "TCM5092" }, { "TCM5093" }, { "TCM5094" }, { "TCM5095" }, { "TCM5098" }, { "" } }; MODULE_DEVICE_TABLE(eisa, el3_eisa_ids); static int el3_eisa_probe (struct device *device); static struct eisa_driver el3_eisa_driver = { .id_table = el3_eisa_ids, .driver = { .name = "3c579", .probe = el3_eisa_probe, .remove = __devexit_p (el3_device_remove), .suspend = el3_suspend, .resume = el3_resume, } }; static int eisa_registered; #endif #ifdef CONFIG_MCA static int el3_mca_probe(struct device *dev); static short el3_mca_adapter_ids[] __initdata = { 0x627c, 0x627d, 0x62db, 0x62f6, 0x62f7, 0x0000 }; static char *el3_mca_adapter_names[] __initdata = { "3Com 3c529 EtherLink III (10base2)", "3Com 3c529 EtherLink III (10baseT)", "3Com 3c529 EtherLink III (test mode)", "3Com 3c529 EtherLink III (TP or coax)", "3Com 3c529 EtherLink III (TP)", NULL }; static struct mca_driver el3_mca_driver = { .id_table = el3_mca_adapter_ids, .driver = { .name = "3c529", .bus = &mca_bus_type, .probe = el3_mca_probe, .remove = __devexit_p(el3_device_remove), .suspend = el3_suspend, .resume = el3_resume, }, }; static int mca_registered; #endif /* CONFIG_MCA */ static const struct net_device_ops netdev_ops = { .ndo_open = el3_open, .ndo_stop = el3_close, .ndo_start_xmit = el3_start_xmit, .ndo_get_stats = el3_get_stats, .ndo_set_rx_mode = set_multicast_list, .ndo_tx_timeout = el3_tx_timeout, .ndo_change_mtu = eth_change_mtu, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = el3_poll_controller, #endif }; static int __devinit el3_common_init(struct net_device *dev) { struct el3_private *lp = netdev_priv(dev); int err; const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"}; spin_lock_init(&lp->lock); if (dev->mem_start & 0x05) { /* xcvr codes 1/3/4/12 */ dev->if_port = (dev->mem_start & 0x0f); } else { /* xcvr codes 0/8 */ /* use eeprom value, but save user's full-duplex selection */ dev->if_port |= (dev->mem_start & 0x08); } /* The EL3-specific entries in the device structure. */ dev->netdev_ops = &netdev_ops; dev->watchdog_timeo = TX_TIMEOUT; SET_ETHTOOL_OPS(dev, &ethtool_ops); err = register_netdev(dev); if (err) { pr_err("Failed to register 3c5x9 at %#3.3lx, IRQ %d.\n", dev->base_addr, dev->irq); release_region(dev->base_addr, EL3_IO_EXTENT); return err; } pr_info("%s: 3c5x9 found at %#3.3lx, %s port, address %pM, IRQ %d.\n", dev->name, dev->base_addr, if_names[(dev->if_port & 0x03)], dev->dev_addr, dev->irq); if (el3_debug > 0) pr_info("%s", version); return 0; } static void el3_common_remove (struct net_device *dev) { unregister_netdev (dev); release_region(dev->base_addr, EL3_IO_EXTENT); free_netdev (dev); } #ifdef CONFIG_MCA static int __init el3_mca_probe(struct device *device) { /* Based on Erik Nygren's (nygren@mit.edu) 3c529 patch, * heavily modified by Chris Beauregard * (cpbeaure@csclub.uwaterloo.ca) to support standard MCA * probing. * * redone for multi-card detection by ZP Gu (zpg@castle.net) * now works as a module */ short i; int ioaddr, irq, if_port; __be16 phys_addr[3]; struct net_device *dev = NULL; u_char pos4, pos5; struct mca_device *mdev = to_mca_device(device); int slot = mdev->slot; int err; pos4 = mca_device_read_stored_pos(mdev, 4); pos5 = mca_device_read_stored_pos(mdev, 5); ioaddr = ((short)((pos4&0xfc)|0x02)) << 8; irq = pos5 & 0x0f; pr_info("3c529: found %s at slot %d\n", el3_mca_adapter_names[mdev->index], slot + 1); /* claim the slot */ strncpy(mdev->name, el3_mca_adapter_names[mdev->index], sizeof(mdev->name)); mca_device_set_claim(mdev, 1); if_port = pos4 & 0x03; irq = mca_device_transform_irq(mdev, irq); ioaddr = mca_device_transform_ioport(mdev, ioaddr); if (el3_debug > 2) { pr_debug("3c529: irq %d ioaddr 0x%x ifport %d\n", irq, ioaddr, if_port); } EL3WINDOW(0); for (i = 0; i < 3; i++) phys_addr[i] = htons(read_eeprom(ioaddr, i)); dev = alloc_etherdev(sizeof (struct el3_private)); if (dev == NULL) { release_region(ioaddr, EL3_IO_EXTENT); return -ENOMEM; } netdev_boot_setup_check(dev); el3_dev_fill(dev, phys_addr, ioaddr, irq, if_port, EL3_MCA); dev_set_drvdata(device, dev); err = el3_common_init(dev); if (err) { dev_set_drvdata(device, NULL); free_netdev(dev); return -ENOMEM; } el3_devs[el3_cards++] = dev; return 0; } #endif /* CONFIG_MCA */ #ifdef CONFIG_EISA static int __init el3_eisa_probe (struct device *device) { short i; int ioaddr, irq, if_port; __be16 phys_addr[3]; struct net_device *dev = NULL; struct eisa_device *edev; int err; /* Yeepee, The driver framework is calling us ! */ edev = to_eisa_device (device); ioaddr = edev->base_addr; if (!request_region(ioaddr, EL3_IO_EXTENT, "3c579-eisa")) return -EBUSY; /* Change the register set to the configuration window 0. */ outw(SelectWindow | 0, ioaddr + 0xC80 + EL3_CMD); irq = inw(ioaddr + WN0_IRQ) >> 12; if_port = inw(ioaddr + 6)>>14; for (i = 0; i < 3; i++) phys_addr[i] = htons(read_eeprom(ioaddr, i)); /* Restore the "Product ID" to the EEPROM read register. */ read_eeprom(ioaddr, 3); dev = alloc_etherdev(sizeof (struct el3_private)); if (dev == NULL) { release_region(ioaddr, EL3_IO_EXTENT); return -ENOMEM; } SET_NETDEV_DEV(dev, device); netdev_boot_setup_check(dev); el3_dev_fill(dev, phys_addr, ioaddr, irq, if_port, EL3_EISA); eisa_set_drvdata (edev, dev); err = el3_common_init(dev); if (err) { eisa_set_drvdata (edev, NULL); free_netdev(dev); return err; } el3_devs[el3_cards++] = dev; return 0; } #endif /* This remove works for all device types. * * The net dev must be stored in the driver data field */ static int __devexit el3_device_remove (struct device *device) { struct net_device *dev; dev = dev_get_drvdata(device); el3_common_remove (dev); return 0; } /* Read a word from the EEPROM using the regular EEPROM access register. Assume that we are in register window zero. */ static ushort read_eeprom(int ioaddr, int index) { outw(EEPROM_READ + index, ioaddr + 10); /* Pause for at least 162 us. for the read to take place. Some chips seem to require much longer */ mdelay(2); return inw(ioaddr + 12); } /* Read a word from the EEPROM when in the ISA ID probe state. */ static ushort id_read_eeprom(int index) { int bit, word = 0; /* Issue read command, and pause for at least 162 us. for it to complete. Assume extra-fast 16Mhz bus. */ outb(EEPROM_READ + index, id_port); /* Pause for at least 162 us. for the read to take place. */ /* Some chips seem to require much longer */ mdelay(4); for (bit = 15; bit >= 0; bit--) word = (word << 1) + (inb(id_port) & 0x01); if (el3_debug > 3) pr_debug(" 3c509 EEPROM word %d %#4.4x.\n", index, word); return word; } static int el3_open(struct net_device *dev) { int ioaddr = dev->base_addr; int i; outw(TxReset, ioaddr + EL3_CMD); outw(RxReset, ioaddr + EL3_CMD); outw(SetStatusEnb | 0x00, ioaddr + EL3_CMD); i = request_irq(dev->irq, el3_interrupt, 0, dev->name, dev); if (i) return i; EL3WINDOW(0); if (el3_debug > 3) pr_debug("%s: Opening, IRQ %d status@%x %4.4x.\n", dev->name, dev->irq, ioaddr + EL3_STATUS, inw(ioaddr + EL3_STATUS)); el3_up(dev); if (el3_debug > 3) pr_debug("%s: Opened 3c509 IRQ %d status %4.4x.\n", dev->name, dev->irq, inw(ioaddr + EL3_STATUS)); return 0; } static void el3_tx_timeout (struct net_device *dev) { int ioaddr = dev->base_addr; /* Transmitter timeout, serious problems. */ pr_warning("%s: transmit timed out, Tx_status %2.2x status %4.4x Tx FIFO room %d.\n", dev->name, inb(ioaddr + TX_STATUS), inw(ioaddr + EL3_STATUS), inw(ioaddr + TX_FREE)); dev->stats.tx_errors++; dev->trans_start = jiffies; /* prevent tx timeout */ /* Issue TX_RESET and TX_START commands. */ outw(TxReset, ioaddr + EL3_CMD); outw(TxEnable, ioaddr + EL3_CMD); netif_wake_queue(dev); } static netdev_tx_t el3_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct el3_private *lp = netdev_priv(dev); int ioaddr = dev->base_addr; unsigned long flags; netif_stop_queue (dev); dev->stats.tx_bytes += skb->len; if (el3_debug > 4) { pr_debug("%s: el3_start_xmit(length = %u) called, status %4.4x.\n", dev->name, skb->len, inw(ioaddr + EL3_STATUS)); } #if 0 #ifndef final_version { /* Error-checking code, delete someday. */ ushort status = inw(ioaddr + EL3_STATUS); if (status & 0x0001 && /* IRQ line active, missed one. */ inw(ioaddr + EL3_STATUS) & 1) { /* Make sure. */ pr_debug("%s: Missed interrupt, status then %04x now %04x" " Tx %2.2x Rx %4.4x.\n", dev->name, status, inw(ioaddr + EL3_STATUS), inb(ioaddr + TX_STATUS), inw(ioaddr + RX_STATUS)); /* Fake interrupt trigger by masking, acknowledge interrupts. */ outw(SetStatusEnb | 0x00, ioaddr + EL3_CMD); outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq, ioaddr + EL3_CMD); outw(SetStatusEnb | 0xff, ioaddr + EL3_CMD); } } #endif #endif /* * We lock the driver against other processors. Note * we don't need to lock versus the IRQ as we suspended * that. This means that we lose the ability to take * an RX during a TX upload. That sucks a bit with SMP * on an original 3c509 (2K buffer) * * Using disable_irq stops us crapping on other * time sensitive devices. */ spin_lock_irqsave(&lp->lock, flags); /* Put out the doubleword header... */ outw(skb->len, ioaddr + TX_FIFO); outw(0x00, ioaddr + TX_FIFO); /* ... and the packet rounded to a doubleword. */ outsl(ioaddr + TX_FIFO, skb->data, (skb->len + 3) >> 2); if (inw(ioaddr + TX_FREE) > 1536) netif_start_queue(dev); else /* Interrupt us when the FIFO has room for max-sized packet. */ outw(SetTxThreshold + 1536, ioaddr + EL3_CMD); spin_unlock_irqrestore(&lp->lock, flags); dev_kfree_skb (skb); /* Clear the Tx status stack. */ { short tx_status; int i = 4; while (--i > 0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) { if (tx_status & 0x38) dev->stats.tx_aborted_errors++; if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD); if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD); outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ } } return NETDEV_TX_OK; } /* The EL3 interrupt handler. */ static irqreturn_t el3_interrupt(int irq, void *dev_id) { struct net_device *dev = dev_id; struct el3_private *lp; int ioaddr, status; int i = max_interrupt_work; lp = netdev_priv(dev); spin_lock(&lp->lock); ioaddr = dev->base_addr; if (el3_debug > 4) { status = inw(ioaddr + EL3_STATUS); pr_debug("%s: interrupt, status %4.4x.\n", dev->name, status); } while ((status = inw(ioaddr + EL3_STATUS)) & (IntLatch | RxComplete | StatsFull)) { if (status & RxComplete) el3_rx(dev); if (status & TxAvailable) { if (el3_debug > 5) pr_debug(" TX room bit was handled.\n"); /* There's room in the FIFO for a full-sized packet. */ outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); netif_wake_queue (dev); } if (status & (AdapterFailure | RxEarly | StatsFull | TxComplete)) { /* Handle all uncommon interrupts. */ if (status & StatsFull) /* Empty statistics. */ update_stats(dev); if (status & RxEarly) { /* Rx early is unused. */ el3_rx(dev); outw(AckIntr | RxEarly, ioaddr + EL3_CMD); } if (status & TxComplete) { /* Really Tx error. */ short tx_status; int i = 4; while (--i>0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) { if (tx_status & 0x38) dev->stats.tx_aborted_errors++; if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD); if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD); outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ } } if (status & AdapterFailure) { /* Adapter failure requires Rx reset and reinit. */ outw(RxReset, ioaddr + EL3_CMD); /* Set the Rx filter to the current state. */ outw(SetRxFilter | RxStation | RxBroadcast | (dev->flags & IFF_ALLMULTI ? RxMulticast : 0) | (dev->flags & IFF_PROMISC ? RxProm : 0), ioaddr + EL3_CMD); outw(RxEnable, ioaddr + EL3_CMD); /* Re-enable the receiver. */ outw(AckIntr | AdapterFailure, ioaddr + EL3_CMD); } } if (--i < 0) { pr_err("%s: Infinite loop in interrupt, status %4.4x.\n", dev->name, status); /* Clear all interrupts. */ outw(AckIntr | 0xFF, ioaddr + EL3_CMD); break; } /* Acknowledge the IRQ. */ outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD); /* Ack IRQ */ } if (el3_debug > 4) { pr_debug("%s: exiting interrupt, status %4.4x.\n", dev->name, inw(ioaddr + EL3_STATUS)); } spin_unlock(&lp->lock); return IRQ_HANDLED; } #ifdef CONFIG_NET_POLL_CONTROLLER /* * Polling receive - used by netconsole and other diagnostic tools * to allow network i/o with interrupts disabled. */ static void el3_poll_controller(struct net_device *dev) { disable_irq(dev->irq); el3_interrupt(dev->irq, dev); enable_irq(dev->irq); } #endif static struct net_device_stats * el3_get_stats(struct net_device *dev) { struct el3_private *lp = netdev_priv(dev); unsigned long flags; /* * This is fast enough not to bother with disable IRQ * stuff. */ spin_lock_irqsave(&lp->lock, flags); update_stats(dev); spin_unlock_irqrestore(&lp->lock, flags); return &dev->stats; } /* Update statistics. We change to register window 6, so this should be run single-threaded if the device is active. This is expected to be a rare operation, and it's simpler for the rest of the driver to assume that window 1 is always valid rather than use a special window-state variable. */ static void update_stats(struct net_device *dev) { int ioaddr = dev->base_addr; if (el3_debug > 5) pr_debug(" Updating the statistics.\n"); /* Turn off statistics updates while reading. */ outw(StatsDisable, ioaddr + EL3_CMD); /* Switch to the stats window, and read everything. */ EL3WINDOW(6); dev->stats.tx_carrier_errors += inb(ioaddr + 0); dev->stats.tx_heartbeat_errors += inb(ioaddr + 1); /* Multiple collisions. */ inb(ioaddr + 2); dev->stats.collisions += inb(ioaddr + 3); dev->stats.tx_window_errors += inb(ioaddr + 4); dev->stats.rx_fifo_errors += inb(ioaddr + 5); dev->stats.tx_packets += inb(ioaddr + 6); /* Rx packets */ inb(ioaddr + 7); /* Tx deferrals */ inb(ioaddr + 8); inw(ioaddr + 10); /* Total Rx and Tx octets. */ inw(ioaddr + 12); /* Back to window 1, and turn statistics back on. */ EL3WINDOW(1); outw(StatsEnable, ioaddr + EL3_CMD); } static int el3_rx(struct net_device *dev) { int ioaddr = dev->base_addr; short rx_status; if (el3_debug > 5) pr_debug(" In rx_packet(), status %4.4x, rx_status %4.4x.\n", inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS)); while ((rx_status = inw(ioaddr + RX_STATUS)) > 0) { if (rx_status & 0x4000) { /* Error, update stats. */ short error = rx_status & 0x3800; outw(RxDiscard, ioaddr + EL3_CMD); dev->stats.rx_errors++; switch (error) { case 0x0000: dev->stats.rx_over_errors++; break; case 0x0800: dev->stats.rx_length_errors++; break; case 0x1000: dev->stats.rx_frame_errors++; break; case 0x1800: dev->stats.rx_length_errors++; break; case 0x2000: dev->stats.rx_frame_errors++; break; case 0x2800: dev->stats.rx_crc_errors++; break; } } else { short pkt_len = rx_status & 0x7ff; struct sk_buff *skb; skb = netdev_alloc_skb(dev, pkt_len + 5); if (el3_debug > 4) pr_debug("Receiving packet size %d status %4.4x.\n", pkt_len, rx_status); if (skb != NULL) { skb_reserve(skb, 2); /* Align IP on 16 byte */ /* 'skb->data' points to the start of sk_buff data area. */ insl(ioaddr + RX_FIFO, skb_put(skb,pkt_len), (pkt_len + 3) >> 2); outw(RxDiscard, ioaddr + EL3_CMD); /* Pop top Rx packet. */ skb->protocol = eth_type_trans(skb,dev); netif_rx(skb); dev->stats.rx_bytes += pkt_len; dev->stats.rx_packets++; continue; } outw(RxDiscard, ioaddr + EL3_CMD); dev->stats.rx_dropped++; if (el3_debug) pr_debug("%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, pkt_len); } inw(ioaddr + EL3_STATUS); /* Delay. */ while (inw(ioaddr + EL3_STATUS) & 0x1000) pr_debug(" Waiting for 3c509 to discard packet, status %x.\n", inw(ioaddr + EL3_STATUS) ); } return 0; } /* * Set or clear the multicast filter for this adaptor. */ static void set_multicast_list(struct net_device *dev) { unsigned long flags; struct el3_private *lp = netdev_priv(dev); int ioaddr = dev->base_addr; int mc_count = netdev_mc_count(dev); if (el3_debug > 1) { static int old; if (old != mc_count) { old = mc_count; pr_debug("%s: Setting Rx mode to %d addresses.\n", dev->name, mc_count); } } spin_lock_irqsave(&lp->lock, flags); if (dev->flags&IFF_PROMISC) { outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm, ioaddr + EL3_CMD); } else if (mc_count || (dev->flags&IFF_ALLMULTI)) { outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast, ioaddr + EL3_CMD); } else outw(SetRxFilter | RxStation | RxBroadcast, ioaddr + EL3_CMD); spin_unlock_irqrestore(&lp->lock, flags); } static int el3_close(struct net_device *dev) { int ioaddr = dev->base_addr; struct el3_private *lp = netdev_priv(dev); if (el3_debug > 2) pr_debug("%s: Shutting down ethercard.\n", dev->name); el3_down(dev); free_irq(dev->irq, dev); /* Switching back to window 0 disables the IRQ. */ EL3WINDOW(0); if (lp->type != EL3_EISA) { /* But we explicitly zero the IRQ line select anyway. Don't do * it on EISA cards, it prevents the module from getting an * IRQ after unload+reload... */ outw(0x0f00, ioaddr + WN0_IRQ); } return 0; } static int el3_link_ok(struct net_device *dev) { int ioaddr = dev->base_addr; u16 tmp; EL3WINDOW(4); tmp = inw(ioaddr + WN4_MEDIA); EL3WINDOW(1); return tmp & (1<<11); } static int el3_netdev_get_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd) { u16 tmp; int ioaddr = dev->base_addr; EL3WINDOW(0); /* obtain current transceiver via WN4_MEDIA? */ tmp = inw(ioaddr + WN0_ADDR_CONF); ecmd->transceiver = XCVR_INTERNAL; switch (tmp >> 14) { case 0: ecmd->port = PORT_TP; break; case 1: ecmd->port = PORT_AUI; ecmd->transceiver = XCVR_EXTERNAL; break; case 3: ecmd->port = PORT_BNC; default: break; } ecmd->duplex = DUPLEX_HALF; ecmd->supported = 0; tmp = inw(ioaddr + WN0_CONF_CTRL); if (tmp & (1<<13)) ecmd->supported |= SUPPORTED_AUI; if (tmp & (1<<12)) ecmd->supported |= SUPPORTED_BNC; if (tmp & (1<<9)) { ecmd->supported |= SUPPORTED_TP | SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full; /* hmm... */ EL3WINDOW(4); tmp = inw(ioaddr + WN4_NETDIAG); if (tmp & FD_ENABLE) ecmd->duplex = DUPLEX_FULL; } ethtool_cmd_speed_set(ecmd, SPEED_10); EL3WINDOW(1); return 0; } static int el3_netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd) { u16 tmp; int ioaddr = dev->base_addr; if (ecmd->speed != SPEED_10) return -EINVAL; if ((ecmd->duplex != DUPLEX_HALF) && (ecmd->duplex != DUPLEX_FULL)) return -EINVAL; if ((ecmd->transceiver != XCVR_INTERNAL) && (ecmd->transceiver != XCVR_EXTERNAL)) return -EINVAL; /* change XCVR type */ EL3WINDOW(0); tmp = inw(ioaddr + WN0_ADDR_CONF); switch (ecmd->port) { case PORT_TP: tmp &= ~(3<<14); dev->if_port = 0; break; case PORT_AUI: tmp |= (1<<14); dev->if_port = 1; break; case PORT_BNC: tmp |= (3<<14); dev->if_port = 3; break; default: return -EINVAL; } outw(tmp, ioaddr + WN0_ADDR_CONF); if (dev->if_port == 3) { /* fire up the DC-DC convertor if BNC gets enabled */ tmp = inw(ioaddr + WN0_ADDR_CONF); if (tmp & (3 << 14)) { outw(StartCoax, ioaddr + EL3_CMD); udelay(800); } else return -EIO; } EL3WINDOW(4); tmp = inw(ioaddr + WN4_NETDIAG); if (ecmd->duplex == DUPLEX_FULL) tmp |= FD_ENABLE; else tmp &= ~FD_ENABLE; outw(tmp, ioaddr + WN4_NETDIAG); EL3WINDOW(1); return 0; } static void el3_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strcpy(info->driver, DRV_NAME); strcpy(info->version, DRV_VERSION); } static int el3_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { struct el3_private *lp = netdev_priv(dev); int ret; spin_lock_irq(&lp->lock); ret = el3_netdev_get_ecmd(dev, ecmd); spin_unlock_irq(&lp->lock); return ret; } static int el3_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { struct el3_private *lp = netdev_priv(dev); int ret; spin_lock_irq(&lp->lock); ret = el3_netdev_set_ecmd(dev, ecmd); spin_unlock_irq(&lp->lock); return ret; } static u32 el3_get_link(struct net_device *dev) { struct el3_private *lp = netdev_priv(dev); u32 ret; spin_lock_irq(&lp->lock); ret = el3_link_ok(dev); spin_unlock_irq(&lp->lock); return ret; } static u32 el3_get_msglevel(struct net_device *dev) { return el3_debug; } static void el3_set_msglevel(struct net_device *dev, u32 v) { el3_debug = v; } static const struct ethtool_ops ethtool_ops = { .get_drvinfo = el3_get_drvinfo, .get_settings = el3_get_settings, .set_settings = el3_set_settings, .get_link = el3_get_link, .get_msglevel = el3_get_msglevel, .set_msglevel = el3_set_msglevel, }; static void el3_down(struct net_device *dev) { int ioaddr = dev->base_addr; netif_stop_queue(dev); /* Turn off statistics ASAP. We update lp->stats below. */ outw(StatsDisable, ioaddr + EL3_CMD); /* Disable the receiver and transmitter. */ outw(RxDisable, ioaddr + EL3_CMD); outw(TxDisable, ioaddr + EL3_CMD); if (dev->if_port == 3) /* Turn off thinnet power. Green! */ outw(StopCoax, ioaddr + EL3_CMD); else if (dev->if_port == 0) { /* Disable link beat and jabber, if_port may change here next open(). */ EL3WINDOW(4); outw(inw(ioaddr + WN4_MEDIA) & ~MEDIA_TP, ioaddr + WN4_MEDIA); } outw(SetIntrEnb | 0x0000, ioaddr + EL3_CMD); update_stats(dev); } static void el3_up(struct net_device *dev) { int i, sw_info, net_diag; int ioaddr = dev->base_addr; /* Activating the board required and does no harm otherwise */ outw(0x0001, ioaddr + 4); /* Set the IRQ line. */ outw((dev->irq << 12) | 0x0f00, ioaddr + WN0_IRQ); /* Set the station address in window 2 each time opened. */ EL3WINDOW(2); for (i = 0; i < 6; i++) outb(dev->dev_addr[i], ioaddr + i); if ((dev->if_port & 0x03) == 3) /* BNC interface */ /* Start the thinnet transceiver. We should really wait 50ms...*/ outw(StartCoax, ioaddr + EL3_CMD); else if ((dev->if_port & 0x03) == 0) { /* 10baseT interface */ /* Combine secondary sw_info word (the adapter level) and primary sw_info word (duplex setting plus other useless bits) */ EL3WINDOW(0); sw_info = (read_eeprom(ioaddr, 0x14) & 0x400f) | (read_eeprom(ioaddr, 0x0d) & 0xBff0); EL3WINDOW(4); net_diag = inw(ioaddr + WN4_NETDIAG); net_diag = (net_diag | FD_ENABLE); /* temporarily assume full-duplex will be set */ pr_info("%s: ", dev->name); switch (dev->if_port & 0x0c) { case 12: /* force full-duplex mode if 3c5x9b */ if (sw_info & 0x000f) { pr_cont("Forcing 3c5x9b full-duplex mode"); break; } case 8: /* set full-duplex mode based on eeprom config setting */ if ((sw_info & 0x000f) && (sw_info & 0x8000)) { pr_cont("Setting 3c5x9b full-duplex mode (from EEPROM configuration bit)"); break; } default: /* xcvr=(0 || 4) OR user has an old 3c5x9 non "B" model */ pr_cont("Setting 3c5x9/3c5x9B half-duplex mode"); net_diag = (net_diag & ~FD_ENABLE); /* disable full duplex */ } outw(net_diag, ioaddr + WN4_NETDIAG); pr_cont(" if_port: %d, sw_info: %4.4x\n", dev->if_port, sw_info); if (el3_debug > 3) pr_debug("%s: 3c5x9 net diag word is now: %4.4x.\n", dev->name, net_diag); /* Enable link beat and jabber check. */ outw(inw(ioaddr + WN4_MEDIA) | MEDIA_TP, ioaddr + WN4_MEDIA); } /* Switch to the stats window, and clear all stats by reading. */ outw(StatsDisable, ioaddr + EL3_CMD); EL3WINDOW(6); for (i = 0; i < 9; i++) inb(ioaddr + i); inw(ioaddr + 10); inw(ioaddr + 12); /* Switch to register set 1 for normal use. */ EL3WINDOW(1); /* Accept b-case and phys addr only. */ outw(SetRxFilter | RxStation | RxBroadcast, ioaddr + EL3_CMD); outw(StatsEnable, ioaddr + EL3_CMD); /* Turn on statistics. */ outw(RxEnable, ioaddr + EL3_CMD); /* Enable the receiver. */ outw(TxEnable, ioaddr + EL3_CMD); /* Enable transmitter. */ /* Allow status bits to be seen. */ outw(SetStatusEnb | 0xff, ioaddr + EL3_CMD); /* Ack all pending events, and set active indicator mask. */ outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq, ioaddr + EL3_CMD); outw(SetIntrEnb | IntLatch|TxAvailable|TxComplete|RxComplete|StatsFull, ioaddr + EL3_CMD); netif_start_queue(dev); } /* Power Management support functions */ #ifdef CONFIG_PM static int el3_suspend(struct device *pdev, pm_message_t state) { unsigned long flags; struct net_device *dev; struct el3_private *lp; int ioaddr; dev = dev_get_drvdata(pdev); lp = netdev_priv(dev); ioaddr = dev->base_addr; spin_lock_irqsave(&lp->lock, flags); if (netif_running(dev)) netif_device_detach(dev); el3_down(dev); outw(PowerDown, ioaddr + EL3_CMD); spin_unlock_irqrestore(&lp->lock, flags); return 0; } static int el3_resume(struct device *pdev) { unsigned long flags; struct net_device *dev; struct el3_private *lp; int ioaddr; dev = dev_get_drvdata(pdev); lp = netdev_priv(dev); ioaddr = dev->base_addr; spin_lock_irqsave(&lp->lock, flags); outw(PowerUp, ioaddr + EL3_CMD); EL3WINDOW(0); el3_up(dev); if (netif_running(dev)) netif_device_attach(dev); spin_unlock_irqrestore(&lp->lock, flags); return 0; } #endif /* CONFIG_PM */ module_param(debug,int, 0); module_param_array(irq, int, NULL, 0); module_param(max_interrupt_work, int, 0); MODULE_PARM_DESC(debug, "debug level (0-6)"); MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)"); MODULE_PARM_DESC(max_interrupt_work, "maximum events handled per interrupt"); #ifdef CONFIG_PNP module_param(nopnp, int, 0); MODULE_PARM_DESC(nopnp, "disable ISA PnP support (0-1)"); #endif /* CONFIG_PNP */ MODULE_DESCRIPTION("3Com Etherlink III (3c509, 3c509B, 3c529, 3c579) ethernet driver"); MODULE_LICENSE("GPL"); static int __init el3_init_module(void) { int ret = 0; if (debug >= 0) el3_debug = debug; #ifdef CONFIG_PNP if (!nopnp) { ret = pnp_register_driver(&el3_pnp_driver); if (!ret) pnp_registered = 1; } #endif /* Select an open I/O location at 0x1*0 to do ISA contention select. */ /* Start with 0x110 to avoid some sound cards.*/ for (id_port = 0x110 ; id_port < 0x200; id_port += 0x10) { if (!request_region(id_port, 1, "3c509-control")) continue; outb(0x00, id_port); outb(0xff, id_port); if (inb(id_port) & 0x01) break; else release_region(id_port, 1); } if (id_port >= 0x200) { id_port = 0; pr_err("No I/O port available for 3c509 activation.\n"); } else { ret = isa_register_driver(&el3_isa_driver, EL3_MAX_CARDS); if (!ret) isa_registered = 1; } #ifdef CONFIG_EISA ret = eisa_driver_register(&el3_eisa_driver); if (!ret) eisa_registered = 1; #endif #ifdef CONFIG_MCA ret = mca_register_driver(&el3_mca_driver); if (!ret) mca_registered = 1; #endif #ifdef CONFIG_PNP if (pnp_registered) ret = 0; #endif if (isa_registered) ret = 0; #ifdef CONFIG_EISA if (eisa_registered) ret = 0; #endif #ifdef CONFIG_MCA if (mca_registered) ret = 0; #endif return ret; } static void __exit el3_cleanup_module(void) { #ifdef CONFIG_PNP if (pnp_registered) pnp_unregister_driver(&el3_pnp_driver); #endif if (isa_registered) isa_unregister_driver(&el3_isa_driver); if (id_port) release_region(id_port, 1); #ifdef CONFIG_EISA if (eisa_registered) eisa_driver_unregister(&el3_eisa_driver); #endif #ifdef CONFIG_MCA if (mca_registered) mca_unregister_driver(&el3_mca_driver); #endif } module_init (el3_init_module); module_exit (el3_cleanup_module);
gpl-2.0
Californication/lge-kernel-msm7x27-SDSL
drivers/infiniband/hw/mlx4/srq.c
4023
8953
/* * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007, 2008 Mellanox Technologies. 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/mlx4/qp.h> #include <linux/mlx4/srq.h> #include <linux/slab.h> #include "mlx4_ib.h" #include "user.h" static void *get_wqe(struct mlx4_ib_srq *srq, int n) { return mlx4_buf_offset(&srq->buf, n << srq->msrq.wqe_shift); } static void mlx4_ib_srq_event(struct mlx4_srq *srq, enum mlx4_event type) { struct ib_event event; struct ib_srq *ibsrq = &to_mibsrq(srq)->ibsrq; if (ibsrq->event_handler) { event.device = ibsrq->device; event.element.srq = ibsrq; switch (type) { case MLX4_EVENT_TYPE_SRQ_LIMIT: event.event = IB_EVENT_SRQ_LIMIT_REACHED; break; case MLX4_EVENT_TYPE_SRQ_CATAS_ERROR: event.event = IB_EVENT_SRQ_ERR; break; default: printk(KERN_WARNING "mlx4_ib: Unexpected event type %d " "on SRQ %06x\n", type, srq->srqn); return; } ibsrq->event_handler(&event, ibsrq->srq_context); } } struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, struct ib_srq_init_attr *init_attr, struct ib_udata *udata) { struct mlx4_ib_dev *dev = to_mdev(pd->device); struct mlx4_ib_srq *srq; struct mlx4_wqe_srq_next_seg *next; struct mlx4_wqe_data_seg *scatter; int desc_size; int buf_size; int err; int i; /* Sanity check SRQ size before proceeding */ if (init_attr->attr.max_wr >= dev->dev->caps.max_srq_wqes || init_attr->attr.max_sge > dev->dev->caps.max_srq_sge) return ERR_PTR(-EINVAL); srq = kmalloc(sizeof *srq, GFP_KERNEL); if (!srq) return ERR_PTR(-ENOMEM); mutex_init(&srq->mutex); spin_lock_init(&srq->lock); srq->msrq.max = roundup_pow_of_two(init_attr->attr.max_wr + 1); srq->msrq.max_gs = init_attr->attr.max_sge; desc_size = max(32UL, roundup_pow_of_two(sizeof (struct mlx4_wqe_srq_next_seg) + srq->msrq.max_gs * sizeof (struct mlx4_wqe_data_seg))); srq->msrq.wqe_shift = ilog2(desc_size); buf_size = srq->msrq.max * desc_size; if (pd->uobject) { struct mlx4_ib_create_srq ucmd; if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { err = -EFAULT; goto err_srq; } srq->umem = ib_umem_get(pd->uobject->context, ucmd.buf_addr, buf_size, 0, 0); if (IS_ERR(srq->umem)) { err = PTR_ERR(srq->umem); goto err_srq; } err = mlx4_mtt_init(dev->dev, ib_umem_page_count(srq->umem), ilog2(srq->umem->page_size), &srq->mtt); if (err) goto err_buf; err = mlx4_ib_umem_write_mtt(dev, &srq->mtt, srq->umem); if (err) goto err_mtt; err = mlx4_ib_db_map_user(to_mucontext(pd->uobject->context), ucmd.db_addr, &srq->db); if (err) goto err_mtt; } else { err = mlx4_db_alloc(dev->dev, &srq->db, 0); if (err) goto err_srq; *srq->db.db = 0; if (mlx4_buf_alloc(dev->dev, buf_size, PAGE_SIZE * 2, &srq->buf)) { err = -ENOMEM; goto err_db; } srq->head = 0; srq->tail = srq->msrq.max - 1; srq->wqe_ctr = 0; for (i = 0; i < srq->msrq.max; ++i) { next = get_wqe(srq, i); next->next_wqe_index = cpu_to_be16((i + 1) & (srq->msrq.max - 1)); for (scatter = (void *) (next + 1); (void *) scatter < (void *) next + desc_size; ++scatter) scatter->lkey = cpu_to_be32(MLX4_INVALID_LKEY); } err = mlx4_mtt_init(dev->dev, srq->buf.npages, srq->buf.page_shift, &srq->mtt); if (err) goto err_buf; err = mlx4_buf_write_mtt(dev->dev, &srq->mtt, &srq->buf); if (err) goto err_mtt; srq->wrid = kmalloc(srq->msrq.max * sizeof (u64), GFP_KERNEL); if (!srq->wrid) { err = -ENOMEM; goto err_mtt; } } err = mlx4_srq_alloc(dev->dev, to_mpd(pd)->pdn, &srq->mtt, srq->db.dma, &srq->msrq); if (err) goto err_wrid; srq->msrq.event = mlx4_ib_srq_event; if (pd->uobject) if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof (__u32))) { err = -EFAULT; goto err_wrid; } init_attr->attr.max_wr = srq->msrq.max - 1; return &srq->ibsrq; err_wrid: if (pd->uobject) mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &srq->db); else kfree(srq->wrid); err_mtt: mlx4_mtt_cleanup(dev->dev, &srq->mtt); err_buf: if (pd->uobject) ib_umem_release(srq->umem); else mlx4_buf_free(dev->dev, buf_size, &srq->buf); err_db: if (!pd->uobject) mlx4_db_free(dev->dev, &srq->db); err_srq: kfree(srq); return ERR_PTR(err); } int mlx4_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, enum ib_srq_attr_mask attr_mask, struct ib_udata *udata) { struct mlx4_ib_dev *dev = to_mdev(ibsrq->device); struct mlx4_ib_srq *srq = to_msrq(ibsrq); int ret; /* We don't support resizing SRQs (yet?) */ if (attr_mask & IB_SRQ_MAX_WR) return -EINVAL; if (attr_mask & IB_SRQ_LIMIT) { if (attr->srq_limit >= srq->msrq.max) return -EINVAL; mutex_lock(&srq->mutex); ret = mlx4_srq_arm(dev->dev, &srq->msrq, attr->srq_limit); mutex_unlock(&srq->mutex); if (ret) return ret; } return 0; } int mlx4_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr) { struct mlx4_ib_dev *dev = to_mdev(ibsrq->device); struct mlx4_ib_srq *srq = to_msrq(ibsrq); int ret; int limit_watermark; ret = mlx4_srq_query(dev->dev, &srq->msrq, &limit_watermark); if (ret) return ret; srq_attr->srq_limit = limit_watermark; srq_attr->max_wr = srq->msrq.max - 1; srq_attr->max_sge = srq->msrq.max_gs; return 0; } int mlx4_ib_destroy_srq(struct ib_srq *srq) { struct mlx4_ib_dev *dev = to_mdev(srq->device); struct mlx4_ib_srq *msrq = to_msrq(srq); mlx4_srq_free(dev->dev, &msrq->msrq); mlx4_mtt_cleanup(dev->dev, &msrq->mtt); if (srq->uobject) { mlx4_ib_db_unmap_user(to_mucontext(srq->uobject->context), &msrq->db); ib_umem_release(msrq->umem); } else { kfree(msrq->wrid); mlx4_buf_free(dev->dev, msrq->msrq.max << msrq->msrq.wqe_shift, &msrq->buf); mlx4_db_free(dev->dev, &msrq->db); } kfree(msrq); return 0; } void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index) { struct mlx4_wqe_srq_next_seg *next; /* always called with interrupts disabled. */ spin_lock(&srq->lock); next = get_wqe(srq, srq->tail); next->next_wqe_index = cpu_to_be16(wqe_index); srq->tail = wqe_index; spin_unlock(&srq->lock); } int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr, struct ib_recv_wr **bad_wr) { struct mlx4_ib_srq *srq = to_msrq(ibsrq); struct mlx4_wqe_srq_next_seg *next; struct mlx4_wqe_data_seg *scat; unsigned long flags; int err = 0; int nreq; int i; spin_lock_irqsave(&srq->lock, flags); for (nreq = 0; wr; ++nreq, wr = wr->next) { if (unlikely(wr->num_sge > srq->msrq.max_gs)) { err = -EINVAL; *bad_wr = wr; break; } if (unlikely(srq->head == srq->tail)) { err = -ENOMEM; *bad_wr = wr; break; } srq->wrid[srq->head] = wr->wr_id; next = get_wqe(srq, srq->head); srq->head = be16_to_cpu(next->next_wqe_index); scat = (struct mlx4_wqe_data_seg *) (next + 1); for (i = 0; i < wr->num_sge; ++i) { scat[i].byte_count = cpu_to_be32(wr->sg_list[i].length); scat[i].lkey = cpu_to_be32(wr->sg_list[i].lkey); scat[i].addr = cpu_to_be64(wr->sg_list[i].addr); } if (i < srq->msrq.max_gs) { scat[i].byte_count = 0; scat[i].lkey = cpu_to_be32(MLX4_INVALID_LKEY); scat[i].addr = 0; } } if (likely(nreq)) { srq->wqe_ctr += nreq; /* * Make sure that descriptors are written before * doorbell record. */ wmb(); *srq->db.db = cpu_to_be32(srq->wqe_ctr); } spin_unlock_irqrestore(&srq->lock, flags); return err; }
gpl-2.0
s9yobena/linux-btrfs
drivers/ide/opti621.c
4791
4568
/* * Copyright (C) 1996-1998 Linus Torvalds & authors (see below) */ /* * Authors: * Jaromir Koutek <miri@punknet.cz>, * Jan Harkes <jaharkes@cwi.nl>, * Mark Lord <mlord@pobox.com> * Some parts of code are from ali14xx.c and from rz1000.c. */ #include <linux/types.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/pci.h> #include <linux/ide.h> #include <asm/io.h> #define DRV_NAME "opti621" #define READ_REG 0 /* index of Read cycle timing register */ #define WRITE_REG 1 /* index of Write cycle timing register */ #define CNTRL_REG 3 /* index of Control register */ #define STRAP_REG 5 /* index of Strap register */ #define MISC_REG 6 /* index of Miscellaneous register */ static int reg_base; static DEFINE_SPINLOCK(opti621_lock); /* Write value to register reg, base of register * is at reg_base (0x1f0 primary, 0x170 secondary, * if not changed by PCI configuration). * This is from setupvic.exe program. */ static void write_reg(u8 value, int reg) { inw(reg_base + 1); inw(reg_base + 1); outb(3, reg_base + 2); outb(value, reg_base + reg); outb(0x83, reg_base + 2); } /* Read value from register reg, base of register * is at reg_base (0x1f0 primary, 0x170 secondary, * if not changed by PCI configuration). * This is from setupvic.exe program. */ static u8 read_reg(int reg) { u8 ret = 0; inw(reg_base + 1); inw(reg_base + 1); outb(3, reg_base + 2); ret = inb(reg_base + reg); outb(0x83, reg_base + 2); return ret; } static void opti621_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) { ide_drive_t *pair = ide_get_pair_dev(drive); unsigned long flags; unsigned long mode = drive->pio_mode, pair_mode; const u8 pio = mode - XFER_PIO_0; u8 tim, misc, addr_pio = pio, clk; /* DRDY is default 2 (by OPTi Databook) */ static const u8 addr_timings[2][5] = { { 0x20, 0x10, 0x00, 0x00, 0x00 }, /* 33 MHz */ { 0x10, 0x10, 0x00, 0x00, 0x00 }, /* 25 MHz */ }; static const u8 data_rec_timings[2][5] = { { 0x5b, 0x45, 0x32, 0x21, 0x20 }, /* 33 MHz */ { 0x48, 0x34, 0x21, 0x10, 0x10 } /* 25 MHz */ }; ide_set_drivedata(drive, (void *)mode); if (pair) { pair_mode = (unsigned long)ide_get_drivedata(pair); if (pair_mode && pair_mode < mode) addr_pio = pair_mode - XFER_PIO_0; } spin_lock_irqsave(&opti621_lock, flags); reg_base = hwif->io_ports.data_addr; /* allow Register-B */ outb(0xc0, reg_base + CNTRL_REG); /* hmm, setupvic.exe does this ;-) */ outb(0xff, reg_base + 5); /* if reads 0xff, adapter not exist? */ (void)inb(reg_base + CNTRL_REG); /* if reads 0xc0, no interface exist? */ read_reg(CNTRL_REG); /* check CLK speed */ clk = read_reg(STRAP_REG) & 1; printk(KERN_INFO "%s: CLK = %d MHz\n", hwif->name, clk ? 25 : 33); tim = data_rec_timings[clk][pio]; misc = addr_timings[clk][addr_pio]; /* select Index-0/1 for Register-A/B */ write_reg(drive->dn & 1, MISC_REG); /* set read cycle timings */ write_reg(tim, READ_REG); /* set write cycle timings */ write_reg(tim, WRITE_REG); /* use Register-A for drive 0 */ /* use Register-B for drive 1 */ write_reg(0x85, CNTRL_REG); /* set address setup, DRDY timings, */ /* and read prefetch for both drives */ write_reg(misc, MISC_REG); spin_unlock_irqrestore(&opti621_lock, flags); } static const struct ide_port_ops opti621_port_ops = { .set_pio_mode = opti621_set_pio_mode, }; static const struct ide_port_info opti621_chipset = { .name = DRV_NAME, .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, .port_ops = &opti621_port_ops, .host_flags = IDE_HFLAG_NO_DMA, .pio_mask = ATA_PIO4, }; static int opti621_init_one(struct pci_dev *dev, const struct pci_device_id *id) { return ide_pci_init_one(dev, &opti621_chipset, NULL); } static const struct pci_device_id opti621_pci_tbl[] = { { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C621), 0 }, { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C825), 0 }, { 0, }, }; MODULE_DEVICE_TABLE(pci, opti621_pci_tbl); static struct pci_driver opti621_pci_driver = { .name = "Opti621_IDE", .id_table = opti621_pci_tbl, .probe = opti621_init_one, .remove = ide_pci_remove, .suspend = ide_pci_suspend, .resume = ide_pci_resume, }; static int __init opti621_ide_init(void) { return ide_pci_register_driver(&opti621_pci_driver); } static void __exit opti621_ide_exit(void) { pci_unregister_driver(&opti621_pci_driver); } module_init(opti621_ide_init); module_exit(opti621_ide_exit); MODULE_AUTHOR("Jaromir Koutek, Jan Harkes, Mark Lord"); MODULE_DESCRIPTION("PCI driver module for Opti621 IDE"); MODULE_LICENSE("GPL");
gpl-2.0
princeofgiri/ridon-kernel_xiaomi_armani
net/decnet/dn_nsp_out.c
4791
17970
/* * DECnet An implementation of the DECnet protocol suite for the LINUX * operating system. DECnet is implemented using the BSD Socket * interface as the means of communication with the user level. * * DECnet Network Services Protocol (Output) * * Author: Eduardo Marcelo Serrat <emserrat@geocities.com> * * Changes: * * Steve Whitehouse: Split into dn_nsp_in.c and dn_nsp_out.c from * original dn_nsp.c. * Steve Whitehouse: Updated to work with my new routing architecture. * Steve Whitehouse: Added changes from Eduardo Serrat's patches. * Steve Whitehouse: Now conninits have the "return" bit set. * Steve Whitehouse: Fixes to check alloc'd skbs are non NULL! * Moved output state machine into one function * Steve Whitehouse: New output state machine * Paul Koning: Connect Confirm message fix. * Eduardo Serrat: Fix to stop dn_nsp_do_disc() sending malformed packets. * Steve Whitehouse: dn_nsp_output() and friends needed a spring clean * Steve Whitehouse: Moved dn_nsp_send() in here from route.h */ /****************************************************************************** (c) 1995-1998 E.M. Serrat emserrat@geocities.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 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/errno.h> #include <linux/types.h> #include <linux/socket.h> #include <linux/in.h> #include <linux/kernel.h> #include <linux/timer.h> #include <linux/string.h> #include <linux/sockios.h> #include <linux/net.h> #include <linux/netdevice.h> #include <linux/inet.h> #include <linux/route.h> #include <linux/slab.h> #include <net/sock.h> #include <linux/fcntl.h> #include <linux/mm.h> #include <linux/termios.h> #include <linux/interrupt.h> #include <linux/proc_fs.h> #include <linux/stat.h> #include <linux/init.h> #include <linux/poll.h> #include <linux/if_packet.h> #include <net/neighbour.h> #include <net/dst.h> #include <net/flow.h> #include <net/dn.h> #include <net/dn_nsp.h> #include <net/dn_dev.h> #include <net/dn_route.h> static int nsp_backoff[NSP_MAXRXTSHIFT + 1] = { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 }; static void dn_nsp_send(struct sk_buff *skb) { struct sock *sk = skb->sk; struct dn_scp *scp = DN_SK(sk); struct dst_entry *dst; struct flowidn fld; skb_reset_transport_header(skb); scp->stamp = jiffies; dst = sk_dst_check(sk, 0); if (dst) { try_again: skb_dst_set(skb, dst); dst_output(skb); return; } memset(&fld, 0, sizeof(fld)); fld.flowidn_oif = sk->sk_bound_dev_if; fld.saddr = dn_saddr2dn(&scp->addr); fld.daddr = dn_saddr2dn(&scp->peer); dn_sk_ports_copy(&fld, scp); fld.flowidn_proto = DNPROTO_NSP; if (dn_route_output_sock(&sk->sk_dst_cache, &fld, sk, 0) == 0) { dst = sk_dst_get(sk); sk->sk_route_caps = dst->dev->features; goto try_again; } sk->sk_err = EHOSTUNREACH; if (!sock_flag(sk, SOCK_DEAD)) sk->sk_state_change(sk); } /* * If sk == NULL, then we assume that we are supposed to be making * a routing layer skb. If sk != NULL, then we are supposed to be * creating an skb for the NSP layer. * * The eventual aim is for each socket to have a cached header size * for its outgoing packets, and to set hdr from this when sk != NULL. */ struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri) { struct sk_buff *skb; int hdr = 64; if ((skb = alloc_skb(size + hdr, pri)) == NULL) return NULL; skb->protocol = htons(ETH_P_DNA_RT); skb->pkt_type = PACKET_OUTGOING; if (sk) skb_set_owner_w(skb, sk); skb_reserve(skb, hdr); return skb; } /* * Calculate persist timer based upon the smoothed round * trip time and the variance. Backoff according to the * nsp_backoff[] array. */ unsigned long dn_nsp_persist(struct sock *sk) { struct dn_scp *scp = DN_SK(sk); unsigned long t = ((scp->nsp_srtt >> 2) + scp->nsp_rttvar) >> 1; t *= nsp_backoff[scp->nsp_rxtshift]; if (t < HZ) t = HZ; if (t > (600*HZ)) t = (600*HZ); if (scp->nsp_rxtshift < NSP_MAXRXTSHIFT) scp->nsp_rxtshift++; /* printk(KERN_DEBUG "rxtshift %lu, t=%lu\n", scp->nsp_rxtshift, t); */ return t; } /* * This is called each time we get an estimate for the rtt * on the link. */ static void dn_nsp_rtt(struct sock *sk, long rtt) { struct dn_scp *scp = DN_SK(sk); long srtt = (long)scp->nsp_srtt; long rttvar = (long)scp->nsp_rttvar; long delta; /* * If the jiffies clock flips over in the middle of timestamp * gathering this value might turn out negative, so we make sure * that is it always positive here. */ if (rtt < 0) rtt = -rtt; /* * Add new rtt to smoothed average */ delta = ((rtt << 3) - srtt); srtt += (delta >> 3); if (srtt >= 1) scp->nsp_srtt = (unsigned long)srtt; else scp->nsp_srtt = 1; /* * Add new rtt varience to smoothed varience */ delta >>= 1; rttvar += ((((delta>0)?(delta):(-delta)) - rttvar) >> 2); if (rttvar >= 1) scp->nsp_rttvar = (unsigned long)rttvar; else scp->nsp_rttvar = 1; /* printk(KERN_DEBUG "srtt=%lu rttvar=%lu\n", scp->nsp_srtt, scp->nsp_rttvar); */ } /** * dn_nsp_clone_and_send - Send a data packet by cloning it * @skb: The packet to clone and transmit * @gfp: memory allocation flag * * Clone a queued data or other data packet and transmit it. * * Returns: The number of times the packet has been sent previously */ static inline unsigned dn_nsp_clone_and_send(struct sk_buff *skb, gfp_t gfp) { struct dn_skb_cb *cb = DN_SKB_CB(skb); struct sk_buff *skb2; int ret = 0; if ((skb2 = skb_clone(skb, gfp)) != NULL) { ret = cb->xmit_count; cb->xmit_count++; cb->stamp = jiffies; skb2->sk = skb->sk; dn_nsp_send(skb2); } return ret; } /** * dn_nsp_output - Try and send something from socket queues * @sk: The socket whose queues are to be investigated * * Try and send the packet on the end of the data and other data queues. * Other data gets priority over data, and if we retransmit a packet we * reduce the window by dividing it in two. * */ void dn_nsp_output(struct sock *sk) { struct dn_scp *scp = DN_SK(sk); struct sk_buff *skb; unsigned reduce_win = 0; /* * First we check for otherdata/linkservice messages */ if ((skb = skb_peek(&scp->other_xmit_queue)) != NULL) reduce_win = dn_nsp_clone_and_send(skb, GFP_ATOMIC); /* * If we may not send any data, we don't. * If we are still trying to get some other data down the * channel, we don't try and send any data. */ if (reduce_win || (scp->flowrem_sw != DN_SEND)) goto recalc_window; if ((skb = skb_peek(&scp->data_xmit_queue)) != NULL) reduce_win = dn_nsp_clone_and_send(skb, GFP_ATOMIC); /* * If we've sent any frame more than once, we cut the * send window size in half. There is always a minimum * window size of one available. */ recalc_window: if (reduce_win) { scp->snd_window >>= 1; if (scp->snd_window < NSP_MIN_WINDOW) scp->snd_window = NSP_MIN_WINDOW; } } int dn_nsp_xmit_timeout(struct sock *sk) { struct dn_scp *scp = DN_SK(sk); dn_nsp_output(sk); if (!skb_queue_empty(&scp->data_xmit_queue) || !skb_queue_empty(&scp->other_xmit_queue)) scp->persist = dn_nsp_persist(sk); return 0; } static inline __le16 *dn_mk_common_header(struct dn_scp *scp, struct sk_buff *skb, unsigned char msgflag, int len) { unsigned char *ptr = skb_push(skb, len); BUG_ON(len < 5); *ptr++ = msgflag; *((__le16 *)ptr) = scp->addrrem; ptr += 2; *((__le16 *)ptr) = scp->addrloc; ptr += 2; return (__le16 __force *)ptr; } static __le16 *dn_mk_ack_header(struct sock *sk, struct sk_buff *skb, unsigned char msgflag, int hlen, int other) { struct dn_scp *scp = DN_SK(sk); unsigned short acknum = scp->numdat_rcv & 0x0FFF; unsigned short ackcrs = scp->numoth_rcv & 0x0FFF; __le16 *ptr; BUG_ON(hlen < 9); scp->ackxmt_dat = acknum; scp->ackxmt_oth = ackcrs; acknum |= 0x8000; ackcrs |= 0x8000; /* If this is an "other data/ack" message, swap acknum and ackcrs */ if (other) { unsigned short tmp = acknum; acknum = ackcrs; ackcrs = tmp; } /* Set "cross subchannel" bit in ackcrs */ ackcrs |= 0x2000; ptr = (__le16 *)dn_mk_common_header(scp, skb, msgflag, hlen); *ptr++ = cpu_to_le16(acknum); *ptr++ = cpu_to_le16(ackcrs); return ptr; } static __le16 *dn_nsp_mk_data_header(struct sock *sk, struct sk_buff *skb, int oth) { struct dn_scp *scp = DN_SK(sk); struct dn_skb_cb *cb = DN_SKB_CB(skb); __le16 *ptr = dn_mk_ack_header(sk, skb, cb->nsp_flags, 11, oth); if (unlikely(oth)) { cb->segnum = scp->numoth; seq_add(&scp->numoth, 1); } else { cb->segnum = scp->numdat; seq_add(&scp->numdat, 1); } *(ptr++) = cpu_to_le16(cb->segnum); return ptr; } void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, gfp_t gfp, int oth) { struct dn_scp *scp = DN_SK(sk); struct dn_skb_cb *cb = DN_SKB_CB(skb); unsigned long t = ((scp->nsp_srtt >> 2) + scp->nsp_rttvar) >> 1; cb->xmit_count = 0; dn_nsp_mk_data_header(sk, skb, oth); /* * Slow start: If we have been idle for more than * one RTT, then reset window to min size. */ if ((jiffies - scp->stamp) > t) scp->snd_window = NSP_MIN_WINDOW; if (oth) skb_queue_tail(&scp->other_xmit_queue, skb); else skb_queue_tail(&scp->data_xmit_queue, skb); if (scp->flowrem_sw != DN_SEND) return; dn_nsp_clone_and_send(skb, gfp); } int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff_head *q, unsigned short acknum) { struct dn_skb_cb *cb = DN_SKB_CB(skb); struct dn_scp *scp = DN_SK(sk); struct sk_buff *skb2, *n, *ack = NULL; int wakeup = 0; int try_retrans = 0; unsigned long reftime = cb->stamp; unsigned long pkttime; unsigned short xmit_count; unsigned short segnum; skb_queue_walk_safe(q, skb2, n) { struct dn_skb_cb *cb2 = DN_SKB_CB(skb2); if (dn_before_or_equal(cb2->segnum, acknum)) ack = skb2; /* printk(KERN_DEBUG "ack: %s %04x %04x\n", ack ? "ACK" : "SKIP", (int)cb2->segnum, (int)acknum); */ if (ack == NULL) continue; /* printk(KERN_DEBUG "check_xmit_queue: %04x, %d\n", acknum, cb2->xmit_count); */ /* Does _last_ packet acked have xmit_count > 1 */ try_retrans = 0; /* Remember to wake up the sending process */ wakeup = 1; /* Keep various statistics */ pkttime = cb2->stamp; xmit_count = cb2->xmit_count; segnum = cb2->segnum; /* Remove and drop ack'ed packet */ skb_unlink(ack, q); kfree_skb(ack); ack = NULL; /* * We don't expect to see acknowledgements for packets we * haven't sent yet. */ WARN_ON(xmit_count == 0); /* * If the packet has only been sent once, we can use it * to calculate the RTT and also open the window a little * further. */ if (xmit_count == 1) { if (dn_equal(segnum, acknum)) dn_nsp_rtt(sk, (long)(pkttime - reftime)); if (scp->snd_window < scp->max_window) scp->snd_window++; } /* * Packet has been sent more than once. If this is the last * packet to be acknowledged then we want to send the next * packet in the send queue again (assumes the remote host does * go-back-N error control). */ if (xmit_count > 1) try_retrans = 1; } if (try_retrans) dn_nsp_output(sk); return wakeup; } void dn_nsp_send_data_ack(struct sock *sk) { struct sk_buff *skb = NULL; if ((skb = dn_alloc_skb(sk, 9, GFP_ATOMIC)) == NULL) return; skb_reserve(skb, 9); dn_mk_ack_header(sk, skb, 0x04, 9, 0); dn_nsp_send(skb); } void dn_nsp_send_oth_ack(struct sock *sk) { struct sk_buff *skb = NULL; if ((skb = dn_alloc_skb(sk, 9, GFP_ATOMIC)) == NULL) return; skb_reserve(skb, 9); dn_mk_ack_header(sk, skb, 0x14, 9, 1); dn_nsp_send(skb); } void dn_send_conn_ack (struct sock *sk) { struct dn_scp *scp = DN_SK(sk); struct sk_buff *skb = NULL; struct nsp_conn_ack_msg *msg; if ((skb = dn_alloc_skb(sk, 3, sk->sk_allocation)) == NULL) return; msg = (struct nsp_conn_ack_msg *)skb_put(skb, 3); msg->msgflg = 0x24; msg->dstaddr = scp->addrrem; dn_nsp_send(skb); } void dn_nsp_delayed_ack(struct sock *sk) { struct dn_scp *scp = DN_SK(sk); if (scp->ackxmt_oth != scp->numoth_rcv) dn_nsp_send_oth_ack(sk); if (scp->ackxmt_dat != scp->numdat_rcv) dn_nsp_send_data_ack(sk); } static int dn_nsp_retrans_conn_conf(struct sock *sk) { struct dn_scp *scp = DN_SK(sk); if (scp->state == DN_CC) dn_send_conn_conf(sk, GFP_ATOMIC); return 0; } void dn_send_conn_conf(struct sock *sk, gfp_t gfp) { struct dn_scp *scp = DN_SK(sk); struct sk_buff *skb = NULL; struct nsp_conn_init_msg *msg; __u8 len = (__u8)le16_to_cpu(scp->conndata_out.opt_optl); if ((skb = dn_alloc_skb(sk, 50 + len, gfp)) == NULL) return; msg = (struct nsp_conn_init_msg *)skb_put(skb, sizeof(*msg)); msg->msgflg = 0x28; msg->dstaddr = scp->addrrem; msg->srcaddr = scp->addrloc; msg->services = scp->services_loc; msg->info = scp->info_loc; msg->segsize = cpu_to_le16(scp->segsize_loc); *skb_put(skb,1) = len; if (len > 0) memcpy(skb_put(skb, len), scp->conndata_out.opt_data, len); dn_nsp_send(skb); scp->persist = dn_nsp_persist(sk); scp->persist_fxn = dn_nsp_retrans_conn_conf; } static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg, unsigned short reason, gfp_t gfp, struct dst_entry *dst, int ddl, unsigned char *dd, __le16 rem, __le16 loc) { struct sk_buff *skb = NULL; int size = 7 + ddl + ((msgflg == NSP_DISCINIT) ? 1 : 0); unsigned char *msg; if ((dst == NULL) || (rem == 0)) { if (net_ratelimit()) printk(KERN_DEBUG "DECnet: dn_nsp_do_disc: BUG! Please report this to SteveW@ACM.org rem=%u dst=%p\n", le16_to_cpu(rem), dst); return; } if ((skb = dn_alloc_skb(sk, size, gfp)) == NULL) return; msg = skb_put(skb, size); *msg++ = msgflg; *(__le16 *)msg = rem; msg += 2; *(__le16 *)msg = loc; msg += 2; *(__le16 *)msg = cpu_to_le16(reason); msg += 2; if (msgflg == NSP_DISCINIT) *msg++ = ddl; if (ddl) { memcpy(msg, dd, ddl); } /* * This doesn't go via the dn_nsp_send() function since we need * to be able to send disc packets out which have no socket * associations. */ skb_dst_set(skb, dst_clone(dst)); dst_output(skb); } void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg, unsigned short reason, gfp_t gfp) { struct dn_scp *scp = DN_SK(sk); int ddl = 0; if (msgflg == NSP_DISCINIT) ddl = le16_to_cpu(scp->discdata_out.opt_optl); if (reason == 0) reason = le16_to_cpu(scp->discdata_out.opt_status); dn_nsp_do_disc(sk, msgflg, reason, gfp, sk->sk_dst_cache, ddl, scp->discdata_out.opt_data, scp->addrrem, scp->addrloc); } void dn_nsp_return_disc(struct sk_buff *skb, unsigned char msgflg, unsigned short reason) { struct dn_skb_cb *cb = DN_SKB_CB(skb); int ddl = 0; gfp_t gfp = GFP_ATOMIC; dn_nsp_do_disc(NULL, msgflg, reason, gfp, skb_dst(skb), ddl, NULL, cb->src_port, cb->dst_port); } void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval) { struct dn_scp *scp = DN_SK(sk); struct sk_buff *skb; unsigned char *ptr; gfp_t gfp = GFP_ATOMIC; if ((skb = dn_alloc_skb(sk, DN_MAX_NSP_DATA_HEADER + 2, gfp)) == NULL) return; skb_reserve(skb, DN_MAX_NSP_DATA_HEADER); ptr = skb_put(skb, 2); DN_SKB_CB(skb)->nsp_flags = 0x10; *ptr++ = lsflags; *ptr = fcval; dn_nsp_queue_xmit(sk, skb, gfp, 1); scp->persist = dn_nsp_persist(sk); scp->persist_fxn = dn_nsp_xmit_timeout; } static int dn_nsp_retrans_conninit(struct sock *sk) { struct dn_scp *scp = DN_SK(sk); if (scp->state == DN_CI) dn_nsp_send_conninit(sk, NSP_RCI); return 0; } void dn_nsp_send_conninit(struct sock *sk, unsigned char msgflg) { struct dn_scp *scp = DN_SK(sk); struct nsp_conn_init_msg *msg; unsigned char aux; unsigned char menuver; struct dn_skb_cb *cb; unsigned char type = 1; gfp_t allocation = (msgflg == NSP_CI) ? sk->sk_allocation : GFP_ATOMIC; struct sk_buff *skb = dn_alloc_skb(sk, 200, allocation); if (!skb) return; cb = DN_SKB_CB(skb); msg = (struct nsp_conn_init_msg *)skb_put(skb,sizeof(*msg)); msg->msgflg = msgflg; msg->dstaddr = 0x0000; /* Remote Node will assign it*/ msg->srcaddr = scp->addrloc; msg->services = scp->services_loc; /* Requested flow control */ msg->info = scp->info_loc; /* Version Number */ msg->segsize = cpu_to_le16(scp->segsize_loc); /* Max segment size */ if (scp->peer.sdn_objnum) type = 0; skb_put(skb, dn_sockaddr2username(&scp->peer, skb_tail_pointer(skb), type)); skb_put(skb, dn_sockaddr2username(&scp->addr, skb_tail_pointer(skb), 2)); menuver = DN_MENUVER_ACC | DN_MENUVER_USR; if (scp->peer.sdn_flags & SDF_PROXY) menuver |= DN_MENUVER_PRX; if (scp->peer.sdn_flags & SDF_UICPROXY) menuver |= DN_MENUVER_UIC; *skb_put(skb, 1) = menuver; /* Menu Version */ aux = scp->accessdata.acc_userl; *skb_put(skb, 1) = aux; if (aux > 0) memcpy(skb_put(skb, aux), scp->accessdata.acc_user, aux); aux = scp->accessdata.acc_passl; *skb_put(skb, 1) = aux; if (aux > 0) memcpy(skb_put(skb, aux), scp->accessdata.acc_pass, aux); aux = scp->accessdata.acc_accl; *skb_put(skb, 1) = aux; if (aux > 0) memcpy(skb_put(skb, aux), scp->accessdata.acc_acc, aux); aux = (__u8)le16_to_cpu(scp->conndata_out.opt_optl); *skb_put(skb, 1) = aux; if (aux > 0) memcpy(skb_put(skb, aux), scp->conndata_out.opt_data, aux); scp->persist = dn_nsp_persist(sk); scp->persist_fxn = dn_nsp_retrans_conninit; cb->rt_flags = DN_RT_F_RQR; dn_nsp_send(skb); }
gpl-2.0
flar2/m8-GPE-5.0.1
drivers/video/omap2/dss/venc.c
4791
21906
/* * linux/drivers/video/omap2/dss/venc.c * * Copyright (C) 2009 Nokia Corporation * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> * * VENC settings from TI's DSS driver * * 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, see <http://www.gnu.org/licenses/>. */ #define DSS_SUBSYS_NAME "VENC" #include <linux/kernel.h> #include <linux/module.h> #include <linux/clk.h> #include <linux/err.h> #include <linux/io.h> #include <linux/mutex.h> #include <linux/completion.h> #include <linux/delay.h> #include <linux/string.h> #include <linux/seq_file.h> #include <linux/platform_device.h> #include <linux/regulator/consumer.h> #include <linux/pm_runtime.h> #include <video/omapdss.h> #include <plat/cpu.h> #include "dss.h" #include "dss_features.h" /* Venc registers */ #define VENC_REV_ID 0x00 #define VENC_STATUS 0x04 #define VENC_F_CONTROL 0x08 #define VENC_VIDOUT_CTRL 0x10 #define VENC_SYNC_CTRL 0x14 #define VENC_LLEN 0x1C #define VENC_FLENS 0x20 #define VENC_HFLTR_CTRL 0x24 #define VENC_CC_CARR_WSS_CARR 0x28 #define VENC_C_PHASE 0x2C #define VENC_GAIN_U 0x30 #define VENC_GAIN_V 0x34 #define VENC_GAIN_Y 0x38 #define VENC_BLACK_LEVEL 0x3C #define VENC_BLANK_LEVEL 0x40 #define VENC_X_COLOR 0x44 #define VENC_M_CONTROL 0x48 #define VENC_BSTAMP_WSS_DATA 0x4C #define VENC_S_CARR 0x50 #define VENC_LINE21 0x54 #define VENC_LN_SEL 0x58 #define VENC_L21__WC_CTL 0x5C #define VENC_HTRIGGER_VTRIGGER 0x60 #define VENC_SAVID__EAVID 0x64 #define VENC_FLEN__FAL 0x68 #define VENC_LAL__PHASE_RESET 0x6C #define VENC_HS_INT_START_STOP_X 0x70 #define VENC_HS_EXT_START_STOP_X 0x74 #define VENC_VS_INT_START_X 0x78 #define VENC_VS_INT_STOP_X__VS_INT_START_Y 0x7C #define VENC_VS_INT_STOP_Y__VS_EXT_START_X 0x80 #define VENC_VS_EXT_STOP_X__VS_EXT_START_Y 0x84 #define VENC_VS_EXT_STOP_Y 0x88 #define VENC_AVID_START_STOP_X 0x90 #define VENC_AVID_START_STOP_Y 0x94 #define VENC_FID_INT_START_X__FID_INT_START_Y 0xA0 #define VENC_FID_INT_OFFSET_Y__FID_EXT_START_X 0xA4 #define VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y 0xA8 #define VENC_TVDETGP_INT_START_STOP_X 0xB0 #define VENC_TVDETGP_INT_START_STOP_Y 0xB4 #define VENC_GEN_CTRL 0xB8 #define VENC_OUTPUT_CONTROL 0xC4 #define VENC_OUTPUT_TEST 0xC8 #define VENC_DAC_B__DAC_C 0xC8 struct venc_config { u32 f_control; u32 vidout_ctrl; u32 sync_ctrl; u32 llen; u32 flens; u32 hfltr_ctrl; u32 cc_carr_wss_carr; u32 c_phase; u32 gain_u; u32 gain_v; u32 gain_y; u32 black_level; u32 blank_level; u32 x_color; u32 m_control; u32 bstamp_wss_data; u32 s_carr; u32 line21; u32 ln_sel; u32 l21__wc_ctl; u32 htrigger_vtrigger; u32 savid__eavid; u32 flen__fal; u32 lal__phase_reset; u32 hs_int_start_stop_x; u32 hs_ext_start_stop_x; u32 vs_int_start_x; u32 vs_int_stop_x__vs_int_start_y; u32 vs_int_stop_y__vs_ext_start_x; u32 vs_ext_stop_x__vs_ext_start_y; u32 vs_ext_stop_y; u32 avid_start_stop_x; u32 avid_start_stop_y; u32 fid_int_start_x__fid_int_start_y; u32 fid_int_offset_y__fid_ext_start_x; u32 fid_ext_start_y__fid_ext_offset_y; u32 tvdetgp_int_start_stop_x; u32 tvdetgp_int_start_stop_y; u32 gen_ctrl; }; /* from TRM */ static const struct venc_config venc_config_pal_trm = { .f_control = 0, .vidout_ctrl = 1, .sync_ctrl = 0x40, .llen = 0x35F, /* 863 */ .flens = 0x270, /* 624 */ .hfltr_ctrl = 0, .cc_carr_wss_carr = 0x2F7225ED, .c_phase = 0, .gain_u = 0x111, .gain_v = 0x181, .gain_y = 0x140, .black_level = 0x3B, .blank_level = 0x3B, .x_color = 0x7, .m_control = 0x2, .bstamp_wss_data = 0x3F, .s_carr = 0x2A098ACB, .line21 = 0, .ln_sel = 0x01290015, .l21__wc_ctl = 0x0000F603, .htrigger_vtrigger = 0, .savid__eavid = 0x06A70108, .flen__fal = 0x00180270, .lal__phase_reset = 0x00040135, .hs_int_start_stop_x = 0x00880358, .hs_ext_start_stop_x = 0x000F035F, .vs_int_start_x = 0x01A70000, .vs_int_stop_x__vs_int_start_y = 0x000001A7, .vs_int_stop_y__vs_ext_start_x = 0x01AF0000, .vs_ext_stop_x__vs_ext_start_y = 0x000101AF, .vs_ext_stop_y = 0x00000025, .avid_start_stop_x = 0x03530083, .avid_start_stop_y = 0x026C002E, .fid_int_start_x__fid_int_start_y = 0x0001008A, .fid_int_offset_y__fid_ext_start_x = 0x002E0138, .fid_ext_start_y__fid_ext_offset_y = 0x01380001, .tvdetgp_int_start_stop_x = 0x00140001, .tvdetgp_int_start_stop_y = 0x00010001, .gen_ctrl = 0x00FF0000, }; /* from TRM */ static const struct venc_config venc_config_ntsc_trm = { .f_control = 0, .vidout_ctrl = 1, .sync_ctrl = 0x8040, .llen = 0x359, .flens = 0x20C, .hfltr_ctrl = 0, .cc_carr_wss_carr = 0x043F2631, .c_phase = 0, .gain_u = 0x102, .gain_v = 0x16C, .gain_y = 0x12F, .black_level = 0x43, .blank_level = 0x38, .x_color = 0x7, .m_control = 0x1, .bstamp_wss_data = 0x38, .s_carr = 0x21F07C1F, .line21 = 0, .ln_sel = 0x01310011, .l21__wc_ctl = 0x0000F003, .htrigger_vtrigger = 0, .savid__eavid = 0x069300F4, .flen__fal = 0x0016020C, .lal__phase_reset = 0x00060107, .hs_int_start_stop_x = 0x008E0350, .hs_ext_start_stop_x = 0x000F0359, .vs_int_start_x = 0x01A00000, .vs_int_stop_x__vs_int_start_y = 0x020701A0, .vs_int_stop_y__vs_ext_start_x = 0x01AC0024, .vs_ext_stop_x__vs_ext_start_y = 0x020D01AC, .vs_ext_stop_y = 0x00000006, .avid_start_stop_x = 0x03480078, .avid_start_stop_y = 0x02060024, .fid_int_start_x__fid_int_start_y = 0x0001008A, .fid_int_offset_y__fid_ext_start_x = 0x01AC0106, .fid_ext_start_y__fid_ext_offset_y = 0x01060006, .tvdetgp_int_start_stop_x = 0x00140001, .tvdetgp_int_start_stop_y = 0x00010001, .gen_ctrl = 0x00F90000, }; static const struct venc_config venc_config_pal_bdghi = { .f_control = 0, .vidout_ctrl = 0, .sync_ctrl = 0, .hfltr_ctrl = 0, .x_color = 0, .line21 = 0, .ln_sel = 21, .htrigger_vtrigger = 0, .tvdetgp_int_start_stop_x = 0x00140001, .tvdetgp_int_start_stop_y = 0x00010001, .gen_ctrl = 0x00FB0000, .llen = 864-1, .flens = 625-1, .cc_carr_wss_carr = 0x2F7625ED, .c_phase = 0xDF, .gain_u = 0x111, .gain_v = 0x181, .gain_y = 0x140, .black_level = 0x3e, .blank_level = 0x3e, .m_control = 0<<2 | 1<<1, .bstamp_wss_data = 0x42, .s_carr = 0x2a098acb, .l21__wc_ctl = 0<<13 | 0x16<<8 | 0<<0, .savid__eavid = 0x06A70108, .flen__fal = 23<<16 | 624<<0, .lal__phase_reset = 2<<17 | 310<<0, .hs_int_start_stop_x = 0x00920358, .hs_ext_start_stop_x = 0x000F035F, .vs_int_start_x = 0x1a7<<16, .vs_int_stop_x__vs_int_start_y = 0x000601A7, .vs_int_stop_y__vs_ext_start_x = 0x01AF0036, .vs_ext_stop_x__vs_ext_start_y = 0x27101af, .vs_ext_stop_y = 0x05, .avid_start_stop_x = 0x03530082, .avid_start_stop_y = 0x0270002E, .fid_int_start_x__fid_int_start_y = 0x0005008A, .fid_int_offset_y__fid_ext_start_x = 0x002E0138, .fid_ext_start_y__fid_ext_offset_y = 0x01380005, }; const struct omap_video_timings omap_dss_pal_timings = { .x_res = 720, .y_res = 574, .pixel_clock = 13500, .hsw = 64, .hfp = 12, .hbp = 68, .vsw = 5, .vfp = 5, .vbp = 41, }; EXPORT_SYMBOL(omap_dss_pal_timings); const struct omap_video_timings omap_dss_ntsc_timings = { .x_res = 720, .y_res = 482, .pixel_clock = 13500, .hsw = 64, .hfp = 16, .hbp = 58, .vsw = 6, .vfp = 6, .vbp = 31, }; EXPORT_SYMBOL(omap_dss_ntsc_timings); static struct { struct platform_device *pdev; void __iomem *base; struct mutex venc_lock; u32 wss_data; struct regulator *vdda_dac_reg; struct clk *tv_dac_clk; } venc; static inline void venc_write_reg(int idx, u32 val) { __raw_writel(val, venc.base + idx); } static inline u32 venc_read_reg(int idx) { u32 l = __raw_readl(venc.base + idx); return l; } static void venc_write_config(const struct venc_config *config) { DSSDBG("write venc conf\n"); venc_write_reg(VENC_LLEN, config->llen); venc_write_reg(VENC_FLENS, config->flens); venc_write_reg(VENC_CC_CARR_WSS_CARR, config->cc_carr_wss_carr); venc_write_reg(VENC_C_PHASE, config->c_phase); venc_write_reg(VENC_GAIN_U, config->gain_u); venc_write_reg(VENC_GAIN_V, config->gain_v); venc_write_reg(VENC_GAIN_Y, config->gain_y); venc_write_reg(VENC_BLACK_LEVEL, config->black_level); venc_write_reg(VENC_BLANK_LEVEL, config->blank_level); venc_write_reg(VENC_M_CONTROL, config->m_control); venc_write_reg(VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data | venc.wss_data); venc_write_reg(VENC_S_CARR, config->s_carr); venc_write_reg(VENC_L21__WC_CTL, config->l21__wc_ctl); venc_write_reg(VENC_SAVID__EAVID, config->savid__eavid); venc_write_reg(VENC_FLEN__FAL, config->flen__fal); venc_write_reg(VENC_LAL__PHASE_RESET, config->lal__phase_reset); venc_write_reg(VENC_HS_INT_START_STOP_X, config->hs_int_start_stop_x); venc_write_reg(VENC_HS_EXT_START_STOP_X, config->hs_ext_start_stop_x); venc_write_reg(VENC_VS_INT_START_X, config->vs_int_start_x); venc_write_reg(VENC_VS_INT_STOP_X__VS_INT_START_Y, config->vs_int_stop_x__vs_int_start_y); venc_write_reg(VENC_VS_INT_STOP_Y__VS_EXT_START_X, config->vs_int_stop_y__vs_ext_start_x); venc_write_reg(VENC_VS_EXT_STOP_X__VS_EXT_START_Y, config->vs_ext_stop_x__vs_ext_start_y); venc_write_reg(VENC_VS_EXT_STOP_Y, config->vs_ext_stop_y); venc_write_reg(VENC_AVID_START_STOP_X, config->avid_start_stop_x); venc_write_reg(VENC_AVID_START_STOP_Y, config->avid_start_stop_y); venc_write_reg(VENC_FID_INT_START_X__FID_INT_START_Y, config->fid_int_start_x__fid_int_start_y); venc_write_reg(VENC_FID_INT_OFFSET_Y__FID_EXT_START_X, config->fid_int_offset_y__fid_ext_start_x); venc_write_reg(VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y, config->fid_ext_start_y__fid_ext_offset_y); venc_write_reg(VENC_DAC_B__DAC_C, venc_read_reg(VENC_DAC_B__DAC_C)); venc_write_reg(VENC_VIDOUT_CTRL, config->vidout_ctrl); venc_write_reg(VENC_HFLTR_CTRL, config->hfltr_ctrl); venc_write_reg(VENC_X_COLOR, config->x_color); venc_write_reg(VENC_LINE21, config->line21); venc_write_reg(VENC_LN_SEL, config->ln_sel); venc_write_reg(VENC_HTRIGGER_VTRIGGER, config->htrigger_vtrigger); venc_write_reg(VENC_TVDETGP_INT_START_STOP_X, config->tvdetgp_int_start_stop_x); venc_write_reg(VENC_TVDETGP_INT_START_STOP_Y, config->tvdetgp_int_start_stop_y); venc_write_reg(VENC_GEN_CTRL, config->gen_ctrl); venc_write_reg(VENC_F_CONTROL, config->f_control); venc_write_reg(VENC_SYNC_CTRL, config->sync_ctrl); } static void venc_reset(void) { int t = 1000; venc_write_reg(VENC_F_CONTROL, 1<<8); while (venc_read_reg(VENC_F_CONTROL) & (1<<8)) { if (--t == 0) { DSSERR("Failed to reset venc\n"); return; } } #ifdef CONFIG_OMAP2_DSS_SLEEP_AFTER_VENC_RESET /* the magical sleep that makes things work */ /* XXX more info? What bug this circumvents? */ msleep(20); #endif } static int venc_runtime_get(void) { int r; DSSDBG("venc_runtime_get\n"); r = pm_runtime_get_sync(&venc.pdev->dev); WARN_ON(r < 0); return r < 0 ? r : 0; } static void venc_runtime_put(void) { int r; DSSDBG("venc_runtime_put\n"); r = pm_runtime_put_sync(&venc.pdev->dev); WARN_ON(r < 0); } static const struct venc_config *venc_timings_to_config( struct omap_video_timings *timings) { if (memcmp(&omap_dss_pal_timings, timings, sizeof(*timings)) == 0) return &venc_config_pal_trm; if (memcmp(&omap_dss_ntsc_timings, timings, sizeof(*timings)) == 0) return &venc_config_ntsc_trm; BUG(); } static int venc_power_on(struct omap_dss_device *dssdev) { u32 l; int r; venc_reset(); venc_write_config(venc_timings_to_config(&dssdev->panel.timings)); dss_set_venc_output(dssdev->phy.venc.type); dss_set_dac_pwrdn_bgz(1); l = 0; if (dssdev->phy.venc.type == OMAP_DSS_VENC_TYPE_COMPOSITE) l |= 1 << 1; else /* S-Video */ l |= (1 << 0) | (1 << 2); if (dssdev->phy.venc.invert_polarity == false) l |= 1 << 3; venc_write_reg(VENC_OUTPUT_CONTROL, l); dispc_set_digit_size(dssdev->panel.timings.x_res, dssdev->panel.timings.y_res/2); regulator_enable(venc.vdda_dac_reg); if (dssdev->platform_enable) dssdev->platform_enable(dssdev); r = dss_mgr_enable(dssdev->manager); if (r) goto err; return 0; err: venc_write_reg(VENC_OUTPUT_CONTROL, 0); dss_set_dac_pwrdn_bgz(0); if (dssdev->platform_disable) dssdev->platform_disable(dssdev); regulator_disable(venc.vdda_dac_reg); return r; } static void venc_power_off(struct omap_dss_device *dssdev) { venc_write_reg(VENC_OUTPUT_CONTROL, 0); dss_set_dac_pwrdn_bgz(0); dss_mgr_disable(dssdev->manager); if (dssdev->platform_disable) dssdev->platform_disable(dssdev); regulator_disable(venc.vdda_dac_reg); } unsigned long venc_get_pixel_clock(void) { /* VENC Pixel Clock in Mhz */ return 13500000; } /* driver */ static int venc_panel_probe(struct omap_dss_device *dssdev) { dssdev->panel.timings = omap_dss_pal_timings; return 0; } static void venc_panel_remove(struct omap_dss_device *dssdev) { } static int venc_panel_enable(struct omap_dss_device *dssdev) { int r = 0; DSSDBG("venc_enable_display\n"); mutex_lock(&venc.venc_lock); r = omap_dss_start_device(dssdev); if (r) { DSSERR("failed to start device\n"); goto err0; } if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) { r = -EINVAL; goto err1; } r = venc_runtime_get(); if (r) goto err1; r = venc_power_on(dssdev); if (r) goto err2; venc.wss_data = 0; dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; mutex_unlock(&venc.venc_lock); return 0; err2: venc_runtime_put(); err1: omap_dss_stop_device(dssdev); err0: mutex_unlock(&venc.venc_lock); return r; } static void venc_panel_disable(struct omap_dss_device *dssdev) { DSSDBG("venc_disable_display\n"); mutex_lock(&venc.venc_lock); if (dssdev->state == OMAP_DSS_DISPLAY_DISABLED) goto end; if (dssdev->state == OMAP_DSS_DISPLAY_SUSPENDED) { /* suspended is the same as disabled with venc */ dssdev->state = OMAP_DSS_DISPLAY_DISABLED; goto end; } venc_power_off(dssdev); venc_runtime_put(); dssdev->state = OMAP_DSS_DISPLAY_DISABLED; omap_dss_stop_device(dssdev); end: mutex_unlock(&venc.venc_lock); } static int venc_panel_suspend(struct omap_dss_device *dssdev) { venc_panel_disable(dssdev); return 0; } static int venc_panel_resume(struct omap_dss_device *dssdev) { return venc_panel_enable(dssdev); } static void venc_get_timings(struct omap_dss_device *dssdev, struct omap_video_timings *timings) { *timings = dssdev->panel.timings; } static void venc_set_timings(struct omap_dss_device *dssdev, struct omap_video_timings *timings) { DSSDBG("venc_set_timings\n"); /* Reset WSS data when the TV standard changes. */ if (memcmp(&dssdev->panel.timings, timings, sizeof(*timings))) venc.wss_data = 0; dssdev->panel.timings = *timings; if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) { /* turn the venc off and on to get new timings to use */ venc_panel_disable(dssdev); venc_panel_enable(dssdev); } } static int venc_check_timings(struct omap_dss_device *dssdev, struct omap_video_timings *timings) { DSSDBG("venc_check_timings\n"); if (memcmp(&omap_dss_pal_timings, timings, sizeof(*timings)) == 0) return 0; if (memcmp(&omap_dss_ntsc_timings, timings, sizeof(*timings)) == 0) return 0; return -EINVAL; } static u32 venc_get_wss(struct omap_dss_device *dssdev) { /* Invert due to VENC_L21_WC_CTL:INV=1 */ return (venc.wss_data >> 8) ^ 0xfffff; } static int venc_set_wss(struct omap_dss_device *dssdev, u32 wss) { const struct venc_config *config; int r; DSSDBG("venc_set_wss\n"); mutex_lock(&venc.venc_lock); config = venc_timings_to_config(&dssdev->panel.timings); /* Invert due to VENC_L21_WC_CTL:INV=1 */ venc.wss_data = (wss ^ 0xfffff) << 8; r = venc_runtime_get(); if (r) goto err; venc_write_reg(VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data | venc.wss_data); venc_runtime_put(); err: mutex_unlock(&venc.venc_lock); return r; } static struct omap_dss_driver venc_driver = { .probe = venc_panel_probe, .remove = venc_panel_remove, .enable = venc_panel_enable, .disable = venc_panel_disable, .suspend = venc_panel_suspend, .resume = venc_panel_resume, .get_resolution = omapdss_default_get_resolution, .get_recommended_bpp = omapdss_default_get_recommended_bpp, .get_timings = venc_get_timings, .set_timings = venc_set_timings, .check_timings = venc_check_timings, .get_wss = venc_get_wss, .set_wss = venc_set_wss, .driver = { .name = "venc", .owner = THIS_MODULE, }, }; /* driver end */ int venc_init_display(struct omap_dss_device *dssdev) { DSSDBG("init_display\n"); if (venc.vdda_dac_reg == NULL) { struct regulator *vdda_dac; vdda_dac = regulator_get(&venc.pdev->dev, "vdda_dac"); if (IS_ERR(vdda_dac)) { DSSERR("can't get VDDA_DAC regulator\n"); return PTR_ERR(vdda_dac); } venc.vdda_dac_reg = vdda_dac; } return 0; } void venc_dump_regs(struct seq_file *s) { #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, venc_read_reg(r)) if (cpu_is_omap44xx()) { seq_printf(s, "VENC currently disabled on OMAP44xx\n"); return; } if (venc_runtime_get()) return; DUMPREG(VENC_F_CONTROL); DUMPREG(VENC_VIDOUT_CTRL); DUMPREG(VENC_SYNC_CTRL); DUMPREG(VENC_LLEN); DUMPREG(VENC_FLENS); DUMPREG(VENC_HFLTR_CTRL); DUMPREG(VENC_CC_CARR_WSS_CARR); DUMPREG(VENC_C_PHASE); DUMPREG(VENC_GAIN_U); DUMPREG(VENC_GAIN_V); DUMPREG(VENC_GAIN_Y); DUMPREG(VENC_BLACK_LEVEL); DUMPREG(VENC_BLANK_LEVEL); DUMPREG(VENC_X_COLOR); DUMPREG(VENC_M_CONTROL); DUMPREG(VENC_BSTAMP_WSS_DATA); DUMPREG(VENC_S_CARR); DUMPREG(VENC_LINE21); DUMPREG(VENC_LN_SEL); DUMPREG(VENC_L21__WC_CTL); DUMPREG(VENC_HTRIGGER_VTRIGGER); DUMPREG(VENC_SAVID__EAVID); DUMPREG(VENC_FLEN__FAL); DUMPREG(VENC_LAL__PHASE_RESET); DUMPREG(VENC_HS_INT_START_STOP_X); DUMPREG(VENC_HS_EXT_START_STOP_X); DUMPREG(VENC_VS_INT_START_X); DUMPREG(VENC_VS_INT_STOP_X__VS_INT_START_Y); DUMPREG(VENC_VS_INT_STOP_Y__VS_EXT_START_X); DUMPREG(VENC_VS_EXT_STOP_X__VS_EXT_START_Y); DUMPREG(VENC_VS_EXT_STOP_Y); DUMPREG(VENC_AVID_START_STOP_X); DUMPREG(VENC_AVID_START_STOP_Y); DUMPREG(VENC_FID_INT_START_X__FID_INT_START_Y); DUMPREG(VENC_FID_INT_OFFSET_Y__FID_EXT_START_X); DUMPREG(VENC_FID_EXT_START_Y__FID_EXT_OFFSET_Y); DUMPREG(VENC_TVDETGP_INT_START_STOP_X); DUMPREG(VENC_TVDETGP_INT_START_STOP_Y); DUMPREG(VENC_GEN_CTRL); DUMPREG(VENC_OUTPUT_CONTROL); DUMPREG(VENC_OUTPUT_TEST); venc_runtime_put(); #undef DUMPREG } static int venc_get_clocks(struct platform_device *pdev) { struct clk *clk; if (dss_has_feature(FEAT_VENC_REQUIRES_TV_DAC_CLK)) { clk = clk_get(&pdev->dev, "tv_dac_clk"); if (IS_ERR(clk)) { DSSERR("can't get tv_dac_clk\n"); return PTR_ERR(clk); } } else { clk = NULL; } venc.tv_dac_clk = clk; return 0; } static void venc_put_clocks(void) { if (venc.tv_dac_clk) clk_put(venc.tv_dac_clk); } /* VENC HW IP initialisation */ static int omap_venchw_probe(struct platform_device *pdev) { u8 rev_id; struct resource *venc_mem; int r; venc.pdev = pdev; mutex_init(&venc.venc_lock); venc.wss_data = 0; venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0); if (!venc_mem) { DSSERR("can't get IORESOURCE_MEM VENC\n"); return -EINVAL; } venc.base = devm_ioremap(&pdev->dev, venc_mem->start, resource_size(venc_mem)); if (!venc.base) { DSSERR("can't ioremap VENC\n"); return -ENOMEM; } r = venc_get_clocks(pdev); if (r) return r; pm_runtime_enable(&pdev->dev); r = venc_runtime_get(); if (r) goto err_runtime_get; rev_id = (u8)(venc_read_reg(VENC_REV_ID) & 0xff); dev_dbg(&pdev->dev, "OMAP VENC rev %d\n", rev_id); venc_runtime_put(); r = omap_dss_register_driver(&venc_driver); if (r) goto err_reg_panel_driver; return 0; err_reg_panel_driver: err_runtime_get: pm_runtime_disable(&pdev->dev); venc_put_clocks(); return r; } static int omap_venchw_remove(struct platform_device *pdev) { if (venc.vdda_dac_reg != NULL) { regulator_put(venc.vdda_dac_reg); venc.vdda_dac_reg = NULL; } omap_dss_unregister_driver(&venc_driver); pm_runtime_disable(&pdev->dev); venc_put_clocks(); return 0; } static int venc_runtime_suspend(struct device *dev) { if (venc.tv_dac_clk) clk_disable(venc.tv_dac_clk); dispc_runtime_put(); dss_runtime_put(); return 0; } static int venc_runtime_resume(struct device *dev) { int r; r = dss_runtime_get(); if (r < 0) goto err_get_dss; r = dispc_runtime_get(); if (r < 0) goto err_get_dispc; if (venc.tv_dac_clk) clk_enable(venc.tv_dac_clk); return 0; err_get_dispc: dss_runtime_put(); err_get_dss: return r; } static const struct dev_pm_ops venc_pm_ops = { .runtime_suspend = venc_runtime_suspend, .runtime_resume = venc_runtime_resume, }; static struct platform_driver omap_venchw_driver = { .probe = omap_venchw_probe, .remove = omap_venchw_remove, .driver = { .name = "omapdss_venc", .owner = THIS_MODULE, .pm = &venc_pm_ops, }, }; int venc_init_platform_driver(void) { if (cpu_is_omap44xx()) return 0; return platform_driver_register(&omap_venchw_driver); } void venc_uninit_platform_driver(void) { if (cpu_is_omap44xx()) return; return platform_driver_unregister(&omap_venchw_driver); }
gpl-2.0
sumitrajdev5842/kernel_samsung_kyleve
drivers/video/omap2/dss/manager.c
4791
15133
/* * linux/drivers/video/omap2/dss/manager.c * * Copyright (C) 2009 Nokia Corporation * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> * * Some code and ideas taken from drivers/video/omap/ driver * by Imre Deak. * * 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, see <http://www.gnu.org/licenses/>. */ #define DSS_SUBSYS_NAME "MANAGER" #include <linux/kernel.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/jiffies.h> #include <video/omapdss.h> #include "dss.h" #include "dss_features.h" static int num_managers; static struct omap_overlay_manager *managers; static ssize_t manager_name_show(struct omap_overlay_manager *mgr, char *buf) { return snprintf(buf, PAGE_SIZE, "%s\n", mgr->name); } static ssize_t manager_display_show(struct omap_overlay_manager *mgr, char *buf) { return snprintf(buf, PAGE_SIZE, "%s\n", mgr->device ? mgr->device->name : "<none>"); } static ssize_t manager_display_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { int r = 0; size_t len = size; struct omap_dss_device *dssdev = NULL; int match(struct omap_dss_device *dssdev, void *data) { const char *str = data; return sysfs_streq(dssdev->name, str); } if (buf[size-1] == '\n') --len; if (len > 0) dssdev = omap_dss_find_device((void *)buf, match); if (len > 0 && dssdev == NULL) return -EINVAL; if (dssdev) DSSDBG("display %s found\n", dssdev->name); if (mgr->device) { r = mgr->unset_device(mgr); if (r) { DSSERR("failed to unset display\n"); goto put_device; } } if (dssdev) { r = mgr->set_device(mgr, dssdev); if (r) { DSSERR("failed to set manager\n"); goto put_device; } r = mgr->apply(mgr); if (r) { DSSERR("failed to apply dispc config\n"); goto put_device; } } put_device: if (dssdev) omap_dss_put_device(dssdev); return r ? r : size; } static ssize_t manager_default_color_show(struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); return snprintf(buf, PAGE_SIZE, "%#x\n", info.default_color); } static ssize_t manager_default_color_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; u32 color; int r; r = kstrtouint(buf, 0, &color); if (r) return r; mgr->get_manager_info(mgr, &info); info.default_color = color; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static const char *trans_key_type_str[] = { "gfx-destination", "video-source", }; static ssize_t manager_trans_key_type_show(struct omap_overlay_manager *mgr, char *buf) { enum omap_dss_trans_key_type key_type; struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); key_type = info.trans_key_type; BUG_ON(key_type >= ARRAY_SIZE(trans_key_type_str)); return snprintf(buf, PAGE_SIZE, "%s\n", trans_key_type_str[key_type]); } static ssize_t manager_trans_key_type_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { enum omap_dss_trans_key_type key_type; struct omap_overlay_manager_info info; int r; for (key_type = OMAP_DSS_COLOR_KEY_GFX_DST; key_type < ARRAY_SIZE(trans_key_type_str); key_type++) { if (sysfs_streq(buf, trans_key_type_str[key_type])) break; } if (key_type == ARRAY_SIZE(trans_key_type_str)) return -EINVAL; mgr->get_manager_info(mgr, &info); info.trans_key_type = key_type; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static ssize_t manager_trans_key_value_show(struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); return snprintf(buf, PAGE_SIZE, "%#x\n", info.trans_key); } static ssize_t manager_trans_key_value_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; u32 key_value; int r; r = kstrtouint(buf, 0, &key_value); if (r) return r; mgr->get_manager_info(mgr, &info); info.trans_key = key_value; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static ssize_t manager_trans_key_enabled_show(struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); return snprintf(buf, PAGE_SIZE, "%d\n", info.trans_enabled); } static ssize_t manager_trans_key_enabled_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; bool enable; int r; r = strtobool(buf, &enable); if (r) return r; mgr->get_manager_info(mgr, &info); info.trans_enabled = enable; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static ssize_t manager_alpha_blending_enabled_show( struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); WARN_ON(!dss_has_feature(FEAT_ALPHA_FIXED_ZORDER)); return snprintf(buf, PAGE_SIZE, "%d\n", info.partial_alpha_enabled); } static ssize_t manager_alpha_blending_enabled_store( struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; bool enable; int r; WARN_ON(!dss_has_feature(FEAT_ALPHA_FIXED_ZORDER)); r = strtobool(buf, &enable); if (r) return r; mgr->get_manager_info(mgr, &info); info.partial_alpha_enabled = enable; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static ssize_t manager_cpr_enable_show(struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); return snprintf(buf, PAGE_SIZE, "%d\n", info.cpr_enable); } static ssize_t manager_cpr_enable_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; int r; bool enable; if (!dss_has_feature(FEAT_CPR)) return -ENODEV; r = strtobool(buf, &enable); if (r) return r; mgr->get_manager_info(mgr, &info); if (info.cpr_enable == enable) return size; info.cpr_enable = enable; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static ssize_t manager_cpr_coef_show(struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); return snprintf(buf, PAGE_SIZE, "%d %d %d %d %d %d %d %d %d\n", info.cpr_coefs.rr, info.cpr_coefs.rg, info.cpr_coefs.rb, info.cpr_coefs.gr, info.cpr_coefs.gg, info.cpr_coefs.gb, info.cpr_coefs.br, info.cpr_coefs.bg, info.cpr_coefs.bb); } static ssize_t manager_cpr_coef_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; struct omap_dss_cpr_coefs coefs; int r, i; s16 *arr; if (!dss_has_feature(FEAT_CPR)) return -ENODEV; if (sscanf(buf, "%hd %hd %hd %hd %hd %hd %hd %hd %hd", &coefs.rr, &coefs.rg, &coefs.rb, &coefs.gr, &coefs.gg, &coefs.gb, &coefs.br, &coefs.bg, &coefs.bb) != 9) return -EINVAL; arr = (s16[]){ coefs.rr, coefs.rg, coefs.rb, coefs.gr, coefs.gg, coefs.gb, coefs.br, coefs.bg, coefs.bb }; for (i = 0; i < 9; ++i) { if (arr[i] < -512 || arr[i] > 511) return -EINVAL; } mgr->get_manager_info(mgr, &info); info.cpr_coefs = coefs; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } struct manager_attribute { struct attribute attr; ssize_t (*show)(struct omap_overlay_manager *, char *); ssize_t (*store)(struct omap_overlay_manager *, const char *, size_t); }; #define MANAGER_ATTR(_name, _mode, _show, _store) \ struct manager_attribute manager_attr_##_name = \ __ATTR(_name, _mode, _show, _store) static MANAGER_ATTR(name, S_IRUGO, manager_name_show, NULL); static MANAGER_ATTR(display, S_IRUGO|S_IWUSR, manager_display_show, manager_display_store); static MANAGER_ATTR(default_color, S_IRUGO|S_IWUSR, manager_default_color_show, manager_default_color_store); static MANAGER_ATTR(trans_key_type, S_IRUGO|S_IWUSR, manager_trans_key_type_show, manager_trans_key_type_store); static MANAGER_ATTR(trans_key_value, S_IRUGO|S_IWUSR, manager_trans_key_value_show, manager_trans_key_value_store); static MANAGER_ATTR(trans_key_enabled, S_IRUGO|S_IWUSR, manager_trans_key_enabled_show, manager_trans_key_enabled_store); static MANAGER_ATTR(alpha_blending_enabled, S_IRUGO|S_IWUSR, manager_alpha_blending_enabled_show, manager_alpha_blending_enabled_store); static MANAGER_ATTR(cpr_enable, S_IRUGO|S_IWUSR, manager_cpr_enable_show, manager_cpr_enable_store); static MANAGER_ATTR(cpr_coef, S_IRUGO|S_IWUSR, manager_cpr_coef_show, manager_cpr_coef_store); static struct attribute *manager_sysfs_attrs[] = { &manager_attr_name.attr, &manager_attr_display.attr, &manager_attr_default_color.attr, &manager_attr_trans_key_type.attr, &manager_attr_trans_key_value.attr, &manager_attr_trans_key_enabled.attr, &manager_attr_alpha_blending_enabled.attr, &manager_attr_cpr_enable.attr, &manager_attr_cpr_coef.attr, NULL }; static ssize_t manager_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct omap_overlay_manager *manager; struct manager_attribute *manager_attr; manager = container_of(kobj, struct omap_overlay_manager, kobj); manager_attr = container_of(attr, struct manager_attribute, attr); if (!manager_attr->show) return -ENOENT; return manager_attr->show(manager, buf); } static ssize_t manager_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t size) { struct omap_overlay_manager *manager; struct manager_attribute *manager_attr; manager = container_of(kobj, struct omap_overlay_manager, kobj); manager_attr = container_of(attr, struct manager_attribute, attr); if (!manager_attr->store) return -ENOENT; return manager_attr->store(manager, buf, size); } static const struct sysfs_ops manager_sysfs_ops = { .show = manager_attr_show, .store = manager_attr_store, }; static struct kobj_type manager_ktype = { .sysfs_ops = &manager_sysfs_ops, .default_attrs = manager_sysfs_attrs, }; static int dss_mgr_wait_for_vsync(struct omap_overlay_manager *mgr) { unsigned long timeout = msecs_to_jiffies(500); u32 irq; int r; r = dispc_runtime_get(); if (r) return r; if (mgr->device->type == OMAP_DISPLAY_TYPE_VENC) { irq = DISPC_IRQ_EVSYNC_ODD; } else if (mgr->device->type == OMAP_DISPLAY_TYPE_HDMI) { irq = DISPC_IRQ_EVSYNC_EVEN; } else { if (mgr->id == OMAP_DSS_CHANNEL_LCD) irq = DISPC_IRQ_VSYNC; else irq = DISPC_IRQ_VSYNC2; } r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout); dispc_runtime_put(); return r; } int dss_init_overlay_managers(struct platform_device *pdev) { int i, r; num_managers = dss_feat_get_num_mgrs(); managers = kzalloc(sizeof(struct omap_overlay_manager) * num_managers, GFP_KERNEL); BUG_ON(managers == NULL); for (i = 0; i < num_managers; ++i) { struct omap_overlay_manager *mgr = &managers[i]; switch (i) { case 0: mgr->name = "lcd"; mgr->id = OMAP_DSS_CHANNEL_LCD; break; case 1: mgr->name = "tv"; mgr->id = OMAP_DSS_CHANNEL_DIGIT; break; case 2: mgr->name = "lcd2"; mgr->id = OMAP_DSS_CHANNEL_LCD2; break; } mgr->set_device = &dss_mgr_set_device; mgr->unset_device = &dss_mgr_unset_device; mgr->apply = &omap_dss_mgr_apply; mgr->set_manager_info = &dss_mgr_set_info; mgr->get_manager_info = &dss_mgr_get_info; mgr->wait_for_go = &dss_mgr_wait_for_go; mgr->wait_for_vsync = &dss_mgr_wait_for_vsync; mgr->caps = 0; mgr->supported_displays = dss_feat_get_supported_displays(mgr->id); INIT_LIST_HEAD(&mgr->overlays); r = kobject_init_and_add(&mgr->kobj, &manager_ktype, &pdev->dev.kobj, "manager%d", i); if (r) DSSERR("failed to create sysfs file\n"); } return 0; } void dss_uninit_overlay_managers(struct platform_device *pdev) { int i; for (i = 0; i < num_managers; ++i) { struct omap_overlay_manager *mgr = &managers[i]; kobject_del(&mgr->kobj); kobject_put(&mgr->kobj); } kfree(managers); managers = NULL; num_managers = 0; } int omap_dss_get_num_overlay_managers(void) { return num_managers; } EXPORT_SYMBOL(omap_dss_get_num_overlay_managers); struct omap_overlay_manager *omap_dss_get_overlay_manager(int num) { if (num >= num_managers) return NULL; return &managers[num]; } EXPORT_SYMBOL(omap_dss_get_overlay_manager); int dss_mgr_simple_check(struct omap_overlay_manager *mgr, const struct omap_overlay_manager_info *info) { if (dss_has_feature(FEAT_ALPHA_FIXED_ZORDER)) { /* * OMAP3 supports only graphics source transparency color key * and alpha blending simultaneously. See TRM 15.4.2.4.2.2 * Alpha Mode. */ if (info->partial_alpha_enabled && info->trans_enabled && info->trans_key_type != OMAP_DSS_COLOR_KEY_GFX_DST) { DSSERR("check_manager: illegal transparency key\n"); return -EINVAL; } } return 0; } static int dss_mgr_check_zorder(struct omap_overlay_manager *mgr, struct omap_overlay_info **overlay_infos) { struct omap_overlay *ovl1, *ovl2; struct omap_overlay_info *info1, *info2; list_for_each_entry(ovl1, &mgr->overlays, list) { info1 = overlay_infos[ovl1->id]; if (info1 == NULL) continue; list_for_each_entry(ovl2, &mgr->overlays, list) { if (ovl1 == ovl2) continue; info2 = overlay_infos[ovl2->id]; if (info2 == NULL) continue; if (info1->zorder == info2->zorder) { DSSERR("overlays %d and %d have the same " "zorder %d\n", ovl1->id, ovl2->id, info1->zorder); return -EINVAL; } } } return 0; } int dss_mgr_check(struct omap_overlay_manager *mgr, struct omap_dss_device *dssdev, struct omap_overlay_manager_info *info, struct omap_overlay_info **overlay_infos) { struct omap_overlay *ovl; int r; if (dss_has_feature(FEAT_ALPHA_FREE_ZORDER)) { r = dss_mgr_check_zorder(mgr, overlay_infos); if (r) return r; } list_for_each_entry(ovl, &mgr->overlays, list) { struct omap_overlay_info *oi; int r; oi = overlay_infos[ovl->id]; if (oi == NULL) continue; r = dss_ovl_check(ovl, oi, dssdev); if (r) return r; } return 0; }
gpl-2.0
tobigun/samsung-kernel-smg800y
drivers/video/omap2/dss/manager.c
4791
15133
/* * linux/drivers/video/omap2/dss/manager.c * * Copyright (C) 2009 Nokia Corporation * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> * * Some code and ideas taken from drivers/video/omap/ driver * by Imre Deak. * * 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, see <http://www.gnu.org/licenses/>. */ #define DSS_SUBSYS_NAME "MANAGER" #include <linux/kernel.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/jiffies.h> #include <video/omapdss.h> #include "dss.h" #include "dss_features.h" static int num_managers; static struct omap_overlay_manager *managers; static ssize_t manager_name_show(struct omap_overlay_manager *mgr, char *buf) { return snprintf(buf, PAGE_SIZE, "%s\n", mgr->name); } static ssize_t manager_display_show(struct omap_overlay_manager *mgr, char *buf) { return snprintf(buf, PAGE_SIZE, "%s\n", mgr->device ? mgr->device->name : "<none>"); } static ssize_t manager_display_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { int r = 0; size_t len = size; struct omap_dss_device *dssdev = NULL; int match(struct omap_dss_device *dssdev, void *data) { const char *str = data; return sysfs_streq(dssdev->name, str); } if (buf[size-1] == '\n') --len; if (len > 0) dssdev = omap_dss_find_device((void *)buf, match); if (len > 0 && dssdev == NULL) return -EINVAL; if (dssdev) DSSDBG("display %s found\n", dssdev->name); if (mgr->device) { r = mgr->unset_device(mgr); if (r) { DSSERR("failed to unset display\n"); goto put_device; } } if (dssdev) { r = mgr->set_device(mgr, dssdev); if (r) { DSSERR("failed to set manager\n"); goto put_device; } r = mgr->apply(mgr); if (r) { DSSERR("failed to apply dispc config\n"); goto put_device; } } put_device: if (dssdev) omap_dss_put_device(dssdev); return r ? r : size; } static ssize_t manager_default_color_show(struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); return snprintf(buf, PAGE_SIZE, "%#x\n", info.default_color); } static ssize_t manager_default_color_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; u32 color; int r; r = kstrtouint(buf, 0, &color); if (r) return r; mgr->get_manager_info(mgr, &info); info.default_color = color; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static const char *trans_key_type_str[] = { "gfx-destination", "video-source", }; static ssize_t manager_trans_key_type_show(struct omap_overlay_manager *mgr, char *buf) { enum omap_dss_trans_key_type key_type; struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); key_type = info.trans_key_type; BUG_ON(key_type >= ARRAY_SIZE(trans_key_type_str)); return snprintf(buf, PAGE_SIZE, "%s\n", trans_key_type_str[key_type]); } static ssize_t manager_trans_key_type_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { enum omap_dss_trans_key_type key_type; struct omap_overlay_manager_info info; int r; for (key_type = OMAP_DSS_COLOR_KEY_GFX_DST; key_type < ARRAY_SIZE(trans_key_type_str); key_type++) { if (sysfs_streq(buf, trans_key_type_str[key_type])) break; } if (key_type == ARRAY_SIZE(trans_key_type_str)) return -EINVAL; mgr->get_manager_info(mgr, &info); info.trans_key_type = key_type; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static ssize_t manager_trans_key_value_show(struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); return snprintf(buf, PAGE_SIZE, "%#x\n", info.trans_key); } static ssize_t manager_trans_key_value_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; u32 key_value; int r; r = kstrtouint(buf, 0, &key_value); if (r) return r; mgr->get_manager_info(mgr, &info); info.trans_key = key_value; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static ssize_t manager_trans_key_enabled_show(struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); return snprintf(buf, PAGE_SIZE, "%d\n", info.trans_enabled); } static ssize_t manager_trans_key_enabled_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; bool enable; int r; r = strtobool(buf, &enable); if (r) return r; mgr->get_manager_info(mgr, &info); info.trans_enabled = enable; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static ssize_t manager_alpha_blending_enabled_show( struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); WARN_ON(!dss_has_feature(FEAT_ALPHA_FIXED_ZORDER)); return snprintf(buf, PAGE_SIZE, "%d\n", info.partial_alpha_enabled); } static ssize_t manager_alpha_blending_enabled_store( struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; bool enable; int r; WARN_ON(!dss_has_feature(FEAT_ALPHA_FIXED_ZORDER)); r = strtobool(buf, &enable); if (r) return r; mgr->get_manager_info(mgr, &info); info.partial_alpha_enabled = enable; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static ssize_t manager_cpr_enable_show(struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); return snprintf(buf, PAGE_SIZE, "%d\n", info.cpr_enable); } static ssize_t manager_cpr_enable_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; int r; bool enable; if (!dss_has_feature(FEAT_CPR)) return -ENODEV; r = strtobool(buf, &enable); if (r) return r; mgr->get_manager_info(mgr, &info); if (info.cpr_enable == enable) return size; info.cpr_enable = enable; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } static ssize_t manager_cpr_coef_show(struct omap_overlay_manager *mgr, char *buf) { struct omap_overlay_manager_info info; mgr->get_manager_info(mgr, &info); return snprintf(buf, PAGE_SIZE, "%d %d %d %d %d %d %d %d %d\n", info.cpr_coefs.rr, info.cpr_coefs.rg, info.cpr_coefs.rb, info.cpr_coefs.gr, info.cpr_coefs.gg, info.cpr_coefs.gb, info.cpr_coefs.br, info.cpr_coefs.bg, info.cpr_coefs.bb); } static ssize_t manager_cpr_coef_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; struct omap_dss_cpr_coefs coefs; int r, i; s16 *arr; if (!dss_has_feature(FEAT_CPR)) return -ENODEV; if (sscanf(buf, "%hd %hd %hd %hd %hd %hd %hd %hd %hd", &coefs.rr, &coefs.rg, &coefs.rb, &coefs.gr, &coefs.gg, &coefs.gb, &coefs.br, &coefs.bg, &coefs.bb) != 9) return -EINVAL; arr = (s16[]){ coefs.rr, coefs.rg, coefs.rb, coefs.gr, coefs.gg, coefs.gb, coefs.br, coefs.bg, coefs.bb }; for (i = 0; i < 9; ++i) { if (arr[i] < -512 || arr[i] > 511) return -EINVAL; } mgr->get_manager_info(mgr, &info); info.cpr_coefs = coefs; r = mgr->set_manager_info(mgr, &info); if (r) return r; r = mgr->apply(mgr); if (r) return r; return size; } struct manager_attribute { struct attribute attr; ssize_t (*show)(struct omap_overlay_manager *, char *); ssize_t (*store)(struct omap_overlay_manager *, const char *, size_t); }; #define MANAGER_ATTR(_name, _mode, _show, _store) \ struct manager_attribute manager_attr_##_name = \ __ATTR(_name, _mode, _show, _store) static MANAGER_ATTR(name, S_IRUGO, manager_name_show, NULL); static MANAGER_ATTR(display, S_IRUGO|S_IWUSR, manager_display_show, manager_display_store); static MANAGER_ATTR(default_color, S_IRUGO|S_IWUSR, manager_default_color_show, manager_default_color_store); static MANAGER_ATTR(trans_key_type, S_IRUGO|S_IWUSR, manager_trans_key_type_show, manager_trans_key_type_store); static MANAGER_ATTR(trans_key_value, S_IRUGO|S_IWUSR, manager_trans_key_value_show, manager_trans_key_value_store); static MANAGER_ATTR(trans_key_enabled, S_IRUGO|S_IWUSR, manager_trans_key_enabled_show, manager_trans_key_enabled_store); static MANAGER_ATTR(alpha_blending_enabled, S_IRUGO|S_IWUSR, manager_alpha_blending_enabled_show, manager_alpha_blending_enabled_store); static MANAGER_ATTR(cpr_enable, S_IRUGO|S_IWUSR, manager_cpr_enable_show, manager_cpr_enable_store); static MANAGER_ATTR(cpr_coef, S_IRUGO|S_IWUSR, manager_cpr_coef_show, manager_cpr_coef_store); static struct attribute *manager_sysfs_attrs[] = { &manager_attr_name.attr, &manager_attr_display.attr, &manager_attr_default_color.attr, &manager_attr_trans_key_type.attr, &manager_attr_trans_key_value.attr, &manager_attr_trans_key_enabled.attr, &manager_attr_alpha_blending_enabled.attr, &manager_attr_cpr_enable.attr, &manager_attr_cpr_coef.attr, NULL }; static ssize_t manager_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct omap_overlay_manager *manager; struct manager_attribute *manager_attr; manager = container_of(kobj, struct omap_overlay_manager, kobj); manager_attr = container_of(attr, struct manager_attribute, attr); if (!manager_attr->show) return -ENOENT; return manager_attr->show(manager, buf); } static ssize_t manager_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t size) { struct omap_overlay_manager *manager; struct manager_attribute *manager_attr; manager = container_of(kobj, struct omap_overlay_manager, kobj); manager_attr = container_of(attr, struct manager_attribute, attr); if (!manager_attr->store) return -ENOENT; return manager_attr->store(manager, buf, size); } static const struct sysfs_ops manager_sysfs_ops = { .show = manager_attr_show, .store = manager_attr_store, }; static struct kobj_type manager_ktype = { .sysfs_ops = &manager_sysfs_ops, .default_attrs = manager_sysfs_attrs, }; static int dss_mgr_wait_for_vsync(struct omap_overlay_manager *mgr) { unsigned long timeout = msecs_to_jiffies(500); u32 irq; int r; r = dispc_runtime_get(); if (r) return r; if (mgr->device->type == OMAP_DISPLAY_TYPE_VENC) { irq = DISPC_IRQ_EVSYNC_ODD; } else if (mgr->device->type == OMAP_DISPLAY_TYPE_HDMI) { irq = DISPC_IRQ_EVSYNC_EVEN; } else { if (mgr->id == OMAP_DSS_CHANNEL_LCD) irq = DISPC_IRQ_VSYNC; else irq = DISPC_IRQ_VSYNC2; } r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout); dispc_runtime_put(); return r; } int dss_init_overlay_managers(struct platform_device *pdev) { int i, r; num_managers = dss_feat_get_num_mgrs(); managers = kzalloc(sizeof(struct omap_overlay_manager) * num_managers, GFP_KERNEL); BUG_ON(managers == NULL); for (i = 0; i < num_managers; ++i) { struct omap_overlay_manager *mgr = &managers[i]; switch (i) { case 0: mgr->name = "lcd"; mgr->id = OMAP_DSS_CHANNEL_LCD; break; case 1: mgr->name = "tv"; mgr->id = OMAP_DSS_CHANNEL_DIGIT; break; case 2: mgr->name = "lcd2"; mgr->id = OMAP_DSS_CHANNEL_LCD2; break; } mgr->set_device = &dss_mgr_set_device; mgr->unset_device = &dss_mgr_unset_device; mgr->apply = &omap_dss_mgr_apply; mgr->set_manager_info = &dss_mgr_set_info; mgr->get_manager_info = &dss_mgr_get_info; mgr->wait_for_go = &dss_mgr_wait_for_go; mgr->wait_for_vsync = &dss_mgr_wait_for_vsync; mgr->caps = 0; mgr->supported_displays = dss_feat_get_supported_displays(mgr->id); INIT_LIST_HEAD(&mgr->overlays); r = kobject_init_and_add(&mgr->kobj, &manager_ktype, &pdev->dev.kobj, "manager%d", i); if (r) DSSERR("failed to create sysfs file\n"); } return 0; } void dss_uninit_overlay_managers(struct platform_device *pdev) { int i; for (i = 0; i < num_managers; ++i) { struct omap_overlay_manager *mgr = &managers[i]; kobject_del(&mgr->kobj); kobject_put(&mgr->kobj); } kfree(managers); managers = NULL; num_managers = 0; } int omap_dss_get_num_overlay_managers(void) { return num_managers; } EXPORT_SYMBOL(omap_dss_get_num_overlay_managers); struct omap_overlay_manager *omap_dss_get_overlay_manager(int num) { if (num >= num_managers) return NULL; return &managers[num]; } EXPORT_SYMBOL(omap_dss_get_overlay_manager); int dss_mgr_simple_check(struct omap_overlay_manager *mgr, const struct omap_overlay_manager_info *info) { if (dss_has_feature(FEAT_ALPHA_FIXED_ZORDER)) { /* * OMAP3 supports only graphics source transparency color key * and alpha blending simultaneously. See TRM 15.4.2.4.2.2 * Alpha Mode. */ if (info->partial_alpha_enabled && info->trans_enabled && info->trans_key_type != OMAP_DSS_COLOR_KEY_GFX_DST) { DSSERR("check_manager: illegal transparency key\n"); return -EINVAL; } } return 0; } static int dss_mgr_check_zorder(struct omap_overlay_manager *mgr, struct omap_overlay_info **overlay_infos) { struct omap_overlay *ovl1, *ovl2; struct omap_overlay_info *info1, *info2; list_for_each_entry(ovl1, &mgr->overlays, list) { info1 = overlay_infos[ovl1->id]; if (info1 == NULL) continue; list_for_each_entry(ovl2, &mgr->overlays, list) { if (ovl1 == ovl2) continue; info2 = overlay_infos[ovl2->id]; if (info2 == NULL) continue; if (info1->zorder == info2->zorder) { DSSERR("overlays %d and %d have the same " "zorder %d\n", ovl1->id, ovl2->id, info1->zorder); return -EINVAL; } } } return 0; } int dss_mgr_check(struct omap_overlay_manager *mgr, struct omap_dss_device *dssdev, struct omap_overlay_manager_info *info, struct omap_overlay_info **overlay_infos) { struct omap_overlay *ovl; int r; if (dss_has_feature(FEAT_ALPHA_FREE_ZORDER)) { r = dss_mgr_check_zorder(mgr, overlay_infos); if (r) return r; } list_for_each_entry(ovl, &mgr->overlays, list) { struct omap_overlay_info *oi; int r; oi = overlay_infos[ovl->id]; if (oi == NULL) continue; r = dss_ovl_check(ovl, oi, dssdev); if (r) return r; } return 0; }
gpl-2.0
UNGLinux/UNGKernel
drivers/media/usb/dvb-usb/dibusb-mc.c
9399
5106
/* DVB USB compliant linux driver for mobile DVB-T USB devices based on * reference designs made by DiBcom (http://www.dibcom.fr/) (DiB3000M-C/P) * * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) * * based on GPL code from DiBcom, which has * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr) * * 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. * * see Documentation/dvb/README.dvb-usb for more information */ #include "dibusb.h" DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); /* USB Driver stuff */ static struct dvb_usb_device_properties dibusb_mc_properties; static int dibusb_mc_probe(struct usb_interface *intf, const struct usb_device_id *id) { return dvb_usb_device_init(intf, &dibusb_mc_properties, THIS_MODULE, NULL, adapter_nr); } /* do not change the order of the ID table */ static struct usb_device_id dibusb_dib3000mc_table [] = { /* 00 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_COLD) }, /* 01 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_WARM) }, /* 02 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_COLD) }, /* 03 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_WARM) }, // ( ? ) /* 04 */ { USB_DEVICE(USB_VID_LITEON, USB_PID_LITEON_DVB_T_COLD) }, /* 05 */ { USB_DEVICE(USB_VID_LITEON, USB_PID_LITEON_DVB_T_WARM) }, /* 06 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_DIGIVOX_MINI_SL_COLD) }, /* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_DIGIVOX_MINI_SL_WARM) }, /* 08 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB2_COLD) }, /* 09 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB2_WARM) }, /* 10 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14_COLD) }, /* 11 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14_WARM) }, /* 12 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_COLD) }, /* 13 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_WARM) }, /* 14 */ { USB_DEVICE(USB_VID_HUMAX_COEX, USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD) }, /* 15 */ { USB_DEVICE(USB_VID_HUMAX_COEX, USB_PID_DVB_T_USB_STICK_HIGH_SPEED_WARM) }, { } /* Terminating entry */ }; MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table); static struct dvb_usb_device_properties dibusb_mc_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-dibusb-6.0.0.8.fw", .num_adapters = 1, .adapter = { { .num_frontends = 1, .fe = {{ .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, .pid_filter_count = 32, .streaming_ctrl = dibusb2_0_streaming_ctrl, .pid_filter = dibusb_pid_filter, .pid_filter_ctrl = dibusb_pid_filter_ctrl, .frontend_attach = dibusb_dib3000mc_frontend_attach, .tuner_attach = dibusb_dib3000mc_tuner_attach, /* parameter for the MPEG2-data transfer */ .stream = { .type = USB_BULK, .count = 8, .endpoint = 0x06, .u = { .bulk = { .buffersize = 4096, } } }, }}, .size_of_priv = sizeof(struct dibusb_state), } }, .power_ctrl = dibusb2_0_power_ctrl, .rc.legacy = { .rc_interval = DEFAULT_RC_INTERVAL, .rc_map_table = rc_map_dibusb_table, .rc_map_size = 111, /* FIXME */ .rc_query = dibusb_rc_query, }, .i2c_algo = &dibusb_i2c_algo, .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 8, .devices = { { "DiBcom USB2.0 DVB-T reference design (MOD3000P)", { &dibusb_dib3000mc_table[0], NULL }, { &dibusb_dib3000mc_table[1], NULL }, }, { "Artec T1 USB2.0 TVBOX (please check the warm ID)", { &dibusb_dib3000mc_table[2], NULL }, { &dibusb_dib3000mc_table[3], NULL }, }, { "LITE-ON USB2.0 DVB-T Tuner", /* Also rebranded as Intuix S800, Toshiba */ { &dibusb_dib3000mc_table[4], NULL }, { &dibusb_dib3000mc_table[5], NULL }, }, { "MSI Digivox Mini SL", { &dibusb_dib3000mc_table[6], NULL }, { &dibusb_dib3000mc_table[7], NULL }, }, { "GRAND - USB2.0 DVB-T adapter", { &dibusb_dib3000mc_table[8], NULL }, { &dibusb_dib3000mc_table[9], NULL }, }, { "Artec T14 - USB2.0 DVB-T", { &dibusb_dib3000mc_table[10], NULL }, { &dibusb_dib3000mc_table[11], NULL }, }, { "Leadtek - USB2.0 Winfast DTV dongle", { &dibusb_dib3000mc_table[12], NULL }, { &dibusb_dib3000mc_table[13], NULL }, }, { "Humax/Coex DVB-T USB Stick 2.0 High Speed", { &dibusb_dib3000mc_table[14], NULL }, { &dibusb_dib3000mc_table[15], NULL }, }, { NULL }, } }; static struct usb_driver dibusb_mc_driver = { .name = "dvb_usb_dibusb_mc", .probe = dibusb_mc_probe, .disconnect = dvb_usb_device_exit, .id_table = dibusb_dib3000mc_table, }; module_usb_driver(dibusb_mc_driver); MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); MODULE_DESCRIPTION("Driver for DiBcom USB2.0 DVB-T (DiB3000M-C/P based) devices"); MODULE_VERSION("1.0"); MODULE_LICENSE("GPL");
gpl-2.0
codesnake/linux-amlogic
drivers/net/wireless/brcm80211/brcmsmac/rate.c
10935
16697
/* * Copyright (c) 2010 Broadcom Corporation * * 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 <brcmu_wifi.h> #include <brcmu_utils.h> #include "d11.h" #include "pub.h" #include "rate.h" /* * Rate info per rate: It tells whether a rate is ofdm or not and its phy_rate * value */ const u8 rate_info[BRCM_MAXRATE + 1] = { /* 0 1 2 3 4 5 6 7 8 9 */ /* 0 */ 0x00, 0x00, 0x0a, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, /* 10 */ 0x00, 0x37, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x00, /* 20 */ 0x00, 0x00, 0x6e, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, /* 30 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, /* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x00, /* 50 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 60 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 70 */ 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, /* 100 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c }; /* rates are in units of Kbps */ const struct brcms_mcs_info mcs_table[MCS_TABLE_SIZE] = { /* MCS 0: SS 1, MOD: BPSK, CR 1/2 */ {6500, 13500, CEIL(6500 * 10, 9), CEIL(13500 * 10, 9), 0x00, BRCM_RATE_6M}, /* MCS 1: SS 1, MOD: QPSK, CR 1/2 */ {13000, 27000, CEIL(13000 * 10, 9), CEIL(27000 * 10, 9), 0x08, BRCM_RATE_12M}, /* MCS 2: SS 1, MOD: QPSK, CR 3/4 */ {19500, 40500, CEIL(19500 * 10, 9), CEIL(40500 * 10, 9), 0x0A, BRCM_RATE_18M}, /* MCS 3: SS 1, MOD: 16QAM, CR 1/2 */ {26000, 54000, CEIL(26000 * 10, 9), CEIL(54000 * 10, 9), 0x10, BRCM_RATE_24M}, /* MCS 4: SS 1, MOD: 16QAM, CR 3/4 */ {39000, 81000, CEIL(39000 * 10, 9), CEIL(81000 * 10, 9), 0x12, BRCM_RATE_36M}, /* MCS 5: SS 1, MOD: 64QAM, CR 2/3 */ {52000, 108000, CEIL(52000 * 10, 9), CEIL(108000 * 10, 9), 0x19, BRCM_RATE_48M}, /* MCS 6: SS 1, MOD: 64QAM, CR 3/4 */ {58500, 121500, CEIL(58500 * 10, 9), CEIL(121500 * 10, 9), 0x1A, BRCM_RATE_54M}, /* MCS 7: SS 1, MOD: 64QAM, CR 5/6 */ {65000, 135000, CEIL(65000 * 10, 9), CEIL(135000 * 10, 9), 0x1C, BRCM_RATE_54M}, /* MCS 8: SS 2, MOD: BPSK, CR 1/2 */ {13000, 27000, CEIL(13000 * 10, 9), CEIL(27000 * 10, 9), 0x40, BRCM_RATE_6M}, /* MCS 9: SS 2, MOD: QPSK, CR 1/2 */ {26000, 54000, CEIL(26000 * 10, 9), CEIL(54000 * 10, 9), 0x48, BRCM_RATE_12M}, /* MCS 10: SS 2, MOD: QPSK, CR 3/4 */ {39000, 81000, CEIL(39000 * 10, 9), CEIL(81000 * 10, 9), 0x4A, BRCM_RATE_18M}, /* MCS 11: SS 2, MOD: 16QAM, CR 1/2 */ {52000, 108000, CEIL(52000 * 10, 9), CEIL(108000 * 10, 9), 0x50, BRCM_RATE_24M}, /* MCS 12: SS 2, MOD: 16QAM, CR 3/4 */ {78000, 162000, CEIL(78000 * 10, 9), CEIL(162000 * 10, 9), 0x52, BRCM_RATE_36M}, /* MCS 13: SS 2, MOD: 64QAM, CR 2/3 */ {104000, 216000, CEIL(104000 * 10, 9), CEIL(216000 * 10, 9), 0x59, BRCM_RATE_48M}, /* MCS 14: SS 2, MOD: 64QAM, CR 3/4 */ {117000, 243000, CEIL(117000 * 10, 9), CEIL(243000 * 10, 9), 0x5A, BRCM_RATE_54M}, /* MCS 15: SS 2, MOD: 64QAM, CR 5/6 */ {130000, 270000, CEIL(130000 * 10, 9), CEIL(270000 * 10, 9), 0x5C, BRCM_RATE_54M}, /* MCS 16: SS 3, MOD: BPSK, CR 1/2 */ {19500, 40500, CEIL(19500 * 10, 9), CEIL(40500 * 10, 9), 0x80, BRCM_RATE_6M}, /* MCS 17: SS 3, MOD: QPSK, CR 1/2 */ {39000, 81000, CEIL(39000 * 10, 9), CEIL(81000 * 10, 9), 0x88, BRCM_RATE_12M}, /* MCS 18: SS 3, MOD: QPSK, CR 3/4 */ {58500, 121500, CEIL(58500 * 10, 9), CEIL(121500 * 10, 9), 0x8A, BRCM_RATE_18M}, /* MCS 19: SS 3, MOD: 16QAM, CR 1/2 */ {78000, 162000, CEIL(78000 * 10, 9), CEIL(162000 * 10, 9), 0x90, BRCM_RATE_24M}, /* MCS 20: SS 3, MOD: 16QAM, CR 3/4 */ {117000, 243000, CEIL(117000 * 10, 9), CEIL(243000 * 10, 9), 0x92, BRCM_RATE_36M}, /* MCS 21: SS 3, MOD: 64QAM, CR 2/3 */ {156000, 324000, CEIL(156000 * 10, 9), CEIL(324000 * 10, 9), 0x99, BRCM_RATE_48M}, /* MCS 22: SS 3, MOD: 64QAM, CR 3/4 */ {175500, 364500, CEIL(175500 * 10, 9), CEIL(364500 * 10, 9), 0x9A, BRCM_RATE_54M}, /* MCS 23: SS 3, MOD: 64QAM, CR 5/6 */ {195000, 405000, CEIL(195000 * 10, 9), CEIL(405000 * 10, 9), 0x9B, BRCM_RATE_54M}, /* MCS 24: SS 4, MOD: BPSK, CR 1/2 */ {26000, 54000, CEIL(26000 * 10, 9), CEIL(54000 * 10, 9), 0xC0, BRCM_RATE_6M}, /* MCS 25: SS 4, MOD: QPSK, CR 1/2 */ {52000, 108000, CEIL(52000 * 10, 9), CEIL(108000 * 10, 9), 0xC8, BRCM_RATE_12M}, /* MCS 26: SS 4, MOD: QPSK, CR 3/4 */ {78000, 162000, CEIL(78000 * 10, 9), CEIL(162000 * 10, 9), 0xCA, BRCM_RATE_18M}, /* MCS 27: SS 4, MOD: 16QAM, CR 1/2 */ {104000, 216000, CEIL(104000 * 10, 9), CEIL(216000 * 10, 9), 0xD0, BRCM_RATE_24M}, /* MCS 28: SS 4, MOD: 16QAM, CR 3/4 */ {156000, 324000, CEIL(156000 * 10, 9), CEIL(324000 * 10, 9), 0xD2, BRCM_RATE_36M}, /* MCS 29: SS 4, MOD: 64QAM, CR 2/3 */ {208000, 432000, CEIL(208000 * 10, 9), CEIL(432000 * 10, 9), 0xD9, BRCM_RATE_48M}, /* MCS 30: SS 4, MOD: 64QAM, CR 3/4 */ {234000, 486000, CEIL(234000 * 10, 9), CEIL(486000 * 10, 9), 0xDA, BRCM_RATE_54M}, /* MCS 31: SS 4, MOD: 64QAM, CR 5/6 */ {260000, 540000, CEIL(260000 * 10, 9), CEIL(540000 * 10, 9), 0xDB, BRCM_RATE_54M}, /* MCS 32: SS 1, MOD: BPSK, CR 1/2 */ {0, 6000, 0, CEIL(6000 * 10, 9), 0x00, BRCM_RATE_6M}, }; /* * phycfg for legacy OFDM frames: code rate, modulation scheme, spatial streams * Number of spatial streams: always 1 other fields: refer to table 78 of * section 17.3.2.2 of the original .11a standard */ struct legacy_phycfg { u32 rate_ofdm; /* ofdm mac rate */ /* phy ctl byte 3, code rate, modulation type, # of streams */ u8 tx_phy_ctl3; }; /* Number of legacy_rate_cfg entries in the table */ #define LEGACY_PHYCFG_TABLE_SIZE 12 /* * In CCK mode LPPHY overloads OFDM Modulation bits with CCK Data Rate * Eventually MIMOPHY would also be converted to this format * 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps */ static const struct legacy_phycfg legacy_phycfg_table[LEGACY_PHYCFG_TABLE_SIZE] = { {BRCM_RATE_1M, 0x00}, /* CCK 1Mbps, data rate 0 */ {BRCM_RATE_2M, 0x08}, /* CCK 2Mbps, data rate 1 */ {BRCM_RATE_5M5, 0x10}, /* CCK 5.5Mbps, data rate 2 */ {BRCM_RATE_11M, 0x18}, /* CCK 11Mbps, data rate 3 */ /* OFDM 6Mbps, code rate 1/2, BPSK, 1 spatial stream */ {BRCM_RATE_6M, 0x00}, /* OFDM 9Mbps, code rate 3/4, BPSK, 1 spatial stream */ {BRCM_RATE_9M, 0x02}, /* OFDM 12Mbps, code rate 1/2, QPSK, 1 spatial stream */ {BRCM_RATE_12M, 0x08}, /* OFDM 18Mbps, code rate 3/4, QPSK, 1 spatial stream */ {BRCM_RATE_18M, 0x0A}, /* OFDM 24Mbps, code rate 1/2, 16-QAM, 1 spatial stream */ {BRCM_RATE_24M, 0x10}, /* OFDM 36Mbps, code rate 3/4, 16-QAM, 1 spatial stream */ {BRCM_RATE_36M, 0x12}, /* OFDM 48Mbps, code rate 2/3, 64-QAM, 1 spatial stream */ {BRCM_RATE_48M, 0x19}, /* OFDM 54Mbps, code rate 3/4, 64-QAM, 1 spatial stream */ {BRCM_RATE_54M, 0x1A}, }; /* Hardware rates (also encodes default basic rates) */ const struct brcms_c_rateset cck_ofdm_mimo_rates = { 12, /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48, */ { 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, /* 54 Mbps */ 0x6c}, 0x00, { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset ofdm_mimo_rates = { 8, /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ { 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, 0x00, { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; /* Default ratesets that include MCS32 for 40BW channels */ static const struct brcms_c_rateset cck_ofdm_40bw_mimo_rates = { 12, /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48 */ { 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, /* 54 Mbps */ 0x6c}, 0x00, { 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; static const struct brcms_c_rateset ofdm_40bw_mimo_rates = { 8, /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ { 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, 0x00, { 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset cck_ofdm_rates = { 12, /* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48,*/ { 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60, /*54 Mbps */ 0x6c}, 0x00, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset gphy_legacy_rates = { 4, /* 1b, 2b, 5.5b, 11b Mbps */ { 0x82, 0x84, 0x8b, 0x96}, 0x00, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset ofdm_rates = { 8, /* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */ { 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c}, 0x00, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; const struct brcms_c_rateset cck_rates = { 4, /* 1b, 2b, 5.5, 11 Mbps */ { 0x82, 0x84, 0x0b, 0x16}, 0x00, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; /* check if rateset is valid. * if check_brate is true, rateset without a basic rate is considered NOT valid. */ static bool brcms_c_rateset_valid(struct brcms_c_rateset *rs, bool check_brate) { uint idx; if (!rs->count) return false; if (!check_brate) return true; /* error if no basic rates */ for (idx = 0; idx < rs->count; idx++) { if (rs->rates[idx] & BRCMS_RATE_FLAG) return true; } return false; } void brcms_c_rateset_mcs_upd(struct brcms_c_rateset *rs, u8 txstreams) { int i; for (i = txstreams; i < MAX_STREAMS_SUPPORTED; i++) rs->mcs[i] = 0; } /* * filter based on hardware rateset, and sort filtered rateset with basic * bit(s) preserved, and check if resulting rateset is valid. */ bool brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs, const struct brcms_c_rateset *hw_rs, bool check_brate, u8 txstreams) { u8 rateset[BRCM_MAXRATE + 1]; u8 r; uint count; uint i; memset(rateset, 0, sizeof(rateset)); count = rs->count; for (i = 0; i < count; i++) { /* mask off "basic rate" bit, BRCMS_RATE_FLAG */ r = (int)rs->rates[i] & BRCMS_RATE_MASK; if ((r > BRCM_MAXRATE) || (rate_info[r] == 0)) continue; rateset[r] = rs->rates[i]; /* preserve basic bit! */ } /* fill out the rates in order, looking at only supported rates */ count = 0; for (i = 0; i < hw_rs->count; i++) { r = hw_rs->rates[i] & BRCMS_RATE_MASK; if (rateset[r]) rs->rates[count++] = rateset[r]; } rs->count = count; /* only set the mcs rate bit if the equivalent hw mcs bit is set */ for (i = 0; i < MCSSET_LEN; i++) rs->mcs[i] = (rs->mcs[i] & hw_rs->mcs[i]); if (brcms_c_rateset_valid(rs, check_brate)) return true; else return false; } /* calculate the rate of a rx'd frame and return it as a ratespec */ u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp) { int phy_type; u32 rspec = PHY_TXC1_BW_20MHZ << RSPEC_BW_SHIFT; phy_type = ((rxh->RxChan & RXS_CHAN_PHYTYPE_MASK) >> RXS_CHAN_PHYTYPE_SHIFT); if ((phy_type == PHY_TYPE_N) || (phy_type == PHY_TYPE_SSN) || (phy_type == PHY_TYPE_LCN) || (phy_type == PHY_TYPE_HT)) { switch (rxh->PhyRxStatus_0 & PRXS0_FT_MASK) { case PRXS0_CCK: rspec = cck_phy2mac_rate( ((struct cck_phy_hdr *) plcp)->signal); break; case PRXS0_OFDM: rspec = ofdm_phy2mac_rate( ((struct ofdm_phy_hdr *) plcp)->rlpt[0]); break; case PRXS0_PREN: rspec = (plcp[0] & MIMO_PLCP_MCS_MASK) | RSPEC_MIMORATE; if (plcp[0] & MIMO_PLCP_40MHZ) { /* indicate rspec is for 40 MHz mode */ rspec &= ~RSPEC_BW_MASK; rspec |= (PHY_TXC1_BW_40MHZ << RSPEC_BW_SHIFT); } break; case PRXS0_STDN: /* fallthru */ default: /* not supported, error condition */ break; } if (plcp3_issgi(plcp[3])) rspec |= RSPEC_SHORT_GI; } else if ((phy_type == PHY_TYPE_A) || (rxh->PhyRxStatus_0 & PRXS0_OFDM)) rspec = ofdm_phy2mac_rate( ((struct ofdm_phy_hdr *) plcp)->rlpt[0]); else rspec = cck_phy2mac_rate( ((struct cck_phy_hdr *) plcp)->signal); return rspec; } /* copy rateset src to dst as-is (no masking or sorting) */ void brcms_c_rateset_copy(const struct brcms_c_rateset *src, struct brcms_c_rateset *dst) { memcpy(dst, src, sizeof(struct brcms_c_rateset)); } /* * Copy and selectively filter one rateset to another. * 'basic_only' means only copy basic rates. * 'rates' indicates cck (11b) and ofdm rates combinations. * - 0: cck and ofdm * - 1: cck only * - 2: ofdm only * 'xmask' is the copy mask (typically 0x7f or 0xff). */ void brcms_c_rateset_filter(struct brcms_c_rateset *src, struct brcms_c_rateset *dst, bool basic_only, u8 rates, uint xmask, bool mcsallow) { uint i; uint r; uint count; count = 0; for (i = 0; i < src->count; i++) { r = src->rates[i]; if (basic_only && !(r & BRCMS_RATE_FLAG)) continue; if (rates == BRCMS_RATES_CCK && is_ofdm_rate((r & BRCMS_RATE_MASK))) continue; if (rates == BRCMS_RATES_OFDM && is_cck_rate((r & BRCMS_RATE_MASK))) continue; dst->rates[count++] = r & xmask; } dst->count = count; dst->htphy_membership = src->htphy_membership; if (mcsallow && rates != BRCMS_RATES_CCK) memcpy(&dst->mcs[0], &src->mcs[0], MCSSET_LEN); else brcms_c_rateset_mcs_clear(dst); } /* select rateset for a given phy_type and bandtype and filter it, sort it * and fill rs_tgt with result */ void brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt, const struct brcms_c_rateset *rs_hw, uint phy_type, int bandtype, bool cck_only, uint rate_mask, bool mcsallow, u8 bw, u8 txstreams) { const struct brcms_c_rateset *rs_dflt; struct brcms_c_rateset rs_sel; if ((PHYTYPE_IS(phy_type, PHY_TYPE_HT)) || (PHYTYPE_IS(phy_type, PHY_TYPE_N)) || (PHYTYPE_IS(phy_type, PHY_TYPE_LCN)) || (PHYTYPE_IS(phy_type, PHY_TYPE_SSN))) { if (bandtype == BRCM_BAND_5G) rs_dflt = (bw == BRCMS_20_MHZ ? &ofdm_mimo_rates : &ofdm_40bw_mimo_rates); else rs_dflt = (bw == BRCMS_20_MHZ ? &cck_ofdm_mimo_rates : &cck_ofdm_40bw_mimo_rates); } else if (PHYTYPE_IS(phy_type, PHY_TYPE_LP)) { rs_dflt = (bandtype == BRCM_BAND_5G) ? &ofdm_rates : &cck_ofdm_rates; } else if (PHYTYPE_IS(phy_type, PHY_TYPE_A)) { rs_dflt = &ofdm_rates; } else if (PHYTYPE_IS(phy_type, PHY_TYPE_G)) { rs_dflt = &cck_ofdm_rates; } else { /* should not happen, error condition */ rs_dflt = &cck_rates; /* force cck */ } /* if hw rateset is not supplied, assign selected rateset to it */ if (!rs_hw) rs_hw = rs_dflt; brcms_c_rateset_copy(rs_dflt, &rs_sel); brcms_c_rateset_mcs_upd(&rs_sel, txstreams); brcms_c_rateset_filter(&rs_sel, rs_tgt, false, cck_only ? BRCMS_RATES_CCK : BRCMS_RATES_CCK_OFDM, rate_mask, mcsallow); brcms_c_rate_hwrs_filter_sort_validate(rs_tgt, rs_hw, false, mcsallow ? txstreams : 1); } s16 brcms_c_rate_legacy_phyctl(uint rate) { uint i; for (i = 0; i < LEGACY_PHYCFG_TABLE_SIZE; i++) if (rate == legacy_phycfg_table[i].rate_ofdm) return legacy_phycfg_table[i].tx_phy_ctl3; return -1; } void brcms_c_rateset_mcs_clear(struct brcms_c_rateset *rateset) { uint i; for (i = 0; i < MCSSET_LEN; i++) rateset->mcs[i] = 0; } void brcms_c_rateset_mcs_build(struct brcms_c_rateset *rateset, u8 txstreams) { memcpy(&rateset->mcs[0], &cck_ofdm_mimo_rates.mcs[0], MCSSET_LEN); brcms_c_rateset_mcs_upd(rateset, txstreams); } /* Based on bandwidth passed, allow/disallow MCS 32 in the rateset */ void brcms_c_rateset_bw_mcs_filter(struct brcms_c_rateset *rateset, u8 bw) { if (bw == BRCMS_40_MHZ) setbit(rateset->mcs, 32); else clrbit(rateset->mcs, 32); }
gpl-2.0
estiko/android_lenovo_a706_kinglplite
drivers/infiniband/hw/cxgb3/iwch_mem.c
13495
5473
/* * Copyright (c) 2006 Chelsio, 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/slab.h> #include <asm/byteorder.h> #include <rdma/iw_cm.h> #include <rdma/ib_verbs.h> #include "cxio_hal.h" #include "cxio_resource.h" #include "iwch.h" #include "iwch_provider.h" static int iwch_finish_mem_reg(struct iwch_mr *mhp, u32 stag) { u32 mmid; mhp->attr.state = 1; mhp->attr.stag = stag; mmid = stag >> 8; mhp->ibmr.rkey = mhp->ibmr.lkey = stag; PDBG("%s mmid 0x%x mhp %p\n", __func__, mmid, mhp); return insert_handle(mhp->rhp, &mhp->rhp->mmidr, mhp, mmid); } int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php, struct iwch_mr *mhp, int shift) { u32 stag; int ret; if (cxio_register_phys_mem(&rhp->rdev, &stag, mhp->attr.pdid, mhp->attr.perms, mhp->attr.zbva, mhp->attr.va_fbo, mhp->attr.len, shift - 12, mhp->attr.pbl_size, mhp->attr.pbl_addr)) return -ENOMEM; ret = iwch_finish_mem_reg(mhp, stag); if (ret) cxio_dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size, mhp->attr.pbl_addr); return ret; } int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php, struct iwch_mr *mhp, int shift, int npages) { u32 stag; int ret; /* We could support this... */ if (npages > mhp->attr.pbl_size) return -ENOMEM; stag = mhp->attr.stag; if (cxio_reregister_phys_mem(&rhp->rdev, &stag, mhp->attr.pdid, mhp->attr.perms, mhp->attr.zbva, mhp->attr.va_fbo, mhp->attr.len, shift - 12, mhp->attr.pbl_size, mhp->attr.pbl_addr)) return -ENOMEM; ret = iwch_finish_mem_reg(mhp, stag); if (ret) cxio_dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size, mhp->attr.pbl_addr); return ret; } int iwch_alloc_pbl(struct iwch_mr *mhp, int npages) { mhp->attr.pbl_addr = cxio_hal_pblpool_alloc(&mhp->rhp->rdev, npages << 3); if (!mhp->attr.pbl_addr) return -ENOMEM; mhp->attr.pbl_size = npages; return 0; } void iwch_free_pbl(struct iwch_mr *mhp) { cxio_hal_pblpool_free(&mhp->rhp->rdev, mhp->attr.pbl_addr, mhp->attr.pbl_size << 3); } int iwch_write_pbl(struct iwch_mr *mhp, __be64 *pages, int npages, int offset) { return cxio_write_pbl(&mhp->rhp->rdev, pages, mhp->attr.pbl_addr + (offset << 3), npages); } int build_phys_page_list(struct ib_phys_buf *buffer_list, int num_phys_buf, u64 *iova_start, u64 *total_size, int *npages, int *shift, __be64 **page_list) { u64 mask; int i, j, n; mask = 0; *total_size = 0; for (i = 0; i < num_phys_buf; ++i) { if (i != 0 && buffer_list[i].addr & ~PAGE_MASK) return -EINVAL; if (i != 0 && i != num_phys_buf - 1 && (buffer_list[i].size & ~PAGE_MASK)) return -EINVAL; *total_size += buffer_list[i].size; if (i > 0) mask |= buffer_list[i].addr; else mask |= buffer_list[i].addr & PAGE_MASK; if (i != num_phys_buf - 1) mask |= buffer_list[i].addr + buffer_list[i].size; else mask |= (buffer_list[i].addr + buffer_list[i].size + PAGE_SIZE - 1) & PAGE_MASK; } if (*total_size > 0xFFFFFFFFULL) return -ENOMEM; /* Find largest page shift we can use to cover buffers */ for (*shift = PAGE_SHIFT; *shift < 27; ++(*shift)) if ((1ULL << *shift) & mask) break; buffer_list[0].size += buffer_list[0].addr & ((1ULL << *shift) - 1); buffer_list[0].addr &= ~0ull << *shift; *npages = 0; for (i = 0; i < num_phys_buf; ++i) *npages += (buffer_list[i].size + (1ULL << *shift) - 1) >> *shift; if (!*npages) return -EINVAL; *page_list = kmalloc(sizeof(u64) * *npages, GFP_KERNEL); if (!*page_list) return -ENOMEM; n = 0; for (i = 0; i < num_phys_buf; ++i) for (j = 0; j < (buffer_list[i].size + (1ULL << *shift) - 1) >> *shift; ++j) (*page_list)[n++] = cpu_to_be64(buffer_list[i].addr + ((u64) j << *shift)); PDBG("%s va 0x%llx mask 0x%llx shift %d len %lld pbl_size %d\n", __func__, (unsigned long long) *iova_start, (unsigned long long) mask, *shift, (unsigned long long) *total_size, *npages); return 0; }
gpl-2.0
padovan/bluetooth-next
arch/score/lib/cmpdi2.c
13751
1213
/* * arch/score/lib/cmpdi2.c * * 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, see the file COPYING, or write * to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <linux/module.h> #include "libgcc.h" word_type __cmpdi2(long long a, long long b) { const DWunion au = { .ll = a }; const DWunion bu = { .ll = b }; if (au.s.high < bu.s.high) return 0; else if (au.s.high > bu.s.high) return 2; if ((unsigned int) au.s.low < (unsigned int) bu.s.low) return 0; else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) return 2; return 1; } EXPORT_SYMBOL(__cmpdi2);
gpl-2.0
jackyxhb/linux
drivers/net/ieee802154/mrf24j40.c
184
20641
/* * Driver for Microchip MRF24J40 802.15.4 Wireless-PAN Networking controller * * Copyright (C) 2012 Alan Ott <alan@signal11.us> * Signal 11 Software * * 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/spi/spi.h> #include <linux/interrupt.h> #include <linux/module.h> #include <linux/ieee802154.h> #include <net/cfg802154.h> #include <net/mac802154.h> /* MRF24J40 Short Address Registers */ #define REG_RXMCR 0x00 /* Receive MAC control */ #define REG_PANIDL 0x01 /* PAN ID (low) */ #define REG_PANIDH 0x02 /* PAN ID (high) */ #define REG_SADRL 0x03 /* Short address (low) */ #define REG_SADRH 0x04 /* Short address (high) */ #define REG_EADR0 0x05 /* Long address (low) (high is EADR7) */ #define REG_TXMCR 0x11 /* Transmit MAC control */ #define REG_PACON0 0x16 /* Power Amplifier Control */ #define REG_PACON1 0x17 /* Power Amplifier Control */ #define REG_PACON2 0x18 /* Power Amplifier Control */ #define REG_TXNCON 0x1B /* Transmit Normal FIFO Control */ #define REG_TXSTAT 0x24 /* TX MAC Status Register */ #define REG_SOFTRST 0x2A /* Soft Reset */ #define REG_TXSTBL 0x2E /* TX Stabilization */ #define REG_INTSTAT 0x31 /* Interrupt Status */ #define REG_INTCON 0x32 /* Interrupt Control */ #define REG_GPIO 0x33 /* GPIO */ #define REG_TRISGPIO 0x34 /* GPIO direction */ #define REG_RFCTL 0x36 /* RF Control Mode Register */ #define REG_BBREG1 0x39 /* Baseband Registers */ #define REG_BBREG2 0x3A /* */ #define REG_BBREG6 0x3E /* */ #define REG_CCAEDTH 0x3F /* Energy Detection Threshold */ /* MRF24J40 Long Address Registers */ #define REG_RFCON0 0x200 /* RF Control Registers */ #define REG_RFCON1 0x201 #define REG_RFCON2 0x202 #define REG_RFCON3 0x203 #define REG_RFCON5 0x205 #define REG_RFCON6 0x206 #define REG_RFCON7 0x207 #define REG_RFCON8 0x208 #define REG_RSSI 0x210 #define REG_SLPCON0 0x211 /* Sleep Clock Control Registers */ #define REG_SLPCON1 0x220 #define REG_WAKETIMEL 0x222 /* Wake-up Time Match Value Low */ #define REG_WAKETIMEH 0x223 /* Wake-up Time Match Value High */ #define REG_TESTMODE 0x22F /* Test mode */ #define REG_RX_FIFO 0x300 /* Receive FIFO */ /* Device configuration: Only channels 11-26 on page 0 are supported. */ #define MRF24J40_CHAN_MIN 11 #define MRF24J40_CHAN_MAX 26 #define CHANNEL_MASK (((u32)1 << (MRF24J40_CHAN_MAX + 1)) \ - ((u32)1 << MRF24J40_CHAN_MIN)) #define TX_FIFO_SIZE 128 /* From datasheet */ #define RX_FIFO_SIZE 144 /* From datasheet */ #define SET_CHANNEL_DELAY_US 192 /* From datasheet */ enum mrf24j40_modules { MRF24J40, MRF24J40MA, MRF24J40MC }; /* Device Private Data */ struct mrf24j40 { struct spi_device *spi; struct ieee802154_hw *hw; struct mutex buffer_mutex; /* only used to protect buf */ struct completion tx_complete; u8 *buf; /* 3 bytes. Used for SPI single-register transfers. */ }; /* Read/Write SPI Commands for Short and Long Address registers. */ #define MRF24J40_READSHORT(reg) ((reg) << 1) #define MRF24J40_WRITESHORT(reg) ((reg) << 1 | 1) #define MRF24J40_READLONG(reg) (1 << 15 | (reg) << 5) #define MRF24J40_WRITELONG(reg) (1 << 15 | (reg) << 5 | 1 << 4) /* The datasheet indicates the theoretical maximum for SCK to be 10MHz */ #define MAX_SPI_SPEED_HZ 10000000 #define printdev(X) (&X->spi->dev) static int write_short_reg(struct mrf24j40 *devrec, u8 reg, u8 value) { int ret; struct spi_message msg; struct spi_transfer xfer = { .len = 2, .tx_buf = devrec->buf, .rx_buf = devrec->buf, }; spi_message_init(&msg); spi_message_add_tail(&xfer, &msg); mutex_lock(&devrec->buffer_mutex); devrec->buf[0] = MRF24J40_WRITESHORT(reg); devrec->buf[1] = value; ret = spi_sync(devrec->spi, &msg); if (ret) dev_err(printdev(devrec), "SPI write Failed for short register 0x%hhx\n", reg); mutex_unlock(&devrec->buffer_mutex); return ret; } static int read_short_reg(struct mrf24j40 *devrec, u8 reg, u8 *val) { int ret = -1; struct spi_message msg; struct spi_transfer xfer = { .len = 2, .tx_buf = devrec->buf, .rx_buf = devrec->buf, }; spi_message_init(&msg); spi_message_add_tail(&xfer, &msg); mutex_lock(&devrec->buffer_mutex); devrec->buf[0] = MRF24J40_READSHORT(reg); devrec->buf[1] = 0; ret = spi_sync(devrec->spi, &msg); if (ret) dev_err(printdev(devrec), "SPI read Failed for short register 0x%hhx\n", reg); else *val = devrec->buf[1]; mutex_unlock(&devrec->buffer_mutex); return ret; } static int read_long_reg(struct mrf24j40 *devrec, u16 reg, u8 *value) { int ret; u16 cmd; struct spi_message msg; struct spi_transfer xfer = { .len = 3, .tx_buf = devrec->buf, .rx_buf = devrec->buf, }; spi_message_init(&msg); spi_message_add_tail(&xfer, &msg); cmd = MRF24J40_READLONG(reg); mutex_lock(&devrec->buffer_mutex); devrec->buf[0] = cmd >> 8 & 0xff; devrec->buf[1] = cmd & 0xff; devrec->buf[2] = 0; ret = spi_sync(devrec->spi, &msg); if (ret) dev_err(printdev(devrec), "SPI read Failed for long register 0x%hx\n", reg); else *value = devrec->buf[2]; mutex_unlock(&devrec->buffer_mutex); return ret; } static int write_long_reg(struct mrf24j40 *devrec, u16 reg, u8 val) { int ret; u16 cmd; struct spi_message msg; struct spi_transfer xfer = { .len = 3, .tx_buf = devrec->buf, .rx_buf = devrec->buf, }; spi_message_init(&msg); spi_message_add_tail(&xfer, &msg); cmd = MRF24J40_WRITELONG(reg); mutex_lock(&devrec->buffer_mutex); devrec->buf[0] = cmd >> 8 & 0xff; devrec->buf[1] = cmd & 0xff; devrec->buf[2] = val; ret = spi_sync(devrec->spi, &msg); if (ret) dev_err(printdev(devrec), "SPI write Failed for long register 0x%hx\n", reg); mutex_unlock(&devrec->buffer_mutex); return ret; } /* This function relies on an undocumented write method. Once a write command and address is set, as many bytes of data as desired can be clocked into the device. The datasheet only shows setting one byte at a time. */ static int write_tx_buf(struct mrf24j40 *devrec, u16 reg, const u8 *data, size_t length) { int ret; u16 cmd; u8 lengths[2]; struct spi_message msg; struct spi_transfer addr_xfer = { .len = 2, .tx_buf = devrec->buf, }; struct spi_transfer lengths_xfer = { .len = 2, .tx_buf = &lengths, /* TODO: Is DMA really required for SPI? */ }; struct spi_transfer data_xfer = { .len = length, .tx_buf = data, }; /* Range check the length. 2 bytes are used for the length fields.*/ if (length > TX_FIFO_SIZE-2) { dev_err(printdev(devrec), "write_tx_buf() was passed too large a buffer. Performing short write.\n"); length = TX_FIFO_SIZE-2; } spi_message_init(&msg); spi_message_add_tail(&addr_xfer, &msg); spi_message_add_tail(&lengths_xfer, &msg); spi_message_add_tail(&data_xfer, &msg); cmd = MRF24J40_WRITELONG(reg); mutex_lock(&devrec->buffer_mutex); devrec->buf[0] = cmd >> 8 & 0xff; devrec->buf[1] = cmd & 0xff; lengths[0] = 0x0; /* Header Length. Set to 0 for now. TODO */ lengths[1] = length; /* Total length */ ret = spi_sync(devrec->spi, &msg); if (ret) dev_err(printdev(devrec), "SPI write Failed for TX buf\n"); mutex_unlock(&devrec->buffer_mutex); return ret; } static int mrf24j40_read_rx_buf(struct mrf24j40 *devrec, u8 *data, u8 *len, u8 *lqi) { u8 rx_len; u8 addr[2]; u8 lqi_rssi[2]; u16 cmd; int ret; struct spi_message msg; struct spi_transfer addr_xfer = { .len = 2, .tx_buf = &addr, }; struct spi_transfer data_xfer = { .len = 0x0, /* set below */ .rx_buf = data, }; struct spi_transfer status_xfer = { .len = 2, .rx_buf = &lqi_rssi, }; /* Get the length of the data in the RX FIFO. The length in this * register exclues the 1-byte length field at the beginning. */ ret = read_long_reg(devrec, REG_RX_FIFO, &rx_len); if (ret) goto out; /* Range check the RX FIFO length, accounting for the one-byte * length field at the beginning. */ if (rx_len > RX_FIFO_SIZE-1) { dev_err(printdev(devrec), "Invalid length read from device. Performing short read.\n"); rx_len = RX_FIFO_SIZE-1; } if (rx_len > *len) { /* Passed in buffer wasn't big enough. Should never happen. */ dev_err(printdev(devrec), "Buffer not big enough. Performing short read\n"); rx_len = *len; } /* Set up the commands to read the data. */ cmd = MRF24J40_READLONG(REG_RX_FIFO+1); addr[0] = cmd >> 8 & 0xff; addr[1] = cmd & 0xff; data_xfer.len = rx_len; spi_message_init(&msg); spi_message_add_tail(&addr_xfer, &msg); spi_message_add_tail(&data_xfer, &msg); spi_message_add_tail(&status_xfer, &msg); ret = spi_sync(devrec->spi, &msg); if (ret) { dev_err(printdev(devrec), "SPI RX Buffer Read Failed.\n"); goto out; } *lqi = lqi_rssi[0]; *len = rx_len; #ifdef DEBUG print_hex_dump(KERN_DEBUG, "mrf24j40 rx: ", DUMP_PREFIX_OFFSET, 16, 1, data, *len, 0); pr_debug("mrf24j40 rx: lqi: %02hhx rssi: %02hhx\n", lqi_rssi[0], lqi_rssi[1]); #endif out: return ret; } static int mrf24j40_tx(struct ieee802154_hw *hw, struct sk_buff *skb) { struct mrf24j40 *devrec = hw->priv; u8 val; int ret = 0; dev_dbg(printdev(devrec), "tx packet of %d bytes\n", skb->len); ret = write_tx_buf(devrec, 0x000, skb->data, skb->len); if (ret) goto err; reinit_completion(&devrec->tx_complete); /* Set TXNTRIG bit of TXNCON to send packet */ ret = read_short_reg(devrec, REG_TXNCON, &val); if (ret) goto err; val |= 0x1; /* Set TXNACKREQ if the ACK bit is set in the packet. */ if (skb->data[0] & IEEE802154_FC_ACK_REQ) val |= 0x4; write_short_reg(devrec, REG_TXNCON, val); /* Wait for the device to send the TX complete interrupt. */ ret = wait_for_completion_interruptible_timeout( &devrec->tx_complete, 5 * HZ); if (ret == -ERESTARTSYS) goto err; if (ret == 0) { dev_warn(printdev(devrec), "Timeout waiting for TX interrupt\n"); ret = -ETIMEDOUT; goto err; } /* Check for send error from the device. */ ret = read_short_reg(devrec, REG_TXSTAT, &val); if (ret) goto err; if (val & 0x1) { dev_dbg(printdev(devrec), "Error Sending. Retry count exceeded\n"); ret = -ECOMM; /* TODO: Better error code ? */ } else dev_dbg(printdev(devrec), "Packet Sent\n"); err: return ret; } static int mrf24j40_ed(struct ieee802154_hw *hw, u8 *level) { /* TODO: */ pr_warn("mrf24j40: ed not implemented\n"); *level = 0; return 0; } static int mrf24j40_start(struct ieee802154_hw *hw) { struct mrf24j40 *devrec = hw->priv; u8 val; int ret; dev_dbg(printdev(devrec), "start\n"); ret = read_short_reg(devrec, REG_INTCON, &val); if (ret) return ret; val &= ~(0x1|0x8); /* Clear TXNIE and RXIE. Enable interrupts */ write_short_reg(devrec, REG_INTCON, val); return 0; } static void mrf24j40_stop(struct ieee802154_hw *hw) { struct mrf24j40 *devrec = hw->priv; u8 val; int ret; dev_dbg(printdev(devrec), "stop\n"); ret = read_short_reg(devrec, REG_INTCON, &val); if (ret) return; val |= 0x1|0x8; /* Set TXNIE and RXIE. Disable Interrupts */ write_short_reg(devrec, REG_INTCON, val); } static int mrf24j40_set_channel(struct ieee802154_hw *hw, u8 page, u8 channel) { struct mrf24j40 *devrec = hw->priv; u8 val; int ret; dev_dbg(printdev(devrec), "Set Channel %d\n", channel); WARN_ON(page != 0); WARN_ON(channel < MRF24J40_CHAN_MIN); WARN_ON(channel > MRF24J40_CHAN_MAX); /* Set Channel TODO */ val = (channel-11) << 4 | 0x03; write_long_reg(devrec, REG_RFCON0, val); /* RF Reset */ ret = read_short_reg(devrec, REG_RFCTL, &val); if (ret) return ret; val |= 0x04; write_short_reg(devrec, REG_RFCTL, val); val &= ~0x04; write_short_reg(devrec, REG_RFCTL, val); udelay(SET_CHANNEL_DELAY_US); /* per datasheet */ return 0; } static int mrf24j40_filter(struct ieee802154_hw *hw, struct ieee802154_hw_addr_filt *filt, unsigned long changed) { struct mrf24j40 *devrec = hw->priv; dev_dbg(printdev(devrec), "filter\n"); if (changed & IEEE802154_AFILT_SADDR_CHANGED) { /* Short Addr */ u8 addrh, addrl; addrh = le16_to_cpu(filt->short_addr) >> 8 & 0xff; addrl = le16_to_cpu(filt->short_addr) & 0xff; write_short_reg(devrec, REG_SADRH, addrh); write_short_reg(devrec, REG_SADRL, addrl); dev_dbg(printdev(devrec), "Set short addr to %04hx\n", filt->short_addr); } if (changed & IEEE802154_AFILT_IEEEADDR_CHANGED) { /* Device Address */ u8 i, addr[8]; memcpy(addr, &filt->ieee_addr, 8); for (i = 0; i < 8; i++) write_short_reg(devrec, REG_EADR0 + i, addr[i]); #ifdef DEBUG pr_debug("Set long addr to: "); for (i = 0; i < 8; i++) pr_debug("%02hhx ", addr[7 - i]); pr_debug("\n"); #endif } if (changed & IEEE802154_AFILT_PANID_CHANGED) { /* PAN ID */ u8 panidl, panidh; panidh = le16_to_cpu(filt->pan_id) >> 8 & 0xff; panidl = le16_to_cpu(filt->pan_id) & 0xff; write_short_reg(devrec, REG_PANIDH, panidh); write_short_reg(devrec, REG_PANIDL, panidl); dev_dbg(printdev(devrec), "Set PANID to %04hx\n", filt->pan_id); } if (changed & IEEE802154_AFILT_PANC_CHANGED) { /* Pan Coordinator */ u8 val; int ret; ret = read_short_reg(devrec, REG_RXMCR, &val); if (ret) return ret; if (filt->pan_coord) val |= 0x8; else val &= ~0x8; write_short_reg(devrec, REG_RXMCR, val); /* REG_SLOTTED is maintained as default (unslotted/CSMA-CA). * REG_ORDER is maintained as default (no beacon/superframe). */ dev_dbg(printdev(devrec), "Set Pan Coord to %s\n", filt->pan_coord ? "on" : "off"); } return 0; } static int mrf24j40_handle_rx(struct mrf24j40 *devrec) { u8 len = RX_FIFO_SIZE; u8 lqi = 0; u8 val; int ret = 0; int ret2; struct sk_buff *skb; /* Turn off reception of packets off the air. This prevents the * device from overwriting the buffer while we're reading it. */ ret = read_short_reg(devrec, REG_BBREG1, &val); if (ret) goto out; val |= 4; /* SET RXDECINV */ write_short_reg(devrec, REG_BBREG1, val); skb = dev_alloc_skb(len); if (!skb) { ret = -ENOMEM; goto out; } ret = mrf24j40_read_rx_buf(devrec, skb_put(skb, len), &len, &lqi); if (ret < 0) { dev_err(printdev(devrec), "Failure reading RX FIFO\n"); kfree_skb(skb); ret = -EINVAL; goto out; } /* Cut off the checksum */ skb_trim(skb, len-2); /* TODO: Other drivers call ieee20154_rx_irqsafe() here (eg: cc2040, * also from a workqueue). I think irqsafe is not necessary here. * Can someone confirm? */ ieee802154_rx_irqsafe(devrec->hw, skb, lqi); dev_dbg(printdev(devrec), "RX Handled\n"); out: /* Turn back on reception of packets off the air. */ ret2 = read_short_reg(devrec, REG_BBREG1, &val); if (ret2) return ret2; val &= ~0x4; /* Clear RXDECINV */ write_short_reg(devrec, REG_BBREG1, val); return ret; } static const struct ieee802154_ops mrf24j40_ops = { .owner = THIS_MODULE, .xmit_sync = mrf24j40_tx, .ed = mrf24j40_ed, .start = mrf24j40_start, .stop = mrf24j40_stop, .set_channel = mrf24j40_set_channel, .set_hw_addr_filt = mrf24j40_filter, }; static irqreturn_t mrf24j40_isr(int irq, void *data) { struct mrf24j40 *devrec = data; u8 intstat; int ret; /* Read the interrupt status */ ret = read_short_reg(devrec, REG_INTSTAT, &intstat); if (ret) goto out; /* Check for TX complete */ if (intstat & 0x1) complete(&devrec->tx_complete); /* Check for Rx */ if (intstat & 0x8) mrf24j40_handle_rx(devrec); out: return IRQ_HANDLED; } static int mrf24j40_hw_init(struct mrf24j40 *devrec) { int ret; u8 val; /* Initialize the device. From datasheet section 3.2: Initialization. */ ret = write_short_reg(devrec, REG_SOFTRST, 0x07); if (ret) goto err_ret; ret = write_short_reg(devrec, REG_PACON2, 0x98); if (ret) goto err_ret; ret = write_short_reg(devrec, REG_TXSTBL, 0x95); if (ret) goto err_ret; ret = write_long_reg(devrec, REG_RFCON0, 0x03); if (ret) goto err_ret; ret = write_long_reg(devrec, REG_RFCON1, 0x01); if (ret) goto err_ret; ret = write_long_reg(devrec, REG_RFCON2, 0x80); if (ret) goto err_ret; ret = write_long_reg(devrec, REG_RFCON6, 0x90); if (ret) goto err_ret; ret = write_long_reg(devrec, REG_RFCON7, 0x80); if (ret) goto err_ret; ret = write_long_reg(devrec, REG_RFCON8, 0x10); if (ret) goto err_ret; ret = write_long_reg(devrec, REG_SLPCON1, 0x21); if (ret) goto err_ret; ret = write_short_reg(devrec, REG_BBREG2, 0x80); if (ret) goto err_ret; ret = write_short_reg(devrec, REG_CCAEDTH, 0x60); if (ret) goto err_ret; ret = write_short_reg(devrec, REG_BBREG6, 0x40); if (ret) goto err_ret; ret = write_short_reg(devrec, REG_RFCTL, 0x04); if (ret) goto err_ret; ret = write_short_reg(devrec, REG_RFCTL, 0x0); if (ret) goto err_ret; udelay(192); /* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */ ret = read_short_reg(devrec, REG_RXMCR, &val); if (ret) goto err_ret; val &= ~0x3; /* Clear RX mode (normal) */ ret = write_short_reg(devrec, REG_RXMCR, val); if (ret) goto err_ret; if (spi_get_device_id(devrec->spi)->driver_data == MRF24J40MC) { /* Enable external amplifier. * From MRF24J40MC datasheet section 1.3: Operation. */ read_long_reg(devrec, REG_TESTMODE, &val); val |= 0x7; /* Configure GPIO 0-2 to control amplifier */ write_long_reg(devrec, REG_TESTMODE, val); read_short_reg(devrec, REG_TRISGPIO, &val); val |= 0x8; /* Set GPIO3 as output. */ write_short_reg(devrec, REG_TRISGPIO, val); read_short_reg(devrec, REG_GPIO, &val); val |= 0x8; /* Set GPIO3 HIGH to enable U5 voltage regulator */ write_short_reg(devrec, REG_GPIO, val); /* Reduce TX pwr to meet FCC requirements. * From MRF24J40MC datasheet section 3.1.1 */ write_long_reg(devrec, REG_RFCON3, 0x28); } return 0; err_ret: return ret; } static int mrf24j40_probe(struct spi_device *spi) { int ret = -ENOMEM; struct mrf24j40 *devrec; dev_info(&spi->dev, "probe(). IRQ: %d\n", spi->irq); devrec = devm_kzalloc(&spi->dev, sizeof(struct mrf24j40), GFP_KERNEL); if (!devrec) goto err_ret; devrec->buf = devm_kzalloc(&spi->dev, 3, GFP_KERNEL); if (!devrec->buf) goto err_ret; spi->mode = SPI_MODE_0; /* TODO: Is this appropriate for right here? */ if (spi->max_speed_hz > MAX_SPI_SPEED_HZ) spi->max_speed_hz = MAX_SPI_SPEED_HZ; mutex_init(&devrec->buffer_mutex); init_completion(&devrec->tx_complete); devrec->spi = spi; spi_set_drvdata(spi, devrec); /* Register with the 802154 subsystem */ devrec->hw = ieee802154_alloc_hw(0, &mrf24j40_ops); if (!devrec->hw) goto err_ret; devrec->hw->priv = devrec; devrec->hw->parent = &devrec->spi->dev; devrec->hw->phy->supported.channels[0] = CHANNEL_MASK; devrec->hw->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AFILT; dev_dbg(printdev(devrec), "registered mrf24j40\n"); ret = ieee802154_register_hw(devrec->hw); if (ret) goto err_register_device; ret = mrf24j40_hw_init(devrec); if (ret) goto err_hw_init; ret = devm_request_threaded_irq(&spi->dev, spi->irq, NULL, mrf24j40_isr, IRQF_TRIGGER_LOW|IRQF_ONESHOT, dev_name(&spi->dev), devrec); if (ret) { dev_err(printdev(devrec), "Unable to get IRQ"); goto err_irq; } return 0; err_irq: err_hw_init: ieee802154_unregister_hw(devrec->hw); err_register_device: ieee802154_free_hw(devrec->hw); err_ret: return ret; } static int mrf24j40_remove(struct spi_device *spi) { struct mrf24j40 *devrec = spi_get_drvdata(spi); dev_dbg(printdev(devrec), "remove\n"); ieee802154_unregister_hw(devrec->hw); ieee802154_free_hw(devrec->hw); /* TODO: Will ieee802154_free_device() wait until ->xmit() is * complete? */ return 0; } static const struct spi_device_id mrf24j40_ids[] = { { "mrf24j40", MRF24J40 }, { "mrf24j40ma", MRF24J40MA }, { "mrf24j40mc", MRF24J40MC }, { }, }; MODULE_DEVICE_TABLE(spi, mrf24j40_ids); static struct spi_driver mrf24j40_driver = { .driver = { .name = "mrf24j40", .bus = &spi_bus_type, .owner = THIS_MODULE, }, .id_table = mrf24j40_ids, .probe = mrf24j40_probe, .remove = mrf24j40_remove, }; module_spi_driver(mrf24j40_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Alan Ott"); MODULE_DESCRIPTION("MRF24J40 SPI 802.15.4 Controller Driver");
gpl-2.0
kinghaitao/git-core
drivers/clocksource/sh_mtu2.c
440
8381
/* * SuperH Timer Support - MTU2 * * Copyright (C) 2009 Magnus Damm * * 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/init.h> #include <linux/platform_device.h> #include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/delay.h> #include <linux/io.h> #include <linux/clk.h> #include <linux/irq.h> #include <linux/err.h> #include <linux/clockchips.h> #include <linux/sh_timer.h> struct sh_mtu2_priv { void __iomem *mapbase; struct clk *clk; struct irqaction irqaction; struct platform_device *pdev; unsigned long rate; unsigned long periodic; struct clock_event_device ced; }; static DEFINE_SPINLOCK(sh_mtu2_lock); #define TSTR -1 /* shared register */ #define TCR 0 /* channel register */ #define TMDR 1 /* channel register */ #define TIOR 2 /* channel register */ #define TIER 3 /* channel register */ #define TSR 4 /* channel register */ #define TCNT 5 /* channel register */ #define TGR 6 /* channel register */ static unsigned long mtu2_reg_offs[] = { [TCR] = 0, [TMDR] = 1, [TIOR] = 2, [TIER] = 4, [TSR] = 5, [TCNT] = 6, [TGR] = 8, }; static inline unsigned long sh_mtu2_read(struct sh_mtu2_priv *p, int reg_nr) { struct sh_timer_config *cfg = p->pdev->dev.platform_data; void __iomem *base = p->mapbase; unsigned long offs; if (reg_nr == TSTR) return ioread8(base + cfg->channel_offset); offs = mtu2_reg_offs[reg_nr]; if ((reg_nr == TCNT) || (reg_nr == TGR)) return ioread16(base + offs); else return ioread8(base + offs); } static inline void sh_mtu2_write(struct sh_mtu2_priv *p, int reg_nr, unsigned long value) { struct sh_timer_config *cfg = p->pdev->dev.platform_data; void __iomem *base = p->mapbase; unsigned long offs; if (reg_nr == TSTR) { iowrite8(value, base + cfg->channel_offset); return; } offs = mtu2_reg_offs[reg_nr]; if ((reg_nr == TCNT) || (reg_nr == TGR)) iowrite16(value, base + offs); else iowrite8(value, base + offs); } static void sh_mtu2_start_stop_ch(struct sh_mtu2_priv *p, int start) { struct sh_timer_config *cfg = p->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ spin_lock_irqsave(&sh_mtu2_lock, flags); value = sh_mtu2_read(p, TSTR); if (start) value |= 1 << cfg->timer_bit; else value &= ~(1 << cfg->timer_bit); sh_mtu2_write(p, TSTR, value); spin_unlock_irqrestore(&sh_mtu2_lock, flags); } static int sh_mtu2_enable(struct sh_mtu2_priv *p) { struct sh_timer_config *cfg = p->pdev->dev.platform_data; int ret; /* enable clock */ ret = clk_enable(p->clk); if (ret) { pr_err("sh_mtu2: cannot enable clock \"%s\"\n", cfg->clk); return ret; } /* make sure channel is disabled */ sh_mtu2_start_stop_ch(p, 0); p->rate = clk_get_rate(p->clk) / 64; p->periodic = (p->rate + HZ/2) / HZ; /* "Periodic Counter Operation" */ sh_mtu2_write(p, TCR, 0x23); /* TGRA clear, divide clock by 64 */ sh_mtu2_write(p, TIOR, 0); sh_mtu2_write(p, TGR, p->periodic); sh_mtu2_write(p, TCNT, 0); sh_mtu2_write(p, TMDR, 0); sh_mtu2_write(p, TIER, 0x01); /* enable channel */ sh_mtu2_start_stop_ch(p, 1); return 0; } static void sh_mtu2_disable(struct sh_mtu2_priv *p) { /* disable channel */ sh_mtu2_start_stop_ch(p, 0); /* stop clock */ clk_disable(p->clk); } static irqreturn_t sh_mtu2_interrupt(int irq, void *dev_id) { struct sh_mtu2_priv *p = dev_id; /* acknowledge interrupt */ sh_mtu2_read(p, TSR); sh_mtu2_write(p, TSR, 0xfe); /* notify clockevent layer */ p->ced.event_handler(&p->ced); return IRQ_HANDLED; } static struct sh_mtu2_priv *ced_to_sh_mtu2(struct clock_event_device *ced) { return container_of(ced, struct sh_mtu2_priv, ced); } static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, struct clock_event_device *ced) { struct sh_mtu2_priv *p = ced_to_sh_mtu2(ced); int disabled = 0; /* deal with old setting first */ switch (ced->mode) { case CLOCK_EVT_MODE_PERIODIC: sh_mtu2_disable(p); disabled = 1; break; default: break; } switch (mode) { case CLOCK_EVT_MODE_PERIODIC: pr_info("sh_mtu2: %s used for periodic clock events\n", ced->name); sh_mtu2_enable(p); break; case CLOCK_EVT_MODE_UNUSED: if (!disabled) sh_mtu2_disable(p); break; case CLOCK_EVT_MODE_SHUTDOWN: default: break; } } static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p, char *name, unsigned long rating) { struct clock_event_device *ced = &p->ced; int ret; memset(ced, 0, sizeof(*ced)); ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->rating = rating; ced->cpumask = cpumask_of(0); ced->set_mode = sh_mtu2_clock_event_mode; ret = setup_irq(p->irqaction.irq, &p->irqaction); if (ret) { pr_err("sh_mtu2: failed to request irq %d\n", p->irqaction.irq); return; } pr_info("sh_mtu2: %s used for clock events\n", ced->name); clockevents_register_device(ced); } static int sh_mtu2_register(struct sh_mtu2_priv *p, char *name, unsigned long clockevent_rating) { if (clockevent_rating) sh_mtu2_register_clockevent(p, name, clockevent_rating); return 0; } static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; int irq, ret; ret = -ENXIO; memset(p, 0, sizeof(*p)); p->pdev = pdev; if (!cfg) { dev_err(&p->pdev->dev, "missing platform data\n"); goto err0; } platform_set_drvdata(pdev, p); res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&p->pdev->dev, "failed to get I/O memory\n"); goto err0; } irq = platform_get_irq(p->pdev, 0); if (irq < 0) { dev_err(&p->pdev->dev, "failed to get irq\n"); goto err0; } /* map memory, let mapbase point to our channel */ p->mapbase = ioremap_nocache(res->start, resource_size(res)); if (p->mapbase == NULL) { pr_err("sh_mtu2: failed to remap I/O memory\n"); goto err0; } /* setup data for setup_irq() (too early for request_irq()) */ p->irqaction.name = cfg->name; p->irqaction.handler = sh_mtu2_interrupt; p->irqaction.dev_id = p; p->irqaction.irq = irq; p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL; /* get hold of clock */ p->clk = clk_get(&p->pdev->dev, cfg->clk); if (IS_ERR(p->clk)) { pr_err("sh_mtu2: cannot get clock \"%s\"\n", cfg->clk); ret = PTR_ERR(p->clk); goto err1; } return sh_mtu2_register(p, cfg->name, cfg->clockevent_rating); err1: iounmap(p->mapbase); err0: return ret; } static int __devinit sh_mtu2_probe(struct platform_device *pdev) { struct sh_mtu2_priv *p = platform_get_drvdata(pdev); struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; if (p) { pr_info("sh_mtu2: %s kept as earlytimer\n", cfg->name); return 0; } p = kmalloc(sizeof(*p), GFP_KERNEL); if (p == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; } ret = sh_mtu2_setup(p, pdev); if (ret) { kfree(p); platform_set_drvdata(pdev, NULL); } return ret; } static int __devexit sh_mtu2_remove(struct platform_device *pdev) { return -EBUSY; /* cannot unregister clockevent */ } static struct platform_driver sh_mtu2_device_driver = { .probe = sh_mtu2_probe, .remove = __devexit_p(sh_mtu2_remove), .driver = { .name = "sh_mtu2", } }; static int __init sh_mtu2_init(void) { return platform_driver_register(&sh_mtu2_device_driver); } static void __exit sh_mtu2_exit(void) { platform_driver_unregister(&sh_mtu2_device_driver); } early_platform_init("earlytimer", &sh_mtu2_device_driver); module_init(sh_mtu2_init); module_exit(sh_mtu2_exit); MODULE_AUTHOR("Magnus Damm"); MODULE_DESCRIPTION("SuperH MTU2 Timer Driver"); MODULE_LICENSE("GPL v2");
gpl-2.0
stevezilla/dplive-linux
arch/arm/mach-s3c64xx/mach-smartq5.c
440
3623
/* * linux/arch/arm/mach-s3c64xx/mach-smartq5.c * * Copyright (C) 2010 Maurus Cuelenaere * * 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/fb.h> #include <linux/gpio.h> #include <linux/gpio_keys.h> #include <linux/init.h> #include <linux/input.h> #include <linux/leds.h> #include <linux/platform_device.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> #include <video/samsung_fimd.h> #include <mach/map.h> #include <mach/regs-gpio.h> #include <mach/gpio-samsung.h> #include <plat/cpu.h> #include <plat/devs.h> #include <plat/fb.h> #include <plat/gpio-cfg.h> #include <plat/samsung-time.h> #include "common.h" #include "mach-smartq.h" static struct gpio_led smartq5_leds[] = { { .name = "smartq5:green", .active_low = 1, .gpio = S3C64XX_GPN(8), }, { .name = "smartq5:red", .active_low = 1, .gpio = S3C64XX_GPN(9), }, }; static struct gpio_led_platform_data smartq5_led_data = { .num_leds = ARRAY_SIZE(smartq5_leds), .leds = smartq5_leds, }; static struct platform_device smartq5_leds_device = { .name = "leds-gpio", .id = -1, .dev.platform_data = &smartq5_led_data, }; /* Labels according to the SmartQ manual */ static struct gpio_keys_button smartq5_buttons[] = { { .gpio = S3C64XX_GPL(14), .code = KEY_POWER, .desc = "Power", .active_low = 1, .debounce_interval = 5, .type = EV_KEY, }, { .gpio = S3C64XX_GPN(2), .code = KEY_KPMINUS, .desc = "Minus", .active_low = 1, .debounce_interval = 5, .type = EV_KEY, }, { .gpio = S3C64XX_GPN(12), .code = KEY_KPPLUS, .desc = "Plus", .active_low = 1, .debounce_interval = 5, .type = EV_KEY, }, { .gpio = S3C64XX_GPN(15), .code = KEY_ENTER, .desc = "Move", .active_low = 1, .debounce_interval = 5, .type = EV_KEY, }, }; static struct gpio_keys_platform_data smartq5_buttons_data = { .buttons = smartq5_buttons, .nbuttons = ARRAY_SIZE(smartq5_buttons), }; static struct platform_device smartq5_buttons_device = { .name = "gpio-keys", .id = 0, .num_resources = 0, .dev = { .platform_data = &smartq5_buttons_data, } }; static struct s3c_fb_pd_win smartq5_fb_win0 = { .max_bpp = 32, .default_bpp = 16, .xres = 800, .yres = 480, }; static struct fb_videomode smartq5_lcd_timing = { .left_margin = 216, .right_margin = 40, .upper_margin = 35, .lower_margin = 10, .hsync_len = 1, .vsync_len = 1, .xres = 800, .yres = 480, .refresh = 80, }; static struct s3c_fb_platdata smartq5_lcd_pdata __initdata = { .setup_gpio = s3c64xx_fb_gpio_setup_24bpp, .vtiming = &smartq5_lcd_timing, .win[0] = &smartq5_fb_win0, .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB, .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC | VIDCON1_INV_VDEN, }; static struct platform_device *smartq5_devices[] __initdata = { &smartq5_leds_device, &smartq5_buttons_device, }; static void __init smartq5_machine_init(void) { s3c_fb_set_platdata(&smartq5_lcd_pdata); smartq_machine_init(); platform_add_devices(smartq5_devices, ARRAY_SIZE(smartq5_devices)); } MACHINE_START(SMARTQ5, "SmartQ 5") /* Maintainer: Maurus Cuelenaere <mcuelenaere AT gmail DOT com> */ .atag_offset = 0x100, .init_irq = s3c6410_init_irq, .map_io = smartq_map_io, .init_machine = smartq5_machine_init, .init_late = s3c64xx_init_late, .init_time = samsung_timer_init, .restart = s3c64xx_restart, MACHINE_END
gpl-2.0
I8552-CM/android_kernel_delos3geur
arch/x86/crypto/aesni-intel_glue.c
440
39617
/* * Support for Intel AES-NI instructions. This file contains glue * code, the real AES implementation is in intel-aes_asm.S. * * Copyright (C) 2008, Intel Corp. * Author: Huang Ying <ying.huang@intel.com> * * Added RFC4106 AES-GCM support for 128-bit keys under the AEAD * interface for 64-bit kernels. * Authors: Adrian Hoban <adrian.hoban@intel.com> * Gabriele Paoloni <gabriele.paoloni@intel.com> * Tadeusz Struk (tadeusz.struk@intel.com) * Aidan O'Mahony (aidan.o.mahony@intel.com) * Copyright (c) 2010, Intel 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. */ #include <linux/hardirq.h> #include <linux/types.h> #include <linux/crypto.h> #include <linux/module.h> #include <linux/err.h> #include <crypto/algapi.h> #include <crypto/aes.h> #include <crypto/cryptd.h> #include <crypto/ctr.h> #include <asm/cpu_device_id.h> #include <asm/i387.h> #include <asm/aes.h> #include <crypto/scatterwalk.h> #include <crypto/internal/aead.h> #include <linux/workqueue.h> #include <linux/spinlock.h> #if defined(CONFIG_CRYPTO_CTR) || defined(CONFIG_CRYPTO_CTR_MODULE) #define HAS_CTR #endif #if defined(CONFIG_CRYPTO_LRW) || defined(CONFIG_CRYPTO_LRW_MODULE) #define HAS_LRW #endif #if defined(CONFIG_CRYPTO_PCBC) || defined(CONFIG_CRYPTO_PCBC_MODULE) #define HAS_PCBC #endif #if defined(CONFIG_CRYPTO_XTS) || defined(CONFIG_CRYPTO_XTS_MODULE) #define HAS_XTS #endif struct async_aes_ctx { struct cryptd_ablkcipher *cryptd_tfm; }; /* This data is stored at the end of the crypto_tfm struct. * It's a type of per "session" data storage location. * This needs to be 16 byte aligned. */ struct aesni_rfc4106_gcm_ctx { u8 hash_subkey[16]; struct crypto_aes_ctx aes_key_expanded; u8 nonce[4]; struct cryptd_aead *cryptd_tfm; }; struct aesni_gcm_set_hash_subkey_result { int err; struct completion completion; }; struct aesni_hash_subkey_req_data { u8 iv[16]; struct aesni_gcm_set_hash_subkey_result result; struct scatterlist sg; }; #define AESNI_ALIGN (16) #define AES_BLOCK_MASK (~(AES_BLOCK_SIZE-1)) #define RFC4106_HASH_SUBKEY_SIZE 16 asmlinkage int aesni_set_key(struct crypto_aes_ctx *ctx, const u8 *in_key, unsigned int key_len); asmlinkage void aesni_enc(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in); asmlinkage void aesni_dec(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in); asmlinkage void aesni_ecb_enc(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in, unsigned int len); asmlinkage void aesni_ecb_dec(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in, unsigned int len); asmlinkage void aesni_cbc_enc(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in, unsigned int len, u8 *iv); asmlinkage void aesni_cbc_dec(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in, unsigned int len, u8 *iv); int crypto_fpu_init(void); void crypto_fpu_exit(void); #ifdef CONFIG_X86_64 asmlinkage void aesni_ctr_enc(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in, unsigned int len, u8 *iv); /* asmlinkage void aesni_gcm_enc() * void *ctx, AES Key schedule. Starts on a 16 byte boundary. * u8 *out, Ciphertext output. Encrypt in-place is allowed. * const u8 *in, Plaintext input * unsigned long plaintext_len, Length of data in bytes for encryption. * u8 *iv, Pre-counter block j0: 4 byte salt (from Security Association) * concatenated with 8 byte Initialisation Vector (from IPSec ESP * Payload) concatenated with 0x00000001. 16-byte aligned pointer. * u8 *hash_subkey, the Hash sub key input. Data starts on a 16-byte boundary. * const u8 *aad, Additional Authentication Data (AAD) * unsigned long aad_len, Length of AAD in bytes. With RFC4106 this * is going to be 8 or 12 bytes * u8 *auth_tag, Authenticated Tag output. * unsigned long auth_tag_len), Authenticated Tag Length in bytes. * Valid values are 16 (most likely), 12 or 8. */ asmlinkage void aesni_gcm_enc(void *ctx, u8 *out, const u8 *in, unsigned long plaintext_len, u8 *iv, u8 *hash_subkey, const u8 *aad, unsigned long aad_len, u8 *auth_tag, unsigned long auth_tag_len); /* asmlinkage void aesni_gcm_dec() * void *ctx, AES Key schedule. Starts on a 16 byte boundary. * u8 *out, Plaintext output. Decrypt in-place is allowed. * const u8 *in, Ciphertext input * unsigned long ciphertext_len, Length of data in bytes for decryption. * u8 *iv, Pre-counter block j0: 4 byte salt (from Security Association) * concatenated with 8 byte Initialisation Vector (from IPSec ESP * Payload) concatenated with 0x00000001. 16-byte aligned pointer. * u8 *hash_subkey, the Hash sub key input. Data starts on a 16-byte boundary. * const u8 *aad, Additional Authentication Data (AAD) * unsigned long aad_len, Length of AAD in bytes. With RFC4106 this is going * to be 8 or 12 bytes * u8 *auth_tag, Authenticated Tag output. * unsigned long auth_tag_len) Authenticated Tag Length in bytes. * Valid values are 16 (most likely), 12 or 8. */ asmlinkage void aesni_gcm_dec(void *ctx, u8 *out, const u8 *in, unsigned long ciphertext_len, u8 *iv, u8 *hash_subkey, const u8 *aad, unsigned long aad_len, u8 *auth_tag, unsigned long auth_tag_len); static inline struct aesni_rfc4106_gcm_ctx *aesni_rfc4106_gcm_ctx_get(struct crypto_aead *tfm) { return (struct aesni_rfc4106_gcm_ctx *) PTR_ALIGN((u8 *) crypto_tfm_ctx(crypto_aead_tfm(tfm)), AESNI_ALIGN); } #endif static inline struct crypto_aes_ctx *aes_ctx(void *raw_ctx) { unsigned long addr = (unsigned long)raw_ctx; unsigned long align = AESNI_ALIGN; if (align <= crypto_tfm_ctx_alignment()) align = 1; return (struct crypto_aes_ctx *)ALIGN(addr, align); } static int aes_set_key_common(struct crypto_tfm *tfm, void *raw_ctx, const u8 *in_key, unsigned int key_len) { struct crypto_aes_ctx *ctx = aes_ctx(raw_ctx); u32 *flags = &tfm->crt_flags; int err; if (key_len != AES_KEYSIZE_128 && key_len != AES_KEYSIZE_192 && key_len != AES_KEYSIZE_256) { *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; return -EINVAL; } if (!irq_fpu_usable()) err = crypto_aes_expand_key(ctx, in_key, key_len); else { kernel_fpu_begin(); err = aesni_set_key(ctx, in_key, key_len); kernel_fpu_end(); } return err; } static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len) { return aes_set_key_common(tfm, crypto_tfm_ctx(tfm), in_key, key_len); } static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) { struct crypto_aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(tfm)); if (!irq_fpu_usable()) crypto_aes_encrypt_x86(ctx, dst, src); else { kernel_fpu_begin(); aesni_enc(ctx, dst, src); kernel_fpu_end(); } } static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) { struct crypto_aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(tfm)); if (!irq_fpu_usable()) crypto_aes_decrypt_x86(ctx, dst, src); else { kernel_fpu_begin(); aesni_dec(ctx, dst, src); kernel_fpu_end(); } } static struct crypto_alg aesni_alg = { .cra_name = "aes", .cra_driver_name = "aes-aesni", .cra_priority = 300, .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct crypto_aes_ctx)+AESNI_ALIGN-1, .cra_alignmask = 0, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(aesni_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = AES_MIN_KEY_SIZE, .cia_max_keysize = AES_MAX_KEY_SIZE, .cia_setkey = aes_set_key, .cia_encrypt = aes_encrypt, .cia_decrypt = aes_decrypt } } }; static void __aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) { struct crypto_aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(tfm)); aesni_enc(ctx, dst, src); } static void __aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) { struct crypto_aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(tfm)); aesni_dec(ctx, dst, src); } static struct crypto_alg __aesni_alg = { .cra_name = "__aes-aesni", .cra_driver_name = "__driver-aes-aesni", .cra_priority = 0, .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct crypto_aes_ctx)+AESNI_ALIGN-1, .cra_alignmask = 0, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(__aesni_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = AES_MIN_KEY_SIZE, .cia_max_keysize = AES_MAX_KEY_SIZE, .cia_setkey = aes_set_key, .cia_encrypt = __aes_encrypt, .cia_decrypt = __aes_decrypt } } }; static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) { struct crypto_aes_ctx *ctx = aes_ctx(crypto_blkcipher_ctx(desc->tfm)); struct blkcipher_walk walk; int err; blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt(desc, &walk); desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; kernel_fpu_begin(); while ((nbytes = walk.nbytes)) { aesni_ecb_enc(ctx, walk.dst.virt.addr, walk.src.virt.addr, nbytes & AES_BLOCK_MASK); nbytes &= AES_BLOCK_SIZE - 1; err = blkcipher_walk_done(desc, &walk, nbytes); } kernel_fpu_end(); return err; } static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) { struct crypto_aes_ctx *ctx = aes_ctx(crypto_blkcipher_ctx(desc->tfm)); struct blkcipher_walk walk; int err; blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt(desc, &walk); desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; kernel_fpu_begin(); while ((nbytes = walk.nbytes)) { aesni_ecb_dec(ctx, walk.dst.virt.addr, walk.src.virt.addr, nbytes & AES_BLOCK_MASK); nbytes &= AES_BLOCK_SIZE - 1; err = blkcipher_walk_done(desc, &walk, nbytes); } kernel_fpu_end(); return err; } static struct crypto_alg blk_ecb_alg = { .cra_name = "__ecb-aes-aesni", .cra_driver_name = "__driver-ecb-aes-aesni", .cra_priority = 0, .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct crypto_aes_ctx)+AESNI_ALIGN-1, .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(blk_ecb_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .setkey = aes_set_key, .encrypt = ecb_encrypt, .decrypt = ecb_decrypt, }, }, }; static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) { struct crypto_aes_ctx *ctx = aes_ctx(crypto_blkcipher_ctx(desc->tfm)); struct blkcipher_walk walk; int err; blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt(desc, &walk); desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; kernel_fpu_begin(); while ((nbytes = walk.nbytes)) { aesni_cbc_enc(ctx, walk.dst.virt.addr, walk.src.virt.addr, nbytes & AES_BLOCK_MASK, walk.iv); nbytes &= AES_BLOCK_SIZE - 1; err = blkcipher_walk_done(desc, &walk, nbytes); } kernel_fpu_end(); return err; } static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) { struct crypto_aes_ctx *ctx = aes_ctx(crypto_blkcipher_ctx(desc->tfm)); struct blkcipher_walk walk; int err; blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt(desc, &walk); desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; kernel_fpu_begin(); while ((nbytes = walk.nbytes)) { aesni_cbc_dec(ctx, walk.dst.virt.addr, walk.src.virt.addr, nbytes & AES_BLOCK_MASK, walk.iv); nbytes &= AES_BLOCK_SIZE - 1; err = blkcipher_walk_done(desc, &walk, nbytes); } kernel_fpu_end(); return err; } static struct crypto_alg blk_cbc_alg = { .cra_name = "__cbc-aes-aesni", .cra_driver_name = "__driver-cbc-aes-aesni", .cra_priority = 0, .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct crypto_aes_ctx)+AESNI_ALIGN-1, .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(blk_cbc_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .setkey = aes_set_key, .encrypt = cbc_encrypt, .decrypt = cbc_decrypt, }, }, }; #ifdef CONFIG_X86_64 static void ctr_crypt_final(struct crypto_aes_ctx *ctx, struct blkcipher_walk *walk) { u8 *ctrblk = walk->iv; u8 keystream[AES_BLOCK_SIZE]; u8 *src = walk->src.virt.addr; u8 *dst = walk->dst.virt.addr; unsigned int nbytes = walk->nbytes; aesni_enc(ctx, keystream, ctrblk); crypto_xor(keystream, src, nbytes); memcpy(dst, keystream, nbytes); crypto_inc(ctrblk, AES_BLOCK_SIZE); } static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) { struct crypto_aes_ctx *ctx = aes_ctx(crypto_blkcipher_ctx(desc->tfm)); struct blkcipher_walk walk; int err; blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt_block(desc, &walk, AES_BLOCK_SIZE); desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; kernel_fpu_begin(); while ((nbytes = walk.nbytes) >= AES_BLOCK_SIZE) { aesni_ctr_enc(ctx, walk.dst.virt.addr, walk.src.virt.addr, nbytes & AES_BLOCK_MASK, walk.iv); nbytes &= AES_BLOCK_SIZE - 1; err = blkcipher_walk_done(desc, &walk, nbytes); } if (walk.nbytes) { ctr_crypt_final(ctx, &walk); err = blkcipher_walk_done(desc, &walk, 0); } kernel_fpu_end(); return err; } static struct crypto_alg blk_ctr_alg = { .cra_name = "__ctr-aes-aesni", .cra_driver_name = "__driver-ctr-aes-aesni", .cra_priority = 0, .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, .cra_blocksize = 1, .cra_ctxsize = sizeof(struct crypto_aes_ctx)+AESNI_ALIGN-1, .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(blk_ctr_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, .setkey = aes_set_key, .encrypt = ctr_crypt, .decrypt = ctr_crypt, }, }, }; #endif static int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key, unsigned int key_len) { struct async_aes_ctx *ctx = crypto_ablkcipher_ctx(tfm); struct crypto_ablkcipher *child = &ctx->cryptd_tfm->base; int err; crypto_ablkcipher_clear_flags(child, CRYPTO_TFM_REQ_MASK); crypto_ablkcipher_set_flags(child, crypto_ablkcipher_get_flags(tfm) & CRYPTO_TFM_REQ_MASK); err = crypto_ablkcipher_setkey(child, key, key_len); crypto_ablkcipher_set_flags(tfm, crypto_ablkcipher_get_flags(child) & CRYPTO_TFM_RES_MASK); return err; } static int ablk_encrypt(struct ablkcipher_request *req) { struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); struct async_aes_ctx *ctx = crypto_ablkcipher_ctx(tfm); if (!irq_fpu_usable()) { struct ablkcipher_request *cryptd_req = ablkcipher_request_ctx(req); memcpy(cryptd_req, req, sizeof(*req)); ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base); return crypto_ablkcipher_encrypt(cryptd_req); } else { struct blkcipher_desc desc; desc.tfm = cryptd_ablkcipher_child(ctx->cryptd_tfm); desc.info = req->info; desc.flags = 0; return crypto_blkcipher_crt(desc.tfm)->encrypt( &desc, req->dst, req->src, req->nbytes); } } static int ablk_decrypt(struct ablkcipher_request *req) { struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); struct async_aes_ctx *ctx = crypto_ablkcipher_ctx(tfm); if (!irq_fpu_usable()) { struct ablkcipher_request *cryptd_req = ablkcipher_request_ctx(req); memcpy(cryptd_req, req, sizeof(*req)); ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base); return crypto_ablkcipher_decrypt(cryptd_req); } else { struct blkcipher_desc desc; desc.tfm = cryptd_ablkcipher_child(ctx->cryptd_tfm); desc.info = req->info; desc.flags = 0; return crypto_blkcipher_crt(desc.tfm)->decrypt( &desc, req->dst, req->src, req->nbytes); } } static void ablk_exit(struct crypto_tfm *tfm) { struct async_aes_ctx *ctx = crypto_tfm_ctx(tfm); cryptd_free_ablkcipher(ctx->cryptd_tfm); } static void ablk_init_common(struct crypto_tfm *tfm, struct cryptd_ablkcipher *cryptd_tfm) { struct async_aes_ctx *ctx = crypto_tfm_ctx(tfm); ctx->cryptd_tfm = cryptd_tfm; tfm->crt_ablkcipher.reqsize = sizeof(struct ablkcipher_request) + crypto_ablkcipher_reqsize(&cryptd_tfm->base); } static int ablk_ecb_init(struct crypto_tfm *tfm) { struct cryptd_ablkcipher *cryptd_tfm; cryptd_tfm = cryptd_alloc_ablkcipher("__driver-ecb-aes-aesni", 0, 0); if (IS_ERR(cryptd_tfm)) return PTR_ERR(cryptd_tfm); ablk_init_common(tfm, cryptd_tfm); return 0; } static struct crypto_alg ablk_ecb_alg = { .cra_name = "ecb(aes)", .cra_driver_name = "ecb-aes-aesni", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER|CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct async_aes_ctx), .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(ablk_ecb_alg.cra_list), .cra_init = ablk_ecb_init, .cra_exit = ablk_exit, .cra_u = { .ablkcipher = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .setkey = ablk_set_key, .encrypt = ablk_encrypt, .decrypt = ablk_decrypt, }, }, }; static int ablk_cbc_init(struct crypto_tfm *tfm) { struct cryptd_ablkcipher *cryptd_tfm; cryptd_tfm = cryptd_alloc_ablkcipher("__driver-cbc-aes-aesni", 0, 0); if (IS_ERR(cryptd_tfm)) return PTR_ERR(cryptd_tfm); ablk_init_common(tfm, cryptd_tfm); return 0; } static struct crypto_alg ablk_cbc_alg = { .cra_name = "cbc(aes)", .cra_driver_name = "cbc-aes-aesni", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER|CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct async_aes_ctx), .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(ablk_cbc_alg.cra_list), .cra_init = ablk_cbc_init, .cra_exit = ablk_exit, .cra_u = { .ablkcipher = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, .setkey = ablk_set_key, .encrypt = ablk_encrypt, .decrypt = ablk_decrypt, }, }, }; #ifdef CONFIG_X86_64 static int ablk_ctr_init(struct crypto_tfm *tfm) { struct cryptd_ablkcipher *cryptd_tfm; cryptd_tfm = cryptd_alloc_ablkcipher("__driver-ctr-aes-aesni", 0, 0); if (IS_ERR(cryptd_tfm)) return PTR_ERR(cryptd_tfm); ablk_init_common(tfm, cryptd_tfm); return 0; } static struct crypto_alg ablk_ctr_alg = { .cra_name = "ctr(aes)", .cra_driver_name = "ctr-aes-aesni", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER|CRYPTO_ALG_ASYNC, .cra_blocksize = 1, .cra_ctxsize = sizeof(struct async_aes_ctx), .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(ablk_ctr_alg.cra_list), .cra_init = ablk_ctr_init, .cra_exit = ablk_exit, .cra_u = { .ablkcipher = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, .setkey = ablk_set_key, .encrypt = ablk_encrypt, .decrypt = ablk_encrypt, .geniv = "chainiv", }, }, }; #ifdef HAS_CTR static int ablk_rfc3686_ctr_init(struct crypto_tfm *tfm) { struct cryptd_ablkcipher *cryptd_tfm; cryptd_tfm = cryptd_alloc_ablkcipher( "rfc3686(__driver-ctr-aes-aesni)", 0, 0); if (IS_ERR(cryptd_tfm)) return PTR_ERR(cryptd_tfm); ablk_init_common(tfm, cryptd_tfm); return 0; } static struct crypto_alg ablk_rfc3686_ctr_alg = { .cra_name = "rfc3686(ctr(aes))", .cra_driver_name = "rfc3686-ctr-aes-aesni", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER|CRYPTO_ALG_ASYNC, .cra_blocksize = 1, .cra_ctxsize = sizeof(struct async_aes_ctx), .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(ablk_rfc3686_ctr_alg.cra_list), .cra_init = ablk_rfc3686_ctr_init, .cra_exit = ablk_exit, .cra_u = { .ablkcipher = { .min_keysize = AES_MIN_KEY_SIZE+CTR_RFC3686_NONCE_SIZE, .max_keysize = AES_MAX_KEY_SIZE+CTR_RFC3686_NONCE_SIZE, .ivsize = CTR_RFC3686_IV_SIZE, .setkey = ablk_set_key, .encrypt = ablk_encrypt, .decrypt = ablk_decrypt, .geniv = "seqiv", }, }, }; #endif #endif #ifdef HAS_LRW static int ablk_lrw_init(struct crypto_tfm *tfm) { struct cryptd_ablkcipher *cryptd_tfm; cryptd_tfm = cryptd_alloc_ablkcipher("fpu(lrw(__driver-aes-aesni))", 0, 0); if (IS_ERR(cryptd_tfm)) return PTR_ERR(cryptd_tfm); ablk_init_common(tfm, cryptd_tfm); return 0; } static struct crypto_alg ablk_lrw_alg = { .cra_name = "lrw(aes)", .cra_driver_name = "lrw-aes-aesni", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER|CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct async_aes_ctx), .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(ablk_lrw_alg.cra_list), .cra_init = ablk_lrw_init, .cra_exit = ablk_exit, .cra_u = { .ablkcipher = { .min_keysize = AES_MIN_KEY_SIZE + AES_BLOCK_SIZE, .max_keysize = AES_MAX_KEY_SIZE + AES_BLOCK_SIZE, .ivsize = AES_BLOCK_SIZE, .setkey = ablk_set_key, .encrypt = ablk_encrypt, .decrypt = ablk_decrypt, }, }, }; #endif #ifdef HAS_PCBC static int ablk_pcbc_init(struct crypto_tfm *tfm) { struct cryptd_ablkcipher *cryptd_tfm; cryptd_tfm = cryptd_alloc_ablkcipher("fpu(pcbc(__driver-aes-aesni))", 0, 0); if (IS_ERR(cryptd_tfm)) return PTR_ERR(cryptd_tfm); ablk_init_common(tfm, cryptd_tfm); return 0; } static struct crypto_alg ablk_pcbc_alg = { .cra_name = "pcbc(aes)", .cra_driver_name = "pcbc-aes-aesni", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER|CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct async_aes_ctx), .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(ablk_pcbc_alg.cra_list), .cra_init = ablk_pcbc_init, .cra_exit = ablk_exit, .cra_u = { .ablkcipher = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, .setkey = ablk_set_key, .encrypt = ablk_encrypt, .decrypt = ablk_decrypt, }, }, }; #endif #ifdef HAS_XTS static int ablk_xts_init(struct crypto_tfm *tfm) { struct cryptd_ablkcipher *cryptd_tfm; cryptd_tfm = cryptd_alloc_ablkcipher("fpu(xts(__driver-aes-aesni))", 0, 0); if (IS_ERR(cryptd_tfm)) return PTR_ERR(cryptd_tfm); ablk_init_common(tfm, cryptd_tfm); return 0; } static struct crypto_alg ablk_xts_alg = { .cra_name = "xts(aes)", .cra_driver_name = "xts-aes-aesni", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER|CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct async_aes_ctx), .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(ablk_xts_alg.cra_list), .cra_init = ablk_xts_init, .cra_exit = ablk_exit, .cra_u = { .ablkcipher = { .min_keysize = 2 * AES_MIN_KEY_SIZE, .max_keysize = 2 * AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, .setkey = ablk_set_key, .encrypt = ablk_encrypt, .decrypt = ablk_decrypt, }, }, }; #endif #ifdef CONFIG_X86_64 static int rfc4106_init(struct crypto_tfm *tfm) { struct cryptd_aead *cryptd_tfm; struct aesni_rfc4106_gcm_ctx *ctx = (struct aesni_rfc4106_gcm_ctx *) PTR_ALIGN((u8 *)crypto_tfm_ctx(tfm), AESNI_ALIGN); struct crypto_aead *cryptd_child; struct aesni_rfc4106_gcm_ctx *child_ctx; cryptd_tfm = cryptd_alloc_aead("__driver-gcm-aes-aesni", 0, 0); if (IS_ERR(cryptd_tfm)) return PTR_ERR(cryptd_tfm); cryptd_child = cryptd_aead_child(cryptd_tfm); child_ctx = aesni_rfc4106_gcm_ctx_get(cryptd_child); memcpy(child_ctx, ctx, sizeof(*ctx)); ctx->cryptd_tfm = cryptd_tfm; tfm->crt_aead.reqsize = sizeof(struct aead_request) + crypto_aead_reqsize(&cryptd_tfm->base); return 0; } static void rfc4106_exit(struct crypto_tfm *tfm) { struct aesni_rfc4106_gcm_ctx *ctx = (struct aesni_rfc4106_gcm_ctx *) PTR_ALIGN((u8 *)crypto_tfm_ctx(tfm), AESNI_ALIGN); if (!IS_ERR(ctx->cryptd_tfm)) cryptd_free_aead(ctx->cryptd_tfm); return; } static void rfc4106_set_hash_subkey_done(struct crypto_async_request *req, int err) { struct aesni_gcm_set_hash_subkey_result *result = req->data; if (err == -EINPROGRESS) return; result->err = err; complete(&result->completion); } static int rfc4106_set_hash_subkey(u8 *hash_subkey, const u8 *key, unsigned int key_len) { struct crypto_ablkcipher *ctr_tfm; struct ablkcipher_request *req; int ret = -EINVAL; struct aesni_hash_subkey_req_data *req_data; ctr_tfm = crypto_alloc_ablkcipher("ctr(aes)", 0, 0); if (IS_ERR(ctr_tfm)) return PTR_ERR(ctr_tfm); crypto_ablkcipher_clear_flags(ctr_tfm, ~0); ret = crypto_ablkcipher_setkey(ctr_tfm, key, key_len); if (ret) goto out_free_ablkcipher; ret = -ENOMEM; req = ablkcipher_request_alloc(ctr_tfm, GFP_KERNEL); if (!req) goto out_free_ablkcipher; req_data = kmalloc(sizeof(*req_data), GFP_KERNEL); if (!req_data) goto out_free_request; memset(req_data->iv, 0, sizeof(req_data->iv)); /* Clear the data in the hash sub key container to zero.*/ /* We want to cipher all zeros to create the hash sub key. */ memset(hash_subkey, 0, RFC4106_HASH_SUBKEY_SIZE); init_completion(&req_data->result.completion); sg_init_one(&req_data->sg, hash_subkey, RFC4106_HASH_SUBKEY_SIZE); ablkcipher_request_set_tfm(req, ctr_tfm); ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP | CRYPTO_TFM_REQ_MAY_BACKLOG, rfc4106_set_hash_subkey_done, &req_data->result); ablkcipher_request_set_crypt(req, &req_data->sg, &req_data->sg, RFC4106_HASH_SUBKEY_SIZE, req_data->iv); ret = crypto_ablkcipher_encrypt(req); if (ret == -EINPROGRESS || ret == -EBUSY) { ret = wait_for_completion_interruptible (&req_data->result.completion); if (!ret) ret = req_data->result.err; } kfree(req_data); out_free_request: ablkcipher_request_free(req); out_free_ablkcipher: crypto_free_ablkcipher(ctr_tfm); return ret; } static int rfc4106_set_key(struct crypto_aead *parent, const u8 *key, unsigned int key_len) { int ret = 0; struct crypto_tfm *tfm = crypto_aead_tfm(parent); struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(parent); struct crypto_aead *cryptd_child = cryptd_aead_child(ctx->cryptd_tfm); struct aesni_rfc4106_gcm_ctx *child_ctx = aesni_rfc4106_gcm_ctx_get(cryptd_child); u8 *new_key_mem = NULL; if (key_len < 4) { crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); return -EINVAL; } /*Account for 4 byte nonce at the end.*/ key_len -= 4; if (key_len != AES_KEYSIZE_128) { crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); return -EINVAL; } memcpy(ctx->nonce, key + key_len, sizeof(ctx->nonce)); /*This must be on a 16 byte boundary!*/ if ((unsigned long)(&(ctx->aes_key_expanded.key_enc[0])) % AESNI_ALIGN) return -EINVAL; if ((unsigned long)key % AESNI_ALIGN) { /*key is not aligned: use an auxuliar aligned pointer*/ new_key_mem = kmalloc(key_len+AESNI_ALIGN, GFP_KERNEL); if (!new_key_mem) return -ENOMEM; new_key_mem = PTR_ALIGN(new_key_mem, AESNI_ALIGN); memcpy(new_key_mem, key, key_len); key = new_key_mem; } if (!irq_fpu_usable()) ret = crypto_aes_expand_key(&(ctx->aes_key_expanded), key, key_len); else { kernel_fpu_begin(); ret = aesni_set_key(&(ctx->aes_key_expanded), key, key_len); kernel_fpu_end(); } /*This must be on a 16 byte boundary!*/ if ((unsigned long)(&(ctx->hash_subkey[0])) % AESNI_ALIGN) { ret = -EINVAL; goto exit; } ret = rfc4106_set_hash_subkey(ctx->hash_subkey, key, key_len); memcpy(child_ctx, ctx, sizeof(*ctx)); exit: kfree(new_key_mem); return ret; } /* This is the Integrity Check Value (aka the authentication tag length and can * be 8, 12 or 16 bytes long. */ static int rfc4106_set_authsize(struct crypto_aead *parent, unsigned int authsize) { struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(parent); struct crypto_aead *cryptd_child = cryptd_aead_child(ctx->cryptd_tfm); switch (authsize) { case 8: case 12: case 16: break; default: return -EINVAL; } crypto_aead_crt(parent)->authsize = authsize; crypto_aead_crt(cryptd_child)->authsize = authsize; return 0; } static int rfc4106_encrypt(struct aead_request *req) { int ret; struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(tfm); if (!irq_fpu_usable()) { struct aead_request *cryptd_req = (struct aead_request *) aead_request_ctx(req); memcpy(cryptd_req, req, sizeof(*req)); aead_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base); return crypto_aead_encrypt(cryptd_req); } else { struct crypto_aead *cryptd_child = cryptd_aead_child(ctx->cryptd_tfm); kernel_fpu_begin(); ret = cryptd_child->base.crt_aead.encrypt(req); kernel_fpu_end(); return ret; } } static int rfc4106_decrypt(struct aead_request *req) { int ret; struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(tfm); if (!irq_fpu_usable()) { struct aead_request *cryptd_req = (struct aead_request *) aead_request_ctx(req); memcpy(cryptd_req, req, sizeof(*req)); aead_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base); return crypto_aead_decrypt(cryptd_req); } else { struct crypto_aead *cryptd_child = cryptd_aead_child(ctx->cryptd_tfm); kernel_fpu_begin(); ret = cryptd_child->base.crt_aead.decrypt(req); kernel_fpu_end(); return ret; } } static struct crypto_alg rfc4106_alg = { .cra_name = "rfc4106(gcm(aes))", .cra_driver_name = "rfc4106-gcm-aesni", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, .cra_blocksize = 1, .cra_ctxsize = sizeof(struct aesni_rfc4106_gcm_ctx) + AESNI_ALIGN, .cra_alignmask = 0, .cra_type = &crypto_nivaead_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(rfc4106_alg.cra_list), .cra_init = rfc4106_init, .cra_exit = rfc4106_exit, .cra_u = { .aead = { .setkey = rfc4106_set_key, .setauthsize = rfc4106_set_authsize, .encrypt = rfc4106_encrypt, .decrypt = rfc4106_decrypt, .geniv = "seqiv", .ivsize = 8, .maxauthsize = 16, }, }, }; static int __driver_rfc4106_encrypt(struct aead_request *req) { u8 one_entry_in_sg = 0; u8 *src, *dst, *assoc; __be32 counter = cpu_to_be32(1); struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(tfm); void *aes_ctx = &(ctx->aes_key_expanded); unsigned long auth_tag_len = crypto_aead_authsize(tfm); u8 iv_tab[16+AESNI_ALIGN]; u8* iv = (u8 *) PTR_ALIGN((u8 *)iv_tab, AESNI_ALIGN); struct scatter_walk src_sg_walk; struct scatter_walk assoc_sg_walk; struct scatter_walk dst_sg_walk; unsigned int i; /* Assuming we are supporting rfc4106 64-bit extended */ /* sequence numbers We need to have the AAD length equal */ /* to 8 or 12 bytes */ if (unlikely(req->assoclen != 8 && req->assoclen != 12)) return -EINVAL; /* IV below built */ for (i = 0; i < 4; i++) *(iv+i) = ctx->nonce[i]; for (i = 0; i < 8; i++) *(iv+4+i) = req->iv[i]; *((__be32 *)(iv+12)) = counter; if ((sg_is_last(req->src)) && (sg_is_last(req->assoc))) { one_entry_in_sg = 1; scatterwalk_start(&src_sg_walk, req->src); scatterwalk_start(&assoc_sg_walk, req->assoc); src = scatterwalk_map(&src_sg_walk); assoc = scatterwalk_map(&assoc_sg_walk); dst = src; if (unlikely(req->src != req->dst)) { scatterwalk_start(&dst_sg_walk, req->dst); dst = scatterwalk_map(&dst_sg_walk); } } else { /* Allocate memory for src, dst, assoc */ src = kmalloc(req->cryptlen + auth_tag_len + req->assoclen, GFP_ATOMIC); if (unlikely(!src)) return -ENOMEM; assoc = (src + req->cryptlen + auth_tag_len); scatterwalk_map_and_copy(src, req->src, 0, req->cryptlen, 0); scatterwalk_map_and_copy(assoc, req->assoc, 0, req->assoclen, 0); dst = src; } aesni_gcm_enc(aes_ctx, dst, src, (unsigned long)req->cryptlen, iv, ctx->hash_subkey, assoc, (unsigned long)req->assoclen, dst + ((unsigned long)req->cryptlen), auth_tag_len); /* The authTag (aka the Integrity Check Value) needs to be written * back to the packet. */ if (one_entry_in_sg) { if (unlikely(req->src != req->dst)) { scatterwalk_unmap(dst); scatterwalk_done(&dst_sg_walk, 0, 0); } scatterwalk_unmap(src); scatterwalk_unmap(assoc); scatterwalk_done(&src_sg_walk, 0, 0); scatterwalk_done(&assoc_sg_walk, 0, 0); } else { scatterwalk_map_and_copy(dst, req->dst, 0, req->cryptlen + auth_tag_len, 1); kfree(src); } return 0; } static int __driver_rfc4106_decrypt(struct aead_request *req) { u8 one_entry_in_sg = 0; u8 *src, *dst, *assoc; unsigned long tempCipherLen = 0; __be32 counter = cpu_to_be32(1); int retval = 0; struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(tfm); void *aes_ctx = &(ctx->aes_key_expanded); unsigned long auth_tag_len = crypto_aead_authsize(tfm); u8 iv_and_authTag[32+AESNI_ALIGN]; u8 *iv = (u8 *) PTR_ALIGN((u8 *)iv_and_authTag, AESNI_ALIGN); u8 *authTag = iv + 16; struct scatter_walk src_sg_walk; struct scatter_walk assoc_sg_walk; struct scatter_walk dst_sg_walk; unsigned int i; if (unlikely((req->cryptlen < auth_tag_len) || (req->assoclen != 8 && req->assoclen != 12))) return -EINVAL; /* Assuming we are supporting rfc4106 64-bit extended */ /* sequence numbers We need to have the AAD length */ /* equal to 8 or 12 bytes */ tempCipherLen = (unsigned long)(req->cryptlen - auth_tag_len); /* IV below built */ for (i = 0; i < 4; i++) *(iv+i) = ctx->nonce[i]; for (i = 0; i < 8; i++) *(iv+4+i) = req->iv[i]; *((__be32 *)(iv+12)) = counter; if ((sg_is_last(req->src)) && (sg_is_last(req->assoc))) { one_entry_in_sg = 1; scatterwalk_start(&src_sg_walk, req->src); scatterwalk_start(&assoc_sg_walk, req->assoc); src = scatterwalk_map(&src_sg_walk); assoc = scatterwalk_map(&assoc_sg_walk); dst = src; if (unlikely(req->src != req->dst)) { scatterwalk_start(&dst_sg_walk, req->dst); dst = scatterwalk_map(&dst_sg_walk); } } else { /* Allocate memory for src, dst, assoc */ src = kmalloc(req->cryptlen + req->assoclen, GFP_ATOMIC); if (!src) return -ENOMEM; assoc = (src + req->cryptlen); scatterwalk_map_and_copy(src, req->src, 0, req->cryptlen, 0); scatterwalk_map_and_copy(assoc, req->assoc, 0, req->assoclen, 0); dst = src; } aesni_gcm_dec(aes_ctx, dst, src, tempCipherLen, iv, ctx->hash_subkey, assoc, (unsigned long)req->assoclen, authTag, auth_tag_len); /* Compare generated tag with passed in tag. */ retval = memcmp(src + tempCipherLen, authTag, auth_tag_len) ? -EBADMSG : 0; if (one_entry_in_sg) { if (unlikely(req->src != req->dst)) { scatterwalk_unmap(dst); scatterwalk_done(&dst_sg_walk, 0, 0); } scatterwalk_unmap(src); scatterwalk_unmap(assoc); scatterwalk_done(&src_sg_walk, 0, 0); scatterwalk_done(&assoc_sg_walk, 0, 0); } else { scatterwalk_map_and_copy(dst, req->dst, 0, tempCipherLen, 1); kfree(src); } return retval; } static struct crypto_alg __rfc4106_alg = { .cra_name = "__gcm-aes-aesni", .cra_driver_name = "__driver-gcm-aes-aesni", .cra_priority = 0, .cra_flags = CRYPTO_ALG_TYPE_AEAD, .cra_blocksize = 1, .cra_ctxsize = sizeof(struct aesni_rfc4106_gcm_ctx) + AESNI_ALIGN, .cra_alignmask = 0, .cra_type = &crypto_aead_type, .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(__rfc4106_alg.cra_list), .cra_u = { .aead = { .encrypt = __driver_rfc4106_encrypt, .decrypt = __driver_rfc4106_decrypt, }, }, }; #endif static const struct x86_cpu_id aesni_cpu_id[] = { X86_FEATURE_MATCH(X86_FEATURE_AES), {} }; MODULE_DEVICE_TABLE(x86cpu, aesni_cpu_id); static int __init aesni_init(void) { int err; if (!x86_match_cpu(aesni_cpu_id)) return -ENODEV; if ((err = crypto_fpu_init())) goto fpu_err; if ((err = crypto_register_alg(&aesni_alg))) goto aes_err; if ((err = crypto_register_alg(&__aesni_alg))) goto __aes_err; if ((err = crypto_register_alg(&blk_ecb_alg))) goto blk_ecb_err; if ((err = crypto_register_alg(&blk_cbc_alg))) goto blk_cbc_err; if ((err = crypto_register_alg(&ablk_ecb_alg))) goto ablk_ecb_err; if ((err = crypto_register_alg(&ablk_cbc_alg))) goto ablk_cbc_err; #ifdef CONFIG_X86_64 if ((err = crypto_register_alg(&blk_ctr_alg))) goto blk_ctr_err; if ((err = crypto_register_alg(&ablk_ctr_alg))) goto ablk_ctr_err; if ((err = crypto_register_alg(&__rfc4106_alg))) goto __aead_gcm_err; if ((err = crypto_register_alg(&rfc4106_alg))) goto aead_gcm_err; #ifdef HAS_CTR if ((err = crypto_register_alg(&ablk_rfc3686_ctr_alg))) goto ablk_rfc3686_ctr_err; #endif #endif #ifdef HAS_LRW if ((err = crypto_register_alg(&ablk_lrw_alg))) goto ablk_lrw_err; #endif #ifdef HAS_PCBC if ((err = crypto_register_alg(&ablk_pcbc_alg))) goto ablk_pcbc_err; #endif #ifdef HAS_XTS if ((err = crypto_register_alg(&ablk_xts_alg))) goto ablk_xts_err; #endif return err; #ifdef HAS_XTS ablk_xts_err: #endif #ifdef HAS_PCBC crypto_unregister_alg(&ablk_pcbc_alg); ablk_pcbc_err: #endif #ifdef HAS_LRW crypto_unregister_alg(&ablk_lrw_alg); ablk_lrw_err: #endif #ifdef CONFIG_X86_64 #ifdef HAS_CTR crypto_unregister_alg(&ablk_rfc3686_ctr_alg); ablk_rfc3686_ctr_err: #endif crypto_unregister_alg(&rfc4106_alg); aead_gcm_err: crypto_unregister_alg(&__rfc4106_alg); __aead_gcm_err: crypto_unregister_alg(&ablk_ctr_alg); ablk_ctr_err: crypto_unregister_alg(&blk_ctr_alg); blk_ctr_err: #endif crypto_unregister_alg(&ablk_cbc_alg); ablk_cbc_err: crypto_unregister_alg(&ablk_ecb_alg); ablk_ecb_err: crypto_unregister_alg(&blk_cbc_alg); blk_cbc_err: crypto_unregister_alg(&blk_ecb_alg); blk_ecb_err: crypto_unregister_alg(&__aesni_alg); __aes_err: crypto_unregister_alg(&aesni_alg); aes_err: fpu_err: return err; } static void __exit aesni_exit(void) { #ifdef HAS_XTS crypto_unregister_alg(&ablk_xts_alg); #endif #ifdef HAS_PCBC crypto_unregister_alg(&ablk_pcbc_alg); #endif #ifdef HAS_LRW crypto_unregister_alg(&ablk_lrw_alg); #endif #ifdef CONFIG_X86_64 #ifdef HAS_CTR crypto_unregister_alg(&ablk_rfc3686_ctr_alg); #endif crypto_unregister_alg(&rfc4106_alg); crypto_unregister_alg(&__rfc4106_alg); crypto_unregister_alg(&ablk_ctr_alg); crypto_unregister_alg(&blk_ctr_alg); #endif crypto_unregister_alg(&ablk_cbc_alg); crypto_unregister_alg(&ablk_ecb_alg); crypto_unregister_alg(&blk_cbc_alg); crypto_unregister_alg(&blk_ecb_alg); crypto_unregister_alg(&__aesni_alg); crypto_unregister_alg(&aesni_alg); crypto_fpu_exit(); } module_init(aesni_init); module_exit(aesni_exit); MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm, Intel AES-NI instructions optimized"); MODULE_LICENSE("GPL"); MODULE_ALIAS("aes");
gpl-2.0
drsn0w/android_kernel_zte_msm7627
drivers/video/riva/fbdev.c
952
59726
/* * linux/drivers/video/riva/fbdev.c - nVidia RIVA 128/TNT/TNT2 fb driver * * Maintained by Ani Joshi <ajoshi@shell.unixbox.com> * * Copyright 1999-2000 Jeff Garzik * * Contributors: * * Ani Joshi: Lots of debugging and cleanup work, really helped * get the driver going * * Ferenc Bakonyi: Bug fixes, cleanup, modularization * * Jindrich Makovicka: Accel code help, hw cursor, mtrr * * Paul Richards: Bug fixes, updates * * Initial template from skeletonfb.c, created 28 Dec 1997 by Geert Uytterhoeven * Includes riva_hw.c from nVidia, see copyright below. * KGI code provided the basis for state storage, init, and mode switching. * * 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. * * Known bugs and issues: * restoring text mode fails * doublescan modes are broken */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/backlight.h> #include <linux/bitrev.h> #ifdef CONFIG_MTRR #include <asm/mtrr.h> #endif #ifdef CONFIG_PPC_OF #include <asm/prom.h> #include <asm/pci-bridge.h> #endif #ifdef CONFIG_PMAC_BACKLIGHT #include <asm/machdep.h> #include <asm/backlight.h> #endif #include "rivafb.h" #include "nvreg.h" /* version number of this driver */ #define RIVAFB_VERSION "0.9.5b" /* ------------------------------------------------------------------------- * * * various helpful macros and constants * * ------------------------------------------------------------------------- */ #ifdef CONFIG_FB_RIVA_DEBUG #define NVTRACE printk #else #define NVTRACE if(0) printk #endif #define NVTRACE_ENTER(...) NVTRACE("%s START\n", __func__) #define NVTRACE_LEAVE(...) NVTRACE("%s END\n", __func__) #ifdef CONFIG_FB_RIVA_DEBUG #define assert(expr) \ if(!(expr)) { \ printk( "Assertion failed! %s,%s,%s,line=%d\n",\ #expr,__FILE__,__func__,__LINE__); \ BUG(); \ } #else #define assert(expr) #endif #define PFX "rivafb: " /* macro that allows you to set overflow bits */ #define SetBitField(value,from,to) SetBF(to,GetBF(value,from)) #define SetBit(n) (1<<(n)) #define Set8Bits(value) ((value)&0xff) /* HW cursor parameters */ #define MAX_CURS 32 /* ------------------------------------------------------------------------- * * * prototypes * * ------------------------------------------------------------------------- */ static int rivafb_blank(int blank, struct fb_info *info); /* ------------------------------------------------------------------------- * * * card identification * * ------------------------------------------------------------------------- */ static struct pci_device_id rivafb_pci_tbl[] = { { PCI_VENDOR_ID_NVIDIA_SG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ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, // NF2/IGP version, GeForce 4 MX, NV18 { PCI_VENDOR_ID_NVIDIA, 0x01f0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_IGEFORCE2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO_DDC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO_5200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0, } /* terminate list */ }; MODULE_DEVICE_TABLE(pci, rivafb_pci_tbl); /* ------------------------------------------------------------------------- * * * global variables * * ------------------------------------------------------------------------- */ /* command line data, set in rivafb_setup() */ static int flatpanel __devinitdata = -1; /* Autodetect later */ static int forceCRTC __devinitdata = -1; static int noaccel __devinitdata = 0; #ifdef CONFIG_MTRR static int nomtrr __devinitdata = 0; #endif #ifdef CONFIG_PMAC_BACKLIGHT static int backlight __devinitdata = 1; #else static int backlight __devinitdata = 0; #endif static char *mode_option __devinitdata = NULL; static int strictmode = 0; static struct fb_fix_screeninfo __devinitdata rivafb_fix = { .type = FB_TYPE_PACKED_PIXELS, .xpanstep = 1, .ypanstep = 1, }; static struct fb_var_screeninfo __devinitdata rivafb_default_var = { .xres = 640, .yres = 480, .xres_virtual = 640, .yres_virtual = 480, .bits_per_pixel = 8, .red = {0, 8, 0}, .green = {0, 8, 0}, .blue = {0, 8, 0}, .transp = {0, 0, 0}, .activate = FB_ACTIVATE_NOW, .height = -1, .width = -1, .pixclock = 39721, .left_margin = 40, .right_margin = 24, .upper_margin = 32, .lower_margin = 11, .hsync_len = 96, .vsync_len = 2, .vmode = FB_VMODE_NONINTERLACED }; /* from GGI */ static const struct riva_regs reg_template = { {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* ATTR */ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x01, 0x0F, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* CRT */ 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3, /* 0x10 */ 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20 */ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40 */ }, {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, /* GRA */ 0xFF}, {0x03, 0x01, 0x0F, 0x00, 0x0E}, /* SEQ */ 0xEB /* MISC */ }; /* * Backlight control */ #ifdef CONFIG_FB_RIVA_BACKLIGHT /* We do not have any information about which values are allowed, thus * we used safe values. */ #define MIN_LEVEL 0x158 #define MAX_LEVEL 0x534 #define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX) static int riva_bl_get_level_brightness(struct riva_par *par, int level) { struct fb_info *info = pci_get_drvdata(par->pdev); int nlevel; /* Get and convert the value */ /* No locking on bl_curve since accessing a single value */ nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP; if (nlevel < 0) nlevel = 0; else if (nlevel < MIN_LEVEL) nlevel = MIN_LEVEL; else if (nlevel > MAX_LEVEL) nlevel = MAX_LEVEL; return nlevel; } static int riva_bl_update_status(struct backlight_device *bd) { struct riva_par *par = bl_get_data(bd); U032 tmp_pcrt, tmp_pmc; int level; if (bd->props.power != FB_BLANK_UNBLANK || bd->props.fb_blank != FB_BLANK_UNBLANK) level = 0; else level = bd->props.brightness; tmp_pmc = NV_RD32(par->riva.PMC, 0x10F0) & 0x0000FFFF; tmp_pcrt = NV_RD32(par->riva.PCRTC0, 0x081C) & 0xFFFFFFFC; if(level > 0) { tmp_pcrt |= 0x1; tmp_pmc |= (1 << 31); /* backlight bit */ tmp_pmc |= riva_bl_get_level_brightness(par, level) << 16; /* level */ } NV_WR32(par->riva.PCRTC0, 0x081C, tmp_pcrt); NV_WR32(par->riva.PMC, 0x10F0, tmp_pmc); return 0; } static int riva_bl_get_brightness(struct backlight_device *bd) { return bd->props.brightness; } static struct backlight_ops riva_bl_ops = { .get_brightness = riva_bl_get_brightness, .update_status = riva_bl_update_status, }; static void riva_bl_init(struct riva_par *par) { struct backlight_properties props; struct fb_info *info = pci_get_drvdata(par->pdev); struct backlight_device *bd; char name[12]; if (!par->FlatPanel) return; #ifdef CONFIG_PMAC_BACKLIGHT if (!machine_is(powermac) || !pmac_has_backlight_type("mnca")) return; #endif snprintf(name, sizeof(name), "rivabl%d", info->node); memset(&props, 0, sizeof(struct backlight_properties)); props.max_brightness = FB_BACKLIGHT_LEVELS - 1; bd = backlight_device_register(name, info->dev, par, &riva_bl_ops, &props); if (IS_ERR(bd)) { info->bl_dev = NULL; printk(KERN_WARNING "riva: Backlight registration failed\n"); goto error; } info->bl_dev = bd; fb_bl_default_curve(info, 0, MIN_LEVEL * FB_BACKLIGHT_MAX / MAX_LEVEL, FB_BACKLIGHT_MAX); bd->props.brightness = bd->props.max_brightness; bd->props.power = FB_BLANK_UNBLANK; backlight_update_status(bd); printk("riva: Backlight initialized (%s)\n", name); return; error: return; } static void riva_bl_exit(struct fb_info *info) { struct backlight_device *bd = info->bl_dev; backlight_device_unregister(bd); printk("riva: Backlight unloaded\n"); } #else static inline void riva_bl_init(struct riva_par *par) {} static inline void riva_bl_exit(struct fb_info *info) {} #endif /* CONFIG_FB_RIVA_BACKLIGHT */ /* ------------------------------------------------------------------------- * * * MMIO access macros * * ------------------------------------------------------------------------- */ static inline void CRTCout(struct riva_par *par, unsigned char index, unsigned char val) { VGA_WR08(par->riva.PCIO, 0x3d4, index); VGA_WR08(par->riva.PCIO, 0x3d5, val); } static inline unsigned char CRTCin(struct riva_par *par, unsigned char index) { VGA_WR08(par->riva.PCIO, 0x3d4, index); return (VGA_RD08(par->riva.PCIO, 0x3d5)); } static inline void GRAout(struct riva_par *par, unsigned char index, unsigned char val) { VGA_WR08(par->riva.PVIO, 0x3ce, index); VGA_WR08(par->riva.PVIO, 0x3cf, val); } static inline unsigned char GRAin(struct riva_par *par, unsigned char index) { VGA_WR08(par->riva.PVIO, 0x3ce, index); return (VGA_RD08(par->riva.PVIO, 0x3cf)); } static inline void SEQout(struct riva_par *par, unsigned char index, unsigned char val) { VGA_WR08(par->riva.PVIO, 0x3c4, index); VGA_WR08(par->riva.PVIO, 0x3c5, val); } static inline unsigned char SEQin(struct riva_par *par, unsigned char index) { VGA_WR08(par->riva.PVIO, 0x3c4, index); return (VGA_RD08(par->riva.PVIO, 0x3c5)); } static inline void ATTRout(struct riva_par *par, unsigned char index, unsigned char val) { VGA_WR08(par->riva.PCIO, 0x3c0, index); VGA_WR08(par->riva.PCIO, 0x3c0, val); } static inline unsigned char ATTRin(struct riva_par *par, unsigned char index) { VGA_WR08(par->riva.PCIO, 0x3c0, index); return (VGA_RD08(par->riva.PCIO, 0x3c1)); } static inline void MISCout(struct riva_par *par, unsigned char val) { VGA_WR08(par->riva.PVIO, 0x3c2, val); } static inline unsigned char MISCin(struct riva_par *par) { return (VGA_RD08(par->riva.PVIO, 0x3cc)); } static inline void reverse_order(u32 *l) { u8 *a = (u8 *)l; a[0] = bitrev8(a[0]); a[1] = bitrev8(a[1]); a[2] = bitrev8(a[2]); a[3] = bitrev8(a[3]); } /* ------------------------------------------------------------------------- * * * cursor stuff * * ------------------------------------------------------------------------- */ /** * rivafb_load_cursor_image - load cursor image to hardware * @data: address to monochrome bitmap (1 = foreground color, 0 = background) * @par: pointer to private data * @w: width of cursor image in pixels * @h: height of cursor image in scanlines * @bg: background color (ARGB1555) - alpha bit determines opacity * @fg: foreground color (ARGB1555) * * DESCRIPTiON: * Loads cursor image based on a monochrome source and mask bitmap. The * image bits determines the color of the pixel, 0 for background, 1 for * foreground. Only the affected region (as determined by @w and @h * parameters) will be updated. * * CALLED FROM: * rivafb_cursor() */ static void rivafb_load_cursor_image(struct riva_par *par, u8 *data8, u16 bg, u16 fg, u32 w, u32 h) { int i, j, k = 0; u32 b, tmp; u32 *data = (u32 *)data8; bg = le16_to_cpu(bg); fg = le16_to_cpu(fg); w = (w + 1) & ~1; for (i = 0; i < h; i++) { b = *data++; reverse_order(&b); for (j = 0; j < w/2; j++) { tmp = 0; #if defined (__BIG_ENDIAN) tmp = (b & (1 << 31)) ? fg << 16 : bg << 16; b <<= 1; tmp |= (b & (1 << 31)) ? fg : bg; b <<= 1; #else tmp = (b & 1) ? fg : bg; b >>= 1; tmp |= (b & 1) ? fg << 16 : bg << 16; b >>= 1; #endif writel(tmp, &par->riva.CURSOR[k++]); } k += (MAX_CURS - w)/2; } } /* ------------------------------------------------------------------------- * * * general utility functions * * ------------------------------------------------------------------------- */ /** * riva_wclut - set CLUT entry * @chip: pointer to RIVA_HW_INST object * @regnum: register number * @red: red component * @green: green component * @blue: blue component * * DESCRIPTION: * Sets color register @regnum. * * CALLED FROM: * rivafb_setcolreg() */ static void riva_wclut(RIVA_HW_INST *chip, unsigned char regnum, unsigned char red, unsigned char green, unsigned char blue) { VGA_WR08(chip->PDIO, 0x3c8, regnum); VGA_WR08(chip->PDIO, 0x3c9, red); VGA_WR08(chip->PDIO, 0x3c9, green); VGA_WR08(chip->PDIO, 0x3c9, blue); } /** * riva_rclut - read fromCLUT register * @chip: pointer to RIVA_HW_INST object * @regnum: register number * @red: red component * @green: green component * @blue: blue component * * DESCRIPTION: * Reads red, green, and blue from color register @regnum. * * CALLED FROM: * rivafb_setcolreg() */ static void riva_rclut(RIVA_HW_INST *chip, unsigned char regnum, unsigned char *red, unsigned char *green, unsigned char *blue) { VGA_WR08(chip->PDIO, 0x3c7, regnum); *red = VGA_RD08(chip->PDIO, 0x3c9); *green = VGA_RD08(chip->PDIO, 0x3c9); *blue = VGA_RD08(chip->PDIO, 0x3c9); } /** * riva_save_state - saves current chip state * @par: pointer to riva_par object containing info for current riva board * @regs: pointer to riva_regs object * * DESCRIPTION: * Saves current chip state to @regs. * * CALLED FROM: * rivafb_probe() */ /* from GGI */ static void riva_save_state(struct riva_par *par, struct riva_regs *regs) { int i; NVTRACE_ENTER(); par->riva.LockUnlock(&par->riva, 0); par->riva.UnloadStateExt(&par->riva, &regs->ext); regs->misc_output = MISCin(par); for (i = 0; i < NUM_CRT_REGS; i++) regs->crtc[i] = CRTCin(par, i); for (i = 0; i < NUM_ATC_REGS; i++) regs->attr[i] = ATTRin(par, i); for (i = 0; i < NUM_GRC_REGS; i++) regs->gra[i] = GRAin(par, i); for (i = 0; i < NUM_SEQ_REGS; i++) regs->seq[i] = SEQin(par, i); NVTRACE_LEAVE(); } /** * riva_load_state - loads current chip state * @par: pointer to riva_par object containing info for current riva board * @regs: pointer to riva_regs object * * DESCRIPTION: * Loads chip state from @regs. * * CALLED FROM: * riva_load_video_mode() * rivafb_probe() * rivafb_remove() */ /* from GGI */ static void riva_load_state(struct riva_par *par, struct riva_regs *regs) { RIVA_HW_STATE *state = &regs->ext; int i; NVTRACE_ENTER(); CRTCout(par, 0x11, 0x00); par->riva.LockUnlock(&par->riva, 0); par->riva.LoadStateExt(&par->riva, state); MISCout(par, regs->misc_output); for (i = 0; i < NUM_CRT_REGS; i++) { switch (i) { case 0x19: case 0x20 ... 0x40: break; default: CRTCout(par, i, regs->crtc[i]); } } for (i = 0; i < NUM_ATC_REGS; i++) ATTRout(par, i, regs->attr[i]); for (i = 0; i < NUM_GRC_REGS; i++) GRAout(par, i, regs->gra[i]); for (i = 0; i < NUM_SEQ_REGS; i++) SEQout(par, i, regs->seq[i]); NVTRACE_LEAVE(); } /** * riva_load_video_mode - calculate timings * @info: pointer to fb_info object containing info for current riva board * * DESCRIPTION: * Calculate some timings and then send em off to riva_load_state(). * * CALLED FROM: * rivafb_set_par() */ static int riva_load_video_mode(struct fb_info *info) { int bpp, width, hDisplaySize, hDisplay, hStart, hEnd, hTotal, height, vDisplay, vStart, vEnd, vTotal, dotClock; int hBlankStart, hBlankEnd, vBlankStart, vBlankEnd; int rc; struct riva_par *par = info->par; struct riva_regs newmode; NVTRACE_ENTER(); /* time to calculate */ rivafb_blank(FB_BLANK_NORMAL, info); bpp = info->var.bits_per_pixel; if (bpp == 16 && info->var.green.length == 5) bpp = 15; width = info->var.xres_virtual; hDisplaySize = info->var.xres; hDisplay = (hDisplaySize / 8) - 1; hStart = (hDisplaySize + info->var.right_margin) / 8 - 1; hEnd = (hDisplaySize + info->var.right_margin + info->var.hsync_len) / 8 - 1; hTotal = (hDisplaySize + info->var.right_margin + info->var.hsync_len + info->var.left_margin) / 8 - 5; hBlankStart = hDisplay; hBlankEnd = hTotal + 4; height = info->var.yres_virtual; vDisplay = info->var.yres - 1; vStart = info->var.yres + info->var.lower_margin - 1; vEnd = info->var.yres + info->var.lower_margin + info->var.vsync_len - 1; vTotal = info->var.yres + info->var.lower_margin + info->var.vsync_len + info->var.upper_margin + 2; vBlankStart = vDisplay; vBlankEnd = vTotal + 1; dotClock = 1000000000 / info->var.pixclock; memcpy(&newmode, &reg_template, sizeof(struct riva_regs)); if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) vTotal |= 1; if (par->FlatPanel) { vStart = vTotal - 3; vEnd = vTotal - 2; vBlankStart = vStart; hStart = hTotal - 3; hEnd = hTotal - 2; hBlankEnd = hTotal + 4; } newmode.crtc[0x0] = Set8Bits (hTotal); newmode.crtc[0x1] = Set8Bits (hDisplay); newmode.crtc[0x2] = Set8Bits (hBlankStart); newmode.crtc[0x3] = SetBitField (hBlankEnd, 4: 0, 4:0) | SetBit (7); newmode.crtc[0x4] = Set8Bits (hStart); newmode.crtc[0x5] = SetBitField (hBlankEnd, 5: 5, 7:7) | SetBitField (hEnd, 4: 0, 4:0); newmode.crtc[0x6] = SetBitField (vTotal, 7: 0, 7:0); newmode.crtc[0x7] = SetBitField (vTotal, 8: 8, 0:0) | SetBitField (vDisplay, 8: 8, 1:1) | SetBitField (vStart, 8: 8, 2:2) | SetBitField (vBlankStart, 8: 8, 3:3) | SetBit (4) | SetBitField (vTotal, 9: 9, 5:5) | SetBitField (vDisplay, 9: 9, 6:6) | SetBitField (vStart, 9: 9, 7:7); newmode.crtc[0x9] = SetBitField (vBlankStart, 9: 9, 5:5) | SetBit (6); newmode.crtc[0x10] = Set8Bits (vStart); newmode.crtc[0x11] = SetBitField (vEnd, 3: 0, 3:0) | SetBit (5); newmode.crtc[0x12] = Set8Bits (vDisplay); newmode.crtc[0x13] = (width / 8) * ((bpp + 1) / 8); newmode.crtc[0x15] = Set8Bits (vBlankStart); newmode.crtc[0x16] = Set8Bits (vBlankEnd); newmode.ext.screen = SetBitField(hBlankEnd,6:6,4:4) | SetBitField(vBlankStart,10:10,3:3) | SetBitField(vStart,10:10,2:2) | SetBitField(vDisplay,10:10,1:1) | SetBitField(vTotal,10:10,0:0); newmode.ext.horiz = SetBitField(hTotal,8:8,0:0) | SetBitField(hDisplay,8:8,1:1) | SetBitField(hBlankStart,8:8,2:2) | SetBitField(hStart,8:8,3:3); newmode.ext.extra = SetBitField(vTotal,11:11,0:0) | SetBitField(vDisplay,11:11,2:2) | SetBitField(vStart,11:11,4:4) | SetBitField(vBlankStart,11:11,6:6); if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { int tmp = (hTotal >> 1) & ~1; newmode.ext.interlace = Set8Bits(tmp); newmode.ext.horiz |= SetBitField(tmp, 8:8,4:4); } else newmode.ext.interlace = 0xff; /* interlace off */ if (par->riva.Architecture >= NV_ARCH_10) par->riva.CURSOR = (U032 __iomem *)(info->screen_base + par->riva.CursorStart); if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) newmode.misc_output &= ~0x40; else newmode.misc_output |= 0x40; if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) newmode.misc_output &= ~0x80; else newmode.misc_output |= 0x80; rc = CalcStateExt(&par->riva, &newmode.ext, bpp, width, hDisplaySize, height, dotClock); if (rc) goto out; newmode.ext.scale = NV_RD32(par->riva.PRAMDAC, 0x00000848) & 0xfff000ff; if (par->FlatPanel == 1) { newmode.ext.pixel |= (1 << 7); newmode.ext.scale |= (1 << 8); } if (par->SecondCRTC) { newmode.ext.head = NV_RD32(par->riva.PCRTC0, 0x00000860) & ~0x00001000; newmode.ext.head2 = NV_RD32(par->riva.PCRTC0, 0x00002860) | 0x00001000; newmode.ext.crtcOwner = 3; newmode.ext.pllsel |= 0x20000800; newmode.ext.vpll2 = newmode.ext.vpll; } else if (par->riva.twoHeads) { newmode.ext.head = NV_RD32(par->riva.PCRTC0, 0x00000860) | 0x00001000; newmode.ext.head2 = NV_RD32(par->riva.PCRTC0, 0x00002860) & ~0x00001000; newmode.ext.crtcOwner = 0; newmode.ext.vpll2 = NV_RD32(par->riva.PRAMDAC0, 0x00000520); } if (par->FlatPanel == 1) { newmode.ext.pixel |= (1 << 7); newmode.ext.scale |= (1 << 8); } newmode.ext.cursorConfig = 0x02000100; par->current_state = newmode; riva_load_state(par, &par->current_state); par->riva.LockUnlock(&par->riva, 0); /* important for HW cursor */ out: rivafb_blank(FB_BLANK_UNBLANK, info); NVTRACE_LEAVE(); return rc; } static void riva_update_var(struct fb_var_screeninfo *var, const struct fb_videomode *modedb) { NVTRACE_ENTER(); var->xres = var->xres_virtual = modedb->xres; var->yres = modedb->yres; if (var->yres_virtual < var->yres) var->yres_virtual = var->yres; var->xoffset = var->yoffset = 0; var->pixclock = modedb->pixclock; var->left_margin = modedb->left_margin; var->right_margin = modedb->right_margin; var->upper_margin = modedb->upper_margin; var->lower_margin = modedb->lower_margin; var->hsync_len = modedb->hsync_len; var->vsync_len = modedb->vsync_len; var->sync = modedb->sync; var->vmode = modedb->vmode; NVTRACE_LEAVE(); } /** * rivafb_do_maximize - * @info: pointer to fb_info object containing info for current riva board * @var: * @nom: * @den: * * DESCRIPTION: * . * * RETURNS: * -EINVAL on failure, 0 on success * * * CALLED FROM: * rivafb_check_var() */ static int rivafb_do_maximize(struct fb_info *info, struct fb_var_screeninfo *var, int nom, int den) { static struct { int xres, yres; } modes[] = { {1600, 1280}, {1280, 1024}, {1024, 768}, {800, 600}, {640, 480}, {-1, -1} }; int i; NVTRACE_ENTER(); /* use highest possible virtual resolution */ if (var->xres_virtual == -1 && var->yres_virtual == -1) { printk(KERN_WARNING PFX "using maximum available virtual resolution\n"); for (i = 0; modes[i].xres != -1; i++) { if (modes[i].xres * nom / den * modes[i].yres < info->fix.smem_len) break; } if (modes[i].xres == -1) { printk(KERN_ERR PFX "could not find a virtual resolution that fits into video memory!!\n"); NVTRACE("EXIT - EINVAL error\n"); return -EINVAL; } var->xres_virtual = modes[i].xres; var->yres_virtual = modes[i].yres; printk(KERN_INFO PFX "virtual resolution set to maximum of %dx%d\n", var->xres_virtual, var->yres_virtual); } else if (var->xres_virtual == -1) { var->xres_virtual = (info->fix.smem_len * den / (nom * var->yres_virtual)) & ~15; printk(KERN_WARNING PFX "setting virtual X resolution to %d\n", var->xres_virtual); } else if (var->yres_virtual == -1) { var->xres_virtual = (var->xres_virtual + 15) & ~15; var->yres_virtual = info->fix.smem_len * den / (nom * var->xres_virtual); printk(KERN_WARNING PFX "setting virtual Y resolution to %d\n", var->yres_virtual); } else { var->xres_virtual = (var->xres_virtual + 15) & ~15; if (var->xres_virtual * nom / den * var->yres_virtual > info->fix.smem_len) { printk(KERN_ERR PFX "mode %dx%dx%d rejected...resolution too high to fit into video memory!\n", var->xres, var->yres, var->bits_per_pixel); NVTRACE("EXIT - EINVAL error\n"); return -EINVAL; } } if (var->xres_virtual * nom / den >= 8192) { printk(KERN_WARNING PFX "virtual X resolution (%d) is too high, lowering to %d\n", var->xres_virtual, 8192 * den / nom - 16); var->xres_virtual = 8192 * den / nom - 16; } if (var->xres_virtual < var->xres) { printk(KERN_ERR PFX "virtual X resolution (%d) is smaller than real\n", var->xres_virtual); return -EINVAL; } if (var->yres_virtual < var->yres) { printk(KERN_ERR PFX "virtual Y resolution (%d) is smaller than real\n", var->yres_virtual); return -EINVAL; } if (var->yres_virtual > 0x7fff/nom) var->yres_virtual = 0x7fff/nom; if (var->xres_virtual > 0x7fff/nom) var->xres_virtual = 0x7fff/nom; NVTRACE_LEAVE(); return 0; } static void riva_set_pattern(struct riva_par *par, int clr0, int clr1, int pat0, int pat1) { RIVA_FIFO_FREE(par->riva, Patt, 4); NV_WR32(&par->riva.Patt->Color0, 0, clr0); NV_WR32(&par->riva.Patt->Color1, 0, clr1); NV_WR32(par->riva.Patt->Monochrome, 0, pat0); NV_WR32(par->riva.Patt->Monochrome, 4, pat1); } /* acceleration routines */ static inline void wait_for_idle(struct riva_par *par) { while (par->riva.Busy(&par->riva)); } /* * Set ROP. Translate X rop into ROP3. Internal routine. */ static void riva_set_rop_solid(struct riva_par *par, int rop) { riva_set_pattern(par, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); RIVA_FIFO_FREE(par->riva, Rop, 1); NV_WR32(&par->riva.Rop->Rop3, 0, rop); } static void riva_setup_accel(struct fb_info *info) { struct riva_par *par = info->par; RIVA_FIFO_FREE(par->riva, Clip, 2); NV_WR32(&par->riva.Clip->TopLeft, 0, 0x0); NV_WR32(&par->riva.Clip->WidthHeight, 0, (info->var.xres_virtual & 0xffff) | (info->var.yres_virtual << 16)); riva_set_rop_solid(par, 0xcc); wait_for_idle(par); } /** * riva_get_cmap_len - query current color map length * @var: standard kernel fb changeable data * * DESCRIPTION: * Get current color map length. * * RETURNS: * Length of color map * * CALLED FROM: * rivafb_setcolreg() */ static int riva_get_cmap_len(const struct fb_var_screeninfo *var) { int rc = 256; /* reasonable default */ switch (var->green.length) { case 8: rc = 256; /* 256 entries (2^8), 8 bpp and RGB8888 */ break; case 5: rc = 32; /* 32 entries (2^5), 16 bpp, RGB555 */ break; case 6: rc = 64; /* 64 entries (2^6), 16 bpp, RGB565 */ break; default: /* should not occur */ break; } return rc; } /* ------------------------------------------------------------------------- * * * framebuffer operations * * ------------------------------------------------------------------------- */ static int rivafb_open(struct fb_info *info, int user) { struct riva_par *par = info->par; NVTRACE_ENTER(); mutex_lock(&par->open_lock); if (!par->ref_count) { #ifdef CONFIG_X86 memset(&par->state, 0, sizeof(struct vgastate)); par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS; /* save the DAC for Riva128 */ if (par->riva.Architecture == NV_ARCH_03) par->state.flags |= VGA_SAVE_CMAP; save_vga(&par->state); #endif /* vgaHWunlock() + riva unlock (0x7F) */ CRTCout(par, 0x11, 0xFF); par->riva.LockUnlock(&par->riva, 0); riva_save_state(par, &par->initial_state); } par->ref_count++; mutex_unlock(&par->open_lock); NVTRACE_LEAVE(); return 0; } static int rivafb_release(struct fb_info *info, int user) { struct riva_par *par = info->par; NVTRACE_ENTER(); mutex_lock(&par->open_lock); if (!par->ref_count) { mutex_unlock(&par->open_lock); return -EINVAL; } if (par->ref_count == 1) { par->riva.LockUnlock(&par->riva, 0); par->riva.LoadStateExt(&par->riva, &par->initial_state.ext); riva_load_state(par, &par->initial_state); #ifdef CONFIG_X86 restore_vga(&par->state); #endif par->riva.LockUnlock(&par->riva, 1); } par->ref_count--; mutex_unlock(&par->open_lock); NVTRACE_LEAVE(); return 0; } static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { const struct fb_videomode *mode; struct riva_par *par = info->par; int nom, den; /* translating from pixels->bytes */ int mode_valid = 0; NVTRACE_ENTER(); switch (var->bits_per_pixel) { case 1 ... 8: var->red.offset = var->green.offset = var->blue.offset = 0; var->red.length = var->green.length = var->blue.length = 8; var->bits_per_pixel = 8; nom = den = 1; break; case 9 ... 15: var->green.length = 5; /* fall through */ case 16: var->bits_per_pixel = 16; /* The Riva128 supports RGB555 only */ if (par->riva.Architecture == NV_ARCH_03) var->green.length = 5; if (var->green.length == 5) { /* 0rrrrrgg gggbbbbb */ var->red.offset = 10; var->green.offset = 5; var->blue.offset = 0; var->red.length = 5; var->green.length = 5; var->blue.length = 5; } else { /* rrrrrggg gggbbbbb */ var->red.offset = 11; var->green.offset = 5; var->blue.offset = 0; var->red.length = 5; var->green.length = 6; var->blue.length = 5; } nom = 2; den = 1; break; case 17 ... 32: var->red.length = var->green.length = var->blue.length = 8; var->bits_per_pixel = 32; var->red.offset = 16; var->green.offset = 8; var->blue.offset = 0; nom = 4; den = 1; break; default: printk(KERN_ERR PFX "mode %dx%dx%d rejected...color depth not supported.\n", var->xres, var->yres, var->bits_per_pixel); NVTRACE("EXIT, returning -EINVAL\n"); return -EINVAL; } if (!strictmode) { if (!info->monspecs.vfmax || !info->monspecs.hfmax || !info->monspecs.dclkmax || !fb_validate_mode(var, info)) mode_valid = 1; } /* calculate modeline if supported by monitor */ if (!mode_valid && info->monspecs.gtf) { if (!fb_get_mode(FB_MAXTIMINGS, 0, var, info)) mode_valid = 1; } if (!mode_valid) { mode = fb_find_best_mode(var, &info->modelist); if (mode) { riva_update_var(var, mode); mode_valid = 1; } } if (!mode_valid && info->monspecs.modedb_len) return -EINVAL; if (var->xres_virtual < var->xres) var->xres_virtual = var->xres; if (var->yres_virtual <= var->yres) var->yres_virtual = -1; if (rivafb_do_maximize(info, var, nom, den) < 0) return -EINVAL; if (var->xoffset < 0) var->xoffset = 0; if (var->yoffset < 0) var->yoffset = 0; /* truncate xoffset and yoffset to maximum if too high */ if (var->xoffset > var->xres_virtual - var->xres) var->xoffset = var->xres_virtual - var->xres - 1; if (var->yoffset > var->yres_virtual - var->yres) var->yoffset = var->yres_virtual - var->yres - 1; var->red.msb_right = var->green.msb_right = var->blue.msb_right = var->transp.offset = var->transp.length = var->transp.msb_right = 0; NVTRACE_LEAVE(); return 0; } static int rivafb_set_par(struct fb_info *info) { struct riva_par *par = info->par; int rc = 0; NVTRACE_ENTER(); /* vgaHWunlock() + riva unlock (0x7F) */ CRTCout(par, 0x11, 0xFF); par->riva.LockUnlock(&par->riva, 0); rc = riva_load_video_mode(info); if (rc) goto out; if(!(info->flags & FBINFO_HWACCEL_DISABLED)) riva_setup_accel(info); par->cursor_reset = 1; info->fix.line_length = (info->var.xres_virtual * (info->var.bits_per_pixel >> 3)); info->fix.visual = (info->var.bits_per_pixel == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; if (info->flags & FBINFO_HWACCEL_DISABLED) info->pixmap.scan_align = 1; else info->pixmap.scan_align = 4; out: NVTRACE_LEAVE(); return rc; } /** * rivafb_pan_display * @var: standard kernel fb changeable data * @con: TODO * @info: pointer to fb_info object containing info for current riva board * * DESCRIPTION: * Pan (or wrap, depending on the `vmode' field) the display using the * `xoffset' and `yoffset' fields of the `var' structure. * If the values don't fit, return -EINVAL. * * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag */ static int rivafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { struct riva_par *par = info->par; unsigned int base; NVTRACE_ENTER(); base = var->yoffset * info->fix.line_length + var->xoffset; par->riva.SetStartAddress(&par->riva, base); NVTRACE_LEAVE(); return 0; } static int rivafb_blank(int blank, struct fb_info *info) { struct riva_par *par= info->par; unsigned char tmp, vesa; tmp = SEQin(par, 0x01) & ~0x20; /* screen on/off */ vesa = CRTCin(par, 0x1a) & ~0xc0; /* sync on/off */ NVTRACE_ENTER(); if (blank) tmp |= 0x20; switch (blank) { case FB_BLANK_UNBLANK: case FB_BLANK_NORMAL: break; case FB_BLANK_VSYNC_SUSPEND: vesa |= 0x80; break; case FB_BLANK_HSYNC_SUSPEND: vesa |= 0x40; break; case FB_BLANK_POWERDOWN: vesa |= 0xc0; break; } SEQout(par, 0x01, tmp); CRTCout(par, 0x1a, vesa); NVTRACE_LEAVE(); return 0; } /** * rivafb_setcolreg * @regno: register index * @red: red component * @green: green component * @blue: blue component * @transp: transparency * @info: pointer to fb_info object containing info for current riva board * * DESCRIPTION: * Set a single color register. The values supplied have a 16 bit * magnitude. * * RETURNS: * Return != 0 for invalid regno. * * CALLED FROM: * fbcmap.c:fb_set_cmap() */ static int rivafb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *info) { struct riva_par *par = info->par; RIVA_HW_INST *chip = &par->riva; int i; if (regno >= riva_get_cmap_len(&info->var)) return -EINVAL; if (info->var.grayscale) { /* gray = 0.30*R + 0.59*G + 0.11*B */ red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; } if (regno < 16 && info->fix.visual == FB_VISUAL_DIRECTCOLOR) { ((u32 *) info->pseudo_palette)[regno] = (regno << info->var.red.offset) | (regno << info->var.green.offset) | (regno << info->var.blue.offset); /* * The Riva128 2D engine requires color information in * TrueColor format even if framebuffer is in DirectColor */ if (par->riva.Architecture == NV_ARCH_03) { switch (info->var.bits_per_pixel) { case 16: par->palette[regno] = ((red & 0xf800) >> 1) | ((green & 0xf800) >> 6) | ((blue & 0xf800) >> 11); break; case 32: par->palette[regno] = ((red & 0xff00) << 8) | ((green & 0xff00)) | ((blue & 0xff00) >> 8); break; } } } switch (info->var.bits_per_pixel) { case 8: /* "transparent" stuff is completely ignored. */ riva_wclut(chip, regno, red >> 8, green >> 8, blue >> 8); break; case 16: if (info->var.green.length == 5) { for (i = 0; i < 8; i++) { riva_wclut(chip, regno*8+i, red >> 8, green >> 8, blue >> 8); } } else { u8 r, g, b; if (regno < 32) { for (i = 0; i < 8; i++) { riva_wclut(chip, regno*8+i, red >> 8, green >> 8, blue >> 8); } } riva_rclut(chip, regno*4, &r, &g, &b); for (i = 0; i < 4; i++) riva_wclut(chip, regno*4+i, r, green >> 8, b); } break; case 32: riva_wclut(chip, regno, red >> 8, green >> 8, blue >> 8); break; default: /* do nothing */ break; } return 0; } /** * rivafb_fillrect - hardware accelerated color fill function * @info: pointer to fb_info structure * @rect: pointer to fb_fillrect structure * * DESCRIPTION: * This function fills up a region of framebuffer memory with a solid * color with a choice of two different ROP's, copy or invert. * * CALLED FROM: * framebuffer hook */ static void rivafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { struct riva_par *par = info->par; u_int color, rop = 0; if ((info->flags & FBINFO_HWACCEL_DISABLED)) { cfb_fillrect(info, rect); return; } if (info->var.bits_per_pixel == 8) color = rect->color; else { if (par->riva.Architecture != NV_ARCH_03) color = ((u32 *)info->pseudo_palette)[rect->color]; else color = par->palette[rect->color]; } switch (rect->rop) { case ROP_XOR: rop = 0x66; break; case ROP_COPY: default: rop = 0xCC; break; } riva_set_rop_solid(par, rop); RIVA_FIFO_FREE(par->riva, Bitmap, 1); NV_WR32(&par->riva.Bitmap->Color1A, 0, color); RIVA_FIFO_FREE(par->riva, Bitmap, 2); NV_WR32(&par->riva.Bitmap->UnclippedRectangle[0].TopLeft, 0, (rect->dx << 16) | rect->dy); mb(); NV_WR32(&par->riva.Bitmap->UnclippedRectangle[0].WidthHeight, 0, (rect->width << 16) | rect->height); mb(); riva_set_rop_solid(par, 0xcc); } /** * rivafb_copyarea - hardware accelerated blit function * @info: pointer to fb_info structure * @region: pointer to fb_copyarea structure * * DESCRIPTION: * This copies an area of pixels from one location to another * * CALLED FROM: * framebuffer hook */ static void rivafb_copyarea(struct fb_info *info, const struct fb_copyarea *region) { struct riva_par *par = info->par; if ((info->flags & FBINFO_HWACCEL_DISABLED)) { cfb_copyarea(info, region); return; } RIVA_FIFO_FREE(par->riva, Blt, 3); NV_WR32(&par->riva.Blt->TopLeftSrc, 0, (region->sy << 16) | region->sx); NV_WR32(&par->riva.Blt->TopLeftDst, 0, (region->dy << 16) | region->dx); mb(); NV_WR32(&par->riva.Blt->WidthHeight, 0, (region->height << 16) | region->width); mb(); } static inline void convert_bgcolor_16(u32 *col) { *col = ((*col & 0x0000F800) << 8) | ((*col & 0x00007E0) << 5) | ((*col & 0x0000001F) << 3) | 0xFF000000; mb(); } /** * rivafb_imageblit: hardware accelerated color expand function * @info: pointer to fb_info structure * @image: pointer to fb_image structure * * DESCRIPTION: * If the source is a monochrome bitmap, the function fills up a a region * of framebuffer memory with pixels whose color is determined by the bit * setting of the bitmap, 1 - foreground, 0 - background. * * If the source is not a monochrome bitmap, color expansion is not done. * In this case, it is channeled to a software function. * * CALLED FROM: * framebuffer hook */ static void rivafb_imageblit(struct fb_info *info, const struct fb_image *image) { struct riva_par *par = info->par; u32 fgx = 0, bgx = 0, width, tmp; u8 *cdat = (u8 *) image->data; volatile u32 __iomem *d; int i, size; if ((info->flags & FBINFO_HWACCEL_DISABLED) || image->depth != 1) { cfb_imageblit(info, image); return; } switch (info->var.bits_per_pixel) { case 8: fgx = image->fg_color; bgx = image->bg_color; break; case 16: case 32: if (par->riva.Architecture != NV_ARCH_03) { fgx = ((u32 *)info->pseudo_palette)[image->fg_color]; bgx = ((u32 *)info->pseudo_palette)[image->bg_color]; } else { fgx = par->palette[image->fg_color]; bgx = par->palette[image->bg_color]; } if (info->var.green.length == 6) convert_bgcolor_16(&bgx); break; } RIVA_FIFO_FREE(par->riva, Bitmap, 7); NV_WR32(&par->riva.Bitmap->ClipE.TopLeft, 0, (image->dy << 16) | (image->dx & 0xFFFF)); NV_WR32(&par->riva.Bitmap->ClipE.BottomRight, 0, (((image->dy + image->height) << 16) | ((image->dx + image->width) & 0xffff))); NV_WR32(&par->riva.Bitmap->Color0E, 0, bgx); NV_WR32(&par->riva.Bitmap->Color1E, 0, fgx); NV_WR32(&par->riva.Bitmap->WidthHeightInE, 0, (image->height << 16) | ((image->width + 31) & ~31)); NV_WR32(&par->riva.Bitmap->WidthHeightOutE, 0, (image->height << 16) | ((image->width + 31) & ~31)); NV_WR32(&par->riva.Bitmap->PointE, 0, (image->dy << 16) | (image->dx & 0xFFFF)); d = &par->riva.Bitmap->MonochromeData01E; width = (image->width + 31)/32; size = width * image->height; while (size >= 16) { RIVA_FIFO_FREE(par->riva, Bitmap, 16); for (i = 0; i < 16; i++) { tmp = *((u32 *)cdat); cdat = (u8 *)((u32 *)cdat + 1); reverse_order(&tmp); NV_WR32(d, i*4, tmp); } size -= 16; } if (size) { RIVA_FIFO_FREE(par->riva, Bitmap, size); for (i = 0; i < size; i++) { tmp = *((u32 *) cdat); cdat = (u8 *)((u32 *)cdat + 1); reverse_order(&tmp); NV_WR32(d, i*4, tmp); } } } /** * rivafb_cursor - hardware cursor function * @info: pointer to info structure * @cursor: pointer to fbcursor structure * * DESCRIPTION: * A cursor function that supports displaying a cursor image via hardware. * Within the kernel, copy and invert rops are supported. If exported * to user space, only the copy rop will be supported. * * CALLED FROM * framebuffer hook */ static int rivafb_cursor(struct fb_info *info, struct fb_cursor *cursor) { struct riva_par *par = info->par; u8 data[MAX_CURS * MAX_CURS/8]; int i, set = cursor->set; u16 fg, bg; if (cursor->image.width > MAX_CURS || cursor->image.height > MAX_CURS) return -ENXIO; par->riva.ShowHideCursor(&par->riva, 0); if (par->cursor_reset) { set = FB_CUR_SETALL; par->cursor_reset = 0; } if (set & FB_CUR_SETSIZE) memset_io(par->riva.CURSOR, 0, MAX_CURS * MAX_CURS * 2); if (set & FB_CUR_SETPOS) { u32 xx, yy, temp; yy = cursor->image.dy - info->var.yoffset; xx = cursor->image.dx - info->var.xoffset; temp = xx & 0xFFFF; temp |= yy << 16; NV_WR32(par->riva.PRAMDAC, 0x0000300, temp); } if (set & (FB_CUR_SETSHAPE | FB_CUR_SETCMAP | FB_CUR_SETIMAGE)) { u32 bg_idx = cursor->image.bg_color; u32 fg_idx = cursor->image.fg_color; u32 s_pitch = (cursor->image.width+7) >> 3; u32 d_pitch = MAX_CURS/8; u8 *dat = (u8 *) cursor->image.data; u8 *msk = (u8 *) cursor->mask; u8 *src; src = kmalloc(s_pitch * cursor->image.height, GFP_ATOMIC); if (src) { switch (cursor->rop) { case ROP_XOR: for (i = 0; i < s_pitch * cursor->image.height; i++) src[i] = dat[i] ^ msk[i]; break; case ROP_COPY: default: for (i = 0; i < s_pitch * cursor->image.height; i++) src[i] = dat[i] & msk[i]; break; } fb_pad_aligned_buffer(data, d_pitch, src, s_pitch, cursor->image.height); bg = ((info->cmap.red[bg_idx] & 0xf8) << 7) | ((info->cmap.green[bg_idx] & 0xf8) << 2) | ((info->cmap.blue[bg_idx] & 0xf8) >> 3) | 1 << 15; fg = ((info->cmap.red[fg_idx] & 0xf8) << 7) | ((info->cmap.green[fg_idx] & 0xf8) << 2) | ((info->cmap.blue[fg_idx] & 0xf8) >> 3) | 1 << 15; par->riva.LockUnlock(&par->riva, 0); rivafb_load_cursor_image(par, data, bg, fg, cursor->image.width, cursor->image.height); kfree(src); } } if (cursor->enable) par->riva.ShowHideCursor(&par->riva, 1); return 0; } static int rivafb_sync(struct fb_info *info) { struct riva_par *par = info->par; wait_for_idle(par); return 0; } /* ------------------------------------------------------------------------- * * * initialization helper functions * * ------------------------------------------------------------------------- */ /* kernel interface */ static struct fb_ops riva_fb_ops = { .owner = THIS_MODULE, .fb_open = rivafb_open, .fb_release = rivafb_release, .fb_check_var = rivafb_check_var, .fb_set_par = rivafb_set_par, .fb_setcolreg = rivafb_setcolreg, .fb_pan_display = rivafb_pan_display, .fb_blank = rivafb_blank, .fb_fillrect = rivafb_fillrect, .fb_copyarea = rivafb_copyarea, .fb_imageblit = rivafb_imageblit, .fb_cursor = rivafb_cursor, .fb_sync = rivafb_sync, }; static int __devinit riva_set_fbinfo(struct fb_info *info) { unsigned int cmap_len; struct riva_par *par = info->par; NVTRACE_ENTER(); info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_XPAN | FBINFO_HWACCEL_YPAN | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT; /* Accel seems to not work properly on NV30 yet...*/ if ((par->riva.Architecture == NV_ARCH_30) || noaccel) { printk(KERN_DEBUG PFX "disabling acceleration\n"); info->flags |= FBINFO_HWACCEL_DISABLED; } info->var = rivafb_default_var; info->fix.visual = (info->var.bits_per_pixel == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; info->pseudo_palette = par->pseudo_palette; cmap_len = riva_get_cmap_len(&info->var); fb_alloc_cmap(&info->cmap, cmap_len, 0); info->pixmap.size = 8 * 1024; info->pixmap.buf_align = 4; info->pixmap.access_align = 32; info->pixmap.flags = FB_PIXMAP_SYSTEM; info->var.yres_virtual = -1; NVTRACE_LEAVE(); return (rivafb_check_var(&info->var, info)); } #ifdef CONFIG_PPC_OF static int __devinit riva_get_EDID_OF(struct fb_info *info, struct pci_dev *pd) { struct riva_par *par = info->par; struct device_node *dp; const unsigned char *pedid = NULL; const unsigned char *disptype = NULL; static char *propnames[] = { "DFP,EDID", "LCD,EDID", "EDID", "EDID1", "EDID,B", "EDID,A", NULL }; int i; NVTRACE_ENTER(); dp = pci_device_to_OF_node(pd); for (; dp != NULL; dp = dp->child) { disptype = of_get_property(dp, "display-type", NULL); if (disptype == NULL) continue; if (strncmp(disptype, "LCD", 3) != 0) continue; for (i = 0; propnames[i] != NULL; ++i) { pedid = of_get_property(dp, propnames[i], NULL); if (pedid != NULL) { par->EDID = (unsigned char *)pedid; NVTRACE("LCD found.\n"); return 1; } } } NVTRACE_LEAVE(); return 0; } #endif /* CONFIG_PPC_OF */ #if defined(CONFIG_FB_RIVA_I2C) && !defined(CONFIG_PPC_OF) static int __devinit riva_get_EDID_i2c(struct fb_info *info) { struct riva_par *par = info->par; struct fb_var_screeninfo var; int i; NVTRACE_ENTER(); riva_create_i2c_busses(par); for (i = 0; i < 3; i++) { if (!par->chan[i].par) continue; riva_probe_i2c_connector(par, i, &par->EDID); if (par->EDID && !fb_parse_edid(par->EDID, &var)) { printk(PFX "Found EDID Block from BUS %i\n", i); break; } } NVTRACE_LEAVE(); return (par->EDID) ? 1 : 0; } #endif /* CONFIG_FB_RIVA_I2C */ static void __devinit riva_update_default_var(struct fb_var_screeninfo *var, struct fb_info *info) { struct fb_monspecs *specs = &info->monspecs; struct fb_videomode modedb; NVTRACE_ENTER(); /* respect mode options */ if (mode_option) { fb_find_mode(var, info, mode_option, specs->modedb, specs->modedb_len, NULL, 8); } else if (specs->modedb != NULL) { /* get preferred timing */ if (info->monspecs.misc & FB_MISC_1ST_DETAIL) { int i; for (i = 0; i < specs->modedb_len; i++) { if (specs->modedb[i].flag & FB_MODE_IS_FIRST) { modedb = specs->modedb[i]; break; } } } else { /* otherwise, get first mode in database */ modedb = specs->modedb[0]; } var->bits_per_pixel = 8; riva_update_var(var, &modedb); } NVTRACE_LEAVE(); } static void __devinit riva_get_EDID(struct fb_info *info, struct pci_dev *pdev) { NVTRACE_ENTER(); #ifdef CONFIG_PPC_OF if (!riva_get_EDID_OF(info, pdev)) printk(PFX "could not retrieve EDID from OF\n"); #elif defined(CONFIG_FB_RIVA_I2C) if (!riva_get_EDID_i2c(info)) printk(PFX "could not retrieve EDID from DDC/I2C\n"); #endif NVTRACE_LEAVE(); } static void __devinit riva_get_edidinfo(struct fb_info *info) { struct fb_var_screeninfo *var = &rivafb_default_var; struct riva_par *par = info->par; fb_edid_to_monspecs(par->EDID, &info->monspecs); fb_videomode_to_modelist(info->monspecs.modedb, info->monspecs.modedb_len, &info->modelist); riva_update_default_var(var, info); /* if user specified flatpanel, we respect that */ if (info->monspecs.input & FB_DISP_DDI) par->FlatPanel = 1; } /* ------------------------------------------------------------------------- * * * PCI bus * * ------------------------------------------------------------------------- */ static u32 __devinit riva_get_arch(struct pci_dev *pd) { u32 arch = 0; switch (pd->device & 0x0ff0) { case 0x0100: /* GeForce 256 */ case 0x0110: /* GeForce2 MX */ case 0x0150: /* GeForce2 */ case 0x0170: /* GeForce4 MX */ case 0x0180: /* GeForce4 MX (8x AGP) */ case 0x01A0: /* nForce */ case 0x01F0: /* nForce2 */ arch = NV_ARCH_10; break; case 0x0200: /* GeForce3 */ case 0x0250: /* GeForce4 Ti */ case 0x0280: /* GeForce4 Ti (8x AGP) */ arch = NV_ARCH_20; break; case 0x0300: /* GeForceFX 5800 */ case 0x0310: /* GeForceFX 5600 */ case 0x0320: /* GeForceFX 5200 */ case 0x0330: /* GeForceFX 5900 */ case 0x0340: /* GeForceFX 5700 */ arch = NV_ARCH_30; break; case 0x0020: /* TNT, TNT2 */ arch = NV_ARCH_04; break; case 0x0010: /* Riva128 */ arch = NV_ARCH_03; break; default: /* unknown architecture */ break; } return arch; } static int __devinit rivafb_probe(struct pci_dev *pd, const struct pci_device_id *ent) { struct riva_par *default_par; struct fb_info *info; int ret; NVTRACE_ENTER(); assert(pd != NULL); info = framebuffer_alloc(sizeof(struct riva_par), &pd->dev); if (!info) { printk (KERN_ERR PFX "could not allocate memory\n"); ret = -ENOMEM; goto err_ret; } default_par = info->par; default_par->pdev = pd; info->pixmap.addr = kzalloc(8 * 1024, GFP_KERNEL); if (info->pixmap.addr == NULL) { ret = -ENOMEM; goto err_framebuffer_release; } ret = pci_enable_device(pd); if (ret < 0) { printk(KERN_ERR PFX "cannot enable PCI device\n"); goto err_free_pixmap; } ret = pci_request_regions(pd, "rivafb"); if (ret < 0) { printk(KERN_ERR PFX "cannot request PCI regions\n"); goto err_disable_device; } mutex_init(&default_par->open_lock); default_par->riva.Architecture = riva_get_arch(pd); default_par->Chipset = (pd->vendor << 16) | pd->device; printk(KERN_INFO PFX "nVidia device/chipset %X\n",default_par->Chipset); if(default_par->riva.Architecture == 0) { printk(KERN_ERR PFX "unknown NV_ARCH\n"); ret=-ENODEV; goto err_release_region; } if(default_par->riva.Architecture == NV_ARCH_10 || default_par->riva.Architecture == NV_ARCH_20 || default_par->riva.Architecture == NV_ARCH_30) { sprintf(rivafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4); } else { sprintf(rivafb_fix.id, "NV%x", default_par->riva.Architecture); } default_par->FlatPanel = flatpanel; if (flatpanel == 1) printk(KERN_INFO PFX "flatpanel support enabled\n"); default_par->forceCRTC = forceCRTC; rivafb_fix.mmio_len = pci_resource_len(pd, 0); rivafb_fix.smem_len = pci_resource_len(pd, 1); { /* enable IO and mem if not already done */ unsigned short cmd; pci_read_config_word(pd, PCI_COMMAND, &cmd); cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY); pci_write_config_word(pd, PCI_COMMAND, cmd); } rivafb_fix.mmio_start = pci_resource_start(pd, 0); rivafb_fix.smem_start = pci_resource_start(pd, 1); default_par->ctrl_base = ioremap(rivafb_fix.mmio_start, rivafb_fix.mmio_len); if (!default_par->ctrl_base) { printk(KERN_ERR PFX "cannot ioremap MMIO base\n"); ret = -EIO; goto err_release_region; } switch (default_par->riva.Architecture) { case NV_ARCH_03: /* Riva128's PRAMIN is in the "framebuffer" space * Since these cards were never made with more than 8 megabytes * we can safely allocate this separately. */ default_par->riva.PRAMIN = ioremap(rivafb_fix.smem_start + 0x00C00000, 0x00008000); if (!default_par->riva.PRAMIN) { printk(KERN_ERR PFX "cannot ioremap PRAMIN region\n"); ret = -EIO; goto err_iounmap_ctrl_base; } break; case NV_ARCH_04: case NV_ARCH_10: case NV_ARCH_20: case NV_ARCH_30: default_par->riva.PCRTC0 = (u32 __iomem *)(default_par->ctrl_base + 0x00600000); default_par->riva.PRAMIN = (u32 __iomem *)(default_par->ctrl_base + 0x00710000); break; } riva_common_setup(default_par); if (default_par->riva.Architecture == NV_ARCH_03) { default_par->riva.PCRTC = default_par->riva.PCRTC0 = default_par->riva.PGRAPH; } rivafb_fix.smem_len = riva_get_memlen(default_par) * 1024; default_par->dclk_max = riva_get_maxdclk(default_par) * 1000; info->screen_base = ioremap(rivafb_fix.smem_start, rivafb_fix.smem_len); if (!info->screen_base) { printk(KERN_ERR PFX "cannot ioremap FB base\n"); ret = -EIO; goto err_iounmap_pramin; } #ifdef CONFIG_MTRR if (!nomtrr) { default_par->mtrr.vram = mtrr_add(rivafb_fix.smem_start, rivafb_fix.smem_len, MTRR_TYPE_WRCOMB, 1); if (default_par->mtrr.vram < 0) { printk(KERN_ERR PFX "unable to setup MTRR\n"); } else { default_par->mtrr.vram_valid = 1; /* let there be speed */ printk(KERN_INFO PFX "RIVA MTRR set to ON\n"); } } #endif /* CONFIG_MTRR */ info->fbops = &riva_fb_ops; info->fix = rivafb_fix; riva_get_EDID(info, pd); riva_get_edidinfo(info); ret=riva_set_fbinfo(info); if (ret < 0) { printk(KERN_ERR PFX "error setting initial video mode\n"); goto err_iounmap_screen_base; } fb_destroy_modedb(info->monspecs.modedb); info->monspecs.modedb = NULL; pci_set_drvdata(pd, info); if (backlight) riva_bl_init(info->par); ret = register_framebuffer(info); if (ret < 0) { printk(KERN_ERR PFX "error registering riva framebuffer\n"); goto err_iounmap_screen_base; } printk(KERN_INFO PFX "PCI nVidia %s framebuffer ver %s (%dMB @ 0x%lX)\n", info->fix.id, RIVAFB_VERSION, info->fix.smem_len / (1024 * 1024), info->fix.smem_start); NVTRACE_LEAVE(); return 0; err_iounmap_screen_base: #ifdef CONFIG_FB_RIVA_I2C riva_delete_i2c_busses(info->par); #endif iounmap(info->screen_base); err_iounmap_pramin: if (default_par->riva.Architecture == NV_ARCH_03) iounmap(default_par->riva.PRAMIN); err_iounmap_ctrl_base: iounmap(default_par->ctrl_base); err_release_region: pci_release_regions(pd); err_disable_device: err_free_pixmap: kfree(info->pixmap.addr); err_framebuffer_release: framebuffer_release(info); err_ret: return ret; } static void __devexit rivafb_remove(struct pci_dev *pd) { struct fb_info *info = pci_get_drvdata(pd); struct riva_par *par = info->par; NVTRACE_ENTER(); #ifdef CONFIG_FB_RIVA_I2C riva_delete_i2c_busses(par); kfree(par->EDID); #endif unregister_framebuffer(info); riva_bl_exit(info); #ifdef CONFIG_MTRR if (par->mtrr.vram_valid) mtrr_del(par->mtrr.vram, info->fix.smem_start, info->fix.smem_len); #endif /* CONFIG_MTRR */ iounmap(par->ctrl_base); iounmap(info->screen_base); if (par->riva.Architecture == NV_ARCH_03) iounmap(par->riva.PRAMIN); pci_release_regions(pd); kfree(info->pixmap.addr); framebuffer_release(info); pci_set_drvdata(pd, NULL); NVTRACE_LEAVE(); } /* ------------------------------------------------------------------------- * * * initialization * * ------------------------------------------------------------------------- */ #ifndef MODULE static int __devinit rivafb_setup(char *options) { char *this_opt; NVTRACE_ENTER(); if (!options || !*options) return 0; while ((this_opt = strsep(&options, ",")) != NULL) { if (!strncmp(this_opt, "forceCRTC", 9)) { char *p; p = this_opt + 9; if (!*p || !*(++p)) continue; forceCRTC = *p - '0'; if (forceCRTC < 0 || forceCRTC > 1) forceCRTC = -1; } else if (!strncmp(this_opt, "flatpanel", 9)) { flatpanel = 1; } else if (!strncmp(this_opt, "backlight:", 10)) { backlight = simple_strtoul(this_opt+10, NULL, 0); #ifdef CONFIG_MTRR } else if (!strncmp(this_opt, "nomtrr", 6)) { nomtrr = 1; #endif } else if (!strncmp(this_opt, "strictmode", 10)) { strictmode = 1; } else if (!strncmp(this_opt, "noaccel", 7)) { noaccel = 1; } else mode_option = this_opt; } NVTRACE_LEAVE(); return 0; } #endif /* !MODULE */ static struct pci_driver rivafb_driver = { .name = "rivafb", .id_table = rivafb_pci_tbl, .probe = rivafb_probe, .remove = __devexit_p(rivafb_remove), }; /* ------------------------------------------------------------------------- * * * modularization * * ------------------------------------------------------------------------- */ static int __devinit rivafb_init(void) { #ifndef MODULE char *option = NULL; if (fb_get_options("rivafb", &option)) return -ENODEV; rivafb_setup(option); #endif return pci_register_driver(&rivafb_driver); } module_init(rivafb_init); static void __exit rivafb_exit(void) { pci_unregister_driver(&rivafb_driver); } module_exit(rivafb_exit); module_param(noaccel, bool, 0); MODULE_PARM_DESC(noaccel, "bool: disable acceleration"); module_param(flatpanel, int, 0); MODULE_PARM_DESC(flatpanel, "Enables experimental flat panel support for some chipsets. (0 or 1=enabled) (default=0)"); module_param(forceCRTC, int, 0); MODULE_PARM_DESC(forceCRTC, "Forces usage of a particular CRTC in case autodetection fails. (0 or 1) (default=autodetect)"); #ifdef CONFIG_MTRR module_param(nomtrr, bool, 0); MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) (default=0)"); #endif module_param(strictmode, bool, 0); MODULE_PARM_DESC(strictmode, "Only use video modes from EDID"); MODULE_AUTHOR("Ani Joshi, maintainer"); MODULE_DESCRIPTION("Framebuffer driver for nVidia Riva 128, TNT, TNT2, and the GeForce series"); MODULE_LICENSE("GPL");
gpl-2.0
caplio/android_kernel_samsung_hltedcm
drivers/of/of_slimbus.c
1208
2276
/* 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. */ /* OF helpers for SLIMbus */ #include <linux/slimbus/slimbus.h> #include <linux/irq.h> #include <linux/slab.h> #include <linux/of.h> #include <linux/of_irq.h> #include <linux/of_slimbus.h> int of_register_slim_devices(struct slim_controller *ctrl) { struct device_node *node; struct slim_boardinfo *binfo = NULL; int n = 0; int ret = 0; if (!ctrl->dev.of_node) return -EINVAL; for_each_child_of_node(ctrl->dev.of_node, node) { struct property *prop; struct slim_device *slim; char *name; prop = of_find_property(node, "elemental-addr", NULL); if (!prop || prop->length != 6) { dev_err(&ctrl->dev, "of_slim: invalid E-addr"); continue; } name = kzalloc(SLIMBUS_NAME_SIZE, GFP_KERNEL); if (!name) { dev_err(&ctrl->dev, "of_slim: out of memory"); ret = -ENOMEM; goto of_slim_err; } if (of_modalias_node(node, name, SLIMBUS_NAME_SIZE) < 0) { dev_err(&ctrl->dev, "of_slim: modalias failure on %s\n", node->full_name); kfree(name); continue; } slim = kzalloc(sizeof(struct slim_device), GFP_KERNEL); if (!slim) { dev_err(&ctrl->dev, "of_slim: out of memory"); ret = -ENOMEM; kfree(name); goto of_slim_err; } memcpy(slim->e_addr, prop->value, 6); binfo = krealloc(binfo, (n + 1) * sizeof(struct slim_boardinfo), GFP_KERNEL); if (!binfo) { dev_err(&ctrl->dev, "out of memory"); kfree(name); kfree(slim); return -ENOMEM; } slim->dev.of_node = of_node_get(node); slim->name = (const char *)name; binfo[n].bus_num = ctrl->nr; binfo[n].slim_slave = slim; n++; } return slim_register_board_info(binfo, n); of_slim_err: n--; while (n >= 0) { kfree(binfo[n].slim_slave->name); kfree(binfo[n].slim_slave); } kfree(binfo); return ret; }
gpl-2.0
mgottschlag/linux
drivers/video/backlight/backlight.c
1464
16071
/* * Backlight Lowlevel Control Abstraction * * Copyright (C) 2003,2004 Hewlett-Packard Company * */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> #include <linux/init.h> #include <linux/device.h> #include <linux/backlight.h> #include <linux/notifier.h> #include <linux/ctype.h> #include <linux/err.h> #include <linux/fb.h> #include <linux/slab.h> #ifdef CONFIG_PMAC_BACKLIGHT #include <asm/backlight.h> #endif static struct list_head backlight_dev_list; static struct mutex backlight_dev_list_mutex; static struct blocking_notifier_head backlight_notifier; static const char *const backlight_types[] = { [BACKLIGHT_RAW] = "raw", [BACKLIGHT_PLATFORM] = "platform", [BACKLIGHT_FIRMWARE] = "firmware", }; #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)) /* This callback gets called when something important happens inside a * framebuffer driver. We're looking if that important event is blanking, * and if it is and necessary, we're switching backlight power as well ... */ static int fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data) { struct backlight_device *bd; struct fb_event *evdata = data; int node = evdata->info->node; int fb_blank = 0; /* If we aren't interested in this event, skip it immediately ... */ if (event != FB_EVENT_BLANK && event != FB_EVENT_CONBLANK) return 0; bd = container_of(self, struct backlight_device, fb_notif); mutex_lock(&bd->ops_lock); if (bd->ops) if (!bd->ops->check_fb || bd->ops->check_fb(bd, evdata->info)) { fb_blank = *(int *)evdata->data; if (fb_blank == FB_BLANK_UNBLANK && !bd->fb_bl_on[node]) { bd->fb_bl_on[node] = true; if (!bd->use_count++) { bd->props.state &= ~BL_CORE_FBBLANK; bd->props.fb_blank = FB_BLANK_UNBLANK; backlight_update_status(bd); } } else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) { bd->fb_bl_on[node] = false; if (!(--bd->use_count)) { bd->props.state |= BL_CORE_FBBLANK; bd->props.fb_blank = fb_blank; backlight_update_status(bd); } } } mutex_unlock(&bd->ops_lock); return 0; } static int backlight_register_fb(struct backlight_device *bd) { memset(&bd->fb_notif, 0, sizeof(bd->fb_notif)); bd->fb_notif.notifier_call = fb_notifier_callback; return fb_register_client(&bd->fb_notif); } static void backlight_unregister_fb(struct backlight_device *bd) { fb_unregister_client(&bd->fb_notif); } #else static inline int backlight_register_fb(struct backlight_device *bd) { return 0; } static inline void backlight_unregister_fb(struct backlight_device *bd) { } #endif /* CONFIG_FB */ static void backlight_generate_event(struct backlight_device *bd, enum backlight_update_reason reason) { char *envp[2]; switch (reason) { case BACKLIGHT_UPDATE_SYSFS: envp[0] = "SOURCE=sysfs"; break; case BACKLIGHT_UPDATE_HOTKEY: envp[0] = "SOURCE=hotkey"; break; default: envp[0] = "SOURCE=unknown"; break; } envp[1] = NULL; kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp); sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness"); } static ssize_t bl_power_show(struct device *dev, struct device_attribute *attr, char *buf) { struct backlight_device *bd = to_backlight_device(dev); return sprintf(buf, "%d\n", bd->props.power); } static ssize_t bl_power_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int rc; struct backlight_device *bd = to_backlight_device(dev); unsigned long power; rc = kstrtoul(buf, 0, &power); if (rc) return rc; rc = -ENXIO; mutex_lock(&bd->ops_lock); if (bd->ops) { pr_debug("set power to %lu\n", power); if (bd->props.power != power) { bd->props.power = power; backlight_update_status(bd); } rc = count; } mutex_unlock(&bd->ops_lock); return rc; } static DEVICE_ATTR_RW(bl_power); static ssize_t brightness_show(struct device *dev, struct device_attribute *attr, char *buf) { struct backlight_device *bd = to_backlight_device(dev); return sprintf(buf, "%d\n", bd->props.brightness); } static ssize_t brightness_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int rc; struct backlight_device *bd = to_backlight_device(dev); unsigned long brightness; rc = kstrtoul(buf, 0, &brightness); if (rc) return rc; rc = -ENXIO; mutex_lock(&bd->ops_lock); if (bd->ops) { if (brightness > bd->props.max_brightness) rc = -EINVAL; else { pr_debug("set brightness to %lu\n", brightness); bd->props.brightness = brightness; backlight_update_status(bd); rc = count; } } mutex_unlock(&bd->ops_lock); backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS); return rc; } static DEVICE_ATTR_RW(brightness); static ssize_t type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct backlight_device *bd = to_backlight_device(dev); return sprintf(buf, "%s\n", backlight_types[bd->props.type]); } static DEVICE_ATTR_RO(type); static ssize_t max_brightness_show(struct device *dev, struct device_attribute *attr, char *buf) { struct backlight_device *bd = to_backlight_device(dev); return sprintf(buf, "%d\n", bd->props.max_brightness); } static DEVICE_ATTR_RO(max_brightness); static ssize_t actual_brightness_show(struct device *dev, struct device_attribute *attr, char *buf) { int rc = -ENXIO; struct backlight_device *bd = to_backlight_device(dev); mutex_lock(&bd->ops_lock); if (bd->ops && bd->ops->get_brightness) rc = sprintf(buf, "%d\n", bd->ops->get_brightness(bd)); else rc = sprintf(buf, "%d\n", bd->props.brightness); mutex_unlock(&bd->ops_lock); return rc; } static DEVICE_ATTR_RO(actual_brightness); static struct class *backlight_class; #ifdef CONFIG_PM_SLEEP static int backlight_suspend(struct device *dev) { struct backlight_device *bd = to_backlight_device(dev); mutex_lock(&bd->ops_lock); if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { bd->props.state |= BL_CORE_SUSPENDED; backlight_update_status(bd); } mutex_unlock(&bd->ops_lock); return 0; } static int backlight_resume(struct device *dev) { struct backlight_device *bd = to_backlight_device(dev); mutex_lock(&bd->ops_lock); if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { bd->props.state &= ~BL_CORE_SUSPENDED; backlight_update_status(bd); } mutex_unlock(&bd->ops_lock); return 0; } #endif static SIMPLE_DEV_PM_OPS(backlight_class_dev_pm_ops, backlight_suspend, backlight_resume); static void bl_device_release(struct device *dev) { struct backlight_device *bd = to_backlight_device(dev); kfree(bd); } static struct attribute *bl_device_attrs[] = { &dev_attr_bl_power.attr, &dev_attr_brightness.attr, &dev_attr_actual_brightness.attr, &dev_attr_max_brightness.attr, &dev_attr_type.attr, NULL, }; ATTRIBUTE_GROUPS(bl_device); /** * backlight_force_update - tell the backlight subsystem that hardware state * has changed * @bd: the backlight device to update * * Updates the internal state of the backlight in response to a hardware event, * and generate a uevent to notify userspace */ void backlight_force_update(struct backlight_device *bd, enum backlight_update_reason reason) { mutex_lock(&bd->ops_lock); if (bd->ops && bd->ops->get_brightness) bd->props.brightness = bd->ops->get_brightness(bd); mutex_unlock(&bd->ops_lock); backlight_generate_event(bd, reason); } EXPORT_SYMBOL(backlight_force_update); /** * backlight_device_register - create and register a new object of * backlight_device class. * @name: the name of the new object(must be the same as the name of the * respective framebuffer device). * @parent: a pointer to the parent device * @devdata: an optional pointer to be stored for private driver use. The * methods may retrieve it by using bl_get_data(bd). * @ops: the backlight operations structure. * * Creates and registers new backlight device. Returns either an * ERR_PTR() or a pointer to the newly allocated device. */ struct backlight_device *backlight_device_register(const char *name, struct device *parent, void *devdata, const struct backlight_ops *ops, const struct backlight_properties *props) { struct backlight_device *new_bd; int rc; pr_debug("backlight_device_register: name=%s\n", name); new_bd = kzalloc(sizeof(struct backlight_device), GFP_KERNEL); if (!new_bd) return ERR_PTR(-ENOMEM); mutex_init(&new_bd->update_lock); mutex_init(&new_bd->ops_lock); new_bd->dev.class = backlight_class; new_bd->dev.parent = parent; new_bd->dev.release = bl_device_release; dev_set_name(&new_bd->dev, "%s", name); dev_set_drvdata(&new_bd->dev, devdata); /* Set default properties */ if (props) { memcpy(&new_bd->props, props, sizeof(struct backlight_properties)); if (props->type <= 0 || props->type >= BACKLIGHT_TYPE_MAX) { WARN(1, "%s: invalid backlight type", name); new_bd->props.type = BACKLIGHT_RAW; } } else { new_bd->props.type = BACKLIGHT_RAW; } rc = device_register(&new_bd->dev); if (rc) { put_device(&new_bd->dev); return ERR_PTR(rc); } rc = backlight_register_fb(new_bd); if (rc) { device_unregister(&new_bd->dev); return ERR_PTR(rc); } new_bd->ops = ops; #ifdef CONFIG_PMAC_BACKLIGHT mutex_lock(&pmac_backlight_mutex); if (!pmac_backlight) pmac_backlight = new_bd; mutex_unlock(&pmac_backlight_mutex); #endif mutex_lock(&backlight_dev_list_mutex); list_add(&new_bd->entry, &backlight_dev_list); mutex_unlock(&backlight_dev_list_mutex); blocking_notifier_call_chain(&backlight_notifier, BACKLIGHT_REGISTERED, new_bd); return new_bd; } EXPORT_SYMBOL(backlight_device_register); bool backlight_device_registered(enum backlight_type type) { bool found = false; struct backlight_device *bd; mutex_lock(&backlight_dev_list_mutex); list_for_each_entry(bd, &backlight_dev_list, entry) { if (bd->props.type == type) { found = true; break; } } mutex_unlock(&backlight_dev_list_mutex); return found; } EXPORT_SYMBOL(backlight_device_registered); /** * backlight_device_unregister - unregisters a backlight device object. * @bd: the backlight device object to be unregistered and freed. * * Unregisters a previously registered via backlight_device_register object. */ void backlight_device_unregister(struct backlight_device *bd) { if (!bd) return; mutex_lock(&backlight_dev_list_mutex); list_del(&bd->entry); mutex_unlock(&backlight_dev_list_mutex); #ifdef CONFIG_PMAC_BACKLIGHT mutex_lock(&pmac_backlight_mutex); if (pmac_backlight == bd) pmac_backlight = NULL; mutex_unlock(&pmac_backlight_mutex); #endif blocking_notifier_call_chain(&backlight_notifier, BACKLIGHT_UNREGISTERED, bd); mutex_lock(&bd->ops_lock); bd->ops = NULL; mutex_unlock(&bd->ops_lock); backlight_unregister_fb(bd); device_unregister(&bd->dev); } EXPORT_SYMBOL(backlight_device_unregister); static void devm_backlight_device_release(struct device *dev, void *res) { struct backlight_device *backlight = *(struct backlight_device **)res; backlight_device_unregister(backlight); } static int devm_backlight_device_match(struct device *dev, void *res, void *data) { struct backlight_device **r = res; return *r == data; } /** * backlight_register_notifier - get notified of backlight (un)registration * @nb: notifier block with the notifier to call on backlight (un)registration * * @return 0 on success, otherwise a negative error code * * Register a notifier to get notified when backlight devices get registered * or unregistered. */ int backlight_register_notifier(struct notifier_block *nb) { return blocking_notifier_chain_register(&backlight_notifier, nb); } EXPORT_SYMBOL(backlight_register_notifier); /** * backlight_unregister_notifier - unregister a backlight notifier * @nb: notifier block to unregister * * @return 0 on success, otherwise a negative error code * * Register a notifier to get notified when backlight devices get registered * or unregistered. */ int backlight_unregister_notifier(struct notifier_block *nb) { return blocking_notifier_chain_unregister(&backlight_notifier, nb); } EXPORT_SYMBOL(backlight_unregister_notifier); /** * devm_backlight_device_register - resource managed backlight_device_register() * @dev: the device to register * @name: the name of the device * @parent: a pointer to the parent device * @devdata: an optional pointer to be stored for private driver use * @ops: the backlight operations structure * @props: the backlight properties * * @return a struct backlight on success, or an ERR_PTR on error * * Managed backlight_device_register(). The backlight_device returned * from this function are automatically freed on driver detach. * See backlight_device_register() for more information. */ struct backlight_device *devm_backlight_device_register(struct device *dev, const char *name, struct device *parent, void *devdata, const struct backlight_ops *ops, const struct backlight_properties *props) { struct backlight_device **ptr, *backlight; ptr = devres_alloc(devm_backlight_device_release, sizeof(*ptr), GFP_KERNEL); if (!ptr) return ERR_PTR(-ENOMEM); backlight = backlight_device_register(name, parent, devdata, ops, props); if (!IS_ERR(backlight)) { *ptr = backlight; devres_add(dev, ptr); } else { devres_free(ptr); } return backlight; } EXPORT_SYMBOL(devm_backlight_device_register); /** * devm_backlight_device_unregister - resource managed backlight_device_unregister() * @dev: the device to unregister * @bd: the backlight device to unregister * * Deallocated a backlight allocated with devm_backlight_device_register(). * Normally this function will not need to be called and the resource management * code will ensure that the resource is freed. */ void devm_backlight_device_unregister(struct device *dev, struct backlight_device *bd) { int rc; rc = devres_release(dev, devm_backlight_device_release, devm_backlight_device_match, bd); WARN_ON(rc); } EXPORT_SYMBOL(devm_backlight_device_unregister); #ifdef CONFIG_OF static int of_parent_match(struct device *dev, const void *data) { return dev->parent && dev->parent->of_node == data; } /** * of_find_backlight_by_node() - find backlight device by device-tree node * @node: device-tree node of the backlight device * * Returns a pointer to the backlight device corresponding to the given DT * node or NULL if no such backlight device exists or if the device hasn't * been probed yet. * * This function obtains a reference on the backlight device and it is the * caller's responsibility to drop the reference by calling put_device() on * the backlight device's .dev field. */ struct backlight_device *of_find_backlight_by_node(struct device_node *node) { struct device *dev; dev = class_find_device(backlight_class, NULL, node, of_parent_match); return dev ? to_backlight_device(dev) : NULL; } EXPORT_SYMBOL(of_find_backlight_by_node); #endif static void __exit backlight_class_exit(void) { class_destroy(backlight_class); } static int __init backlight_class_init(void) { backlight_class = class_create(THIS_MODULE, "backlight"); if (IS_ERR(backlight_class)) { pr_warn("Unable to create backlight class; errno = %ld\n", PTR_ERR(backlight_class)); return PTR_ERR(backlight_class); } backlight_class->dev_groups = bl_device_groups; backlight_class->pm = &backlight_class_dev_pm_ops; INIT_LIST_HEAD(&backlight_dev_list); mutex_init(&backlight_dev_list_mutex); BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier); return 0; } /* * if this is compiled into the kernel, we need to ensure that the * class is registered before users of the class try to register lcd's */ postcore_initcall(backlight_class_init); module_exit(backlight_class_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Jamey Hicks <jamey.hicks@hp.com>, Andrew Zabolotny <zap@homelink.ru>"); MODULE_DESCRIPTION("Backlight Lowlevel Control Abstraction");
gpl-2.0
leeymcj/linuxrk-tk1
drivers/memstick/core/mspro_block.c
1720
39961
/* * Sony MemoryStick Pro storage support * * Copyright (C) 2007 Alex Dubov <oakad@yahoo.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. * * Special thanks to Carlos Corbacho for providing various MemoryStick cards * that made this driver possible. * */ #include <linux/blkdev.h> #include <linux/idr.h> #include <linux/hdreg.h> #include <linux/kthread.h> #include <linux/delay.h> #include <linux/slab.h> #include <linux/mutex.h> #include <linux/memstick.h> #include <linux/module.h> #define DRIVER_NAME "mspro_block" static int major; module_param(major, int, 0644); #define MSPRO_BLOCK_MAX_SEGS 32 #define MSPRO_BLOCK_MAX_PAGES ((2 << 16) - 1) #define MSPRO_BLOCK_SIGNATURE 0xa5c3 #define MSPRO_BLOCK_MAX_ATTRIBUTES 41 #define MSPRO_BLOCK_PART_SHIFT 3 enum { MSPRO_BLOCK_ID_SYSINFO = 0x10, MSPRO_BLOCK_ID_MODELNAME = 0x15, MSPRO_BLOCK_ID_MBR = 0x20, MSPRO_BLOCK_ID_PBR16 = 0x21, MSPRO_BLOCK_ID_PBR32 = 0x22, MSPRO_BLOCK_ID_SPECFILEVALUES1 = 0x25, MSPRO_BLOCK_ID_SPECFILEVALUES2 = 0x26, MSPRO_BLOCK_ID_DEVINFO = 0x30 }; struct mspro_sys_attr { size_t size; void *data; unsigned char id; char name[32]; struct device_attribute dev_attr; }; struct mspro_attr_entry { __be32 address; __be32 size; unsigned char id; unsigned char reserved[3]; } __attribute__((packed)); struct mspro_attribute { __be16 signature; unsigned short version; unsigned char count; unsigned char reserved[11]; struct mspro_attr_entry entries[]; } __attribute__((packed)); struct mspro_sys_info { unsigned char class; unsigned char reserved0; __be16 block_size; __be16 block_count; __be16 user_block_count; __be16 page_size; unsigned char reserved1[2]; unsigned char assembly_date[8]; __be32 serial_number; unsigned char assembly_maker_code; unsigned char assembly_model_code[3]; __be16 memory_maker_code; __be16 memory_model_code; unsigned char reserved2[4]; unsigned char vcc; unsigned char vpp; __be16 controller_number; __be16 controller_function; __be16 start_sector; __be16 unit_size; unsigned char ms_sub_class; unsigned char reserved3[4]; unsigned char interface_type; __be16 controller_code; unsigned char format_type; unsigned char reserved4; unsigned char device_type; unsigned char reserved5[7]; unsigned char mspro_id[16]; unsigned char reserved6[16]; } __attribute__((packed)); struct mspro_mbr { unsigned char boot_partition; unsigned char start_head; unsigned char start_sector; unsigned char start_cylinder; unsigned char partition_type; unsigned char end_head; unsigned char end_sector; unsigned char end_cylinder; unsigned int start_sectors; unsigned int sectors_per_partition; } __attribute__((packed)); struct mspro_specfile { char name[8]; char ext[3]; unsigned char attr; unsigned char reserved[10]; unsigned short time; unsigned short date; unsigned short cluster; unsigned int size; } __attribute__((packed)); struct mspro_devinfo { __be16 cylinders; __be16 heads; __be16 bytes_per_track; __be16 bytes_per_sector; __be16 sectors_per_track; unsigned char reserved[6]; } __attribute__((packed)); struct mspro_block_data { struct memstick_dev *card; unsigned int usage_count; unsigned int caps; struct gendisk *disk; struct request_queue *queue; struct request *block_req; spinlock_t q_lock; unsigned short page_size; unsigned short cylinders; unsigned short heads; unsigned short sectors_per_track; unsigned char system; unsigned char read_only:1, eject:1, has_request:1, data_dir:1, active:1; unsigned char transfer_cmd; int (*mrq_handler)(struct memstick_dev *card, struct memstick_request **mrq); /* Default request setup function for data access method preferred by * this host instance. */ void (*setup_transfer)(struct memstick_dev *card, u64 offset, size_t length); struct attribute_group attr_group; struct scatterlist req_sg[MSPRO_BLOCK_MAX_SEGS]; unsigned int seg_count; unsigned int current_seg; unsigned int current_page; }; static DEFINE_IDR(mspro_block_disk_idr); static DEFINE_MUTEX(mspro_block_disk_lock); static int mspro_block_complete_req(struct memstick_dev *card, int error); /*** Block device ***/ static int mspro_block_bd_open(struct block_device *bdev, fmode_t mode) { struct gendisk *disk = bdev->bd_disk; struct mspro_block_data *msb = disk->private_data; int rc = -ENXIO; mutex_lock(&mspro_block_disk_lock); if (msb && msb->card) { msb->usage_count++; if ((mode & FMODE_WRITE) && msb->read_only) rc = -EROFS; else rc = 0; } mutex_unlock(&mspro_block_disk_lock); return rc; } static void mspro_block_disk_release(struct gendisk *disk) { struct mspro_block_data *msb = disk->private_data; int disk_id = MINOR(disk_devt(disk)) >> MSPRO_BLOCK_PART_SHIFT; mutex_lock(&mspro_block_disk_lock); if (msb) { if (msb->usage_count) msb->usage_count--; if (!msb->usage_count) { kfree(msb); disk->private_data = NULL; idr_remove(&mspro_block_disk_idr, disk_id); put_disk(disk); } } mutex_unlock(&mspro_block_disk_lock); } static void mspro_block_bd_release(struct gendisk *disk, fmode_t mode) { mspro_block_disk_release(disk); } static int mspro_block_bd_getgeo(struct block_device *bdev, struct hd_geometry *geo) { struct mspro_block_data *msb = bdev->bd_disk->private_data; geo->heads = msb->heads; geo->sectors = msb->sectors_per_track; geo->cylinders = msb->cylinders; return 0; } static const struct block_device_operations ms_block_bdops = { .open = mspro_block_bd_open, .release = mspro_block_bd_release, .getgeo = mspro_block_bd_getgeo, .owner = THIS_MODULE }; /*** Information ***/ static struct mspro_sys_attr *mspro_from_sysfs_attr(struct attribute *attr) { struct device_attribute *dev_attr = container_of(attr, struct device_attribute, attr); return container_of(dev_attr, struct mspro_sys_attr, dev_attr); } static const char *mspro_block_attr_name(unsigned char tag) { switch (tag) { case MSPRO_BLOCK_ID_SYSINFO: return "attr_sysinfo"; case MSPRO_BLOCK_ID_MODELNAME: return "attr_modelname"; case MSPRO_BLOCK_ID_MBR: return "attr_mbr"; case MSPRO_BLOCK_ID_PBR16: return "attr_pbr16"; case MSPRO_BLOCK_ID_PBR32: return "attr_pbr32"; case MSPRO_BLOCK_ID_SPECFILEVALUES1: return "attr_specfilevalues1"; case MSPRO_BLOCK_ID_SPECFILEVALUES2: return "attr_specfilevalues2"; case MSPRO_BLOCK_ID_DEVINFO: return "attr_devinfo"; default: return NULL; }; } typedef ssize_t (*sysfs_show_t)(struct device *dev, struct device_attribute *attr, char *buffer); static ssize_t mspro_block_attr_show_default(struct device *dev, struct device_attribute *attr, char *buffer) { struct mspro_sys_attr *s_attr = container_of(attr, struct mspro_sys_attr, dev_attr); ssize_t cnt, rc = 0; for (cnt = 0; cnt < s_attr->size; cnt++) { if (cnt && !(cnt % 16)) { if (PAGE_SIZE - rc) buffer[rc++] = '\n'; } rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "%02x ", ((unsigned char *)s_attr->data)[cnt]); } return rc; } static ssize_t mspro_block_attr_show_sysinfo(struct device *dev, struct device_attribute *attr, char *buffer) { struct mspro_sys_attr *x_attr = container_of(attr, struct mspro_sys_attr, dev_attr); struct mspro_sys_info *x_sys = x_attr->data; ssize_t rc = 0; int date_tz = 0, date_tz_f = 0; if (x_sys->assembly_date[0] > 0x80U) { date_tz = (~x_sys->assembly_date[0]) + 1; date_tz_f = date_tz & 3; date_tz >>= 2; date_tz = -date_tz; date_tz_f *= 15; } else if (x_sys->assembly_date[0] < 0x80U) { date_tz = x_sys->assembly_date[0]; date_tz_f = date_tz & 3; date_tz >>= 2; date_tz_f *= 15; } rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "class: %x\n", x_sys->class); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "block size: %x\n", be16_to_cpu(x_sys->block_size)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "block count: %x\n", be16_to_cpu(x_sys->block_count)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "user block count: %x\n", be16_to_cpu(x_sys->user_block_count)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "page size: %x\n", be16_to_cpu(x_sys->page_size)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "assembly date: " "GMT%+d:%d %04u-%02u-%02u %02u:%02u:%02u\n", date_tz, date_tz_f, be16_to_cpup((__be16 *)&x_sys->assembly_date[1]), x_sys->assembly_date[3], x_sys->assembly_date[4], x_sys->assembly_date[5], x_sys->assembly_date[6], x_sys->assembly_date[7]); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "serial number: %x\n", be32_to_cpu(x_sys->serial_number)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "assembly maker code: %x\n", x_sys->assembly_maker_code); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "assembly model code: " "%02x%02x%02x\n", x_sys->assembly_model_code[0], x_sys->assembly_model_code[1], x_sys->assembly_model_code[2]); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "memory maker code: %x\n", be16_to_cpu(x_sys->memory_maker_code)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "memory model code: %x\n", be16_to_cpu(x_sys->memory_model_code)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "vcc: %x\n", x_sys->vcc); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "vpp: %x\n", x_sys->vpp); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "controller number: %x\n", be16_to_cpu(x_sys->controller_number)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "controller function: %x\n", be16_to_cpu(x_sys->controller_function)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start sector: %x\n", be16_to_cpu(x_sys->start_sector)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "unit size: %x\n", be16_to_cpu(x_sys->unit_size)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "sub class: %x\n", x_sys->ms_sub_class); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "interface type: %x\n", x_sys->interface_type); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "controller code: %x\n", be16_to_cpu(x_sys->controller_code)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "format type: %x\n", x_sys->format_type); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "device type: %x\n", x_sys->device_type); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "mspro id: %s\n", x_sys->mspro_id); return rc; } static ssize_t mspro_block_attr_show_modelname(struct device *dev, struct device_attribute *attr, char *buffer) { struct mspro_sys_attr *s_attr = container_of(attr, struct mspro_sys_attr, dev_attr); return scnprintf(buffer, PAGE_SIZE, "%s", (char *)s_attr->data); } static ssize_t mspro_block_attr_show_mbr(struct device *dev, struct device_attribute *attr, char *buffer) { struct mspro_sys_attr *x_attr = container_of(attr, struct mspro_sys_attr, dev_attr); struct mspro_mbr *x_mbr = x_attr->data; ssize_t rc = 0; rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "boot partition: %x\n", x_mbr->boot_partition); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start head: %x\n", x_mbr->start_head); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start sector: %x\n", x_mbr->start_sector); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start cylinder: %x\n", x_mbr->start_cylinder); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "partition type: %x\n", x_mbr->partition_type); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "end head: %x\n", x_mbr->end_head); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "end sector: %x\n", x_mbr->end_sector); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "end cylinder: %x\n", x_mbr->end_cylinder); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start sectors: %x\n", x_mbr->start_sectors); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "sectors per partition: %x\n", x_mbr->sectors_per_partition); return rc; } static ssize_t mspro_block_attr_show_specfile(struct device *dev, struct device_attribute *attr, char *buffer) { struct mspro_sys_attr *x_attr = container_of(attr, struct mspro_sys_attr, dev_attr); struct mspro_specfile *x_spfile = x_attr->data; char name[9], ext[4]; ssize_t rc = 0; memcpy(name, x_spfile->name, 8); name[8] = 0; memcpy(ext, x_spfile->ext, 3); ext[3] = 0; rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "name: %s\n", name); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "ext: %s\n", ext); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "attribute: %x\n", x_spfile->attr); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "time: %d:%d:%d\n", x_spfile->time >> 11, (x_spfile->time >> 5) & 0x3f, (x_spfile->time & 0x1f) * 2); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "date: %d-%d-%d\n", (x_spfile->date >> 9) + 1980, (x_spfile->date >> 5) & 0xf, x_spfile->date & 0x1f); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start cluster: %x\n", x_spfile->cluster); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "size: %x\n", x_spfile->size); return rc; } static ssize_t mspro_block_attr_show_devinfo(struct device *dev, struct device_attribute *attr, char *buffer) { struct mspro_sys_attr *x_attr = container_of(attr, struct mspro_sys_attr, dev_attr); struct mspro_devinfo *x_devinfo = x_attr->data; ssize_t rc = 0; rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "cylinders: %x\n", be16_to_cpu(x_devinfo->cylinders)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "heads: %x\n", be16_to_cpu(x_devinfo->heads)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "bytes per track: %x\n", be16_to_cpu(x_devinfo->bytes_per_track)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "bytes per sector: %x\n", be16_to_cpu(x_devinfo->bytes_per_sector)); rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "sectors per track: %x\n", be16_to_cpu(x_devinfo->sectors_per_track)); return rc; } static sysfs_show_t mspro_block_attr_show(unsigned char tag) { switch (tag) { case MSPRO_BLOCK_ID_SYSINFO: return mspro_block_attr_show_sysinfo; case MSPRO_BLOCK_ID_MODELNAME: return mspro_block_attr_show_modelname; case MSPRO_BLOCK_ID_MBR: return mspro_block_attr_show_mbr; case MSPRO_BLOCK_ID_SPECFILEVALUES1: case MSPRO_BLOCK_ID_SPECFILEVALUES2: return mspro_block_attr_show_specfile; case MSPRO_BLOCK_ID_DEVINFO: return mspro_block_attr_show_devinfo; default: return mspro_block_attr_show_default; } } /*** Protocol handlers ***/ /* * Functions prefixed with "h_" are protocol callbacks. They can be called from * interrupt context. Return value of 0 means that request processing is still * ongoing, while special error value of -EAGAIN means that current request is * finished (and request processor should come back some time later). */ static int h_mspro_block_req_init(struct memstick_dev *card, struct memstick_request **mrq) { struct mspro_block_data *msb = memstick_get_drvdata(card); *mrq = &card->current_mrq; card->next_request = msb->mrq_handler; return 0; } static int h_mspro_block_default(struct memstick_dev *card, struct memstick_request **mrq) { return mspro_block_complete_req(card, (*mrq)->error); } static int h_mspro_block_default_bad(struct memstick_dev *card, struct memstick_request **mrq) { return -ENXIO; } static int h_mspro_block_get_ro(struct memstick_dev *card, struct memstick_request **mrq) { struct mspro_block_data *msb = memstick_get_drvdata(card); if (!(*mrq)->error) { if ((*mrq)->data[offsetof(struct ms_status_register, status0)] & MEMSTICK_STATUS0_WP) msb->read_only = 1; else msb->read_only = 0; } return mspro_block_complete_req(card, (*mrq)->error); } static int h_mspro_block_wait_for_ced(struct memstick_dev *card, struct memstick_request **mrq) { dev_dbg(&card->dev, "wait for ced: value %x\n", (*mrq)->data[0]); if (!(*mrq)->error) { if ((*mrq)->data[0] & (MEMSTICK_INT_CMDNAK | MEMSTICK_INT_ERR)) (*mrq)->error = -EFAULT; else if (!((*mrq)->data[0] & MEMSTICK_INT_CED)) return 0; } return mspro_block_complete_req(card, (*mrq)->error); } static int h_mspro_block_transfer_data(struct memstick_dev *card, struct memstick_request **mrq) { struct mspro_block_data *msb = memstick_get_drvdata(card); unsigned char t_val = 0; struct scatterlist t_sg = { 0 }; size_t t_offset; if ((*mrq)->error) return mspro_block_complete_req(card, (*mrq)->error); switch ((*mrq)->tpc) { case MS_TPC_WRITE_REG: memstick_init_req(*mrq, MS_TPC_SET_CMD, &msb->transfer_cmd, 1); (*mrq)->need_card_int = 1; return 0; case MS_TPC_SET_CMD: t_val = (*mrq)->int_reg; memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1); if (msb->caps & MEMSTICK_CAP_AUTO_GET_INT) goto has_int_reg; return 0; case MS_TPC_GET_INT: t_val = (*mrq)->data[0]; has_int_reg: if (t_val & (MEMSTICK_INT_CMDNAK | MEMSTICK_INT_ERR)) { t_val = MSPRO_CMD_STOP; memstick_init_req(*mrq, MS_TPC_SET_CMD, &t_val, 1); card->next_request = h_mspro_block_default; return 0; } if (msb->current_page == (msb->req_sg[msb->current_seg].length / msb->page_size)) { msb->current_page = 0; msb->current_seg++; if (msb->current_seg == msb->seg_count) { if (t_val & MEMSTICK_INT_CED) { return mspro_block_complete_req(card, 0); } else { card->next_request = h_mspro_block_wait_for_ced; memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1); return 0; } } } if (!(t_val & MEMSTICK_INT_BREQ)) { memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1); return 0; } t_offset = msb->req_sg[msb->current_seg].offset; t_offset += msb->current_page * msb->page_size; sg_set_page(&t_sg, nth_page(sg_page(&(msb->req_sg[msb->current_seg])), t_offset >> PAGE_SHIFT), msb->page_size, offset_in_page(t_offset)); memstick_init_req_sg(*mrq, msb->data_dir == READ ? MS_TPC_READ_LONG_DATA : MS_TPC_WRITE_LONG_DATA, &t_sg); (*mrq)->need_card_int = 1; return 0; case MS_TPC_READ_LONG_DATA: case MS_TPC_WRITE_LONG_DATA: msb->current_page++; if (msb->caps & MEMSTICK_CAP_AUTO_GET_INT) { t_val = (*mrq)->int_reg; goto has_int_reg; } else { memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1); return 0; } default: BUG(); } } /*** Transfer setup functions for different access methods. ***/ /** Setup data transfer request for SET_CMD TPC with arguments in card * registers. * * @card Current media instance * @offset Target data offset in bytes * @length Required transfer length in bytes. */ static void h_mspro_block_setup_cmd(struct memstick_dev *card, u64 offset, size_t length) { struct mspro_block_data *msb = memstick_get_drvdata(card); struct mspro_param_register param = { .system = msb->system, .data_count = cpu_to_be16((uint16_t)(length / msb->page_size)), /* ISO C90 warning precludes direct initialization for now. */ .data_address = 0, .tpc_param = 0 }; do_div(offset, msb->page_size); param.data_address = cpu_to_be32((uint32_t)offset); card->next_request = h_mspro_block_req_init; msb->mrq_handler = h_mspro_block_transfer_data; memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, &param, sizeof(param)); } /*** Data transfer ***/ static int mspro_block_issue_req(struct memstick_dev *card, int chunk) { struct mspro_block_data *msb = memstick_get_drvdata(card); u64 t_off; unsigned int count; try_again: while (chunk) { msb->current_page = 0; msb->current_seg = 0; msb->seg_count = blk_rq_map_sg(msb->block_req->q, msb->block_req, msb->req_sg); if (!msb->seg_count) { chunk = __blk_end_request_cur(msb->block_req, -ENOMEM); continue; } t_off = blk_rq_pos(msb->block_req); t_off <<= 9; count = blk_rq_bytes(msb->block_req); msb->setup_transfer(card, t_off, count); msb->data_dir = rq_data_dir(msb->block_req); msb->transfer_cmd = msb->data_dir == READ ? MSPRO_CMD_READ_DATA : MSPRO_CMD_WRITE_DATA; memstick_new_req(card->host); return 0; } dev_dbg(&card->dev, "blk_fetch\n"); msb->block_req = blk_fetch_request(msb->queue); if (!msb->block_req) { dev_dbg(&card->dev, "issue end\n"); return -EAGAIN; } dev_dbg(&card->dev, "trying again\n"); chunk = 1; goto try_again; } static int mspro_block_complete_req(struct memstick_dev *card, int error) { struct mspro_block_data *msb = memstick_get_drvdata(card); int chunk, cnt; unsigned int t_len = 0; unsigned long flags; spin_lock_irqsave(&msb->q_lock, flags); dev_dbg(&card->dev, "complete %d, %d\n", msb->has_request ? 1 : 0, error); if (msb->has_request) { /* Nothing to do - not really an error */ if (error == -EAGAIN) error = 0; if (error || (card->current_mrq.tpc == MSPRO_CMD_STOP)) { if (msb->data_dir == READ) { for (cnt = 0; cnt < msb->current_seg; cnt++) t_len += msb->req_sg[cnt].length / msb->page_size; if (msb->current_page) t_len += msb->current_page - 1; t_len *= msb->page_size; } } else t_len = blk_rq_bytes(msb->block_req); dev_dbg(&card->dev, "transferred %x (%d)\n", t_len, error); if (error && !t_len) t_len = blk_rq_cur_bytes(msb->block_req); chunk = __blk_end_request(msb->block_req, error, t_len); error = mspro_block_issue_req(card, chunk); if (!error) goto out; else msb->has_request = 0; } else { if (!error) error = -EAGAIN; } card->next_request = h_mspro_block_default_bad; complete_all(&card->mrq_complete); out: spin_unlock_irqrestore(&msb->q_lock, flags); return error; } static void mspro_block_stop(struct memstick_dev *card) { struct mspro_block_data *msb = memstick_get_drvdata(card); int rc = 0; unsigned long flags; while (1) { spin_lock_irqsave(&msb->q_lock, flags); if (!msb->has_request) { blk_stop_queue(msb->queue); rc = 1; } spin_unlock_irqrestore(&msb->q_lock, flags); if (rc) break; wait_for_completion(&card->mrq_complete); } } static void mspro_block_start(struct memstick_dev *card) { struct mspro_block_data *msb = memstick_get_drvdata(card); unsigned long flags; spin_lock_irqsave(&msb->q_lock, flags); blk_start_queue(msb->queue); spin_unlock_irqrestore(&msb->q_lock, flags); } static int mspro_block_prepare_req(struct request_queue *q, struct request *req) { if (req->cmd_type != REQ_TYPE_FS && req->cmd_type != REQ_TYPE_BLOCK_PC) { blk_dump_rq_flags(req, "MSPro unsupported request"); return BLKPREP_KILL; } req->cmd_flags |= REQ_DONTPREP; return BLKPREP_OK; } static void mspro_block_submit_req(struct request_queue *q) { struct memstick_dev *card = q->queuedata; struct mspro_block_data *msb = memstick_get_drvdata(card); struct request *req = NULL; if (msb->has_request) return; if (msb->eject) { while ((req = blk_fetch_request(q)) != NULL) __blk_end_request_all(req, -ENODEV); return; } msb->has_request = 1; if (mspro_block_issue_req(card, 0)) msb->has_request = 0; } /*** Initialization ***/ static int mspro_block_wait_for_ced(struct memstick_dev *card) { struct mspro_block_data *msb = memstick_get_drvdata(card); card->next_request = h_mspro_block_req_init; msb->mrq_handler = h_mspro_block_wait_for_ced; memstick_init_req(&card->current_mrq, MS_TPC_GET_INT, NULL, 1); memstick_new_req(card->host); wait_for_completion(&card->mrq_complete); return card->current_mrq.error; } static int mspro_block_set_interface(struct memstick_dev *card, unsigned char sys_reg) { struct memstick_host *host = card->host; struct mspro_block_data *msb = memstick_get_drvdata(card); struct mspro_param_register param = { .system = sys_reg, .data_count = 0, .data_address = 0, .tpc_param = 0 }; card->next_request = h_mspro_block_req_init; msb->mrq_handler = h_mspro_block_default; memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, &param, sizeof(param)); memstick_new_req(host); wait_for_completion(&card->mrq_complete); return card->current_mrq.error; } static int mspro_block_switch_interface(struct memstick_dev *card) { struct memstick_host *host = card->host; struct mspro_block_data *msb = memstick_get_drvdata(card); int rc = 0; try_again: if (msb->caps & MEMSTICK_CAP_PAR4) rc = mspro_block_set_interface(card, MEMSTICK_SYS_PAR4); else return 0; if (rc) { printk(KERN_WARNING "%s: could not switch to 4-bit mode, error %d\n", dev_name(&card->dev), rc); return 0; } msb->system = MEMSTICK_SYS_PAR4; host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_PAR4); printk(KERN_INFO "%s: switching to 4-bit parallel mode\n", dev_name(&card->dev)); if (msb->caps & MEMSTICK_CAP_PAR8) { rc = mspro_block_set_interface(card, MEMSTICK_SYS_PAR8); if (!rc) { msb->system = MEMSTICK_SYS_PAR8; host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_PAR8); printk(KERN_INFO "%s: switching to 8-bit parallel mode\n", dev_name(&card->dev)); } else printk(KERN_WARNING "%s: could not switch to 8-bit mode, error %d\n", dev_name(&card->dev), rc); } card->next_request = h_mspro_block_req_init; msb->mrq_handler = h_mspro_block_default; memstick_init_req(&card->current_mrq, MS_TPC_GET_INT, NULL, 1); memstick_new_req(card->host); wait_for_completion(&card->mrq_complete); rc = card->current_mrq.error; if (rc) { printk(KERN_WARNING "%s: interface error, trying to fall back to serial\n", dev_name(&card->dev)); msb->system = MEMSTICK_SYS_SERIAL; host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); msleep(10); host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL); rc = memstick_set_rw_addr(card); if (!rc) rc = mspro_block_set_interface(card, msb->system); if (!rc) { msleep(150); rc = mspro_block_wait_for_ced(card); if (rc) return rc; if (msb->caps & MEMSTICK_CAP_PAR8) { msb->caps &= ~MEMSTICK_CAP_PAR8; goto try_again; } } } return rc; } /* Memory allocated for attributes by this function should be freed by * mspro_block_data_clear, no matter if the initialization process succeeded * or failed. */ static int mspro_block_read_attributes(struct memstick_dev *card) { struct mspro_block_data *msb = memstick_get_drvdata(card); struct mspro_attribute *attr = NULL; struct mspro_sys_attr *s_attr = NULL; unsigned char *buffer = NULL; int cnt, rc, attr_count; /* While normally physical device offsets, represented here by * attr_offset and attr_len will be of large numeric types, we can be * sure, that attributes are close enough to the beginning of the * device, to save ourselves some trouble. */ unsigned int addr, attr_offset = 0, attr_len = msb->page_size; attr = kmalloc(msb->page_size, GFP_KERNEL); if (!attr) return -ENOMEM; sg_init_one(&msb->req_sg[0], attr, msb->page_size); msb->seg_count = 1; msb->current_seg = 0; msb->current_page = 0; msb->data_dir = READ; msb->transfer_cmd = MSPRO_CMD_READ_ATRB; msb->setup_transfer(card, attr_offset, attr_len); memstick_new_req(card->host); wait_for_completion(&card->mrq_complete); if (card->current_mrq.error) { rc = card->current_mrq.error; goto out_free_attr; } if (be16_to_cpu(attr->signature) != MSPRO_BLOCK_SIGNATURE) { printk(KERN_ERR "%s: unrecognized device signature %x\n", dev_name(&card->dev), be16_to_cpu(attr->signature)); rc = -ENODEV; goto out_free_attr; } if (attr->count > MSPRO_BLOCK_MAX_ATTRIBUTES) { printk(KERN_WARNING "%s: way too many attribute entries\n", dev_name(&card->dev)); attr_count = MSPRO_BLOCK_MAX_ATTRIBUTES; } else attr_count = attr->count; msb->attr_group.attrs = kzalloc((attr_count + 1) * sizeof(struct attribute), GFP_KERNEL); if (!msb->attr_group.attrs) { rc = -ENOMEM; goto out_free_attr; } msb->attr_group.name = "media_attributes"; buffer = kmalloc(attr_len, GFP_KERNEL); if (!buffer) { rc = -ENOMEM; goto out_free_attr; } memcpy(buffer, (char *)attr, attr_len); for (cnt = 0; cnt < attr_count; ++cnt) { s_attr = kzalloc(sizeof(struct mspro_sys_attr), GFP_KERNEL); if (!s_attr) { rc = -ENOMEM; goto out_free_buffer; } msb->attr_group.attrs[cnt] = &s_attr->dev_attr.attr; addr = be32_to_cpu(attr->entries[cnt].address); s_attr->size = be32_to_cpu(attr->entries[cnt].size); dev_dbg(&card->dev, "adding attribute %d: id %x, address %x, " "size %zx\n", cnt, attr->entries[cnt].id, addr, s_attr->size); s_attr->id = attr->entries[cnt].id; if (mspro_block_attr_name(s_attr->id)) snprintf(s_attr->name, sizeof(s_attr->name), "%s", mspro_block_attr_name(attr->entries[cnt].id)); else snprintf(s_attr->name, sizeof(s_attr->name), "attr_x%02x", attr->entries[cnt].id); sysfs_attr_init(&s_attr->dev_attr.attr); s_attr->dev_attr.attr.name = s_attr->name; s_attr->dev_attr.attr.mode = S_IRUGO; s_attr->dev_attr.show = mspro_block_attr_show(s_attr->id); if (!s_attr->size) continue; s_attr->data = kmalloc(s_attr->size, GFP_KERNEL); if (!s_attr->data) { rc = -ENOMEM; goto out_free_buffer; } if (((addr / msb->page_size) == (attr_offset / msb->page_size)) && (((addr + s_attr->size - 1) / msb->page_size) == (attr_offset / msb->page_size))) { memcpy(s_attr->data, buffer + addr % msb->page_size, s_attr->size); continue; } attr_offset = (addr / msb->page_size) * msb->page_size; if ((attr_offset + attr_len) < (addr + s_attr->size)) { kfree(buffer); attr_len = (((addr + s_attr->size) / msb->page_size) + 1 ) * msb->page_size - attr_offset; buffer = kmalloc(attr_len, GFP_KERNEL); if (!buffer) { rc = -ENOMEM; goto out_free_attr; } } sg_init_one(&msb->req_sg[0], buffer, attr_len); msb->seg_count = 1; msb->current_seg = 0; msb->current_page = 0; msb->data_dir = READ; msb->transfer_cmd = MSPRO_CMD_READ_ATRB; dev_dbg(&card->dev, "reading attribute range %x, %x\n", attr_offset, attr_len); msb->setup_transfer(card, attr_offset, attr_len); memstick_new_req(card->host); wait_for_completion(&card->mrq_complete); if (card->current_mrq.error) { rc = card->current_mrq.error; goto out_free_buffer; } memcpy(s_attr->data, buffer + addr % msb->page_size, s_attr->size); } rc = 0; out_free_buffer: kfree(buffer); out_free_attr: kfree(attr); return rc; } static int mspro_block_init_card(struct memstick_dev *card) { struct mspro_block_data *msb = memstick_get_drvdata(card); struct memstick_host *host = card->host; int rc = 0; msb->system = MEMSTICK_SYS_SERIAL; msb->setup_transfer = h_mspro_block_setup_cmd; card->reg_addr.r_offset = offsetof(struct mspro_register, status); card->reg_addr.r_length = sizeof(struct ms_status_register); card->reg_addr.w_offset = offsetof(struct mspro_register, param); card->reg_addr.w_length = sizeof(struct mspro_param_register); if (memstick_set_rw_addr(card)) return -EIO; msb->caps = host->caps; msleep(150); rc = mspro_block_wait_for_ced(card); if (rc) return rc; rc = mspro_block_switch_interface(card); if (rc) return rc; dev_dbg(&card->dev, "card activated\n"); if (msb->system != MEMSTICK_SYS_SERIAL) msb->caps |= MEMSTICK_CAP_AUTO_GET_INT; card->next_request = h_mspro_block_req_init; msb->mrq_handler = h_mspro_block_get_ro; memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, NULL, sizeof(struct ms_status_register)); memstick_new_req(card->host); wait_for_completion(&card->mrq_complete); if (card->current_mrq.error) return card->current_mrq.error; dev_dbg(&card->dev, "card r/w status %d\n", msb->read_only ? 0 : 1); msb->page_size = 512; rc = mspro_block_read_attributes(card); if (rc) return rc; dev_dbg(&card->dev, "attributes loaded\n"); return 0; } static int mspro_block_init_disk(struct memstick_dev *card) { struct mspro_block_data *msb = memstick_get_drvdata(card); struct memstick_host *host = card->host; struct mspro_devinfo *dev_info = NULL; struct mspro_sys_info *sys_info = NULL; struct mspro_sys_attr *s_attr = NULL; int rc, disk_id; u64 limit = BLK_BOUNCE_HIGH; unsigned long capacity; if (host->dev.dma_mask && *(host->dev.dma_mask)) limit = *(host->dev.dma_mask); for (rc = 0; msb->attr_group.attrs[rc]; ++rc) { s_attr = mspro_from_sysfs_attr(msb->attr_group.attrs[rc]); if (s_attr->id == MSPRO_BLOCK_ID_DEVINFO) dev_info = s_attr->data; else if (s_attr->id == MSPRO_BLOCK_ID_SYSINFO) sys_info = s_attr->data; } if (!dev_info || !sys_info) return -ENODEV; msb->cylinders = be16_to_cpu(dev_info->cylinders); msb->heads = be16_to_cpu(dev_info->heads); msb->sectors_per_track = be16_to_cpu(dev_info->sectors_per_track); msb->page_size = be16_to_cpu(sys_info->unit_size); mutex_lock(&mspro_block_disk_lock); disk_id = idr_alloc(&mspro_block_disk_idr, card, 0, 256, GFP_KERNEL); mutex_unlock(&mspro_block_disk_lock); if (disk_id < 0) return disk_id; msb->disk = alloc_disk(1 << MSPRO_BLOCK_PART_SHIFT); if (!msb->disk) { rc = -ENOMEM; goto out_release_id; } msb->queue = blk_init_queue(mspro_block_submit_req, &msb->q_lock); if (!msb->queue) { rc = -ENOMEM; goto out_put_disk; } msb->queue->queuedata = card; blk_queue_prep_rq(msb->queue, mspro_block_prepare_req); blk_queue_bounce_limit(msb->queue, limit); blk_queue_max_hw_sectors(msb->queue, MSPRO_BLOCK_MAX_PAGES); blk_queue_max_segments(msb->queue, MSPRO_BLOCK_MAX_SEGS); blk_queue_max_segment_size(msb->queue, MSPRO_BLOCK_MAX_PAGES * msb->page_size); msb->disk->major = major; msb->disk->first_minor = disk_id << MSPRO_BLOCK_PART_SHIFT; msb->disk->fops = &ms_block_bdops; msb->usage_count = 1; msb->disk->private_data = msb; msb->disk->queue = msb->queue; msb->disk->driverfs_dev = &card->dev; sprintf(msb->disk->disk_name, "mspblk%d", disk_id); blk_queue_logical_block_size(msb->queue, msb->page_size); capacity = be16_to_cpu(sys_info->user_block_count); capacity *= be16_to_cpu(sys_info->block_size); capacity *= msb->page_size >> 9; set_capacity(msb->disk, capacity); dev_dbg(&card->dev, "capacity set %ld\n", capacity); add_disk(msb->disk); msb->active = 1; return 0; out_put_disk: put_disk(msb->disk); out_release_id: mutex_lock(&mspro_block_disk_lock); idr_remove(&mspro_block_disk_idr, disk_id); mutex_unlock(&mspro_block_disk_lock); return rc; } static void mspro_block_data_clear(struct mspro_block_data *msb) { int cnt; struct mspro_sys_attr *s_attr; if (msb->attr_group.attrs) { for (cnt = 0; msb->attr_group.attrs[cnt]; ++cnt) { s_attr = mspro_from_sysfs_attr(msb->attr_group .attrs[cnt]); kfree(s_attr->data); kfree(s_attr); } kfree(msb->attr_group.attrs); } msb->card = NULL; } static int mspro_block_check_card(struct memstick_dev *card) { struct mspro_block_data *msb = memstick_get_drvdata(card); return (msb->active == 1); } static int mspro_block_probe(struct memstick_dev *card) { struct mspro_block_data *msb; int rc = 0; msb = kzalloc(sizeof(struct mspro_block_data), GFP_KERNEL); if (!msb) return -ENOMEM; memstick_set_drvdata(card, msb); msb->card = card; spin_lock_init(&msb->q_lock); rc = mspro_block_init_card(card); if (rc) goto out_free; rc = sysfs_create_group(&card->dev.kobj, &msb->attr_group); if (rc) goto out_free; rc = mspro_block_init_disk(card); if (!rc) { card->check = mspro_block_check_card; card->stop = mspro_block_stop; card->start = mspro_block_start; return 0; } sysfs_remove_group(&card->dev.kobj, &msb->attr_group); out_free: memstick_set_drvdata(card, NULL); mspro_block_data_clear(msb); kfree(msb); return rc; } static void mspro_block_remove(struct memstick_dev *card) { struct mspro_block_data *msb = memstick_get_drvdata(card); unsigned long flags; spin_lock_irqsave(&msb->q_lock, flags); msb->eject = 1; blk_start_queue(msb->queue); spin_unlock_irqrestore(&msb->q_lock, flags); del_gendisk(msb->disk); dev_dbg(&card->dev, "mspro block remove\n"); blk_cleanup_queue(msb->queue); msb->queue = NULL; sysfs_remove_group(&card->dev.kobj, &msb->attr_group); mutex_lock(&mspro_block_disk_lock); mspro_block_data_clear(msb); mutex_unlock(&mspro_block_disk_lock); mspro_block_disk_release(msb->disk); memstick_set_drvdata(card, NULL); } #ifdef CONFIG_PM static int mspro_block_suspend(struct memstick_dev *card, pm_message_t state) { struct mspro_block_data *msb = memstick_get_drvdata(card); unsigned long flags; spin_lock_irqsave(&msb->q_lock, flags); blk_stop_queue(msb->queue); msb->active = 0; spin_unlock_irqrestore(&msb->q_lock, flags); return 0; } static int mspro_block_resume(struct memstick_dev *card) { struct mspro_block_data *msb = memstick_get_drvdata(card); unsigned long flags; int rc = 0; #ifdef CONFIG_MEMSTICK_UNSAFE_RESUME struct mspro_block_data *new_msb; struct memstick_host *host = card->host; struct mspro_sys_attr *s_attr, *r_attr; unsigned char cnt; mutex_lock(&host->lock); new_msb = kzalloc(sizeof(struct mspro_block_data), GFP_KERNEL); if (!new_msb) { rc = -ENOMEM; goto out_unlock; } new_msb->card = card; memstick_set_drvdata(card, new_msb); if (mspro_block_init_card(card)) goto out_free; for (cnt = 0; new_msb->attr_group.attrs[cnt] && msb->attr_group.attrs[cnt]; ++cnt) { s_attr = mspro_from_sysfs_attr(new_msb->attr_group.attrs[cnt]); r_attr = mspro_from_sysfs_attr(msb->attr_group.attrs[cnt]); if (s_attr->id == MSPRO_BLOCK_ID_SYSINFO && r_attr->id == s_attr->id) { if (memcmp(s_attr->data, r_attr->data, s_attr->size)) break; msb->active = 1; break; } } out_free: memstick_set_drvdata(card, msb); mspro_block_data_clear(new_msb); kfree(new_msb); out_unlock: mutex_unlock(&host->lock); #endif /* CONFIG_MEMSTICK_UNSAFE_RESUME */ spin_lock_irqsave(&msb->q_lock, flags); blk_start_queue(msb->queue); spin_unlock_irqrestore(&msb->q_lock, flags); return rc; } #else #define mspro_block_suspend NULL #define mspro_block_resume NULL #endif /* CONFIG_PM */ static struct memstick_device_id mspro_block_id_tbl[] = { {MEMSTICK_MATCH_ALL, MEMSTICK_TYPE_PRO, MEMSTICK_CATEGORY_STORAGE_DUO, MEMSTICK_CLASS_DUO}, {} }; static struct memstick_driver mspro_block_driver = { .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE }, .id_table = mspro_block_id_tbl, .probe = mspro_block_probe, .remove = mspro_block_remove, .suspend = mspro_block_suspend, .resume = mspro_block_resume }; static int __init mspro_block_init(void) { int rc = -ENOMEM; rc = register_blkdev(major, DRIVER_NAME); if (rc < 0) { printk(KERN_ERR DRIVER_NAME ": failed to register " "major %d, error %d\n", major, rc); return rc; } if (!major) major = rc; rc = memstick_register_driver(&mspro_block_driver); if (rc) unregister_blkdev(major, DRIVER_NAME); return rc; } static void __exit mspro_block_exit(void) { memstick_unregister_driver(&mspro_block_driver); unregister_blkdev(major, DRIVER_NAME); idr_destroy(&mspro_block_disk_idr); } module_init(mspro_block_init); module_exit(mspro_block_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Alex Dubov"); MODULE_DESCRIPTION("Sony MemoryStickPro block device driver"); MODULE_DEVICE_TABLE(memstick, mspro_block_id_tbl);
gpl-2.0
BlackBox-Kernel/blackbox_tomato_lp
drivers/video/bfin-t350mcqb-fb.c
2232
16614
/* * File: drivers/video/bfin-t350mcqb-fb.c * Based on: * Author: Michael Hennerich <hennerich@blackfin.uclinux.org> * * Created: * Description: Blackfin LCD Framebuffer driver * * * Modified: * Copyright 2004-2007 Analog Devices Inc. * * Bugs: Enter bugs at http://blackfin.uclinux.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, see the file COPYING, or write * to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/gfp.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/types.h> #include <linux/interrupt.h> #include <linux/device.h> #include <linux/backlight.h> #include <linux/lcd.h> #include <linux/dma-mapping.h> #include <linux/platform_device.h> #include <asm/blackfin.h> #include <asm/irq.h> #include <asm/dma-mapping.h> #include <asm/dma.h> #include <asm/portmux.h> #include <asm/gptimers.h> #define NO_BL_SUPPORT #define LCD_X_RES 320 /* Horizontal Resolution */ #define LCD_Y_RES 240 /* Vertical Resolution */ #define LCD_BPP 24 /* Bit Per Pixel */ #define DMA_BUS_SIZE 16 #define LCD_CLK (12*1000*1000) /* 12MHz */ #define CLOCKS_PER_PIX 3 /* * HS and VS timing parameters (all in number of PPI clk ticks) */ #define U_LINE 1 /* Blanking Lines */ #define H_ACTPIX (LCD_X_RES * CLOCKS_PER_PIX) /* active horizontal pixel */ #define H_PERIOD (408 * CLOCKS_PER_PIX) /* HS period */ #define H_PULSE 90 /* HS pulse width */ #define H_START 204 /* first valid pixel */ #define V_LINES (LCD_Y_RES + U_LINE) /* total vertical lines */ #define V_PULSE (3 * H_PERIOD) /* VS pulse width (1-5 H_PERIODs) */ #define V_PERIOD (H_PERIOD * V_LINES) /* VS period */ #define ACTIVE_VIDEO_MEM_OFFSET (U_LINE * H_ACTPIX) #define BFIN_LCD_NBR_PALETTE_ENTRIES 256 #define DRIVER_NAME "bfin-t350mcqb" static char driver_name[] = DRIVER_NAME; struct bfin_t350mcqbfb_info { struct fb_info *fb; struct device *dev; unsigned char *fb_buffer; /* RGB Buffer */ dma_addr_t dma_handle; int lq043_open_cnt; int irq; spinlock_t lock; /* lock */ u32 pseudo_pal[16]; }; static int nocursor; module_param(nocursor, int, 0644); MODULE_PARM_DESC(nocursor, "cursor enable/disable"); #define PPI_TX_MODE 0x2 #define PPI_XFER_TYPE_11 0xC #define PPI_PORT_CFG_01 0x10 #define PPI_PACK_EN 0x80 #define PPI_POLS_1 0x8000 static void bfin_t350mcqb_config_ppi(struct bfin_t350mcqbfb_info *fbi) { bfin_write_PPI_DELAY(H_START); bfin_write_PPI_COUNT(H_ACTPIX-1); bfin_write_PPI_FRAME(V_LINES); bfin_write_PPI_CONTROL(PPI_TX_MODE | /* output mode , PORT_DIR */ PPI_XFER_TYPE_11 | /* sync mode XFR_TYPE */ PPI_PORT_CFG_01 | /* two frame sync PORT_CFG */ PPI_PACK_EN | /* packing enabled PACK_EN */ PPI_POLS_1); /* faling edge syncs POLS */ } static inline void bfin_t350mcqb_disable_ppi(void) { bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() & ~PORT_EN); } static inline void bfin_t350mcqb_enable_ppi(void) { bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() | PORT_EN); } static void bfin_t350mcqb_start_timers(void) { unsigned long flags; local_irq_save(flags); enable_gptimers(TIMER1bit); enable_gptimers(TIMER0bit); local_irq_restore(flags); } static void bfin_t350mcqb_stop_timers(void) { disable_gptimers(TIMER0bit | TIMER1bit); set_gptimer_status(0, TIMER_STATUS_TRUN0 | TIMER_STATUS_TRUN1 | TIMER_STATUS_TIMIL0 | TIMER_STATUS_TIMIL1 | TIMER_STATUS_TOVF0 | TIMER_STATUS_TOVF1); } static void bfin_t350mcqb_init_timers(void) { bfin_t350mcqb_stop_timers(); set_gptimer_period(TIMER0_id, H_PERIOD); set_gptimer_pwidth(TIMER0_id, H_PULSE); set_gptimer_config(TIMER0_id, TIMER_MODE_PWM | TIMER_PERIOD_CNT | TIMER_TIN_SEL | TIMER_CLK_SEL| TIMER_EMU_RUN); set_gptimer_period(TIMER1_id, V_PERIOD); set_gptimer_pwidth(TIMER1_id, V_PULSE); set_gptimer_config(TIMER1_id, TIMER_MODE_PWM | TIMER_PERIOD_CNT | TIMER_TIN_SEL | TIMER_CLK_SEL | TIMER_EMU_RUN); } static void bfin_t350mcqb_config_dma(struct bfin_t350mcqbfb_info *fbi) { set_dma_config(CH_PPI, set_bfin_dma_config(DIR_READ, DMA_FLOW_AUTO, INTR_DISABLE, DIMENSION_2D, DATA_SIZE_16, DMA_NOSYNC_KEEP_DMA_BUF)); set_dma_x_count(CH_PPI, (LCD_X_RES * LCD_BPP) / DMA_BUS_SIZE); set_dma_x_modify(CH_PPI, DMA_BUS_SIZE / 8); set_dma_y_count(CH_PPI, V_LINES); set_dma_y_modify(CH_PPI, DMA_BUS_SIZE / 8); set_dma_start_addr(CH_PPI, (unsigned long)fbi->fb_buffer); } static u16 ppi0_req_8[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2, P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3, P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7, 0}; static int bfin_t350mcqb_request_ports(int action) { if (action) { if (peripheral_request_list(ppi0_req_8, DRIVER_NAME)) { printk(KERN_ERR "Requesting Peripherals failed\n"); return -EFAULT; } } else peripheral_free_list(ppi0_req_8); return 0; } static int bfin_t350mcqb_fb_open(struct fb_info *info, int user) { struct bfin_t350mcqbfb_info *fbi = info->par; spin_lock(&fbi->lock); fbi->lq043_open_cnt++; if (fbi->lq043_open_cnt <= 1) { bfin_t350mcqb_disable_ppi(); SSYNC(); bfin_t350mcqb_config_dma(fbi); bfin_t350mcqb_config_ppi(fbi); bfin_t350mcqb_init_timers(); /* start dma */ enable_dma(CH_PPI); bfin_t350mcqb_enable_ppi(); bfin_t350mcqb_start_timers(); } spin_unlock(&fbi->lock); return 0; } static int bfin_t350mcqb_fb_release(struct fb_info *info, int user) { struct bfin_t350mcqbfb_info *fbi = info->par; spin_lock(&fbi->lock); fbi->lq043_open_cnt--; if (fbi->lq043_open_cnt <= 0) { bfin_t350mcqb_disable_ppi(); SSYNC(); disable_dma(CH_PPI); bfin_t350mcqb_stop_timers(); } spin_unlock(&fbi->lock); return 0; } static int bfin_t350mcqb_fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { switch (var->bits_per_pixel) { case 24:/* TRUECOLOUR, 16m */ var->red.offset = 0; var->green.offset = 8; var->blue.offset = 16; var->red.length = var->green.length = var->blue.length = 8; var->transp.offset = 0; var->transp.length = 0; var->transp.msb_right = 0; var->red.msb_right = 0; var->green.msb_right = 0; var->blue.msb_right = 0; break; default: pr_debug("%s: depth not supported: %u BPP\n", __func__, var->bits_per_pixel); return -EINVAL; } if (info->var.xres != var->xres || info->var.yres != var->yres || info->var.xres_virtual != var->xres_virtual || info->var.yres_virtual != var->yres_virtual) { pr_debug("%s: Resolution not supported: X%u x Y%u \n", __func__, var->xres, var->yres); return -EINVAL; } /* * Memory limit */ if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) { pr_debug("%s: Memory Limit requested yres_virtual = %u\n", __func__, var->yres_virtual); return -ENOMEM; } return 0; } int bfin_t350mcqb_fb_cursor(struct fb_info *info, struct fb_cursor *cursor) { if (nocursor) return 0; else return -EINVAL; /* just to force soft_cursor() call */ } static int bfin_t350mcqb_fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info) { if (regno >= BFIN_LCD_NBR_PALETTE_ENTRIES) return -EINVAL; if (info->var.grayscale) { /* grayscale = 0.30*R + 0.59*G + 0.11*B */ red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; } if (info->fix.visual == FB_VISUAL_TRUECOLOR) { u32 value; /* Place color in the pseudopalette */ if (regno > 16) return -EINVAL; red >>= (16 - info->var.red.length); green >>= (16 - info->var.green.length); blue >>= (16 - info->var.blue.length); value = (red << info->var.red.offset) | (green << info->var.green.offset) | (blue << info->var.blue.offset); value &= 0xFFFFFF; ((u32 *) (info->pseudo_palette))[regno] = value; } return 0; } static struct fb_ops bfin_t350mcqb_fb_ops = { .owner = THIS_MODULE, .fb_open = bfin_t350mcqb_fb_open, .fb_release = bfin_t350mcqb_fb_release, .fb_check_var = bfin_t350mcqb_fb_check_var, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, .fb_cursor = bfin_t350mcqb_fb_cursor, .fb_setcolreg = bfin_t350mcqb_fb_setcolreg, }; #ifndef NO_BL_SUPPORT static int bl_get_brightness(struct backlight_device *bd) { return 0; } static const struct backlight_ops bfin_lq043fb_bl_ops = { .get_brightness = bl_get_brightness, }; static struct backlight_device *bl_dev; static int bfin_lcd_get_power(struct lcd_device *dev) { return 0; } static int bfin_lcd_set_power(struct lcd_device *dev, int power) { return 0; } static int bfin_lcd_get_contrast(struct lcd_device *dev) { return 0; } static int bfin_lcd_set_contrast(struct lcd_device *dev, int contrast) { return 0; } static int bfin_lcd_check_fb(struct lcd_device *dev, struct fb_info *fi) { if (!fi || (fi == &bfin_t350mcqb_fb)) return 1; return 0; } static struct lcd_ops bfin_lcd_ops = { .get_power = bfin_lcd_get_power, .set_power = bfin_lcd_set_power, .get_contrast = bfin_lcd_get_contrast, .set_contrast = bfin_lcd_set_contrast, .check_fb = bfin_lcd_check_fb, }; static struct lcd_device *lcd_dev; #endif static irqreturn_t bfin_t350mcqb_irq_error(int irq, void *dev_id) { /*struct bfin_t350mcqbfb_info *info = (struct bfin_t350mcqbfb_info *)dev_id;*/ u16 status = bfin_read_PPI_STATUS(); bfin_write_PPI_STATUS(0xFFFF); if (status) { bfin_t350mcqb_disable_ppi(); disable_dma(CH_PPI); /* start dma */ enable_dma(CH_PPI); bfin_t350mcqb_enable_ppi(); bfin_write_PPI_STATUS(0xFFFF); } return IRQ_HANDLED; } static int bfin_t350mcqb_probe(struct platform_device *pdev) { #ifndef NO_BL_SUPPORT struct backlight_properties props; #endif struct bfin_t350mcqbfb_info *info; struct fb_info *fbinfo; int ret; printk(KERN_INFO DRIVER_NAME ": %dx%d %d-bit RGB FrameBuffer initializing...\n", LCD_X_RES, LCD_Y_RES, LCD_BPP); if (request_dma(CH_PPI, "CH_PPI") < 0) { printk(KERN_ERR DRIVER_NAME ": couldn't request CH_PPI DMA\n"); ret = -EFAULT; goto out1; } fbinfo = framebuffer_alloc(sizeof(struct bfin_t350mcqbfb_info), &pdev->dev); if (!fbinfo) { ret = -ENOMEM; goto out2; } info = fbinfo->par; info->fb = fbinfo; info->dev = &pdev->dev; spin_lock_init(&info->lock); platform_set_drvdata(pdev, fbinfo); strcpy(fbinfo->fix.id, driver_name); fbinfo->fix.type = FB_TYPE_PACKED_PIXELS; fbinfo->fix.type_aux = 0; fbinfo->fix.xpanstep = 0; fbinfo->fix.ypanstep = 0; fbinfo->fix.ywrapstep = 0; fbinfo->fix.accel = FB_ACCEL_NONE; fbinfo->fix.visual = FB_VISUAL_TRUECOLOR; fbinfo->var.nonstd = 0; fbinfo->var.activate = FB_ACTIVATE_NOW; fbinfo->var.height = 53; fbinfo->var.width = 70; fbinfo->var.accel_flags = 0; fbinfo->var.vmode = FB_VMODE_NONINTERLACED; fbinfo->var.xres = LCD_X_RES; fbinfo->var.xres_virtual = LCD_X_RES; fbinfo->var.yres = LCD_Y_RES; fbinfo->var.yres_virtual = LCD_Y_RES; fbinfo->var.bits_per_pixel = LCD_BPP; fbinfo->var.red.offset = 0; fbinfo->var.green.offset = 8; fbinfo->var.blue.offset = 16; fbinfo->var.transp.offset = 0; fbinfo->var.red.length = 8; fbinfo->var.green.length = 8; fbinfo->var.blue.length = 8; fbinfo->var.transp.length = 0; fbinfo->fix.smem_len = LCD_X_RES * LCD_Y_RES * LCD_BPP / 8; fbinfo->fix.line_length = fbinfo->var.xres_virtual * fbinfo->var.bits_per_pixel / 8; fbinfo->fbops = &bfin_t350mcqb_fb_ops; fbinfo->flags = FBINFO_FLAG_DEFAULT; info->fb_buffer = dma_alloc_coherent(NULL, fbinfo->fix.smem_len + ACTIVE_VIDEO_MEM_OFFSET, &info->dma_handle, GFP_KERNEL); if (NULL == info->fb_buffer) { printk(KERN_ERR DRIVER_NAME ": couldn't allocate dma buffer.\n"); ret = -ENOMEM; goto out3; } fbinfo->screen_base = (void *)info->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET; fbinfo->fix.smem_start = (int)info->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET; fbinfo->fbops = &bfin_t350mcqb_fb_ops; fbinfo->pseudo_palette = &info->pseudo_pal; if (fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0) < 0) { printk(KERN_ERR DRIVER_NAME "Fail to allocate colormap (%d entries)\n", BFIN_LCD_NBR_PALETTE_ENTRIES); ret = -EFAULT; goto out4; } if (bfin_t350mcqb_request_ports(1)) { printk(KERN_ERR DRIVER_NAME ": couldn't request gpio port.\n"); ret = -EFAULT; goto out6; } info->irq = platform_get_irq(pdev, 0); if (info->irq < 0) { ret = -EINVAL; goto out7; } ret = request_irq(info->irq, bfin_t350mcqb_irq_error, 0, "PPI ERROR", info); if (ret < 0) { printk(KERN_ERR DRIVER_NAME ": unable to request PPI ERROR IRQ\n"); goto out7; } if (register_framebuffer(fbinfo) < 0) { printk(KERN_ERR DRIVER_NAME ": unable to register framebuffer.\n"); ret = -EINVAL; goto out8; } #ifndef NO_BL_SUPPORT memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = 255; bl_dev = backlight_device_register("bf52x-bl", NULL, NULL, &bfin_lq043fb_bl_ops, &props); if (IS_ERR(bl_dev)) { printk(KERN_ERR DRIVER_NAME ": unable to register backlight.\n"); ret = -EINVAL; unregister_framebuffer(fbinfo); goto out8; } lcd_dev = lcd_device_register(DRIVER_NAME, NULL, &bfin_lcd_ops); lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n"); #endif return 0; out8: free_irq(info->irq, info); out7: bfin_t350mcqb_request_ports(0); out6: fb_dealloc_cmap(&fbinfo->cmap); out4: dma_free_coherent(NULL, fbinfo->fix.smem_len + ACTIVE_VIDEO_MEM_OFFSET, info->fb_buffer, info->dma_handle); out3: framebuffer_release(fbinfo); out2: free_dma(CH_PPI); out1: platform_set_drvdata(pdev, NULL); return ret; } static int bfin_t350mcqb_remove(struct platform_device *pdev) { struct fb_info *fbinfo = platform_get_drvdata(pdev); struct bfin_t350mcqbfb_info *info = fbinfo->par; unregister_framebuffer(fbinfo); free_dma(CH_PPI); free_irq(info->irq, info); if (info->fb_buffer != NULL) dma_free_coherent(NULL, fbinfo->fix.smem_len + ACTIVE_VIDEO_MEM_OFFSET, info->fb_buffer, info->dma_handle); fb_dealloc_cmap(&fbinfo->cmap); #ifndef NO_BL_SUPPORT lcd_device_unregister(lcd_dev); backlight_device_unregister(bl_dev); #endif bfin_t350mcqb_request_ports(0); platform_set_drvdata(pdev, NULL); framebuffer_release(fbinfo); printk(KERN_INFO DRIVER_NAME ": Unregister LCD driver.\n"); return 0; } #ifdef CONFIG_PM static int bfin_t350mcqb_suspend(struct platform_device *pdev, pm_message_t state) { struct fb_info *fbinfo = platform_get_drvdata(pdev); struct bfin_t350mcqbfb_info *fbi = fbinfo->par; if (fbi->lq043_open_cnt) { bfin_t350mcqb_disable_ppi(); disable_dma(CH_PPI); bfin_t350mcqb_stop_timers(); bfin_write_PPI_STATUS(-1); } return 0; } static int bfin_t350mcqb_resume(struct platform_device *pdev) { struct fb_info *fbinfo = platform_get_drvdata(pdev); struct bfin_t350mcqbfb_info *fbi = fbinfo->par; if (fbi->lq043_open_cnt) { bfin_t350mcqb_config_dma(fbi); bfin_t350mcqb_config_ppi(fbi); bfin_t350mcqb_init_timers(); /* start dma */ enable_dma(CH_PPI); bfin_t350mcqb_enable_ppi(); bfin_t350mcqb_start_timers(); } return 0; } #else #define bfin_t350mcqb_suspend NULL #define bfin_t350mcqb_resume NULL #endif static struct platform_driver bfin_t350mcqb_driver = { .probe = bfin_t350mcqb_probe, .remove = bfin_t350mcqb_remove, .suspend = bfin_t350mcqb_suspend, .resume = bfin_t350mcqb_resume, .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, }, }; static int __init bfin_t350mcqb_driver_init(void) { return platform_driver_register(&bfin_t350mcqb_driver); } static void __exit bfin_t350mcqb_driver_cleanup(void) { platform_driver_unregister(&bfin_t350mcqb_driver); } MODULE_DESCRIPTION("Blackfin TFT LCD Driver"); MODULE_LICENSE("GPL"); module_init(bfin_t350mcqb_driver_init); module_exit(bfin_t350mcqb_driver_cleanup);
gpl-2.0
maxwen/android_kernel_oppo_msm8916
fs/xfs/xfs_rename.c
2488
9393
/* * Copyright (c) 2000-2003,2005 Silicon 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. * * 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_fs.h" #include "xfs_types.h" #include "xfs_log.h" #include "xfs_trans.h" #include "xfs_sb.h" #include "xfs_ag.h" #include "xfs_dir2.h" #include "xfs_mount.h" #include "xfs_da_btree.h" #include "xfs_bmap_btree.h" #include "xfs_dinode.h" #include "xfs_inode.h" #include "xfs_inode_item.h" #include "xfs_bmap.h" #include "xfs_error.h" #include "xfs_quota.h" #include "xfs_utils.h" #include "xfs_trans_space.h" #include "xfs_vnodeops.h" #include "xfs_trace.h" /* * Enter all inodes for a rename transaction into a sorted array. */ STATIC void xfs_sort_for_rename( xfs_inode_t *dp1, /* in: old (source) directory inode */ xfs_inode_t *dp2, /* in: new (target) directory inode */ xfs_inode_t *ip1, /* in: inode of old entry */ xfs_inode_t *ip2, /* in: inode of new entry, if it already exists, NULL otherwise. */ xfs_inode_t **i_tab,/* out: array of inode returned, sorted */ int *num_inodes) /* out: number of inodes in array */ { xfs_inode_t *temp; int i, j; /* * i_tab contains a list of pointers to inodes. We initialize * the table here & we'll sort it. We will then use it to * order the acquisition of the inode locks. * * Note that the table may contain duplicates. e.g., dp1 == dp2. */ i_tab[0] = dp1; i_tab[1] = dp2; i_tab[2] = ip1; if (ip2) { *num_inodes = 4; i_tab[3] = ip2; } else { *num_inodes = 3; i_tab[3] = NULL; } /* * Sort the elements via bubble sort. (Remember, there are at * most 4 elements to sort, so this is adequate.) */ for (i = 0; i < *num_inodes; i++) { for (j = 1; j < *num_inodes; j++) { if (i_tab[j]->i_ino < i_tab[j-1]->i_ino) { temp = i_tab[j]; i_tab[j] = i_tab[j-1]; i_tab[j-1] = temp; } } } } /* * xfs_rename */ int xfs_rename( xfs_inode_t *src_dp, struct xfs_name *src_name, xfs_inode_t *src_ip, xfs_inode_t *target_dp, struct xfs_name *target_name, xfs_inode_t *target_ip) { xfs_trans_t *tp = NULL; xfs_mount_t *mp = src_dp->i_mount; int new_parent; /* moving to a new dir */ int src_is_directory; /* src_name is a directory */ int error; xfs_bmap_free_t free_list; xfs_fsblock_t first_block; int cancel_flags; int committed; xfs_inode_t *inodes[4]; int spaceres; int num_inodes; trace_xfs_rename(src_dp, target_dp, src_name, target_name); new_parent = (src_dp != target_dp); src_is_directory = S_ISDIR(src_ip->i_d.di_mode); xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip, inodes, &num_inodes); xfs_bmap_init(&free_list, &first_block); tp = xfs_trans_alloc(mp, XFS_TRANS_RENAME); cancel_flags = XFS_TRANS_RELEASE_LOG_RES; spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len); error = xfs_trans_reserve(tp, spaceres, XFS_RENAME_LOG_RES(mp), 0, XFS_TRANS_PERM_LOG_RES, XFS_RENAME_LOG_COUNT); if (error == ENOSPC) { spaceres = 0; error = xfs_trans_reserve(tp, 0, XFS_RENAME_LOG_RES(mp), 0, XFS_TRANS_PERM_LOG_RES, XFS_RENAME_LOG_COUNT); } if (error) { xfs_trans_cancel(tp, 0); goto std_return; } /* * Attach the dquots to the inodes */ error = xfs_qm_vop_rename_dqattach(inodes); if (error) { xfs_trans_cancel(tp, cancel_flags); goto std_return; } /* * Lock all the participating inodes. Depending upon whether * the target_name exists in the target directory, and * whether the target directory is the same as the source * directory, we can lock from 2 to 4 inodes. */ xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL); /* * Join all the inodes to the transaction. From this point on, * we can rely on either trans_commit or trans_cancel to unlock * them. */ xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL); if (new_parent) xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, src_ip, XFS_ILOCK_EXCL); if (target_ip) xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL); /* * If we are using project inheritance, we only allow renames * into our tree when the project IDs are the same; else the * tree quota mechanism would be circumvented. */ if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) && (xfs_get_projid(target_dp) != xfs_get_projid(src_ip)))) { error = XFS_ERROR(EXDEV); goto error_return; } /* * Set up the target. */ if (target_ip == NULL) { /* * If there's no space reservation, check the entry will * fit before actually inserting it. */ error = xfs_dir_canenter(tp, target_dp, target_name, spaceres); if (error) goto error_return; /* * If target does not exist and the rename crosses * directories, adjust the target directory link count * to account for the ".." reference from the new entry. */ error = xfs_dir_createname(tp, target_dp, target_name, src_ip->i_ino, &first_block, &free_list, spaceres); if (error == ENOSPC) goto error_return; if (error) goto abort_return; xfs_trans_ichgtime(tp, target_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); if (new_parent && src_is_directory) { error = xfs_bumplink(tp, target_dp); if (error) goto abort_return; } } else { /* target_ip != NULL */ /* * If target exists and it's a directory, check that both * target and source are directories and that target can be * destroyed, or that neither is a directory. */ if (S_ISDIR(target_ip->i_d.di_mode)) { /* * Make sure target dir is empty. */ if (!(xfs_dir_isempty(target_ip)) || (target_ip->i_d.di_nlink > 2)) { error = XFS_ERROR(EEXIST); goto error_return; } } /* * Link the source inode under the target name. * If the source inode is a directory and we are moving * it across directories, its ".." entry will be * inconsistent until we replace that down below. * * In case there is already an entry with the same * name at the destination directory, remove it first. */ error = xfs_dir_replace(tp, target_dp, target_name, src_ip->i_ino, &first_block, &free_list, spaceres); if (error) goto abort_return; xfs_trans_ichgtime(tp, target_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); /* * Decrement the link count on the target since the target * dir no longer points to it. */ error = xfs_droplink(tp, target_ip); if (error) goto abort_return; if (src_is_directory) { /* * Drop the link from the old "." entry. */ error = xfs_droplink(tp, target_ip); if (error) goto abort_return; } } /* target_ip != NULL */ /* * Remove the source. */ if (new_parent && src_is_directory) { /* * Rewrite the ".." entry to point to the new * directory. */ error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, target_dp->i_ino, &first_block, &free_list, spaceres); ASSERT(error != EEXIST); if (error) goto abort_return; } /* * We always want to hit the ctime on the source inode. * * This isn't strictly required by the standards since the source * inode isn't really being changed, but old unix file systems did * it and some incremental backup programs won't work without it. */ xfs_trans_ichgtime(tp, src_ip, XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, src_ip, XFS_ILOG_CORE); /* * Adjust the link count on src_dp. This is necessary when * renaming a directory, either within one parent when * the target existed, or across two parent directories. */ if (src_is_directory && (new_parent || target_ip != NULL)) { /* * Decrement link count on src_directory since the * entry that's moved no longer points to it. */ error = xfs_droplink(tp, src_dp); if (error) goto abort_return; } error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, &first_block, &free_list, spaceres); if (error) goto abort_return; xfs_trans_ichgtime(tp, src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE); if (new_parent) xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); /* * If this is a synchronous mount, make sure that the * rename transaction goes to disk before returning to * the user. */ if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) { xfs_trans_set_sync(tp); } error = xfs_bmap_finish(&tp, &free_list, &committed); if (error) { xfs_bmap_cancel(&free_list); xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT)); goto std_return; } /* * trans_commit will unlock src_ip, target_ip & decrement * the vnode references. */ return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); abort_return: cancel_flags |= XFS_TRANS_ABORT; error_return: xfs_bmap_cancel(&free_list); xfs_trans_cancel(tp, cancel_flags); std_return: return error; }
gpl-2.0
go2ev-devteam/Yoda-Kernel-ICS
arch/mips/ath79/setup.c
3000
4352
/* * Atheros AR71XX/AR724X/AR913X specific setup * * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> * * Parts of this file are based on Atheros' 2.6.15 BSP * * 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/init.h> #include <linux/bootmem.h> #include <linux/err.h> #include <linux/clk.h> #include <asm/bootinfo.h> #include <asm/time.h> /* for mips_hpt_frequency */ #include <asm/reboot.h> /* for _machine_{restart,halt} */ #include <asm/mips_machine.h> #include <asm/mach-ath79/ath79.h> #include <asm/mach-ath79/ar71xx_regs.h> #include "common.h" #include "dev-common.h" #include "machtypes.h" #define ATH79_SYS_TYPE_LEN 64 #define AR71XX_BASE_FREQ 40000000 #define AR724X_BASE_FREQ 5000000 #define AR913X_BASE_FREQ 5000000 static char ath79_sys_type[ATH79_SYS_TYPE_LEN]; static void ath79_restart(char *command) { ath79_device_reset_set(AR71XX_RESET_FULL_CHIP); for (;;) if (cpu_wait) cpu_wait(); } static void ath79_halt(void) { while (1) cpu_wait(); } static void __init ath79_detect_mem_size(void) { unsigned long size; for (size = ATH79_MEM_SIZE_MIN; size < ATH79_MEM_SIZE_MAX; size <<= 1) { if (!memcmp(ath79_detect_mem_size, ath79_detect_mem_size + size, 1024)) break; } add_memory_region(0, size, BOOT_MEM_RAM); } static void __init ath79_detect_sys_type(void) { char *chip = "????"; u32 id; u32 major; u32 minor; u32 rev = 0; id = ath79_reset_rr(AR71XX_RESET_REG_REV_ID); major = id & REV_ID_MAJOR_MASK; switch (major) { case REV_ID_MAJOR_AR71XX: minor = id & AR71XX_REV_ID_MINOR_MASK; rev = id >> AR71XX_REV_ID_REVISION_SHIFT; rev &= AR71XX_REV_ID_REVISION_MASK; switch (minor) { case AR71XX_REV_ID_MINOR_AR7130: ath79_soc = ATH79_SOC_AR7130; chip = "7130"; break; case AR71XX_REV_ID_MINOR_AR7141: ath79_soc = ATH79_SOC_AR7141; chip = "7141"; break; case AR71XX_REV_ID_MINOR_AR7161: ath79_soc = ATH79_SOC_AR7161; chip = "7161"; break; } break; case REV_ID_MAJOR_AR7240: ath79_soc = ATH79_SOC_AR7240; chip = "7240"; rev = (id & AR724X_REV_ID_REVISION_MASK); break; case REV_ID_MAJOR_AR7241: ath79_soc = ATH79_SOC_AR7241; chip = "7241"; rev = (id & AR724X_REV_ID_REVISION_MASK); break; case REV_ID_MAJOR_AR7242: ath79_soc = ATH79_SOC_AR7242; chip = "7242"; rev = (id & AR724X_REV_ID_REVISION_MASK); break; case REV_ID_MAJOR_AR913X: minor = id & AR913X_REV_ID_MINOR_MASK; rev = id >> AR913X_REV_ID_REVISION_SHIFT; rev &= AR913X_REV_ID_REVISION_MASK; switch (minor) { case AR913X_REV_ID_MINOR_AR9130: ath79_soc = ATH79_SOC_AR9130; chip = "9130"; break; case AR913X_REV_ID_MINOR_AR9132: ath79_soc = ATH79_SOC_AR9132; chip = "9132"; break; } break; default: panic("ath79: unknown SoC, id:0x%08x\n", id); } sprintf(ath79_sys_type, "Atheros AR%s rev %u", chip, rev); pr_info("SoC: %s\n", ath79_sys_type); } const char *get_system_type(void) { return ath79_sys_type; } unsigned int __cpuinit get_c0_compare_int(void) { return CP0_LEGACY_COMPARE_IRQ; } void __init plat_mem_setup(void) { set_io_port_base(KSEG1); ath79_reset_base = ioremap_nocache(AR71XX_RESET_BASE, AR71XX_RESET_SIZE); ath79_pll_base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE); ath79_ddr_base = ioremap_nocache(AR71XX_DDR_CTRL_BASE, AR71XX_DDR_CTRL_SIZE); ath79_detect_sys_type(); ath79_detect_mem_size(); ath79_clocks_init(); _machine_restart = ath79_restart; _machine_halt = ath79_halt; pm_power_off = ath79_halt; } void __init plat_time_init(void) { struct clk *clk; clk = clk_get(NULL, "cpu"); if (IS_ERR(clk)) panic("unable to get CPU clock, err=%ld", PTR_ERR(clk)); mips_hpt_frequency = clk_get_rate(clk) / 2; } static int __init ath79_setup(void) { ath79_gpio_init(); ath79_register_uart(); ath79_register_wdt(); mips_machine_setup(); return 0; } arch_initcall(ath79_setup); static void __init ath79_generic_init(void) { /* Nothing to do */ } MIPS_MACHINE(ATH79_MACH_GENERIC, "Generic", "Generic AR71XX/AR724X/AR913X based board", ath79_generic_init);
gpl-2.0
AMD-Grifon/android_kernel_samsung_aries
sound/pci/ice1712/ak4xxx.c
4024
5063
/* * ALSA driver for ICEnsemble ICE1712 (Envy24) * * AK4524 / AK4528 / AK4529 / AK4355 / AK4381 interface * * Copyright (c) 2000 Jaroslav Kysela <perex@perex.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; 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 <asm/io.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/slab.h> #include <linux/init.h> #include <sound/core.h> #include <sound/initval.h> #include "ice1712.h" MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); MODULE_DESCRIPTION("ICEnsemble ICE17xx <-> AK4xxx AD/DA chip interface"); MODULE_LICENSE("GPL"); static void snd_ice1712_akm4xxx_lock(struct snd_akm4xxx *ak, int chip) { struct snd_ice1712 *ice = ak->private_data[0]; snd_ice1712_save_gpio_status(ice); } static void snd_ice1712_akm4xxx_unlock(struct snd_akm4xxx *ak, int chip) { struct snd_ice1712 *ice = ak->private_data[0]; snd_ice1712_restore_gpio_status(ice); } /* * write AK4xxx register */ static void snd_ice1712_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char addr, unsigned char data) { unsigned int tmp; int idx; unsigned int addrdata; struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; struct snd_ice1712 *ice = ak->private_data[0]; if (snd_BUG_ON(chip < 0 || chip >= 4)) return; tmp = snd_ice1712_gpio_read(ice); tmp |= priv->add_flags; tmp &= ~priv->mask_flags; if (priv->cs_mask == priv->cs_addr) { if (priv->cif) { tmp |= priv->cs_mask; /* start without chip select */ } else { tmp &= ~priv->cs_mask; /* chip select low */ snd_ice1712_gpio_write(ice, tmp); udelay(1); } } else { /* doesn't handle cf=1 yet */ tmp &= ~priv->cs_mask; tmp |= priv->cs_addr; snd_ice1712_gpio_write(ice, tmp); udelay(1); } /* build I2C address + data byte */ addrdata = (priv->caddr << 6) | 0x20 | (addr & 0x1f); addrdata = (addrdata << 8) | data; for (idx = 15; idx >= 0; idx--) { /* drop clock */ tmp &= ~priv->clk_mask; snd_ice1712_gpio_write(ice, tmp); udelay(1); /* set data */ if (addrdata & (1 << idx)) tmp |= priv->data_mask; else tmp &= ~priv->data_mask; snd_ice1712_gpio_write(ice, tmp); udelay(1); /* raise clock */ tmp |= priv->clk_mask; snd_ice1712_gpio_write(ice, tmp); udelay(1); } if (priv->cs_mask == priv->cs_addr) { if (priv->cif) { /* assert a cs pulse to trigger */ tmp &= ~priv->cs_mask; snd_ice1712_gpio_write(ice, tmp); udelay(1); } tmp |= priv->cs_mask; /* chip select high to trigger */ } else { tmp &= ~priv->cs_mask; tmp |= priv->cs_none; /* deselect address */ } snd_ice1712_gpio_write(ice, tmp); udelay(1); } /* * initialize the struct snd_akm4xxx record with the template */ int snd_ice1712_akm4xxx_init(struct snd_akm4xxx *ak, const struct snd_akm4xxx *temp, const struct snd_ak4xxx_private *_priv, struct snd_ice1712 *ice) { struct snd_ak4xxx_private *priv; if (_priv != NULL) { priv = kmalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) return -ENOMEM; *priv = *_priv; } else { priv = NULL; } *ak = *temp; ak->card = ice->card; ak->private_value[0] = (unsigned long)priv; ak->private_data[0] = ice; if (ak->ops.lock == NULL) ak->ops.lock = snd_ice1712_akm4xxx_lock; if (ak->ops.unlock == NULL) ak->ops.unlock = snd_ice1712_akm4xxx_unlock; if (ak->ops.write == NULL) ak->ops.write = snd_ice1712_akm4xxx_write; snd_akm4xxx_init(ak); return 0; } void snd_ice1712_akm4xxx_free(struct snd_ice1712 *ice) { unsigned int akidx; if (ice->akm == NULL) return; for (akidx = 0; akidx < ice->akm_codecs; akidx++) { struct snd_akm4xxx *ak = &ice->akm[akidx]; kfree((void*)ak->private_value[0]); } kfree(ice->akm); } /* * build AK4xxx controls */ int snd_ice1712_akm4xxx_build_controls(struct snd_ice1712 *ice) { unsigned int akidx; int err; for (akidx = 0; akidx < ice->akm_codecs; akidx++) { struct snd_akm4xxx *ak = &ice->akm[akidx]; err = snd_akm4xxx_build_controls(ak); if (err < 0) return err; } return 0; } static int __init alsa_ice1712_akm4xxx_module_init(void) { return 0; } static void __exit alsa_ice1712_akm4xxx_module_exit(void) { } module_init(alsa_ice1712_akm4xxx_module_init) module_exit(alsa_ice1712_akm4xxx_module_exit) EXPORT_SYMBOL(snd_ice1712_akm4xxx_init); EXPORT_SYMBOL(snd_ice1712_akm4xxx_free); EXPORT_SYMBOL(snd_ice1712_akm4xxx_build_controls);
gpl-2.0
echo31/athena
sound/soc/omap/omap-dmic.c
4792
12730
/* * omap-dmic.c -- OMAP ASoC DMIC DAI driver * * Copyright (C) 2010 - 2011 Texas Instruments * * Author: David Lambert <dlambert@ti.com> * Misael Lopez Cruz <misael.lopez@ti.com> * Liam Girdwood <lrg@ti.com> * Peter Ujfalusi <peter.ujfalusi@ti.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #include <linux/init.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/err.h> #include <linux/clk.h> #include <linux/io.h> #include <linux/slab.h> #include <linux/pm_runtime.h> #include <plat/dma.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/initval.h> #include <sound/soc.h> #include "omap-pcm.h" #include "omap-dmic.h" struct omap_dmic { struct device *dev; void __iomem *io_base; struct clk *fclk; int fclk_freq; int out_freq; int clk_div; int sysclk; int threshold; u32 ch_enabled; bool active; struct mutex mutex; }; /* * Stream DMA parameters */ static struct omap_pcm_dma_data omap_dmic_dai_dma_params = { .name = "DMIC capture", .data_type = OMAP_DMA_DATA_TYPE_S32, .sync_mode = OMAP_DMA_SYNC_PACKET, }; static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val) { __raw_writel(val, dmic->io_base + reg); } static inline int omap_dmic_read(struct omap_dmic *dmic, u16 reg) { return __raw_readl(dmic->io_base + reg); } static inline void omap_dmic_start(struct omap_dmic *dmic) { u32 ctrl = omap_dmic_read(dmic, OMAP_DMIC_CTRL_REG); /* Configure DMA controller */ omap_dmic_write(dmic, OMAP_DMIC_DMAENABLE_SET_REG, OMAP_DMIC_DMA_ENABLE); omap_dmic_write(dmic, OMAP_DMIC_CTRL_REG, ctrl | dmic->ch_enabled); } static inline void omap_dmic_stop(struct omap_dmic *dmic) { u32 ctrl = omap_dmic_read(dmic, OMAP_DMIC_CTRL_REG); omap_dmic_write(dmic, OMAP_DMIC_CTRL_REG, ctrl & ~OMAP_DMIC_UP_ENABLE_MASK); /* Disable DMA request generation */ omap_dmic_write(dmic, OMAP_DMIC_DMAENABLE_CLR_REG, OMAP_DMIC_DMA_ENABLE); } static inline int dmic_is_enabled(struct omap_dmic *dmic) { return omap_dmic_read(dmic, OMAP_DMIC_CTRL_REG) & OMAP_DMIC_UP_ENABLE_MASK; } static int omap_dmic_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai); int ret = 0; mutex_lock(&dmic->mutex); if (!dai->active) dmic->active = 1; else ret = -EBUSY; mutex_unlock(&dmic->mutex); return ret; } static void omap_dmic_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai); mutex_lock(&dmic->mutex); if (!dai->active) dmic->active = 0; mutex_unlock(&dmic->mutex); } static int omap_dmic_select_divider(struct omap_dmic *dmic, int sample_rate) { int divider = -EINVAL; /* * 192KHz rate is only supported with 19.2MHz/3.84MHz clock * configuration. */ if (sample_rate == 192000) { if (dmic->fclk_freq == 19200000 && dmic->out_freq == 3840000) divider = 0x6; /* Divider: 5 (192KHz sampling rate) */ else dev_err(dmic->dev, "invalid clock configuration for 192KHz\n"); return divider; } switch (dmic->out_freq) { case 1536000: if (dmic->fclk_freq != 24576000) goto div_err; divider = 0x4; /* Divider: 16 */ break; case 2400000: switch (dmic->fclk_freq) { case 12000000: divider = 0x5; /* Divider: 5 */ break; case 19200000: divider = 0x0; /* Divider: 8 */ break; case 24000000: divider = 0x2; /* Divider: 10 */ break; default: goto div_err; } break; case 3072000: if (dmic->fclk_freq != 24576000) goto div_err; divider = 0x3; /* Divider: 8 */ break; case 3840000: if (dmic->fclk_freq != 19200000) goto div_err; divider = 0x1; /* Divider: 5 (96KHz sampling rate) */ break; default: dev_err(dmic->dev, "invalid out frequency: %dHz\n", dmic->out_freq); break; } return divider; div_err: dev_err(dmic->dev, "invalid out frequency %dHz for %dHz input\n", dmic->out_freq, dmic->fclk_freq); return -EINVAL; } static int omap_dmic_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai); int channels; dmic->clk_div = omap_dmic_select_divider(dmic, params_rate(params)); if (dmic->clk_div < 0) { dev_err(dmic->dev, "no valid divider for %dHz from %dHz\n", dmic->out_freq, dmic->fclk_freq); return -EINVAL; } dmic->ch_enabled = 0; channels = params_channels(params); switch (channels) { case 6: dmic->ch_enabled |= OMAP_DMIC_UP3_ENABLE; case 4: dmic->ch_enabled |= OMAP_DMIC_UP2_ENABLE; case 2: dmic->ch_enabled |= OMAP_DMIC_UP1_ENABLE; break; default: dev_err(dmic->dev, "invalid number of legacy channels\n"); return -EINVAL; } /* packet size is threshold * channels */ omap_dmic_dai_dma_params.packet_size = dmic->threshold * channels; snd_soc_dai_set_dma_data(dai, substream, &omap_dmic_dai_dma_params); return 0; } static int omap_dmic_dai_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai); u32 ctrl; /* Configure uplink threshold */ omap_dmic_write(dmic, OMAP_DMIC_FIFO_CTRL_REG, dmic->threshold); ctrl = omap_dmic_read(dmic, OMAP_DMIC_CTRL_REG); /* Set dmic out format */ ctrl &= ~(OMAP_DMIC_FORMAT | OMAP_DMIC_POLAR_MASK); ctrl |= (OMAP_DMICOUTFORMAT_LJUST | OMAP_DMIC_POLAR1 | OMAP_DMIC_POLAR2 | OMAP_DMIC_POLAR3); /* Configure dmic clock divider */ ctrl &= ~OMAP_DMIC_CLK_DIV_MASK; ctrl |= OMAP_DMIC_CLK_DIV(dmic->clk_div); omap_dmic_write(dmic, OMAP_DMIC_CTRL_REG, ctrl); omap_dmic_write(dmic, OMAP_DMIC_CTRL_REG, ctrl | OMAP_DMICOUTFORMAT_LJUST | OMAP_DMIC_POLAR1 | OMAP_DMIC_POLAR2 | OMAP_DMIC_POLAR3); return 0; } static int omap_dmic_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai); switch (cmd) { case SNDRV_PCM_TRIGGER_START: omap_dmic_start(dmic); break; case SNDRV_PCM_TRIGGER_STOP: omap_dmic_stop(dmic); break; default: break; } return 0; } static int omap_dmic_select_fclk(struct omap_dmic *dmic, int clk_id, unsigned int freq) { struct clk *parent_clk; char *parent_clk_name; int ret = 0; switch (freq) { case 12000000: case 19200000: case 24000000: case 24576000: break; default: dev_err(dmic->dev, "invalid input frequency: %dHz\n", freq); dmic->fclk_freq = 0; return -EINVAL; } if (dmic->sysclk == clk_id) { dmic->fclk_freq = freq; return 0; } /* re-parent not allowed if a stream is ongoing */ if (dmic->active && dmic_is_enabled(dmic)) { dev_err(dmic->dev, "can't re-parent when DMIC active\n"); return -EBUSY; } switch (clk_id) { case OMAP_DMIC_SYSCLK_PAD_CLKS: parent_clk_name = "pad_clks_ck"; break; case OMAP_DMIC_SYSCLK_SLIMBLUS_CLKS: parent_clk_name = "slimbus_clk"; break; case OMAP_DMIC_SYSCLK_SYNC_MUX_CLKS: parent_clk_name = "dmic_sync_mux_ck"; break; default: dev_err(dmic->dev, "fclk clk_id (%d) not supported\n", clk_id); return -EINVAL; } parent_clk = clk_get(dmic->dev, parent_clk_name); if (IS_ERR(parent_clk)) { dev_err(dmic->dev, "can't get %s\n", parent_clk_name); return -ENODEV; } mutex_lock(&dmic->mutex); if (dmic->active) { /* disable clock while reparenting */ pm_runtime_put_sync(dmic->dev); ret = clk_set_parent(dmic->fclk, parent_clk); pm_runtime_get_sync(dmic->dev); } else { ret = clk_set_parent(dmic->fclk, parent_clk); } mutex_unlock(&dmic->mutex); if (ret < 0) { dev_err(dmic->dev, "re-parent failed\n"); goto err_busy; } dmic->sysclk = clk_id; dmic->fclk_freq = freq; err_busy: clk_put(parent_clk); return ret; } static int omap_dmic_select_outclk(struct omap_dmic *dmic, int clk_id, unsigned int freq) { int ret = 0; if (clk_id != OMAP_DMIC_ABE_DMIC_CLK) { dev_err(dmic->dev, "output clk_id (%d) not supported\n", clk_id); return -EINVAL; } switch (freq) { case 1536000: case 2400000: case 3072000: case 3840000: dmic->out_freq = freq; break; default: dev_err(dmic->dev, "invalid out frequency: %dHz\n", freq); dmic->out_freq = 0; ret = -EINVAL; } return ret; } static int omap_dmic_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai); if (dir == SND_SOC_CLOCK_IN) return omap_dmic_select_fclk(dmic, clk_id, freq); else if (dir == SND_SOC_CLOCK_OUT) return omap_dmic_select_outclk(dmic, clk_id, freq); dev_err(dmic->dev, "invalid clock direction (%d)\n", dir); return -EINVAL; } static const struct snd_soc_dai_ops omap_dmic_dai_ops = { .startup = omap_dmic_dai_startup, .shutdown = omap_dmic_dai_shutdown, .hw_params = omap_dmic_dai_hw_params, .prepare = omap_dmic_dai_prepare, .trigger = omap_dmic_dai_trigger, .set_sysclk = omap_dmic_set_dai_sysclk, }; static int omap_dmic_probe(struct snd_soc_dai *dai) { struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai); pm_runtime_enable(dmic->dev); /* Disable lines while request is ongoing */ pm_runtime_get_sync(dmic->dev); omap_dmic_write(dmic, OMAP_DMIC_CTRL_REG, 0x00); pm_runtime_put_sync(dmic->dev); /* Configure DMIC threshold value */ dmic->threshold = OMAP_DMIC_THRES_MAX - 3; return 0; } static int omap_dmic_remove(struct snd_soc_dai *dai) { struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai); pm_runtime_disable(dmic->dev); return 0; } static struct snd_soc_dai_driver omap_dmic_dai = { .name = "omap-dmic", .probe = omap_dmic_probe, .remove = omap_dmic_remove, .capture = { .channels_min = 2, .channels_max = 6, .rates = SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, .formats = SNDRV_PCM_FMTBIT_S32_LE, .sig_bits = 24, }, .ops = &omap_dmic_dai_ops, }; static __devinit int asoc_dmic_probe(struct platform_device *pdev) { struct omap_dmic *dmic; struct resource *res; int ret; dmic = devm_kzalloc(&pdev->dev, sizeof(struct omap_dmic), GFP_KERNEL); if (!dmic) return -ENOMEM; platform_set_drvdata(pdev, dmic); dmic->dev = &pdev->dev; dmic->sysclk = OMAP_DMIC_SYSCLK_SYNC_MUX_CLKS; mutex_init(&dmic->mutex); dmic->fclk = clk_get(dmic->dev, "dmic_fck"); if (IS_ERR(dmic->fclk)) { dev_err(dmic->dev, "cant get dmic_fck\n"); return -ENODEV; } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma"); if (!res) { dev_err(dmic->dev, "invalid dma memory resource\n"); ret = -ENODEV; goto err_put_clk; } omap_dmic_dai_dma_params.port_addr = res->start + OMAP_DMIC_DATA_REG; res = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!res) { dev_err(dmic->dev, "invalid dma resource\n"); ret = -ENODEV; goto err_put_clk; } omap_dmic_dai_dma_params.dma_req = res->start; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); if (!res) { dev_err(dmic->dev, "invalid memory resource\n"); ret = -ENODEV; goto err_put_clk; } if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res), pdev->name)) { dev_err(dmic->dev, "memory region already claimed\n"); ret = -ENODEV; goto err_put_clk; } dmic->io_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!dmic->io_base) { ret = -ENOMEM; goto err_put_clk; } ret = snd_soc_register_dai(&pdev->dev, &omap_dmic_dai); if (ret) goto err_put_clk; return 0; err_put_clk: clk_put(dmic->fclk); return ret; } static int __devexit asoc_dmic_remove(struct platform_device *pdev) { struct omap_dmic *dmic = platform_get_drvdata(pdev); snd_soc_unregister_dai(&pdev->dev); clk_put(dmic->fclk); return 0; } static struct platform_driver asoc_dmic_driver = { .driver = { .name = "omap-dmic", .owner = THIS_MODULE, }, .probe = asoc_dmic_probe, .remove = __devexit_p(asoc_dmic_remove), }; module_platform_driver(asoc_dmic_driver); MODULE_ALIAS("platform:omap-dmic"); MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>"); MODULE_DESCRIPTION("OMAP DMIC ASoC Interface"); MODULE_LICENSE("GPL");
gpl-2.0
sonulohani/Xperia-L-Kernel
drivers/acpi/glue.c
5048
6011
/* * Link physical devices with ACPI devices support * * Copyright (c) 2005 David Shaohua Li <shaohua.li@intel.com> * Copyright (c) 2005 Intel Corp. * * This file is released under the GPLv2. */ #include <linux/export.h> #include <linux/init.h> #include <linux/list.h> #include <linux/device.h> #include <linux/slab.h> #include <linux/rwsem.h> #include <linux/acpi.h> #include "internal.h" #define ACPI_GLUE_DEBUG 0 #if ACPI_GLUE_DEBUG #define DBG(x...) printk(PREFIX x) #else #define DBG(x...) do { } while(0) #endif static LIST_HEAD(bus_type_list); static DECLARE_RWSEM(bus_type_sem); int register_acpi_bus_type(struct acpi_bus_type *type) { if (acpi_disabled) return -ENODEV; if (type && type->bus && type->find_device) { down_write(&bus_type_sem); list_add_tail(&type->list, &bus_type_list); up_write(&bus_type_sem); printk(KERN_INFO PREFIX "bus type %s registered\n", type->bus->name); return 0; } return -ENODEV; } int unregister_acpi_bus_type(struct acpi_bus_type *type) { if (acpi_disabled) return 0; if (type) { down_write(&bus_type_sem); list_del_init(&type->list); up_write(&bus_type_sem); printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", type->bus->name); return 0; } return -ENODEV; } static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type) { struct acpi_bus_type *tmp, *ret = NULL; down_read(&bus_type_sem); list_for_each_entry(tmp, &bus_type_list, list) { if (tmp->bus == type) { ret = tmp; break; } } up_read(&bus_type_sem); return ret; } static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle) { struct acpi_bus_type *tmp; int ret = -ENODEV; down_read(&bus_type_sem); list_for_each_entry(tmp, &bus_type_list, list) { if (tmp->find_bridge && !tmp->find_bridge(dev, handle)) { ret = 0; break; } } up_read(&bus_type_sem); return ret; } /* Get device's handler per its address under its parent */ struct acpi_find_child { acpi_handle handle; u64 address; }; static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv) { acpi_status status; struct acpi_device_info *info; struct acpi_find_child *find = context; status = acpi_get_object_info(handle, &info); if (ACPI_SUCCESS(status)) { if ((info->address == find->address) && (info->valid & ACPI_VALID_ADR)) find->handle = handle; kfree(info); } return AE_OK; } acpi_handle acpi_get_child(acpi_handle parent, u64 address) { struct acpi_find_child find = { NULL, address }; if (!parent) return NULL; acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, do_acpi_find_child, NULL, &find, NULL); return find.handle; } EXPORT_SYMBOL(acpi_get_child); /* Link ACPI devices with physical devices */ static void acpi_glue_data_handler(acpi_handle handle, void *context) { /* we provide an empty handler */ } /* Note: a success call will increase reference count by one */ struct device *acpi_get_physical_device(acpi_handle handle) { acpi_status status; struct device *dev; status = acpi_get_data(handle, acpi_glue_data_handler, (void **)&dev); if (ACPI_SUCCESS(status)) return get_device(dev); return NULL; } EXPORT_SYMBOL(acpi_get_physical_device); static int acpi_bind_one(struct device *dev, acpi_handle handle) { struct acpi_device *acpi_dev; acpi_status status; if (dev->archdata.acpi_handle) { dev_warn(dev, "Drivers changed 'acpi_handle'\n"); return -EINVAL; } get_device(dev); status = acpi_attach_data(handle, acpi_glue_data_handler, dev); if (ACPI_FAILURE(status)) { put_device(dev); return -EINVAL; } dev->archdata.acpi_handle = handle; status = acpi_bus_get_device(handle, &acpi_dev); if (!ACPI_FAILURE(status)) { int ret; ret = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, "firmware_node"); ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, "physical_node"); if (acpi_dev->wakeup.flags.valid) device_set_wakeup_capable(dev, true); } return 0; } static int acpi_unbind_one(struct device *dev) { if (!dev->archdata.acpi_handle) return 0; if (dev == acpi_get_physical_device(dev->archdata.acpi_handle)) { struct acpi_device *acpi_dev; /* acpi_get_physical_device increase refcnt by one */ put_device(dev); if (!acpi_bus_get_device(dev->archdata.acpi_handle, &acpi_dev)) { sysfs_remove_link(&dev->kobj, "firmware_node"); sysfs_remove_link(&acpi_dev->dev.kobj, "physical_node"); } acpi_detach_data(dev->archdata.acpi_handle, acpi_glue_data_handler); dev->archdata.acpi_handle = NULL; /* acpi_bind_one increase refcnt by one */ put_device(dev); } else { dev_err(dev, "Oops, 'acpi_handle' corrupt\n"); } return 0; } static int acpi_platform_notify(struct device *dev) { struct acpi_bus_type *type; acpi_handle handle; int ret = -EINVAL; if (!dev->bus || !dev->parent) { /* bridge devices genernally haven't bus or parent */ ret = acpi_find_bridge_device(dev, &handle); goto end; } type = acpi_get_bus_type(dev->bus); if (!type) { DBG("No ACPI bus support for %s\n", dev_name(dev)); ret = -EINVAL; goto end; } if ((ret = type->find_device(dev, &handle)) != 0) DBG("Can't get handler for %s\n", dev_name(dev)); end: if (!ret) acpi_bind_one(dev, handle); #if ACPI_GLUE_DEBUG if (!ret) { struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; acpi_get_name(dev->archdata.acpi_handle, ACPI_FULL_PATHNAME, &buffer); DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer); kfree(buffer.pointer); } else DBG("Device %s -> No ACPI support\n", dev_name(dev)); #endif return ret; } static int acpi_platform_notify_remove(struct device *dev) { acpi_unbind_one(dev); return 0; } int __init init_acpi_device_notify(void) { if (platform_notify || platform_notify_remove) { printk(KERN_ERR PREFIX "Can't use platform_notify\n"); return 0; } platform_notify = acpi_platform_notify; platform_notify_remove = acpi_platform_notify_remove; return 0; }
gpl-2.0
figue/chroma_kernel_mako
crypto/lrw.c
7352
9419
/* LRW: as defined by Cyril Guyot in * http://grouper.ieee.org/groups/1619/email/pdf00017.pdf * * Copyright (c) 2006 Rik Snel <rsnel@cube.dyndns.org> * * Based on ecb.c * Copyright (c) 2006 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. */ /* This implementation is checked against the test vectors in the above * document and by a test vector provided by Ken Buchanan at * http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html * * The test vectors are included in the testing module tcrypt.[ch] */ #include <crypto/algapi.h> #include <linux/err.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/scatterlist.h> #include <linux/slab.h> #include <crypto/b128ops.h> #include <crypto/gf128mul.h> #include <crypto/lrw.h> struct priv { struct crypto_cipher *child; struct lrw_table_ctx table; }; static inline void setbit128_bbe(void *b, int bit) { __set_bit(bit ^ (0x80 - #ifdef __BIG_ENDIAN BITS_PER_LONG #else BITS_PER_BYTE #endif ), b); } int lrw_init_table(struct lrw_table_ctx *ctx, const u8 *tweak) { be128 tmp = { 0 }; int i; if (ctx->table) gf128mul_free_64k(ctx->table); /* initialize multiplication table for Key2 */ ctx->table = gf128mul_init_64k_bbe((be128 *)tweak); if (!ctx->table) return -ENOMEM; /* initialize optimization table */ for (i = 0; i < 128; i++) { setbit128_bbe(&tmp, i); ctx->mulinc[i] = tmp; gf128mul_64k_bbe(&ctx->mulinc[i], ctx->table); } return 0; } EXPORT_SYMBOL_GPL(lrw_init_table); void lrw_free_table(struct lrw_table_ctx *ctx) { if (ctx->table) gf128mul_free_64k(ctx->table); } EXPORT_SYMBOL_GPL(lrw_free_table); static int setkey(struct crypto_tfm *parent, const u8 *key, unsigned int keylen) { struct priv *ctx = crypto_tfm_ctx(parent); struct crypto_cipher *child = ctx->child; int err, bsize = LRW_BLOCK_SIZE; const u8 *tweak = key + keylen - bsize; crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK); crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) & CRYPTO_TFM_REQ_MASK); err = crypto_cipher_setkey(child, key, keylen - bsize); if (err) return err; crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) & CRYPTO_TFM_RES_MASK); return lrw_init_table(&ctx->table, tweak); } struct sinfo { be128 t; struct crypto_tfm *tfm; void (*fn)(struct crypto_tfm *, u8 *, const u8 *); }; static inline void inc(be128 *iv) { be64_add_cpu(&iv->b, 1); if (!iv->b) be64_add_cpu(&iv->a, 1); } static inline void lrw_round(struct sinfo *s, void *dst, const void *src) { be128_xor(dst, &s->t, src); /* PP <- T xor P */ s->fn(s->tfm, dst, dst); /* CC <- E(Key2,PP) */ be128_xor(dst, dst, &s->t); /* C <- T xor CC */ } /* this returns the number of consequative 1 bits starting * from the right, get_index128(00 00 00 00 00 00 ... 00 00 10 FB) = 2 */ static inline int get_index128(be128 *block) { int x; __be32 *p = (__be32 *) block; for (p += 3, x = 0; x < 128; p--, x += 32) { u32 val = be32_to_cpup(p); if (!~val) continue; return x + ffz(val); } return x; } static int crypt(struct blkcipher_desc *d, struct blkcipher_walk *w, struct priv *ctx, void (*fn)(struct crypto_tfm *, u8 *, const u8 *)) { int err; unsigned int avail; const int bs = LRW_BLOCK_SIZE; struct sinfo s = { .tfm = crypto_cipher_tfm(ctx->child), .fn = fn }; be128 *iv; u8 *wsrc; u8 *wdst; err = blkcipher_walk_virt(d, w); if (!(avail = w->nbytes)) return err; wsrc = w->src.virt.addr; wdst = w->dst.virt.addr; /* calculate first value of T */ iv = (be128 *)w->iv; s.t = *iv; /* T <- I*Key2 */ gf128mul_64k_bbe(&s.t, ctx->table.table); goto first; for (;;) { do { /* T <- I*Key2, using the optimization * discussed in the specification */ be128_xor(&s.t, &s.t, &ctx->table.mulinc[get_index128(iv)]); inc(iv); first: lrw_round(&s, wdst, wsrc); wsrc += bs; wdst += bs; } while ((avail -= bs) >= bs); err = blkcipher_walk_done(d, w, avail); if (!(avail = w->nbytes)) break; wsrc = w->src.virt.addr; wdst = w->dst.virt.addr; } return err; } static int encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) { struct priv *ctx = crypto_blkcipher_ctx(desc->tfm); struct blkcipher_walk w; blkcipher_walk_init(&w, dst, src, nbytes); return crypt(desc, &w, ctx, crypto_cipher_alg(ctx->child)->cia_encrypt); } static int decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) { struct priv *ctx = crypto_blkcipher_ctx(desc->tfm); struct blkcipher_walk w; blkcipher_walk_init(&w, dst, src, nbytes); return crypt(desc, &w, ctx, crypto_cipher_alg(ctx->child)->cia_decrypt); } int lrw_crypt(struct blkcipher_desc *desc, struct scatterlist *sdst, struct scatterlist *ssrc, unsigned int nbytes, struct lrw_crypt_req *req) { const unsigned int bsize = LRW_BLOCK_SIZE; const unsigned int max_blks = req->tbuflen / bsize; struct lrw_table_ctx *ctx = req->table_ctx; struct blkcipher_walk walk; unsigned int nblocks; be128 *iv, *src, *dst, *t; be128 *t_buf = req->tbuf; int err, i; BUG_ON(max_blks < 1); blkcipher_walk_init(&walk, sdst, ssrc, nbytes); err = blkcipher_walk_virt(desc, &walk); nbytes = walk.nbytes; if (!nbytes) return err; nblocks = min(walk.nbytes / bsize, max_blks); src = (be128 *)walk.src.virt.addr; dst = (be128 *)walk.dst.virt.addr; /* calculate first value of T */ iv = (be128 *)walk.iv; t_buf[0] = *iv; /* T <- I*Key2 */ gf128mul_64k_bbe(&t_buf[0], ctx->table); i = 0; goto first; for (;;) { do { for (i = 0; i < nblocks; i++) { /* T <- I*Key2, using the optimization * discussed in the specification */ be128_xor(&t_buf[i], t, &ctx->mulinc[get_index128(iv)]); inc(iv); first: t = &t_buf[i]; /* PP <- T xor P */ be128_xor(dst + i, t, src + i); } /* CC <- E(Key2,PP) */ req->crypt_fn(req->crypt_ctx, (u8 *)dst, nblocks * bsize); /* C <- T xor CC */ for (i = 0; i < nblocks; i++) be128_xor(dst + i, dst + i, &t_buf[i]); src += nblocks; dst += nblocks; nbytes -= nblocks * bsize; nblocks = min(nbytes / bsize, max_blks); } while (nblocks > 0); err = blkcipher_walk_done(desc, &walk, nbytes); nbytes = walk.nbytes; if (!nbytes) break; nblocks = min(nbytes / bsize, max_blks); src = (be128 *)walk.src.virt.addr; dst = (be128 *)walk.dst.virt.addr; } return err; } EXPORT_SYMBOL_GPL(lrw_crypt); static int init_tfm(struct crypto_tfm *tfm) { struct crypto_cipher *cipher; struct crypto_instance *inst = (void *)tfm->__crt_alg; struct crypto_spawn *spawn = crypto_instance_ctx(inst); struct priv *ctx = crypto_tfm_ctx(tfm); u32 *flags = &tfm->crt_flags; cipher = crypto_spawn_cipher(spawn); if (IS_ERR(cipher)) return PTR_ERR(cipher); if (crypto_cipher_blocksize(cipher) != LRW_BLOCK_SIZE) { *flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN; crypto_free_cipher(cipher); return -EINVAL; } ctx->child = cipher; return 0; } static void exit_tfm(struct crypto_tfm *tfm) { struct priv *ctx = crypto_tfm_ctx(tfm); lrw_free_table(&ctx->table); crypto_free_cipher(ctx->child); } static struct crypto_instance *alloc(struct rtattr **tb) { struct crypto_instance *inst; struct crypto_alg *alg; int err; err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER); if (err) return ERR_PTR(err); alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER, CRYPTO_ALG_TYPE_MASK); if (IS_ERR(alg)) return ERR_CAST(alg); inst = crypto_alloc_instance("lrw", alg); if (IS_ERR(inst)) goto out_put_alg; inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER; inst->alg.cra_priority = alg->cra_priority; inst->alg.cra_blocksize = alg->cra_blocksize; if (alg->cra_alignmask < 7) inst->alg.cra_alignmask = 7; else inst->alg.cra_alignmask = alg->cra_alignmask; inst->alg.cra_type = &crypto_blkcipher_type; if (!(alg->cra_blocksize % 4)) inst->alg.cra_alignmask |= 3; inst->alg.cra_blkcipher.ivsize = alg->cra_blocksize; inst->alg.cra_blkcipher.min_keysize = alg->cra_cipher.cia_min_keysize + alg->cra_blocksize; inst->alg.cra_blkcipher.max_keysize = alg->cra_cipher.cia_max_keysize + alg->cra_blocksize; inst->alg.cra_ctxsize = sizeof(struct priv); inst->alg.cra_init = init_tfm; inst->alg.cra_exit = exit_tfm; inst->alg.cra_blkcipher.setkey = setkey; inst->alg.cra_blkcipher.encrypt = encrypt; inst->alg.cra_blkcipher.decrypt = decrypt; out_put_alg: crypto_mod_put(alg); return inst; } static void free(struct crypto_instance *inst) { crypto_drop_spawn(crypto_instance_ctx(inst)); kfree(inst); } static struct crypto_template crypto_tmpl = { .name = "lrw", .alloc = alloc, .free = free, .module = THIS_MODULE, }; static int __init crypto_module_init(void) { return crypto_register_template(&crypto_tmpl); } static void __exit crypto_module_exit(void) { crypto_unregister_template(&crypto_tmpl); } module_init(crypto_module_init); module_exit(crypto_module_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("LRW block cipher mode");
gpl-2.0
uliamo/android_kernel_zte_quantum
drivers/hid/hid-lcpower.c
8120
1919
/* * HID driver for LC Power Model RC1000MCE * * Copyright (c) 2011 Chris Schlund * based on hid-topseed module */ /* * 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/device.h> #include <linux/hid.h> #include <linux/module.h> #include "hid-ids.h" #define ts_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ EV_KEY, (c)) static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { if ((usage->hid & HID_USAGE_PAGE) != 0x0ffbc0000) return 0; switch (usage->hid & HID_USAGE) { case 0x046: ts_map_key_clear(KEY_YELLOW); break; case 0x047: ts_map_key_clear(KEY_GREEN); break; case 0x049: ts_map_key_clear(KEY_BLUE); break; case 0x04a: ts_map_key_clear(KEY_RED); break; case 0x00d: ts_map_key_clear(KEY_HOME); break; case 0x025: ts_map_key_clear(KEY_TV); break; case 0x048: ts_map_key_clear(KEY_VCR); break; case 0x024: ts_map_key_clear(KEY_MENU); break; default: return 0; } return 1; } static const struct hid_device_id ts_devices[] = { { HID_USB_DEVICE( USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000) }, { } }; MODULE_DEVICE_TABLE(hid, ts_devices); static struct hid_driver ts_driver = { .name = "LC RC1000MCE", .id_table = ts_devices, .input_mapping = ts_input_mapping, }; static int __init ts_init(void) { return hid_register_driver(&ts_driver); } static void __exit ts_exit(void) { hid_unregister_driver(&ts_driver); } module_init(ts_init); module_exit(ts_exit); MODULE_LICENSE("GPL");
gpl-2.0
agat63/AGAT_R970_USC
arch/mips/pmc-sierra/yosemite/atmel_read_eeprom.c
8632
3613
/* * Copyright (C) 2003 PMC-Sierra Inc. * Author: Manish Lachwani (lachwani@pmc-sierra.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. */ /* * Description: * * This code reads the ATMEL 24CXX EEPROM. The PMC-Sierra Yosemite board uses the ATMEL * 24C32/24C64 which uses two byte addressing as compared to 24C16. Note that this program * uses the serial port like /dev/ttyS0, to communicate with the EEPROM. Hence, you are * expected to have a connectivity from the EEPROM to the serial port. This program does * __not__ communicate using the I2C protocol */ #include "atmel_read_eeprom.h" static void delay(int delay) { while (delay--); } static void send_bit(unsigned char bit) { scl_lo; delay(TXX); if (bit) sda_hi; else sda_lo; delay(TXX); scl_hi; delay(TXX); } static void send_ack(void) { send_bit(0); } static void send_byte(unsigned char byte) { int i = 0; for (i = 7; i >= 0; i--) send_bit((byte >> i) & 0x01); } static void send_start(void) { sda_hi; delay(TXX); scl_hi; delay(TXX); sda_lo; delay(TXX); } static void send_stop(void) { sda_lo; delay(TXX); scl_hi; delay(TXX); sda_hi; delay(TXX); } static void do_idle(void) { sda_hi; scl_hi; vcc_off; } static int recv_bit(void) { int status; scl_lo; delay(TXX); sda_hi; delay(TXX); scl_hi; delay(TXX); return 1; } static unsigned char recv_byte(void) { int i; unsigned char byte=0; for (i=7;i>=0;i--) byte |= (recv_bit() << i); return byte; } static int recv_ack(void) { unsigned int ack; ack = (unsigned int)recv_bit(); scl_lo; if (ack) { do_idle(); printk(KERN_ERR "Error reading the Atmel 24C32/24C64 EEPROM\n"); return -1; } return ack; } /* * This function does the actual read of the EEPROM. It needs the buffer into which the * read data is copied, the size of the EEPROM being read and the buffer size */ int read_eeprom(char *buffer, int eeprom_size, int size) { int i = 0, err; send_start(); send_byte(W_HEADER); recv_ack(); /* EEPROM with size of more than 2K need two byte addressing */ if (eeprom_size > 2048) { send_byte(0x00); recv_ack(); } send_start(); send_byte(R_HEADER); err = recv_ack(); if (err == -1) return err; for (i = 0; i < size; i++) { *buffer++ = recv_byte(); send_ack(); } /* Note : We should do some check if the buffer contains correct information */ send_stop(); }
gpl-2.0
KFire-Android/kernel_omap_otter-common
drivers/misc/iwmc3200top/fw-download.c
9144
10191
/* * iwmc3200top - Intel Wireless MultiCom 3200 Top Driver * drivers/misc/iwmc3200top/fw-download.c * * Copyright (C) 2009 Intel Corporation. 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., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. * * * Author Name: Maxim Grabarnik <maxim.grabarnink@intel.com> * - * */ #include <linux/firmware.h> #include <linux/mmc/sdio_func.h> #include <linux/slab.h> #include <asm/unaligned.h> #include "iwmc3200top.h" #include "log.h" #include "fw-msg.h" #define CHECKSUM_BYTES_NUM sizeof(u32) /** init parser struct with file */ static int iwmct_fw_parser_init(struct iwmct_priv *priv, const u8 *file, size_t file_size, size_t block_size) { struct iwmct_parser *parser = &priv->parser; struct iwmct_fw_hdr *fw_hdr = &parser->versions; LOG_TRACE(priv, FW_DOWNLOAD, "-->\n"); LOG_INFO(priv, FW_DOWNLOAD, "file_size=%zd\n", file_size); parser->file = file; parser->file_size = file_size; parser->cur_pos = 0; parser->entry_point = 0; parser->buf = kzalloc(block_size, GFP_KERNEL); if (!parser->buf) { LOG_ERROR(priv, FW_DOWNLOAD, "kzalloc error\n"); return -ENOMEM; } parser->buf_size = block_size; /* extract fw versions */ memcpy(fw_hdr, parser->file, sizeof(struct iwmct_fw_hdr)); LOG_INFO(priv, FW_DOWNLOAD, "fw versions are:\n" "top %u.%u.%u gps %u.%u.%u bt %u.%u.%u tic %s\n", fw_hdr->top_major, fw_hdr->top_minor, fw_hdr->top_revision, fw_hdr->gps_major, fw_hdr->gps_minor, fw_hdr->gps_revision, fw_hdr->bt_major, fw_hdr->bt_minor, fw_hdr->bt_revision, fw_hdr->tic_name); parser->cur_pos += sizeof(struct iwmct_fw_hdr); LOG_TRACE(priv, FW_DOWNLOAD, "<--\n"); return 0; } static bool iwmct_checksum(struct iwmct_priv *priv) { struct iwmct_parser *parser = &priv->parser; __le32 *file = (__le32 *)parser->file; int i, pad, steps; u32 accum = 0; u32 checksum; u32 mask = 0xffffffff; pad = (parser->file_size - CHECKSUM_BYTES_NUM) % 4; steps = (parser->file_size - CHECKSUM_BYTES_NUM) / 4; LOG_INFO(priv, FW_DOWNLOAD, "pad=%d steps=%d\n", pad, steps); for (i = 0; i < steps; i++) accum += le32_to_cpu(file[i]); if (pad) { mask <<= 8 * (4 - pad); accum += le32_to_cpu(file[steps]) & mask; } checksum = get_unaligned_le32((__le32 *)(parser->file + parser->file_size - CHECKSUM_BYTES_NUM)); LOG_INFO(priv, FW_DOWNLOAD, "compare checksum accum=0x%x to checksum=0x%x\n", accum, checksum); return checksum == accum; } static int iwmct_parse_next_section(struct iwmct_priv *priv, const u8 **p_sec, size_t *sec_size, __le32 *sec_addr) { struct iwmct_parser *parser = &priv->parser; struct iwmct_dbg *dbg = &priv->dbg; struct iwmct_fw_sec_hdr *sec_hdr; LOG_TRACE(priv, FW_DOWNLOAD, "-->\n"); while (parser->cur_pos + sizeof(struct iwmct_fw_sec_hdr) <= parser->file_size) { sec_hdr = (struct iwmct_fw_sec_hdr *) (parser->file + parser->cur_pos); parser->cur_pos += sizeof(struct iwmct_fw_sec_hdr); LOG_INFO(priv, FW_DOWNLOAD, "sec hdr: type=%s addr=0x%x size=%d\n", sec_hdr->type, sec_hdr->target_addr, sec_hdr->data_size); if (strcmp(sec_hdr->type, "ENT") == 0) parser->entry_point = le32_to_cpu(sec_hdr->target_addr); else if (strcmp(sec_hdr->type, "LBL") == 0) strcpy(dbg->label_fw, parser->file + parser->cur_pos); else if (((strcmp(sec_hdr->type, "TOP") == 0) && (priv->barker & BARKER_DNLOAD_TOP_MSK)) || ((strcmp(sec_hdr->type, "GPS") == 0) && (priv->barker & BARKER_DNLOAD_GPS_MSK)) || ((strcmp(sec_hdr->type, "BTH") == 0) && (priv->barker & BARKER_DNLOAD_BT_MSK))) { *sec_addr = sec_hdr->target_addr; *sec_size = le32_to_cpu(sec_hdr->data_size); *p_sec = parser->file + parser->cur_pos; parser->cur_pos += le32_to_cpu(sec_hdr->data_size); return 1; } else if (strcmp(sec_hdr->type, "LOG") != 0) LOG_WARNING(priv, FW_DOWNLOAD, "skipping section type %s\n", sec_hdr->type); parser->cur_pos += le32_to_cpu(sec_hdr->data_size); LOG_INFO(priv, FW_DOWNLOAD, "finished with section cur_pos=%zd\n", parser->cur_pos); } LOG_TRACE(priv, INIT, "<--\n"); return 0; } static int iwmct_download_section(struct iwmct_priv *priv, const u8 *p_sec, size_t sec_size, __le32 addr) { struct iwmct_parser *parser = &priv->parser; struct iwmct_fw_load_hdr *hdr = (struct iwmct_fw_load_hdr *)parser->buf; const u8 *cur_block = p_sec; size_t sent = 0; int cnt = 0; int ret = 0; u32 cmd = 0; LOG_TRACE(priv, FW_DOWNLOAD, "-->\n"); LOG_INFO(priv, FW_DOWNLOAD, "Download address 0x%x size 0x%zx\n", addr, sec_size); while (sent < sec_size) { int i; u32 chksm = 0; u32 reset = atomic_read(&priv->reset); /* actual FW data */ u32 data_size = min(parser->buf_size - sizeof(*hdr), sec_size - sent); /* Pad to block size */ u32 trans_size = (data_size + sizeof(*hdr) + IWMC_SDIO_BLK_SIZE - 1) & ~(IWMC_SDIO_BLK_SIZE - 1); ++cnt; /* in case of reset, interrupt FW DOWNLAOD */ if (reset) { LOG_INFO(priv, FW_DOWNLOAD, "Reset detected. Abort FW download!!!"); ret = -ECANCELED; goto exit; } memset(parser->buf, 0, parser->buf_size); cmd |= IWMC_OPCODE_WRITE << CMD_HDR_OPCODE_POS; cmd |= IWMC_CMD_SIGNATURE << CMD_HDR_SIGNATURE_POS; cmd |= (priv->dbg.direct ? 1 : 0) << CMD_HDR_DIRECT_ACCESS_POS; cmd |= (priv->dbg.checksum ? 1 : 0) << CMD_HDR_USE_CHECKSUM_POS; hdr->data_size = cpu_to_le32(data_size); hdr->target_addr = addr; /* checksum is allowed for sizes divisible by 4 */ if (data_size & 0x3) cmd &= ~CMD_HDR_USE_CHECKSUM_MSK; memcpy(hdr->data, cur_block, data_size); if (cmd & CMD_HDR_USE_CHECKSUM_MSK) { chksm = data_size + le32_to_cpu(addr) + cmd; for (i = 0; i < data_size >> 2; i++) chksm += ((u32 *)cur_block)[i]; hdr->block_chksm = cpu_to_le32(chksm); LOG_INFO(priv, FW_DOWNLOAD, "Checksum = 0x%X\n", hdr->block_chksm); } LOG_INFO(priv, FW_DOWNLOAD, "trans#%d, len=%d, sent=%zd, " "sec_size=%zd, startAddress 0x%X\n", cnt, trans_size, sent, sec_size, addr); if (priv->dbg.dump) LOG_HEXDUMP(FW_DOWNLOAD, parser->buf, trans_size); hdr->cmd = cpu_to_le32(cmd); /* send it down */ /* TODO: add more proper sending and error checking */ ret = iwmct_tx(priv, parser->buf, trans_size); if (ret != 0) { LOG_INFO(priv, FW_DOWNLOAD, "iwmct_tx returned %d\n", ret); goto exit; } addr = cpu_to_le32(le32_to_cpu(addr) + data_size); sent += data_size; cur_block = p_sec + sent; if (priv->dbg.blocks && (cnt + 1) >= priv->dbg.blocks) { LOG_INFO(priv, FW_DOWNLOAD, "Block number limit is reached [%d]\n", priv->dbg.blocks); break; } } if (sent < sec_size) ret = -EINVAL; exit: LOG_TRACE(priv, FW_DOWNLOAD, "<--\n"); return ret; } static int iwmct_kick_fw(struct iwmct_priv *priv, bool jump) { struct iwmct_parser *parser = &priv->parser; struct iwmct_fw_load_hdr *hdr = (struct iwmct_fw_load_hdr *)parser->buf; int ret; u32 cmd; LOG_TRACE(priv, FW_DOWNLOAD, "-->\n"); memset(parser->buf, 0, parser->buf_size); cmd = IWMC_CMD_SIGNATURE << CMD_HDR_SIGNATURE_POS; if (jump) { cmd |= IWMC_OPCODE_JUMP << CMD_HDR_OPCODE_POS; hdr->target_addr = cpu_to_le32(parser->entry_point); LOG_INFO(priv, FW_DOWNLOAD, "jump address 0x%x\n", parser->entry_point); } else { cmd |= IWMC_OPCODE_LAST_COMMAND << CMD_HDR_OPCODE_POS; LOG_INFO(priv, FW_DOWNLOAD, "last command\n"); } hdr->cmd = cpu_to_le32(cmd); LOG_HEXDUMP(FW_DOWNLOAD, parser->buf, sizeof(*hdr)); /* send it down */ /* TODO: add more proper sending and error checking */ ret = iwmct_tx(priv, parser->buf, IWMC_SDIO_BLK_SIZE); if (ret) LOG_INFO(priv, FW_DOWNLOAD, "iwmct_tx returned %d", ret); LOG_TRACE(priv, FW_DOWNLOAD, "<--\n"); return 0; } int iwmct_fw_load(struct iwmct_priv *priv) { const u8 *fw_name = FW_NAME(FW_API_VER); const struct firmware *raw; const u8 *pdata; size_t len; __le32 addr; int ret; LOG_INFO(priv, FW_DOWNLOAD, "barker download request 0x%x is:\n", priv->barker); LOG_INFO(priv, FW_DOWNLOAD, "******* Top FW %s requested ********\n", (priv->barker & BARKER_DNLOAD_TOP_MSK) ? "was" : "not"); LOG_INFO(priv, FW_DOWNLOAD, "******* GPS FW %s requested ********\n", (priv->barker & BARKER_DNLOAD_GPS_MSK) ? "was" : "not"); LOG_INFO(priv, FW_DOWNLOAD, "******* BT FW %s requested ********\n", (priv->barker & BARKER_DNLOAD_BT_MSK) ? "was" : "not"); /* get the firmware */ ret = request_firmware(&raw, fw_name, &priv->func->dev); if (ret < 0) { LOG_ERROR(priv, FW_DOWNLOAD, "%s request_firmware failed %d\n", fw_name, ret); goto exit; } if (raw->size < sizeof(struct iwmct_fw_sec_hdr)) { LOG_ERROR(priv, FW_DOWNLOAD, "%s smaller then (%zd) (%zd)\n", fw_name, sizeof(struct iwmct_fw_sec_hdr), raw->size); goto exit; } LOG_INFO(priv, FW_DOWNLOAD, "Read firmware '%s'\n", fw_name); /* clear parser struct */ ret = iwmct_fw_parser_init(priv, raw->data, raw->size, priv->trans_len); if (ret < 0) { LOG_ERROR(priv, FW_DOWNLOAD, "iwmct_parser_init failed: Reason %d\n", ret); goto exit; } if (!iwmct_checksum(priv)) { LOG_ERROR(priv, FW_DOWNLOAD, "checksum error\n"); ret = -EINVAL; goto exit; } /* download firmware to device */ while (iwmct_parse_next_section(priv, &pdata, &len, &addr)) { ret = iwmct_download_section(priv, pdata, len, addr); if (ret) { LOG_ERROR(priv, FW_DOWNLOAD, "%s download section failed\n", fw_name); goto exit; } } ret = iwmct_kick_fw(priv, !!(priv->barker & BARKER_DNLOAD_JUMP_MSK)); exit: kfree(priv->parser.buf); release_firmware(raw); return ret; }
gpl-2.0
Perseus71/KT747
arch/tile/lib/memset_32.c
9912
6375
/* * Copyright 2010 Tilera Corporation. 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, version 2. * * 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, GOOD TITLE or * NON INFRINGEMENT. See the GNU General Public License for * more details. */ #include <arch/chip.h> #include <linux/types.h> #include <linux/string.h> #include <linux/module.h> #undef memset void *memset(void *s, int c, size_t n) { uint32_t *out32; int n32; uint32_t v16, v32; uint8_t *out8 = s; #if !CHIP_HAS_WH64() int ahead32; #else int to_align32; #endif /* Experimentation shows that a trivial tight loop is a win up until * around a size of 20, where writing a word at a time starts to win. */ #define BYTE_CUTOFF 20 #if BYTE_CUTOFF < 3 /* This must be at least at least this big, or some code later * on doesn't work. */ #error "BYTE_CUTOFF is too small" #endif if (n < BYTE_CUTOFF) { /* Strangely, this turns out to be the tightest way to * write this loop. */ if (n != 0) { do { /* Strangely, combining these into one line * performs worse. */ *out8 = c; out8++; } while (--n != 0); } return s; } #if !CHIP_HAS_WH64() /* Use a spare issue slot to start prefetching the first cache * line early. This instruction is free as the store can be buried * in otherwise idle issue slots doing ALU ops. */ __insn_prefetch(out8); /* We prefetch the end so that a short memset that spans two cache * lines gets some prefetching benefit. Again we believe this is free * to issue. */ __insn_prefetch(&out8[n - 1]); #endif /* !CHIP_HAS_WH64() */ /* Align 'out8'. We know n >= 3 so this won't write past the end. */ while (((uintptr_t) out8 & 3) != 0) { *out8++ = c; --n; } /* Align 'n'. */ while (n & 3) out8[--n] = c; out32 = (uint32_t *) out8; n32 = n >> 2; /* Tile input byte out to 32 bits. */ v16 = __insn_intlb(c, c); v32 = __insn_intlh(v16, v16); /* This must be at least 8 or the following loop doesn't work. */ #define CACHE_LINE_SIZE_IN_WORDS (CHIP_L2_LINE_SIZE() / 4) #if !CHIP_HAS_WH64() ahead32 = CACHE_LINE_SIZE_IN_WORDS; /* We already prefetched the first and last cache lines, so * we only need to do more prefetching if we are storing * to more than two cache lines. */ if (n32 > CACHE_LINE_SIZE_IN_WORDS * 2) { int i; /* Prefetch the next several cache lines. * This is the setup code for the software-pipelined * loop below. */ #define MAX_PREFETCH 5 ahead32 = n32 & -CACHE_LINE_SIZE_IN_WORDS; if (ahead32 > MAX_PREFETCH * CACHE_LINE_SIZE_IN_WORDS) ahead32 = MAX_PREFETCH * CACHE_LINE_SIZE_IN_WORDS; for (i = CACHE_LINE_SIZE_IN_WORDS; i < ahead32; i += CACHE_LINE_SIZE_IN_WORDS) __insn_prefetch(&out32[i]); } if (n32 > ahead32) { while (1) { int j; /* Prefetch by reading one word several cache lines * ahead. Since loads are non-blocking this will * cause the full cache line to be read while we are * finishing earlier cache lines. Using a store * here causes microarchitectural performance * problems where a victimizing store miss goes to * the head of the retry FIFO and locks the pipe for * a few cycles. So a few subsequent stores in this * loop go into the retry FIFO, and then later * stores see other stores to the same cache line * are already in the retry FIFO and themselves go * into the retry FIFO, filling it up and grinding * to a halt waiting for the original miss to be * satisfied. */ __insn_prefetch(&out32[ahead32]); #if CACHE_LINE_SIZE_IN_WORDS % 4 != 0 #error "Unhandled CACHE_LINE_SIZE_IN_WORDS" #endif n32 -= CACHE_LINE_SIZE_IN_WORDS; /* Save icache space by only partially unrolling * this loop. */ for (j = CACHE_LINE_SIZE_IN_WORDS / 4; j > 0; j--) { *out32++ = v32; *out32++ = v32; *out32++ = v32; *out32++ = v32; } /* To save compiled code size, reuse this loop even * when we run out of prefetching to do by dropping * ahead32 down. */ if (n32 <= ahead32) { /* Not even a full cache line left, * so stop now. */ if (n32 < CACHE_LINE_SIZE_IN_WORDS) break; /* Choose a small enough value that we don't * prefetch past the end. There's no sense * in touching cache lines we don't have to. */ ahead32 = CACHE_LINE_SIZE_IN_WORDS - 1; } } } #else /* CHIP_HAS_WH64() */ /* Determine how many words we need to emit before the 'out32' * pointer becomes aligned modulo the cache line size. */ to_align32 = (-((uintptr_t)out32 >> 2)) & (CACHE_LINE_SIZE_IN_WORDS - 1); /* Only bother aligning and using wh64 if there is at least * one full cache line to process. This check also prevents * overrunning the end of the buffer with alignment words. */ if (to_align32 <= n32 - CACHE_LINE_SIZE_IN_WORDS) { int lines_left; /* Align out32 mod the cache line size so we can use wh64. */ n32 -= to_align32; for (; to_align32 != 0; to_align32--) { *out32 = v32; out32++; } /* Use unsigned divide to turn this into a right shift. */ lines_left = (unsigned)n32 / CACHE_LINE_SIZE_IN_WORDS; do { /* Only wh64 a few lines at a time, so we don't * exceed the maximum number of victim lines. */ int x = ((lines_left < CHIP_MAX_OUTSTANDING_VICTIMS()) ? lines_left : CHIP_MAX_OUTSTANDING_VICTIMS()); uint32_t *wh = out32; int i = x; int j; lines_left -= x; do { __insn_wh64(wh); wh += CACHE_LINE_SIZE_IN_WORDS; } while (--i); for (j = x * (CACHE_LINE_SIZE_IN_WORDS / 4); j != 0; j--) { *out32++ = v32; *out32++ = v32; *out32++ = v32; *out32++ = v32; } } while (lines_left != 0); /* We processed all full lines above, so only this many * words remain to be processed. */ n32 &= CACHE_LINE_SIZE_IN_WORDS - 1; } #endif /* CHIP_HAS_WH64() */ /* Now handle any leftover values. */ if (n32 != 0) { do { *out32 = v32; out32++; } while (--n32 != 0); } return s; } EXPORT_SYMBOL(memset);
gpl-2.0
Twisted-Kernel/S6-MM
arch/arm/vfp/vfpsingle.c
12472
29552
/* * linux/arch/arm/vfp/vfpsingle.c * * This code is derived in part from John R. Housers softfloat library, which * carries the following notice: * * =========================================================================== * This C source file is part of the SoftFloat IEC/IEEE Floating-point * Arithmetic Package, Release 2. * * Written by John R. Hauser. This work was made possible in part by the * International Computer Science Institute, located at Suite 600, 1947 Center * Street, Berkeley, California 94704. Funding was partially provided by the * National Science Foundation under grant MIP-9311980. The original version * of this code was written as part of a project to build a fixed-point vector * processor in collaboration with the University of California at Berkeley, * overseen by Profs. Nelson Morgan and John Wawrzynek. More information * is available through the web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ * arithmetic/softfloat.html'. * * THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort * has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT * TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO * PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY * AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. * * Derivative works are acceptable, even for commercial purposes, so long as * (1) they include prominent notice that the work is derivative, and (2) they * include prominent notice akin to these three paragraphs for those parts of * this code that are retained. * =========================================================================== */ #include <linux/kernel.h> #include <linux/bitops.h> #include <asm/div64.h> #include <asm/vfp.h> #include "vfpinstr.h" #include "vfp.h" static struct vfp_single vfp_single_default_qnan = { .exponent = 255, .sign = 0, .significand = VFP_SINGLE_SIGNIFICAND_QNAN, }; static void vfp_single_dump(const char *str, struct vfp_single *s) { pr_debug("VFP: %s: sign=%d exponent=%d significand=%08x\n", str, s->sign != 0, s->exponent, s->significand); } static void vfp_single_normalise_denormal(struct vfp_single *vs) { int bits = 31 - fls(vs->significand); vfp_single_dump("normalise_denormal: in", vs); if (bits) { vs->exponent -= bits - 1; vs->significand <<= bits; } vfp_single_dump("normalise_denormal: out", vs); } #ifndef DEBUG #define vfp_single_normaliseround(sd,vsd,fpscr,except,func) __vfp_single_normaliseround(sd,vsd,fpscr,except) u32 __vfp_single_normaliseround(int sd, struct vfp_single *vs, u32 fpscr, u32 exceptions) #else u32 vfp_single_normaliseround(int sd, struct vfp_single *vs, u32 fpscr, u32 exceptions, const char *func) #endif { u32 significand, incr, rmode; int exponent, shift, underflow; vfp_single_dump("pack: in", vs); /* * Infinities and NaNs are a special case. */ if (vs->exponent == 255 && (vs->significand == 0 || exceptions)) goto pack; /* * Special-case zero. */ if (vs->significand == 0) { vs->exponent = 0; goto pack; } exponent = vs->exponent; significand = vs->significand; /* * Normalise first. Note that we shift the significand up to * bit 31, so we have VFP_SINGLE_LOW_BITS + 1 below the least * significant bit. */ shift = 32 - fls(significand); if (shift < 32 && shift) { exponent -= shift; significand <<= shift; } #ifdef DEBUG vs->exponent = exponent; vs->significand = significand; vfp_single_dump("pack: normalised", vs); #endif /* * Tiny number? */ underflow = exponent < 0; if (underflow) { significand = vfp_shiftright32jamming(significand, -exponent); exponent = 0; #ifdef DEBUG vs->exponent = exponent; vs->significand = significand; vfp_single_dump("pack: tiny number", vs); #endif if (!(significand & ((1 << (VFP_SINGLE_LOW_BITS + 1)) - 1))) underflow = 0; } /* * Select rounding increment. */ incr = 0; rmode = fpscr & FPSCR_RMODE_MASK; if (rmode == FPSCR_ROUND_NEAREST) { incr = 1 << VFP_SINGLE_LOW_BITS; if ((significand & (1 << (VFP_SINGLE_LOW_BITS + 1))) == 0) incr -= 1; } else if (rmode == FPSCR_ROUND_TOZERO) { incr = 0; } else if ((rmode == FPSCR_ROUND_PLUSINF) ^ (vs->sign != 0)) incr = (1 << (VFP_SINGLE_LOW_BITS + 1)) - 1; pr_debug("VFP: rounding increment = 0x%08x\n", incr); /* * Is our rounding going to overflow? */ if ((significand + incr) < significand) { exponent += 1; significand = (significand >> 1) | (significand & 1); incr >>= 1; #ifdef DEBUG vs->exponent = exponent; vs->significand = significand; vfp_single_dump("pack: overflow", vs); #endif } /* * If any of the low bits (which will be shifted out of the * number) are non-zero, the result is inexact. */ if (significand & ((1 << (VFP_SINGLE_LOW_BITS + 1)) - 1)) exceptions |= FPSCR_IXC; /* * Do our rounding. */ significand += incr; /* * Infinity? */ if (exponent >= 254) { exceptions |= FPSCR_OFC | FPSCR_IXC; if (incr == 0) { vs->exponent = 253; vs->significand = 0x7fffffff; } else { vs->exponent = 255; /* infinity */ vs->significand = 0; } } else { if (significand >> (VFP_SINGLE_LOW_BITS + 1) == 0) exponent = 0; if (exponent || significand > 0x80000000) underflow = 0; if (underflow) exceptions |= FPSCR_UFC; vs->exponent = exponent; vs->significand = significand >> 1; } pack: vfp_single_dump("pack: final", vs); { s32 d = vfp_single_pack(vs); #ifdef DEBUG pr_debug("VFP: %s: d(s%d)=%08x exceptions=%08x\n", func, sd, d, exceptions); #endif vfp_put_float(d, sd); } return exceptions; } /* * Propagate the NaN, setting exceptions if it is signalling. * 'n' is always a NaN. 'm' may be a number, NaN or infinity. */ static u32 vfp_propagate_nan(struct vfp_single *vsd, struct vfp_single *vsn, struct vfp_single *vsm, u32 fpscr) { struct vfp_single *nan; int tn, tm = 0; tn = vfp_single_type(vsn); if (vsm) tm = vfp_single_type(vsm); if (fpscr & FPSCR_DEFAULT_NAN) /* * Default NaN mode - always returns a quiet NaN */ nan = &vfp_single_default_qnan; else { /* * Contemporary mode - select the first signalling * NAN, or if neither are signalling, the first * quiet NAN. */ if (tn == VFP_SNAN || (tm != VFP_SNAN && tn == VFP_QNAN)) nan = vsn; else nan = vsm; /* * Make the NaN quiet. */ nan->significand |= VFP_SINGLE_SIGNIFICAND_QNAN; } *vsd = *nan; /* * If one was a signalling NAN, raise invalid operation. */ return tn == VFP_SNAN || tm == VFP_SNAN ? FPSCR_IOC : VFP_NAN_FLAG; } /* * Extended operations */ static u32 vfp_single_fabs(int sd, int unused, s32 m, u32 fpscr) { vfp_put_float(vfp_single_packed_abs(m), sd); return 0; } static u32 vfp_single_fcpy(int sd, int unused, s32 m, u32 fpscr) { vfp_put_float(m, sd); return 0; } static u32 vfp_single_fneg(int sd, int unused, s32 m, u32 fpscr) { vfp_put_float(vfp_single_packed_negate(m), sd); return 0; } static const u16 sqrt_oddadjust[] = { 0x0004, 0x0022, 0x005d, 0x00b1, 0x011d, 0x019f, 0x0236, 0x02e0, 0x039c, 0x0468, 0x0545, 0x0631, 0x072b, 0x0832, 0x0946, 0x0a67 }; static const u16 sqrt_evenadjust[] = { 0x0a2d, 0x08af, 0x075a, 0x0629, 0x051a, 0x0429, 0x0356, 0x029e, 0x0200, 0x0179, 0x0109, 0x00af, 0x0068, 0x0034, 0x0012, 0x0002 }; u32 vfp_estimate_sqrt_significand(u32 exponent, u32 significand) { int index; u32 z, a; if ((significand & 0xc0000000) != 0x40000000) { printk(KERN_WARNING "VFP: estimate_sqrt: invalid significand\n"); } a = significand << 1; index = (a >> 27) & 15; if (exponent & 1) { z = 0x4000 + (a >> 17) - sqrt_oddadjust[index]; z = ((a / z) << 14) + (z << 15); a >>= 1; } else { z = 0x8000 + (a >> 17) - sqrt_evenadjust[index]; z = a / z + z; z = (z >= 0x20000) ? 0xffff8000 : (z << 15); if (z <= a) return (s32)a >> 1; } { u64 v = (u64)a << 31; do_div(v, z); return v + (z >> 1); } } static u32 vfp_single_fsqrt(int sd, int unused, s32 m, u32 fpscr) { struct vfp_single vsm, vsd; int ret, tm; vfp_single_unpack(&vsm, m); tm = vfp_single_type(&vsm); if (tm & (VFP_NAN|VFP_INFINITY)) { struct vfp_single *vsp = &vsd; if (tm & VFP_NAN) ret = vfp_propagate_nan(vsp, &vsm, NULL, fpscr); else if (vsm.sign == 0) { sqrt_copy: vsp = &vsm; ret = 0; } else { sqrt_invalid: vsp = &vfp_single_default_qnan; ret = FPSCR_IOC; } vfp_put_float(vfp_single_pack(vsp), sd); return ret; } /* * sqrt(+/- 0) == +/- 0 */ if (tm & VFP_ZERO) goto sqrt_copy; /* * Normalise a denormalised number */ if (tm & VFP_DENORMAL) vfp_single_normalise_denormal(&vsm); /* * sqrt(<0) = invalid */ if (vsm.sign) goto sqrt_invalid; vfp_single_dump("sqrt", &vsm); /* * Estimate the square root. */ vsd.sign = 0; vsd.exponent = ((vsm.exponent - 127) >> 1) + 127; vsd.significand = vfp_estimate_sqrt_significand(vsm.exponent, vsm.significand) + 2; vfp_single_dump("sqrt estimate", &vsd); /* * And now adjust. */ if ((vsd.significand & VFP_SINGLE_LOW_BITS_MASK) <= 5) { if (vsd.significand < 2) { vsd.significand = 0xffffffff; } else { u64 term; s64 rem; vsm.significand <<= !(vsm.exponent & 1); term = (u64)vsd.significand * vsd.significand; rem = ((u64)vsm.significand << 32) - term; pr_debug("VFP: term=%016llx rem=%016llx\n", term, rem); while (rem < 0) { vsd.significand -= 1; rem += ((u64)vsd.significand << 1) | 1; } vsd.significand |= rem != 0; } } vsd.significand = vfp_shiftright32jamming(vsd.significand, 1); return vfp_single_normaliseround(sd, &vsd, fpscr, 0, "fsqrt"); } /* * Equal := ZC * Less than := N * Greater than := C * Unordered := CV */ static u32 vfp_compare(int sd, int signal_on_qnan, s32 m, u32 fpscr) { s32 d; u32 ret = 0; d = vfp_get_float(sd); if (vfp_single_packed_exponent(m) == 255 && vfp_single_packed_mantissa(m)) { ret |= FPSCR_C | FPSCR_V; if (signal_on_qnan || !(vfp_single_packed_mantissa(m) & (1 << (VFP_SINGLE_MANTISSA_BITS - 1)))) /* * Signalling NaN, or signalling on quiet NaN */ ret |= FPSCR_IOC; } if (vfp_single_packed_exponent(d) == 255 && vfp_single_packed_mantissa(d)) { ret |= FPSCR_C | FPSCR_V; if (signal_on_qnan || !(vfp_single_packed_mantissa(d) & (1 << (VFP_SINGLE_MANTISSA_BITS - 1)))) /* * Signalling NaN, or signalling on quiet NaN */ ret |= FPSCR_IOC; } if (ret == 0) { if (d == m || vfp_single_packed_abs(d | m) == 0) { /* * equal */ ret |= FPSCR_Z | FPSCR_C; } else if (vfp_single_packed_sign(d ^ m)) { /* * different signs */ if (vfp_single_packed_sign(d)) /* * d is negative, so d < m */ ret |= FPSCR_N; else /* * d is positive, so d > m */ ret |= FPSCR_C; } else if ((vfp_single_packed_sign(d) != 0) ^ (d < m)) { /* * d < m */ ret |= FPSCR_N; } else if ((vfp_single_packed_sign(d) != 0) ^ (d > m)) { /* * d > m */ ret |= FPSCR_C; } } return ret; } static u32 vfp_single_fcmp(int sd, int unused, s32 m, u32 fpscr) { return vfp_compare(sd, 0, m, fpscr); } static u32 vfp_single_fcmpe(int sd, int unused, s32 m, u32 fpscr) { return vfp_compare(sd, 1, m, fpscr); } static u32 vfp_single_fcmpz(int sd, int unused, s32 m, u32 fpscr) { return vfp_compare(sd, 0, 0, fpscr); } static u32 vfp_single_fcmpez(int sd, int unused, s32 m, u32 fpscr) { return vfp_compare(sd, 1, 0, fpscr); } static u32 vfp_single_fcvtd(int dd, int unused, s32 m, u32 fpscr) { struct vfp_single vsm; struct vfp_double vdd; int tm; u32 exceptions = 0; vfp_single_unpack(&vsm, m); tm = vfp_single_type(&vsm); /* * If we have a signalling NaN, signal invalid operation. */ if (tm == VFP_SNAN) exceptions = FPSCR_IOC; if (tm & VFP_DENORMAL) vfp_single_normalise_denormal(&vsm); vdd.sign = vsm.sign; vdd.significand = (u64)vsm.significand << 32; /* * If we have an infinity or NaN, the exponent must be 2047. */ if (tm & (VFP_INFINITY|VFP_NAN)) { vdd.exponent = 2047; if (tm == VFP_QNAN) vdd.significand |= VFP_DOUBLE_SIGNIFICAND_QNAN; goto pack_nan; } else if (tm & VFP_ZERO) vdd.exponent = 0; else vdd.exponent = vsm.exponent + (1023 - 127); return vfp_double_normaliseround(dd, &vdd, fpscr, exceptions, "fcvtd"); pack_nan: vfp_put_double(vfp_double_pack(&vdd), dd); return exceptions; } static u32 vfp_single_fuito(int sd, int unused, s32 m, u32 fpscr) { struct vfp_single vs; vs.sign = 0; vs.exponent = 127 + 31 - 1; vs.significand = (u32)m; return vfp_single_normaliseround(sd, &vs, fpscr, 0, "fuito"); } static u32 vfp_single_fsito(int sd, int unused, s32 m, u32 fpscr) { struct vfp_single vs; vs.sign = (m & 0x80000000) >> 16; vs.exponent = 127 + 31 - 1; vs.significand = vs.sign ? -m : m; return vfp_single_normaliseround(sd, &vs, fpscr, 0, "fsito"); } static u32 vfp_single_ftoui(int sd, int unused, s32 m, u32 fpscr) { struct vfp_single vsm; u32 d, exceptions = 0; int rmode = fpscr & FPSCR_RMODE_MASK; int tm; vfp_single_unpack(&vsm, m); vfp_single_dump("VSM", &vsm); /* * Do we have a denormalised number? */ tm = vfp_single_type(&vsm); if (tm & VFP_DENORMAL) exceptions |= FPSCR_IDC; if (tm & VFP_NAN) vsm.sign = 0; if (vsm.exponent >= 127 + 32) { d = vsm.sign ? 0 : 0xffffffff; exceptions = FPSCR_IOC; } else if (vsm.exponent >= 127 - 1) { int shift = 127 + 31 - vsm.exponent; u32 rem, incr = 0; /* * 2^0 <= m < 2^32-2^8 */ d = (vsm.significand << 1) >> shift; rem = vsm.significand << (33 - shift); if (rmode == FPSCR_ROUND_NEAREST) { incr = 0x80000000; if ((d & 1) == 0) incr -= 1; } else if (rmode == FPSCR_ROUND_TOZERO) { incr = 0; } else if ((rmode == FPSCR_ROUND_PLUSINF) ^ (vsm.sign != 0)) { incr = ~0; } if ((rem + incr) < rem) { if (d < 0xffffffff) d += 1; else exceptions |= FPSCR_IOC; } if (d && vsm.sign) { d = 0; exceptions |= FPSCR_IOC; } else if (rem) exceptions |= FPSCR_IXC; } else { d = 0; if (vsm.exponent | vsm.significand) { exceptions |= FPSCR_IXC; if (rmode == FPSCR_ROUND_PLUSINF && vsm.sign == 0) d = 1; else if (rmode == FPSCR_ROUND_MINUSINF && vsm.sign) { d = 0; exceptions |= FPSCR_IOC; } } } pr_debug("VFP: ftoui: d(s%d)=%08x exceptions=%08x\n", sd, d, exceptions); vfp_put_float(d, sd); return exceptions; } static u32 vfp_single_ftouiz(int sd, int unused, s32 m, u32 fpscr) { return vfp_single_ftoui(sd, unused, m, FPSCR_ROUND_TOZERO); } static u32 vfp_single_ftosi(int sd, int unused, s32 m, u32 fpscr) { struct vfp_single vsm; u32 d, exceptions = 0; int rmode = fpscr & FPSCR_RMODE_MASK; int tm; vfp_single_unpack(&vsm, m); vfp_single_dump("VSM", &vsm); /* * Do we have a denormalised number? */ tm = vfp_single_type(&vsm); if (vfp_single_type(&vsm) & VFP_DENORMAL) exceptions |= FPSCR_IDC; if (tm & VFP_NAN) { d = 0; exceptions |= FPSCR_IOC; } else if (vsm.exponent >= 127 + 32) { /* * m >= 2^31-2^7: invalid */ d = 0x7fffffff; if (vsm.sign) d = ~d; exceptions |= FPSCR_IOC; } else if (vsm.exponent >= 127 - 1) { int shift = 127 + 31 - vsm.exponent; u32 rem, incr = 0; /* 2^0 <= m <= 2^31-2^7 */ d = (vsm.significand << 1) >> shift; rem = vsm.significand << (33 - shift); if (rmode == FPSCR_ROUND_NEAREST) { incr = 0x80000000; if ((d & 1) == 0) incr -= 1; } else if (rmode == FPSCR_ROUND_TOZERO) { incr = 0; } else if ((rmode == FPSCR_ROUND_PLUSINF) ^ (vsm.sign != 0)) { incr = ~0; } if ((rem + incr) < rem && d < 0xffffffff) d += 1; if (d > 0x7fffffff + (vsm.sign != 0)) { d = 0x7fffffff + (vsm.sign != 0); exceptions |= FPSCR_IOC; } else if (rem) exceptions |= FPSCR_IXC; if (vsm.sign) d = -d; } else { d = 0; if (vsm.exponent | vsm.significand) { exceptions |= FPSCR_IXC; if (rmode == FPSCR_ROUND_PLUSINF && vsm.sign == 0) d = 1; else if (rmode == FPSCR_ROUND_MINUSINF && vsm.sign) d = -1; } } pr_debug("VFP: ftosi: d(s%d)=%08x exceptions=%08x\n", sd, d, exceptions); vfp_put_float((s32)d, sd); return exceptions; } static u32 vfp_single_ftosiz(int sd, int unused, s32 m, u32 fpscr) { return vfp_single_ftosi(sd, unused, m, FPSCR_ROUND_TOZERO); } static struct op fops_ext[32] = { [FEXT_TO_IDX(FEXT_FCPY)] = { vfp_single_fcpy, 0 }, [FEXT_TO_IDX(FEXT_FABS)] = { vfp_single_fabs, 0 }, [FEXT_TO_IDX(FEXT_FNEG)] = { vfp_single_fneg, 0 }, [FEXT_TO_IDX(FEXT_FSQRT)] = { vfp_single_fsqrt, 0 }, [FEXT_TO_IDX(FEXT_FCMP)] = { vfp_single_fcmp, OP_SCALAR }, [FEXT_TO_IDX(FEXT_FCMPE)] = { vfp_single_fcmpe, OP_SCALAR }, [FEXT_TO_IDX(FEXT_FCMPZ)] = { vfp_single_fcmpz, OP_SCALAR }, [FEXT_TO_IDX(FEXT_FCMPEZ)] = { vfp_single_fcmpez, OP_SCALAR }, [FEXT_TO_IDX(FEXT_FCVT)] = { vfp_single_fcvtd, OP_SCALAR|OP_DD }, [FEXT_TO_IDX(FEXT_FUITO)] = { vfp_single_fuito, OP_SCALAR }, [FEXT_TO_IDX(FEXT_FSITO)] = { vfp_single_fsito, OP_SCALAR }, [FEXT_TO_IDX(FEXT_FTOUI)] = { vfp_single_ftoui, OP_SCALAR }, [FEXT_TO_IDX(FEXT_FTOUIZ)] = { vfp_single_ftouiz, OP_SCALAR }, [FEXT_TO_IDX(FEXT_FTOSI)] = { vfp_single_ftosi, OP_SCALAR }, [FEXT_TO_IDX(FEXT_FTOSIZ)] = { vfp_single_ftosiz, OP_SCALAR }, }; static u32 vfp_single_fadd_nonnumber(struct vfp_single *vsd, struct vfp_single *vsn, struct vfp_single *vsm, u32 fpscr) { struct vfp_single *vsp; u32 exceptions = 0; int tn, tm; tn = vfp_single_type(vsn); tm = vfp_single_type(vsm); if (tn & tm & VFP_INFINITY) { /* * Two infinities. Are they different signs? */ if (vsn->sign ^ vsm->sign) { /* * different signs -> invalid */ exceptions = FPSCR_IOC; vsp = &vfp_single_default_qnan; } else { /* * same signs -> valid */ vsp = vsn; } } else if (tn & VFP_INFINITY && tm & VFP_NUMBER) { /* * One infinity and one number -> infinity */ vsp = vsn; } else { /* * 'n' is a NaN of some type */ return vfp_propagate_nan(vsd, vsn, vsm, fpscr); } *vsd = *vsp; return exceptions; } static u32 vfp_single_add(struct vfp_single *vsd, struct vfp_single *vsn, struct vfp_single *vsm, u32 fpscr) { u32 exp_diff, m_sig; if (vsn->significand & 0x80000000 || vsm->significand & 0x80000000) { pr_info("VFP: bad FP values in %s\n", __func__); vfp_single_dump("VSN", vsn); vfp_single_dump("VSM", vsm); } /* * Ensure that 'n' is the largest magnitude number. Note that * if 'n' and 'm' have equal exponents, we do not swap them. * This ensures that NaN propagation works correctly. */ if (vsn->exponent < vsm->exponent) { struct vfp_single *t = vsn; vsn = vsm; vsm = t; } /* * Is 'n' an infinity or a NaN? Note that 'm' may be a number, * infinity or a NaN here. */ if (vsn->exponent == 255) return vfp_single_fadd_nonnumber(vsd, vsn, vsm, fpscr); /* * We have two proper numbers, where 'vsn' is the larger magnitude. * * Copy 'n' to 'd' before doing the arithmetic. */ *vsd = *vsn; /* * Align both numbers. */ exp_diff = vsn->exponent - vsm->exponent; m_sig = vfp_shiftright32jamming(vsm->significand, exp_diff); /* * If the signs are different, we are really subtracting. */ if (vsn->sign ^ vsm->sign) { m_sig = vsn->significand - m_sig; if ((s32)m_sig < 0) { vsd->sign = vfp_sign_negate(vsd->sign); m_sig = -m_sig; } else if (m_sig == 0) { vsd->sign = (fpscr & FPSCR_RMODE_MASK) == FPSCR_ROUND_MINUSINF ? 0x8000 : 0; } } else { m_sig = vsn->significand + m_sig; } vsd->significand = m_sig; return 0; } static u32 vfp_single_multiply(struct vfp_single *vsd, struct vfp_single *vsn, struct vfp_single *vsm, u32 fpscr) { vfp_single_dump("VSN", vsn); vfp_single_dump("VSM", vsm); /* * Ensure that 'n' is the largest magnitude number. Note that * if 'n' and 'm' have equal exponents, we do not swap them. * This ensures that NaN propagation works correctly. */ if (vsn->exponent < vsm->exponent) { struct vfp_single *t = vsn; vsn = vsm; vsm = t; pr_debug("VFP: swapping M <-> N\n"); } vsd->sign = vsn->sign ^ vsm->sign; /* * If 'n' is an infinity or NaN, handle it. 'm' may be anything. */ if (vsn->exponent == 255) { if (vsn->significand || (vsm->exponent == 255 && vsm->significand)) return vfp_propagate_nan(vsd, vsn, vsm, fpscr); if ((vsm->exponent | vsm->significand) == 0) { *vsd = vfp_single_default_qnan; return FPSCR_IOC; } vsd->exponent = vsn->exponent; vsd->significand = 0; return 0; } /* * If 'm' is zero, the result is always zero. In this case, * 'n' may be zero or a number, but it doesn't matter which. */ if ((vsm->exponent | vsm->significand) == 0) { vsd->exponent = 0; vsd->significand = 0; return 0; } /* * We add 2 to the destination exponent for the same reason as * the addition case - though this time we have +1 from each * input operand. */ vsd->exponent = vsn->exponent + vsm->exponent - 127 + 2; vsd->significand = vfp_hi64to32jamming((u64)vsn->significand * vsm->significand); vfp_single_dump("VSD", vsd); return 0; } #define NEG_MULTIPLY (1 << 0) #define NEG_SUBTRACT (1 << 1) static u32 vfp_single_multiply_accumulate(int sd, int sn, s32 m, u32 fpscr, u32 negate, char *func) { struct vfp_single vsd, vsp, vsn, vsm; u32 exceptions; s32 v; v = vfp_get_float(sn); pr_debug("VFP: s%u = %08x\n", sn, v); vfp_single_unpack(&vsn, v); if (vsn.exponent == 0 && vsn.significand) vfp_single_normalise_denormal(&vsn); vfp_single_unpack(&vsm, m); if (vsm.exponent == 0 && vsm.significand) vfp_single_normalise_denormal(&vsm); exceptions = vfp_single_multiply(&vsp, &vsn, &vsm, fpscr); if (negate & NEG_MULTIPLY) vsp.sign = vfp_sign_negate(vsp.sign); v = vfp_get_float(sd); pr_debug("VFP: s%u = %08x\n", sd, v); vfp_single_unpack(&vsn, v); if (negate & NEG_SUBTRACT) vsn.sign = vfp_sign_negate(vsn.sign); exceptions |= vfp_single_add(&vsd, &vsn, &vsp, fpscr); return vfp_single_normaliseround(sd, &vsd, fpscr, exceptions, func); } /* * Standard operations */ /* * sd = sd + (sn * sm) */ static u32 vfp_single_fmac(int sd, int sn, s32 m, u32 fpscr) { return vfp_single_multiply_accumulate(sd, sn, m, fpscr, 0, "fmac"); } /* * sd = sd - (sn * sm) */ static u32 vfp_single_fnmac(int sd, int sn, s32 m, u32 fpscr) { return vfp_single_multiply_accumulate(sd, sn, m, fpscr, NEG_MULTIPLY, "fnmac"); } /* * sd = -sd + (sn * sm) */ static u32 vfp_single_fmsc(int sd, int sn, s32 m, u32 fpscr) { return vfp_single_multiply_accumulate(sd, sn, m, fpscr, NEG_SUBTRACT, "fmsc"); } /* * sd = -sd - (sn * sm) */ static u32 vfp_single_fnmsc(int sd, int sn, s32 m, u32 fpscr) { return vfp_single_multiply_accumulate(sd, sn, m, fpscr, NEG_SUBTRACT | NEG_MULTIPLY, "fnmsc"); } /* * sd = sn * sm */ static u32 vfp_single_fmul(int sd, int sn, s32 m, u32 fpscr) { struct vfp_single vsd, vsn, vsm; u32 exceptions; s32 n = vfp_get_float(sn); pr_debug("VFP: s%u = %08x\n", sn, n); vfp_single_unpack(&vsn, n); if (vsn.exponent == 0 && vsn.significand) vfp_single_normalise_denormal(&vsn); vfp_single_unpack(&vsm, m); if (vsm.exponent == 0 && vsm.significand) vfp_single_normalise_denormal(&vsm); exceptions = vfp_single_multiply(&vsd, &vsn, &vsm, fpscr); return vfp_single_normaliseround(sd, &vsd, fpscr, exceptions, "fmul"); } /* * sd = -(sn * sm) */ static u32 vfp_single_fnmul(int sd, int sn, s32 m, u32 fpscr) { struct vfp_single vsd, vsn, vsm; u32 exceptions; s32 n = vfp_get_float(sn); pr_debug("VFP: s%u = %08x\n", sn, n); vfp_single_unpack(&vsn, n); if (vsn.exponent == 0 && vsn.significand) vfp_single_normalise_denormal(&vsn); vfp_single_unpack(&vsm, m); if (vsm.exponent == 0 && vsm.significand) vfp_single_normalise_denormal(&vsm); exceptions = vfp_single_multiply(&vsd, &vsn, &vsm, fpscr); vsd.sign = vfp_sign_negate(vsd.sign); return vfp_single_normaliseround(sd, &vsd, fpscr, exceptions, "fnmul"); } /* * sd = sn + sm */ static u32 vfp_single_fadd(int sd, int sn, s32 m, u32 fpscr) { struct vfp_single vsd, vsn, vsm; u32 exceptions; s32 n = vfp_get_float(sn); pr_debug("VFP: s%u = %08x\n", sn, n); /* * Unpack and normalise denormals. */ vfp_single_unpack(&vsn, n); if (vsn.exponent == 0 && vsn.significand) vfp_single_normalise_denormal(&vsn); vfp_single_unpack(&vsm, m); if (vsm.exponent == 0 && vsm.significand) vfp_single_normalise_denormal(&vsm); exceptions = vfp_single_add(&vsd, &vsn, &vsm, fpscr); return vfp_single_normaliseround(sd, &vsd, fpscr, exceptions, "fadd"); } /* * sd = sn - sm */ static u32 vfp_single_fsub(int sd, int sn, s32 m, u32 fpscr) { /* * Subtraction is addition with one sign inverted. */ return vfp_single_fadd(sd, sn, vfp_single_packed_negate(m), fpscr); } /* * sd = sn / sm */ static u32 vfp_single_fdiv(int sd, int sn, s32 m, u32 fpscr) { struct vfp_single vsd, vsn, vsm; u32 exceptions = 0; s32 n = vfp_get_float(sn); int tm, tn; pr_debug("VFP: s%u = %08x\n", sn, n); vfp_single_unpack(&vsn, n); vfp_single_unpack(&vsm, m); vsd.sign = vsn.sign ^ vsm.sign; tn = vfp_single_type(&vsn); tm = vfp_single_type(&vsm); /* * Is n a NAN? */ if (tn & VFP_NAN) goto vsn_nan; /* * Is m a NAN? */ if (tm & VFP_NAN) goto vsm_nan; /* * If n and m are infinity, the result is invalid * If n and m are zero, the result is invalid */ if (tm & tn & (VFP_INFINITY|VFP_ZERO)) goto invalid; /* * If n is infinity, the result is infinity */ if (tn & VFP_INFINITY) goto infinity; /* * If m is zero, raise div0 exception */ if (tm & VFP_ZERO) goto divzero; /* * If m is infinity, or n is zero, the result is zero */ if (tm & VFP_INFINITY || tn & VFP_ZERO) goto zero; if (tn & VFP_DENORMAL) vfp_single_normalise_denormal(&vsn); if (tm & VFP_DENORMAL) vfp_single_normalise_denormal(&vsm); /* * Ok, we have two numbers, we can perform division. */ vsd.exponent = vsn.exponent - vsm.exponent + 127 - 1; vsm.significand <<= 1; if (vsm.significand <= (2 * vsn.significand)) { vsn.significand >>= 1; vsd.exponent++; } { u64 significand = (u64)vsn.significand << 32; do_div(significand, vsm.significand); vsd.significand = significand; } if ((vsd.significand & 0x3f) == 0) vsd.significand |= ((u64)vsm.significand * vsd.significand != (u64)vsn.significand << 32); return vfp_single_normaliseround(sd, &vsd, fpscr, 0, "fdiv"); vsn_nan: exceptions = vfp_propagate_nan(&vsd, &vsn, &vsm, fpscr); pack: vfp_put_float(vfp_single_pack(&vsd), sd); return exceptions; vsm_nan: exceptions = vfp_propagate_nan(&vsd, &vsm, &vsn, fpscr); goto pack; zero: vsd.exponent = 0; vsd.significand = 0; goto pack; divzero: exceptions = FPSCR_DZC; infinity: vsd.exponent = 255; vsd.significand = 0; goto pack; invalid: vfp_put_float(vfp_single_pack(&vfp_single_default_qnan), sd); return FPSCR_IOC; } static struct op fops[16] = { [FOP_TO_IDX(FOP_FMAC)] = { vfp_single_fmac, 0 }, [FOP_TO_IDX(FOP_FNMAC)] = { vfp_single_fnmac, 0 }, [FOP_TO_IDX(FOP_FMSC)] = { vfp_single_fmsc, 0 }, [FOP_TO_IDX(FOP_FNMSC)] = { vfp_single_fnmsc, 0 }, [FOP_TO_IDX(FOP_FMUL)] = { vfp_single_fmul, 0 }, [FOP_TO_IDX(FOP_FNMUL)] = { vfp_single_fnmul, 0 }, [FOP_TO_IDX(FOP_FADD)] = { vfp_single_fadd, 0 }, [FOP_TO_IDX(FOP_FSUB)] = { vfp_single_fsub, 0 }, [FOP_TO_IDX(FOP_FDIV)] = { vfp_single_fdiv, 0 }, }; #define FREG_BANK(x) ((x) & 0x18) #define FREG_IDX(x) ((x) & 7) u32 vfp_single_cpdo(u32 inst, u32 fpscr) { u32 op = inst & FOP_MASK; u32 exceptions = 0; unsigned int dest; unsigned int sn = vfp_get_sn(inst); unsigned int sm = vfp_get_sm(inst); unsigned int vecitr, veclen, vecstride; struct op *fop; vecstride = 1 + ((fpscr & FPSCR_STRIDE_MASK) == FPSCR_STRIDE_MASK); fop = (op == FOP_EXT) ? &fops_ext[FEXT_TO_IDX(inst)] : &fops[FOP_TO_IDX(op)]; /* * fcvtsd takes a dN register number as destination, not sN. * Technically, if bit 0 of dd is set, this is an invalid * instruction. However, we ignore this for efficiency. * It also only operates on scalars. */ if (fop->flags & OP_DD) dest = vfp_get_dd(inst); else dest = vfp_get_sd(inst); /* * If destination bank is zero, vector length is always '1'. * ARM DDI0100F C5.1.3, C5.3.2. */ if ((fop->flags & OP_SCALAR) || FREG_BANK(dest) == 0) veclen = 0; else veclen = fpscr & FPSCR_LENGTH_MASK; pr_debug("VFP: vecstride=%u veclen=%u\n", vecstride, (veclen >> FPSCR_LENGTH_BIT) + 1); if (!fop->fn) goto invalid; for (vecitr = 0; vecitr <= veclen; vecitr += 1 << FPSCR_LENGTH_BIT) { s32 m = vfp_get_float(sm); u32 except; char type; type = fop->flags & OP_DD ? 'd' : 's'; if (op == FOP_EXT) pr_debug("VFP: itr%d (%c%u) = op[%u] (s%u=%08x)\n", vecitr >> FPSCR_LENGTH_BIT, type, dest, sn, sm, m); else pr_debug("VFP: itr%d (%c%u) = (s%u) op[%u] (s%u=%08x)\n", vecitr >> FPSCR_LENGTH_BIT, type, dest, sn, FOP_TO_IDX(op), sm, m); except = fop->fn(dest, sn, m, fpscr); pr_debug("VFP: itr%d: exceptions=%08x\n", vecitr >> FPSCR_LENGTH_BIT, except); exceptions |= except; /* * CHECK: It appears to be undefined whether we stop when * we encounter an exception. We continue. */ dest = FREG_BANK(dest) + ((FREG_IDX(dest) + vecstride) & 7); sn = FREG_BANK(sn) + ((FREG_IDX(sn) + vecstride) & 7); if (FREG_BANK(sm) != 0) sm = FREG_BANK(sm) + ((FREG_IDX(sm) + vecstride) & 7); } return exceptions; invalid: return (u32)-1; }
gpl-2.0
BreakawayConsulting/gcc
gcc/testsuite/gcc.dg/cpp/pr33466.c
185
3802
/* { dg-do compile } */ /* { dg-options "-std=gnu99" } */ /* Test various invalid constant float suffixes made up of letters of valid suffixes. These are invalid regardless of whether the target compiler supports decimal float or fixed-point types. */ long double rh = 0.5rh; /* { dg-error "invalid suffix" } */ long double rl = 0.5rl; /* { dg-error "invalid suffix" } */ long double rll = 0.5rll; /* { dg-error "invalid suffix" } */ long double kh = 0.5kh; /* { dg-error "invalid suffix" } */ long double kl = 0.5kl; /* { dg-error "invalid suffix" } */ long double kll = 0.5kll; /* { dg-error "invalid suffix" } */ long double ru = 0.5ru; /* { dg-error "invalid suffix" } */ long double urh = 0.5urh; /* { dg-error "invalid suffix" } */ long double hur = 0.5hur; /* { dg-error "invalid suffix" } */ long double hru = 0.5hru; /* { dg-error "invalid suffix" } */ long double ruh = 0.5ruh; /* { dg-error "invalid suffix" } */ long double rhu = 0.5rhu; /* { dg-error "invalid suffix" } */ long double url = 0.5url; /* { dg-error "invalid suffix" } */ long double lur = 0.5lur; /* { dg-error "invalid suffix" } */ long double lru = 0.5lru; /* { dg-error "invalid suffix" } */ long double rul = 0.5rul; /* { dg-error "invalid suffix" } */ long double rlu = 0.5rlu; /* { dg-error "invalid suffix" } */ long double urll = 0.5urll; /* { dg-error "invalid suffix" } */ long double llur = 0.5llur; /* { dg-error "invalid suffix" } */ long double llru = 0.5llru; /* { dg-error "invalid suffix" } */ long double rull = 0.5rull; /* { dg-error "invalid suffix" } */ long double rllu = 0.5rllu; /* { dg-error "invalid suffix" } */ long double ku = 0.5ku; /* { dg-error "invalid suffix" } */ long double ukh = 0.5ukh; /* { dg-error "invalid suffix" } */ long double huk = 0.5huk; /* { dg-error "invalid suffix" } */ long double hku = 0.5hku; /* { dg-error "invalid suffix" } */ long double kuh = 0.5kuh; /* { dg-error "invalid suffix" } */ long double khu = 0.5khu; /* { dg-error "invalid suffix" } */ long double ukl = 0.5ukl; /* { dg-error "invalid suffix" } */ long double luk = 0.5luk; /* { dg-error "invalid suffix" } */ long double lku = 0.5lku; /* { dg-error "invalid suffix" } */ long double kul = 0.5kul; /* { dg-error "invalid suffix" } */ long double klu = 0.5klu; /* { dg-error "invalid suffix" } */ long double ukll = 0.5ukll; /* { dg-error "invalid suffix" } */ long double lluk = 0.5lluk; /* { dg-error "invalid suffix" } */ long double llku = 0.5llku; /* { dg-error "invalid suffix" } */ long double kull = 0.5kull; /* { dg-error "invalid suffix" } */ long double kllu = 0.5kllu; /* { dg-error "invalid suffix" } */ long double ld = 0.5ld; /* { dg-error "invalid suffix" } */ long double fd = 0.5fd; /* { dg-error "invalid suffix" } */ long double dk = 0.5dk; /* { dg-error "invalid suffix" } */ long double dr = 0.5dr; /* { dg-error "invalid suffix" } */ long double ddw = 0.5ddw; /* { dg-error "invalid suffix" } */ long double ddq = 0.5ddq; /* { dg-error "invalid suffix" } */ long double ddl = 0.5ddl; /* { dg-error "invalid suffix" } */ long double ddf = 0.5ddf; /* { dg-error "invalid suffix" } */ long double ddd = 0.5ddd; /* { dg-error "invalid suffix" } */ long double dw = 0.5dw; /* { dg-error "invalid suffix" } */ long double dq = 0.5dq; /* { dg-error "invalid suffix" } */ long double wd = 0.5wd; /* { dg-error "invalid suffix" } */ long double qd = 0.5qd; /* { dg-error "invalid suffix" } */ long double wdd = 0.5wdd; /* { dg-error "invalid suffix" } */ long double qdd = 0.5qdd; /* { dg-error "invalid suffix" } */ long double ldd = 0.5ldd; /* { dg-error "invalid suffix" } */ long double fdd = 0.5fdd; /* { dg-error "invalid suffix" } */ long double ddi = 0.5ddi; /* { dg-error "invalid suffix" } */ long double idd = 0.5idd; /* { dg-error "invalid suffix" } */
gpl-2.0
SteveLinCH/linux
net/netfilter/nf_conntrack_labels.c
441
3102
/* * test/set flag bits stored in conntrack extension area. * * (C) 2013 Astaro GmbH & Co KG * * 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/export.h> #include <linux/types.h> #include <net/netfilter/nf_conntrack_ecache.h> #include <net/netfilter/nf_conntrack_labels.h> static spinlock_t nf_connlabels_lock; static unsigned int label_bits(const struct nf_conn_labels *l) { unsigned int longs = l->words; return longs * BITS_PER_LONG; } bool nf_connlabel_match(const struct nf_conn *ct, u16 bit) { struct nf_conn_labels *labels = nf_ct_labels_find(ct); if (!labels) return false; return bit < label_bits(labels) && test_bit(bit, labels->bits); } EXPORT_SYMBOL_GPL(nf_connlabel_match); int nf_connlabel_set(struct nf_conn *ct, u16 bit) { struct nf_conn_labels *labels = nf_ct_labels_find(ct); if (!labels || bit >= label_bits(labels)) return -ENOSPC; if (test_bit(bit, labels->bits)) return 0; if (!test_and_set_bit(bit, labels->bits)) nf_conntrack_event_cache(IPCT_LABEL, ct); return 0; } EXPORT_SYMBOL_GPL(nf_connlabel_set); static void replace_u32(u32 *address, u32 mask, u32 new) { u32 old, tmp; do { old = *address; tmp = (old & mask) ^ new; } while (cmpxchg(address, old, tmp) != old); } int nf_connlabels_replace(struct nf_conn *ct, const u32 *data, const u32 *mask, unsigned int words32) { struct nf_conn_labels *labels; unsigned int size, i; u32 *dst; labels = nf_ct_labels_find(ct); if (!labels) return -ENOSPC; size = labels->words * sizeof(long); if (size < (words32 * sizeof(u32))) words32 = size / sizeof(u32); dst = (u32 *) labels->bits; if (words32) { for (i = 0; i < words32; i++) replace_u32(&dst[i], mask ? ~mask[i] : 0, data[i]); } size /= sizeof(u32); for (i = words32; i < size; i++) /* pad */ replace_u32(&dst[i], 0, 0); nf_conntrack_event_cache(IPCT_LABEL, ct); return 0; } EXPORT_SYMBOL_GPL(nf_connlabels_replace); int nf_connlabels_get(struct net *net, unsigned int n_bits) { size_t words; if (n_bits > (NF_CT_LABELS_MAX_SIZE * BITS_PER_BYTE)) return -ERANGE; words = BITS_TO_LONGS(n_bits); spin_lock(&nf_connlabels_lock); net->ct.labels_used++; if (words > net->ct.label_words) net->ct.label_words = words; spin_unlock(&nf_connlabels_lock); return 0; } EXPORT_SYMBOL_GPL(nf_connlabels_get); void nf_connlabels_put(struct net *net) { spin_lock(&nf_connlabels_lock); net->ct.labels_used--; if (net->ct.labels_used == 0) net->ct.label_words = 0; spin_unlock(&nf_connlabels_lock); } EXPORT_SYMBOL_GPL(nf_connlabels_put); static struct nf_ct_ext_type labels_extend __read_mostly = { .len = sizeof(struct nf_conn_labels), .align = __alignof__(struct nf_conn_labels), .id = NF_CT_EXT_LABELS, }; int nf_conntrack_labels_init(void) { spin_lock_init(&nf_connlabels_lock); return nf_ct_extend_register(&labels_extend); } void nf_conntrack_labels_fini(void) { nf_ct_extend_unregister(&labels_extend); }
gpl-2.0
Sikyou/s7_kernel
drivers/misc/ioc4.c
697
14889
/* * 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) 2005-2006 Silicon Graphics, Inc. All Rights Reserved. */ /* This file contains the master driver module for use by SGI IOC4 subdrivers. * * It allocates any resources shared between multiple subdevices, and * provides accessor functions (where needed) and the like for those * resources. It also provides a mechanism for the subdevice modules * to support loading and unloading. * * Non-shared resources (e.g. external interrupt A_INT_OUT register page * alias, serial port and UART registers) are handled by the subdevice * modules themselves. * * This is all necessary because IOC4 is not implemented as a multi-function * PCI device, but an amalgamation of disparate registers for several * types of device (ATA, serial, external interrupts). The normal * resource management in the kernel doesn't have quite the right interfaces * to handle this situation (e.g. multiple modules can't claim the same * PCI ID), thus this IOC4 master module. */ #include <linux/errno.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/ioc4.h> #include <linux/ktime.h> #include <linux/mutex.h> #include <linux/time.h> #include <asm/io.h> /*************** * Definitions * ***************/ /* Tweakable values */ /* PCI bus speed detection/calibration */ #define IOC4_CALIBRATE_COUNT 63 /* Calibration cycle period */ #define IOC4_CALIBRATE_CYCLES 256 /* Average over this many cycles */ #define IOC4_CALIBRATE_DISCARD 2 /* Discard first few cycles */ #define IOC4_CALIBRATE_LOW_MHZ 25 /* Lower bound on bus speed sanity */ #define IOC4_CALIBRATE_HIGH_MHZ 75 /* Upper bound on bus speed sanity */ #define IOC4_CALIBRATE_DEFAULT_MHZ 66 /* Assumed if sanity check fails */ /************************ * Submodule management * ************************/ static DEFINE_MUTEX(ioc4_mutex); static LIST_HEAD(ioc4_devices); static LIST_HEAD(ioc4_submodules); /* Register an IOC4 submodule */ int ioc4_register_submodule(struct ioc4_submodule *is) { struct ioc4_driver_data *idd; mutex_lock(&ioc4_mutex); list_add(&is->is_list, &ioc4_submodules); /* Initialize submodule for each IOC4 */ if (!is->is_probe) goto out; list_for_each_entry(idd, &ioc4_devices, idd_list) { if (is->is_probe(idd)) { printk(KERN_WARNING "%s: IOC4 submodule %s probe failed " "for pci_dev %s", __func__, module_name(is->is_owner), pci_name(idd->idd_pdev)); } } out: mutex_unlock(&ioc4_mutex); return 0; } /* Unregister an IOC4 submodule */ void ioc4_unregister_submodule(struct ioc4_submodule *is) { struct ioc4_driver_data *idd; mutex_lock(&ioc4_mutex); list_del(&is->is_list); /* Remove submodule for each IOC4 */ if (!is->is_remove) goto out; list_for_each_entry(idd, &ioc4_devices, idd_list) { if (is->is_remove(idd)) { printk(KERN_WARNING "%s: IOC4 submodule %s remove failed " "for pci_dev %s.\n", __func__, module_name(is->is_owner), pci_name(idd->idd_pdev)); } } out: mutex_unlock(&ioc4_mutex); } /********************* * Device management * *********************/ #define IOC4_CALIBRATE_LOW_LIMIT \ (1000*IOC4_EXTINT_COUNT_DIVISOR/IOC4_CALIBRATE_LOW_MHZ) #define IOC4_CALIBRATE_HIGH_LIMIT \ (1000*IOC4_EXTINT_COUNT_DIVISOR/IOC4_CALIBRATE_HIGH_MHZ) #define IOC4_CALIBRATE_DEFAULT \ (1000*IOC4_EXTINT_COUNT_DIVISOR/IOC4_CALIBRATE_DEFAULT_MHZ) #define IOC4_CALIBRATE_END \ (IOC4_CALIBRATE_CYCLES + IOC4_CALIBRATE_DISCARD) #define IOC4_INT_OUT_MODE_TOGGLE 0x7 /* Toggle INT_OUT every COUNT+1 ticks */ /* Determines external interrupt output clock period of the PCI bus an * IOC4 is attached to. This value can be used to determine the PCI * bus speed. * * IOC4 has a design feature that various internal timers are derived from * the PCI bus clock. This causes IOC4 device drivers to need to take the * bus speed into account when setting various register values (e.g. INT_OUT * register COUNT field, UART divisors, etc). Since this information is * needed by several subdrivers, it is determined by the main IOC4 driver, * even though the following code utilizes external interrupt registers * to perform the speed calculation. */ static void ioc4_clock_calibrate(struct ioc4_driver_data *idd) { union ioc4_int_out int_out; union ioc4_gpcr gpcr; unsigned int state, last_state = 1; struct timespec start_ts, end_ts; uint64_t start, end, period; unsigned int count = 0; /* Enable output */ gpcr.raw = 0; gpcr.fields.dir = IOC4_GPCR_DIR_0; gpcr.fields.int_out_en = 1; writel(gpcr.raw, &idd->idd_misc_regs->gpcr_s.raw); /* Reset to power-on state */ writel(0, &idd->idd_misc_regs->int_out.raw); mmiowb(); /* Set up square wave */ int_out.raw = 0; int_out.fields.count = IOC4_CALIBRATE_COUNT; int_out.fields.mode = IOC4_INT_OUT_MODE_TOGGLE; int_out.fields.diag = 0; writel(int_out.raw, &idd->idd_misc_regs->int_out.raw); mmiowb(); /* Check square wave period averaged over some number of cycles */ do { int_out.raw = readl(&idd->idd_misc_regs->int_out.raw); state = int_out.fields.int_out; if (!last_state && state) { count++; if (count == IOC4_CALIBRATE_END) { ktime_get_ts(&end_ts); break; } else if (count == IOC4_CALIBRATE_DISCARD) ktime_get_ts(&start_ts); } last_state = state; } while (1); /* Calculation rearranged to preserve intermediate precision. * Logically: * 1. "end - start" gives us the measurement period over all * the square wave cycles. * 2. Divide by number of square wave cycles to get the period * of a square wave cycle. * 3. Divide by 2*(int_out.fields.count+1), which is the formula * by which the IOC4 generates the square wave, to get the * period of an IOC4 INT_OUT count. */ end = end_ts.tv_sec * NSEC_PER_SEC + end_ts.tv_nsec; start = start_ts.tv_sec * NSEC_PER_SEC + start_ts.tv_nsec; period = (end - start) / (IOC4_CALIBRATE_CYCLES * 2 * (IOC4_CALIBRATE_COUNT + 1)); /* Bounds check the result. */ if (period > IOC4_CALIBRATE_LOW_LIMIT || period < IOC4_CALIBRATE_HIGH_LIMIT) { printk(KERN_INFO "IOC4 %s: Clock calibration failed. Assuming" "PCI clock is %d ns.\n", pci_name(idd->idd_pdev), IOC4_CALIBRATE_DEFAULT / IOC4_EXTINT_COUNT_DIVISOR); period = IOC4_CALIBRATE_DEFAULT; } else { u64 ns = period; do_div(ns, IOC4_EXTINT_COUNT_DIVISOR); printk(KERN_DEBUG "IOC4 %s: PCI clock is %llu ns.\n", pci_name(idd->idd_pdev), (unsigned long long)ns); } /* Remember results. We store the extint clock period rather * than the PCI clock period so that greater precision is * retained. Divide by IOC4_EXTINT_COUNT_DIVISOR to get * PCI clock period. */ idd->count_period = period; } /* There are three variants of IOC4 cards: IO9, IO10, and PCI-RT. * Each brings out different combinations of IOC4 signals, thus. * the IOC4 subdrivers need to know to which we're attached. * * We look for the presence of a SCSI (IO9) or SATA (IO10) controller * on the same PCI bus at slot number 3 to differentiate IO9 from IO10. * If neither is present, it's a PCI-RT. */ static unsigned int ioc4_variant(struct ioc4_driver_data *idd) { struct pci_dev *pdev = NULL; int found = 0; /* IO9: Look for a QLogic ISP 12160 at the same bus and slot 3. */ do { pdev = pci_get_device(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP12160, pdev); if (pdev && idd->idd_pdev->bus->number == pdev->bus->number && 3 == PCI_SLOT(pdev->devfn)) found = 1; } while (pdev && !found); if (NULL != pdev) { pci_dev_put(pdev); return IOC4_VARIANT_IO9; } /* IO10: Look for a Vitesse VSC 7174 at the same bus and slot 3. */ pdev = NULL; do { pdev = pci_get_device(PCI_VENDOR_ID_VITESSE, PCI_DEVICE_ID_VITESSE_VSC7174, pdev); if (pdev && idd->idd_pdev->bus->number == pdev->bus->number && 3 == PCI_SLOT(pdev->devfn)) found = 1; } while (pdev && !found); if (NULL != pdev) { pci_dev_put(pdev); return IOC4_VARIANT_IO10; } /* PCI-RT: No SCSI/SATA controller will be present */ return IOC4_VARIANT_PCI_RT; } static void ioc4_load_modules(struct work_struct *work) { /* arg just has to be freed */ request_module("sgiioc4"); kfree(work); } /* Adds a new instance of an IOC4 card */ static int ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) { struct ioc4_driver_data *idd; struct ioc4_submodule *is; uint32_t pcmd; int ret; /* Enable IOC4 and take ownership of it */ if ((ret = pci_enable_device(pdev))) { printk(KERN_WARNING "%s: Failed to enable IOC4 device for pci_dev %s.\n", __func__, pci_name(pdev)); goto out; } pci_set_master(pdev); /* Set up per-IOC4 data */ idd = kmalloc(sizeof(struct ioc4_driver_data), GFP_KERNEL); if (!idd) { printk(KERN_WARNING "%s: Failed to allocate IOC4 data for pci_dev %s.\n", __func__, pci_name(pdev)); ret = -ENODEV; goto out_idd; } idd->idd_pdev = pdev; idd->idd_pci_id = pci_id; /* Map IOC4 misc registers. These are shared between subdevices * so the main IOC4 module manages them. */ idd->idd_bar0 = pci_resource_start(idd->idd_pdev, 0); if (!idd->idd_bar0) { printk(KERN_WARNING "%s: Unable to find IOC4 misc resource " "for pci_dev %s.\n", __func__, pci_name(idd->idd_pdev)); ret = -ENODEV; goto out_pci; } if (!request_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs), "ioc4_misc")) { printk(KERN_WARNING "%s: Unable to request IOC4 misc region " "for pci_dev %s.\n", __func__, pci_name(idd->idd_pdev)); ret = -ENODEV; goto out_pci; } idd->idd_misc_regs = ioremap(idd->idd_bar0, sizeof(struct ioc4_misc_regs)); if (!idd->idd_misc_regs) { printk(KERN_WARNING "%s: Unable to remap IOC4 misc region " "for pci_dev %s.\n", __func__, pci_name(idd->idd_pdev)); ret = -ENODEV; goto out_misc_region; } /* Failsafe portion of per-IOC4 initialization */ /* Detect card variant */ idd->idd_variant = ioc4_variant(idd); printk(KERN_INFO "IOC4 %s: %s card detected.\n", pci_name(pdev), idd->idd_variant == IOC4_VARIANT_IO9 ? "IO9" : idd->idd_variant == IOC4_VARIANT_PCI_RT ? "PCI-RT" : idd->idd_variant == IOC4_VARIANT_IO10 ? "IO10" : "unknown"); /* Initialize IOC4 */ pci_read_config_dword(idd->idd_pdev, PCI_COMMAND, &pcmd); pci_write_config_dword(idd->idd_pdev, PCI_COMMAND, pcmd | PCI_COMMAND_PARITY | PCI_COMMAND_SERR); /* Determine PCI clock */ ioc4_clock_calibrate(idd); /* Disable/clear all interrupts. Need to do this here lest * one submodule request the shared IOC4 IRQ, but interrupt * is generated by a different subdevice. */ /* Disable */ writel(~0, &idd->idd_misc_regs->other_iec.raw); writel(~0, &idd->idd_misc_regs->sio_iec); /* Clear (i.e. acknowledge) */ writel(~0, &idd->idd_misc_regs->other_ir.raw); writel(~0, &idd->idd_misc_regs->sio_ir); /* Track PCI-device specific data */ idd->idd_serial_data = NULL; pci_set_drvdata(idd->idd_pdev, idd); mutex_lock(&ioc4_mutex); list_add_tail(&idd->idd_list, &ioc4_devices); /* Add this IOC4 to all submodules */ list_for_each_entry(is, &ioc4_submodules, is_list) { if (is->is_probe && is->is_probe(idd)) { printk(KERN_WARNING "%s: IOC4 submodule 0x%s probe failed " "for pci_dev %s.\n", __func__, module_name(is->is_owner), pci_name(idd->idd_pdev)); } } mutex_unlock(&ioc4_mutex); /* Request sgiioc4 IDE driver on boards that bring that functionality * off of IOC4. The root filesystem may be hosted on a drive connected * to IOC4, so we need to make sure the sgiioc4 driver is loaded as it * won't be picked up by modprobes due to the ioc4 module owning the * PCI device. */ if (idd->idd_variant != IOC4_VARIANT_PCI_RT) { struct work_struct *work; work = kzalloc(sizeof(struct work_struct), GFP_KERNEL); if (!work) { printk(KERN_WARNING "%s: IOC4 unable to allocate memory for " "load of sub-modules.\n", __func__); } else { /* Request the module from a work procedure as the * modprobe goes out to a userland helper and that * will hang if done directly from ioc4_probe(). */ printk(KERN_INFO "IOC4 loading sgiioc4 submodule\n"); INIT_WORK(work, ioc4_load_modules); schedule_work(work); } } return 0; out_misc_region: release_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs)); out_pci: kfree(idd); out_idd: pci_disable_device(pdev); out: return ret; } /* Removes a particular instance of an IOC4 card. */ static void ioc4_remove(struct pci_dev *pdev) { struct ioc4_submodule *is; struct ioc4_driver_data *idd; idd = pci_get_drvdata(pdev); /* Remove this IOC4 from all submodules */ mutex_lock(&ioc4_mutex); list_for_each_entry(is, &ioc4_submodules, is_list) { if (is->is_remove && is->is_remove(idd)) { printk(KERN_WARNING "%s: IOC4 submodule 0x%s remove failed " "for pci_dev %s.\n", __func__, module_name(is->is_owner), pci_name(idd->idd_pdev)); } } mutex_unlock(&ioc4_mutex); /* Release resources */ iounmap(idd->idd_misc_regs); if (!idd->idd_bar0) { printk(KERN_WARNING "%s: Unable to get IOC4 misc mapping for pci_dev %s. " "Device removal may be incomplete.\n", __func__, pci_name(idd->idd_pdev)); } release_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs)); /* Disable IOC4 and relinquish */ pci_disable_device(pdev); /* Remove and free driver data */ mutex_lock(&ioc4_mutex); list_del(&idd->idd_list); mutex_unlock(&ioc4_mutex); kfree(idd); } static struct pci_device_id ioc4_id_table[] = { {PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC4, PCI_ANY_ID, PCI_ANY_ID, 0x0b4000, 0xFFFFFF}, {0} }; static struct pci_driver ioc4_driver = { .name = "IOC4", .id_table = ioc4_id_table, .probe = ioc4_probe, .remove = ioc4_remove, }; MODULE_DEVICE_TABLE(pci, ioc4_id_table); /********************* * Module management * *********************/ /* Module load */ static int __devinit ioc4_init(void) { return pci_register_driver(&ioc4_driver); } /* Module unload */ static void __devexit ioc4_exit(void) { /* Ensure ioc4_load_modules() has completed before exiting */ flush_scheduled_work(); pci_unregister_driver(&ioc4_driver); } module_init(ioc4_init); module_exit(ioc4_exit); MODULE_AUTHOR("Brent Casavant - Silicon Graphics, Inc. <bcasavan@sgi.com>"); MODULE_DESCRIPTION("PCI driver master module for SGI IOC4 Base-IO Card"); MODULE_LICENSE("GPL"); EXPORT_SYMBOL(ioc4_register_submodule); EXPORT_SYMBOL(ioc4_unregister_submodule);
gpl-2.0
nviennot/linux-2.6-scribe
drivers/media/IR/keymaps/rc-videomate-tv-pvr.c
953
1928
/* videomate-tv-pvr.h - Keytable for videomate_tv_pvr Remote Controller * * keymap imported from ir-keymaps.c * * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.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 <media/rc-map.h> static struct ir_scancode videomate_tv_pvr[] = { { 0x14, KEY_MUTE }, { 0x24, KEY_ZOOM }, { 0x01, KEY_DVD }, { 0x23, KEY_RADIO }, { 0x00, KEY_TV }, { 0x0a, KEY_REWIND }, { 0x08, KEY_PLAYPAUSE }, { 0x0f, KEY_FORWARD }, { 0x02, KEY_PREVIOUS }, { 0x07, KEY_STOP }, { 0x06, KEY_NEXT }, { 0x0c, KEY_UP }, { 0x0e, KEY_DOWN }, { 0x0b, KEY_LEFT }, { 0x0d, KEY_RIGHT }, { 0x11, KEY_OK }, { 0x03, KEY_MENU }, { 0x09, KEY_SETUP }, { 0x05, KEY_VIDEO }, { 0x22, KEY_CHANNEL }, { 0x12, KEY_VOLUMEUP }, { 0x15, KEY_VOLUMEDOWN }, { 0x10, KEY_CHANNELUP }, { 0x13, KEY_CHANNELDOWN }, { 0x04, KEY_RECORD }, { 0x16, KEY_1 }, { 0x17, KEY_2 }, { 0x18, KEY_3 }, { 0x19, KEY_4 }, { 0x1a, KEY_5 }, { 0x1b, KEY_6 }, { 0x1c, KEY_7 }, { 0x1d, KEY_8 }, { 0x1e, KEY_9 }, { 0x1f, KEY_0 }, { 0x20, KEY_LANGUAGE }, { 0x21, KEY_SLEEP }, }; static struct rc_keymap videomate_tv_pvr_map = { .map = { .scan = videomate_tv_pvr, .size = ARRAY_SIZE(videomate_tv_pvr), .ir_type = IR_TYPE_UNKNOWN, /* Legacy IR type */ .name = RC_MAP_VIDEOMATE_TV_PVR, } }; static int __init init_rc_map_videomate_tv_pvr(void) { return ir_register_map(&videomate_tv_pvr_map); } static void __exit exit_rc_map_videomate_tv_pvr(void) { ir_unregister_map(&videomate_tv_pvr_map); } module_init(init_rc_map_videomate_tv_pvr) module_exit(exit_rc_map_videomate_tv_pvr) MODULE_LICENSE("GPL"); MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
gpl-2.0
ND-3500/golden_cm10.2_kernel
drivers/net/sfc/tx.c
953
34445
/**************************************************************************** * Driver for Solarflare Solarstorm network controllers and boards * Copyright 2005-2006 Fen Systems Ltd. * Copyright 2005-2010 Solarflare Communications Inc. * * 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, incorporated herein by reference. */ #include <linux/pci.h> #include <linux/tcp.h> #include <linux/ip.h> #include <linux/in.h> #include <linux/ipv6.h> #include <linux/slab.h> #include <net/ipv6.h> #include <linux/if_ether.h> #include <linux/highmem.h> #include "net_driver.h" #include "efx.h" #include "nic.h" #include "workarounds.h" /* * TX descriptor ring full threshold * * The tx_queue descriptor ring fill-level must fall below this value * before we restart the netif queue */ #define EFX_TXQ_THRESHOLD(_efx) ((_efx)->txq_entries / 2u) static void efx_dequeue_buffer(struct efx_tx_queue *tx_queue, struct efx_tx_buffer *buffer) { if (buffer->unmap_len) { struct pci_dev *pci_dev = tx_queue->efx->pci_dev; dma_addr_t unmap_addr = (buffer->dma_addr + buffer->len - buffer->unmap_len); if (buffer->unmap_single) pci_unmap_single(pci_dev, unmap_addr, buffer->unmap_len, PCI_DMA_TODEVICE); else pci_unmap_page(pci_dev, unmap_addr, buffer->unmap_len, PCI_DMA_TODEVICE); buffer->unmap_len = 0; buffer->unmap_single = false; } if (buffer->skb) { dev_kfree_skb_any((struct sk_buff *) buffer->skb); buffer->skb = NULL; netif_vdbg(tx_queue->efx, tx_done, tx_queue->efx->net_dev, "TX queue %d transmission id %x complete\n", tx_queue->queue, tx_queue->read_count); } } /** * struct efx_tso_header - a DMA mapped buffer for packet headers * @next: Linked list of free ones. * The list is protected by the TX queue lock. * @dma_unmap_len: Length to unmap for an oversize buffer, or 0. * @dma_addr: The DMA address of the header below. * * This controls the memory used for a TSO header. Use TSOH_DATA() * to find the packet header data. Use TSOH_SIZE() to calculate the * total size required for a given packet header length. TSO headers * in the free list are exactly %TSOH_STD_SIZE bytes in size. */ struct efx_tso_header { union { struct efx_tso_header *next; size_t unmap_len; }; dma_addr_t dma_addr; }; static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue, struct sk_buff *skb); static void efx_fini_tso(struct efx_tx_queue *tx_queue); static void efx_tsoh_heap_free(struct efx_tx_queue *tx_queue, struct efx_tso_header *tsoh); static void efx_tsoh_free(struct efx_tx_queue *tx_queue, struct efx_tx_buffer *buffer) { if (buffer->tsoh) { if (likely(!buffer->tsoh->unmap_len)) { buffer->tsoh->next = tx_queue->tso_headers_free; tx_queue->tso_headers_free = buffer->tsoh; } else { efx_tsoh_heap_free(tx_queue, buffer->tsoh); } buffer->tsoh = NULL; } } static inline unsigned efx_max_tx_len(struct efx_nic *efx, dma_addr_t dma_addr) { /* Depending on the NIC revision, we can use descriptor * lengths up to 8K or 8K-1. However, since PCI Express * devices must split read requests at 4K boundaries, there is * little benefit from using descriptors that cross those * boundaries and we keep things simple by not doing so. */ unsigned len = (~dma_addr & 0xfff) + 1; /* Work around hardware bug for unaligned buffers. */ if (EFX_WORKAROUND_5391(efx) && (dma_addr & 0xf)) len = min_t(unsigned, len, 512 - (dma_addr & 0xf)); return len; } unsigned int efx_tx_max_skb_descs(struct efx_nic *efx) { /* Header and payload descriptor for each output segment, plus * one for every input fragment boundary within a segment */ unsigned int max_descs = EFX_TSO_MAX_SEGS * 2 + MAX_SKB_FRAGS; /* Possibly one more per segment for the alignment workaround */ if (EFX_WORKAROUND_5391(efx)) max_descs += EFX_TSO_MAX_SEGS; /* Possibly more for PCIe page boundaries within input fragments */ if (PAGE_SIZE > EFX_PAGE_SIZE) max_descs += max_t(unsigned int, MAX_SKB_FRAGS, DIV_ROUND_UP(GSO_MAX_SIZE, EFX_PAGE_SIZE)); return max_descs; } /* * Add a socket buffer to a TX queue * * This maps all fragments of a socket buffer for DMA and adds them to * the TX queue. The queue's insert pointer will be incremented by * the number of fragments in the socket buffer. * * If any DMA mapping fails, any mapped fragments will be unmapped, * the queue's insert pointer will be restored to its original value. * * This function is split out from efx_hard_start_xmit to allow the * loopback test to direct packets via specific TX queues. * * Returns NETDEV_TX_OK or NETDEV_TX_BUSY * You must hold netif_tx_lock() to call this function. */ netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb) { struct efx_nic *efx = tx_queue->efx; struct pci_dev *pci_dev = efx->pci_dev; struct efx_tx_buffer *buffer; skb_frag_t *fragment; struct page *page; int page_offset; unsigned int len, unmap_len = 0, fill_level, insert_ptr; dma_addr_t dma_addr, unmap_addr = 0; unsigned int dma_len; bool unmap_single; int q_space, i = 0; netdev_tx_t rc = NETDEV_TX_OK; EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count); if (skb_shinfo(skb)->gso_size) return efx_enqueue_skb_tso(tx_queue, skb); /* Get size of the initial fragment */ len = skb_headlen(skb); /* Pad if necessary */ if (EFX_WORKAROUND_15592(efx) && skb->len <= 32) { EFX_BUG_ON_PARANOID(skb->data_len); len = 32 + 1; if (skb_pad(skb, len - skb->len)) return NETDEV_TX_OK; } fill_level = tx_queue->insert_count - tx_queue->old_read_count; q_space = efx->txq_entries - 1 - fill_level; /* Map for DMA. Use pci_map_single rather than pci_map_page * since this is more efficient on machines with sparse * memory. */ unmap_single = true; dma_addr = pci_map_single(pci_dev, skb->data, len, PCI_DMA_TODEVICE); /* Process all fragments */ while (1) { if (unlikely(pci_dma_mapping_error(pci_dev, dma_addr))) goto pci_err; /* Store fields for marking in the per-fragment final * descriptor */ unmap_len = len; unmap_addr = dma_addr; /* Add to TX queue, splitting across DMA boundaries */ do { if (unlikely(q_space-- <= 0)) { /* It might be that completions have * happened since the xmit path last * checked. Update the xmit path's * copy of read_count. */ netif_tx_stop_queue(tx_queue->core_txq); /* This memory barrier protects the * change of queue state from the access * of read_count. */ smp_mb(); tx_queue->old_read_count = ACCESS_ONCE(tx_queue->read_count); fill_level = (tx_queue->insert_count - tx_queue->old_read_count); q_space = efx->txq_entries - 1 - fill_level; if (unlikely(q_space-- <= 0)) { rc = NETDEV_TX_BUSY; goto unwind; } smp_mb(); if (likely(!efx->loopback_selftest)) netif_tx_start_queue( tx_queue->core_txq); } insert_ptr = tx_queue->insert_count & tx_queue->ptr_mask; buffer = &tx_queue->buffer[insert_ptr]; efx_tsoh_free(tx_queue, buffer); EFX_BUG_ON_PARANOID(buffer->tsoh); EFX_BUG_ON_PARANOID(buffer->skb); EFX_BUG_ON_PARANOID(buffer->len); EFX_BUG_ON_PARANOID(!buffer->continuation); EFX_BUG_ON_PARANOID(buffer->unmap_len); dma_len = efx_max_tx_len(efx, dma_addr); if (likely(dma_len >= len)) dma_len = len; /* Fill out per descriptor fields */ buffer->len = dma_len; buffer->dma_addr = dma_addr; len -= dma_len; dma_addr += dma_len; ++tx_queue->insert_count; } while (len); /* Transfer ownership of the unmapping to the final buffer */ buffer->unmap_single = unmap_single; buffer->unmap_len = unmap_len; unmap_len = 0; /* Get address and size of next fragment */ if (i >= skb_shinfo(skb)->nr_frags) break; fragment = &skb_shinfo(skb)->frags[i]; len = fragment->size; page = fragment->page; page_offset = fragment->page_offset; i++; /* Map for DMA */ unmap_single = false; dma_addr = pci_map_page(pci_dev, page, page_offset, len, PCI_DMA_TODEVICE); } /* Transfer ownership of the skb to the final buffer */ buffer->skb = skb; buffer->continuation = false; /* Pass off to hardware */ efx_nic_push_buffers(tx_queue); return NETDEV_TX_OK; pci_err: netif_err(efx, tx_err, efx->net_dev, " TX queue %d could not map skb with %d bytes %d " "fragments for DMA\n", tx_queue->queue, skb->len, skb_shinfo(skb)->nr_frags + 1); /* Mark the packet as transmitted, and free the SKB ourselves */ dev_kfree_skb_any(skb); unwind: /* Work backwards until we hit the original insert pointer value */ while (tx_queue->insert_count != tx_queue->write_count) { --tx_queue->insert_count; insert_ptr = tx_queue->insert_count & tx_queue->ptr_mask; buffer = &tx_queue->buffer[insert_ptr]; efx_dequeue_buffer(tx_queue, buffer); buffer->len = 0; } /* Free the fragment we were mid-way through pushing */ if (unmap_len) { if (unmap_single) pci_unmap_single(pci_dev, unmap_addr, unmap_len, PCI_DMA_TODEVICE); else pci_unmap_page(pci_dev, unmap_addr, unmap_len, PCI_DMA_TODEVICE); } return rc; } /* Remove packets from the TX queue * * This removes packets from the TX queue, up to and including the * specified index. */ static void efx_dequeue_buffers(struct efx_tx_queue *tx_queue, unsigned int index) { struct efx_nic *efx = tx_queue->efx; unsigned int stop_index, read_ptr; stop_index = (index + 1) & tx_queue->ptr_mask; read_ptr = tx_queue->read_count & tx_queue->ptr_mask; while (read_ptr != stop_index) { struct efx_tx_buffer *buffer = &tx_queue->buffer[read_ptr]; if (unlikely(buffer->len == 0)) { netif_err(efx, tx_err, efx->net_dev, "TX queue %d spurious TX completion id %x\n", tx_queue->queue, read_ptr); efx_schedule_reset(efx, RESET_TYPE_TX_SKIP); return; } efx_dequeue_buffer(tx_queue, buffer); buffer->continuation = true; buffer->len = 0; ++tx_queue->read_count; read_ptr = tx_queue->read_count & tx_queue->ptr_mask; } } /* Initiate a packet transmission. We use one channel per CPU * (sharing when we have more CPUs than channels). On Falcon, the TX * completion events will be directed back to the CPU that transmitted * the packet, which should be cache-efficient. * * Context: non-blocking. * Note that returning anything other than NETDEV_TX_OK will cause the * OS to free the skb. */ netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev) { struct efx_nic *efx = netdev_priv(net_dev); struct efx_tx_queue *tx_queue; unsigned index, type; EFX_WARN_ON_PARANOID(!netif_device_present(net_dev)); index = skb_get_queue_mapping(skb); type = skb->ip_summed == CHECKSUM_PARTIAL ? EFX_TXQ_TYPE_OFFLOAD : 0; if (index >= efx->n_tx_channels) { index -= efx->n_tx_channels; type |= EFX_TXQ_TYPE_HIGHPRI; } tx_queue = efx_get_tx_queue(efx, index, type); return efx_enqueue_skb(tx_queue, skb); } void efx_init_tx_queue_core_txq(struct efx_tx_queue *tx_queue) { struct efx_nic *efx = tx_queue->efx; /* Must be inverse of queue lookup in efx_hard_start_xmit() */ tx_queue->core_txq = netdev_get_tx_queue(efx->net_dev, tx_queue->queue / EFX_TXQ_TYPES + ((tx_queue->queue & EFX_TXQ_TYPE_HIGHPRI) ? efx->n_tx_channels : 0)); } int efx_setup_tc(struct net_device *net_dev, u8 num_tc) { struct efx_nic *efx = netdev_priv(net_dev); struct efx_channel *channel; struct efx_tx_queue *tx_queue; unsigned tc; int rc; if (efx_nic_rev(efx) < EFX_REV_FALCON_B0 || num_tc > EFX_MAX_TX_TC) return -EINVAL; if (num_tc == net_dev->num_tc) return 0; for (tc = 0; tc < num_tc; tc++) { net_dev->tc_to_txq[tc].offset = tc * efx->n_tx_channels; net_dev->tc_to_txq[tc].count = efx->n_tx_channels; } if (num_tc > net_dev->num_tc) { /* Initialise high-priority queues as necessary */ efx_for_each_channel(channel, efx) { efx_for_each_possible_channel_tx_queue(tx_queue, channel) { if (!(tx_queue->queue & EFX_TXQ_TYPE_HIGHPRI)) continue; if (!tx_queue->buffer) { rc = efx_probe_tx_queue(tx_queue); if (rc) return rc; } if (!tx_queue->initialised) efx_init_tx_queue(tx_queue); efx_init_tx_queue_core_txq(tx_queue); } } } else { /* Reduce number of classes before number of queues */ net_dev->num_tc = num_tc; } rc = netif_set_real_num_tx_queues(net_dev, max_t(int, num_tc, 1) * efx->n_tx_channels); if (rc) return rc; /* Do not destroy high-priority queues when they become * unused. We would have to flush them first, and it is * fairly difficult to flush a subset of TX queues. Leave * it to efx_fini_channels(). */ net_dev->num_tc = num_tc; return 0; } void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index) { unsigned fill_level; struct efx_nic *efx = tx_queue->efx; EFX_BUG_ON_PARANOID(index > tx_queue->ptr_mask); efx_dequeue_buffers(tx_queue, index); /* See if we need to restart the netif queue. This barrier * separates the update of read_count from the test of the * queue state. */ smp_mb(); if (unlikely(netif_tx_queue_stopped(tx_queue->core_txq)) && likely(efx->port_enabled) && likely(netif_device_present(efx->net_dev))) { fill_level = tx_queue->insert_count - tx_queue->read_count; if (fill_level < EFX_TXQ_THRESHOLD(efx)) { EFX_BUG_ON_PARANOID(!efx_dev_registered(efx)); netif_tx_wake_queue(tx_queue->core_txq); } } /* Check whether the hardware queue is now empty */ if ((int)(tx_queue->read_count - tx_queue->old_write_count) >= 0) { tx_queue->old_write_count = ACCESS_ONCE(tx_queue->write_count); if (tx_queue->read_count == tx_queue->old_write_count) { smp_mb(); tx_queue->empty_read_count = tx_queue->read_count | EFX_EMPTY_COUNT_VALID; } } } int efx_probe_tx_queue(struct efx_tx_queue *tx_queue) { struct efx_nic *efx = tx_queue->efx; unsigned int entries; int i, rc; /* Create the smallest power-of-two aligned ring */ entries = max(roundup_pow_of_two(efx->txq_entries), EFX_MIN_DMAQ_SIZE); EFX_BUG_ON_PARANOID(entries > EFX_MAX_DMAQ_SIZE); tx_queue->ptr_mask = entries - 1; netif_dbg(efx, probe, efx->net_dev, "creating TX queue %d size %#x mask %#x\n", tx_queue->queue, efx->txq_entries, tx_queue->ptr_mask); /* Allocate software ring */ tx_queue->buffer = kzalloc(entries * sizeof(*tx_queue->buffer), GFP_KERNEL); if (!tx_queue->buffer) return -ENOMEM; for (i = 0; i <= tx_queue->ptr_mask; ++i) tx_queue->buffer[i].continuation = true; /* Allocate hardware ring */ rc = efx_nic_probe_tx(tx_queue); if (rc) goto fail; return 0; fail: kfree(tx_queue->buffer); tx_queue->buffer = NULL; return rc; } void efx_init_tx_queue(struct efx_tx_queue *tx_queue) { netif_dbg(tx_queue->efx, drv, tx_queue->efx->net_dev, "initialising TX queue %d\n", tx_queue->queue); tx_queue->insert_count = 0; tx_queue->write_count = 0; tx_queue->old_write_count = 0; tx_queue->read_count = 0; tx_queue->old_read_count = 0; tx_queue->empty_read_count = 0 | EFX_EMPTY_COUNT_VALID; /* Set up TX descriptor ring */ efx_nic_init_tx(tx_queue); tx_queue->initialised = true; } void efx_release_tx_buffers(struct efx_tx_queue *tx_queue) { struct efx_tx_buffer *buffer; if (!tx_queue->buffer) return; /* Free any buffers left in the ring */ while (tx_queue->read_count != tx_queue->write_count) { buffer = &tx_queue->buffer[tx_queue->read_count & tx_queue->ptr_mask]; efx_dequeue_buffer(tx_queue, buffer); buffer->continuation = true; buffer->len = 0; ++tx_queue->read_count; } } void efx_fini_tx_queue(struct efx_tx_queue *tx_queue) { if (!tx_queue->initialised) return; netif_dbg(tx_queue->efx, drv, tx_queue->efx->net_dev, "shutting down TX queue %d\n", tx_queue->queue); tx_queue->initialised = false; /* Flush TX queue, remove descriptor ring */ efx_nic_fini_tx(tx_queue); efx_release_tx_buffers(tx_queue); /* Free up TSO header cache */ efx_fini_tso(tx_queue); } void efx_remove_tx_queue(struct efx_tx_queue *tx_queue) { if (!tx_queue->buffer) return; netif_dbg(tx_queue->efx, drv, tx_queue->efx->net_dev, "destroying TX queue %d\n", tx_queue->queue); efx_nic_remove_tx(tx_queue); kfree(tx_queue->buffer); tx_queue->buffer = NULL; } /* Efx TCP segmentation acceleration. * * Why? Because by doing it here in the driver we can go significantly * faster than the GSO. * * Requires TX checksum offload support. */ /* Number of bytes inserted at the start of a TSO header buffer, * similar to NET_IP_ALIGN. */ #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS #define TSOH_OFFSET 0 #else #define TSOH_OFFSET NET_IP_ALIGN #endif #define TSOH_BUFFER(tsoh) ((u8 *)(tsoh + 1) + TSOH_OFFSET) /* Total size of struct efx_tso_header, buffer and padding */ #define TSOH_SIZE(hdr_len) \ (sizeof(struct efx_tso_header) + TSOH_OFFSET + hdr_len) /* Size of blocks on free list. Larger blocks must be allocated from * the heap. */ #define TSOH_STD_SIZE 128 #define PTR_DIFF(p1, p2) ((u8 *)(p1) - (u8 *)(p2)) #define ETH_HDR_LEN(skb) (skb_network_header(skb) - (skb)->data) #define SKB_TCP_OFF(skb) PTR_DIFF(tcp_hdr(skb), (skb)->data) #define SKB_IPV4_OFF(skb) PTR_DIFF(ip_hdr(skb), (skb)->data) #define SKB_IPV6_OFF(skb) PTR_DIFF(ipv6_hdr(skb), (skb)->data) /** * struct tso_state - TSO state for an SKB * @out_len: Remaining length in current segment * @seqnum: Current sequence number * @ipv4_id: Current IPv4 ID, host endian * @packet_space: Remaining space in current packet * @dma_addr: DMA address of current position * @in_len: Remaining length in current SKB fragment * @unmap_len: Length of SKB fragment * @unmap_addr: DMA address of SKB fragment * @unmap_single: DMA single vs page mapping flag * @protocol: Network protocol (after any VLAN header) * @header_len: Number of bytes of header * @full_packet_size: Number of bytes to put in each outgoing segment * * The state used during segmentation. It is put into this data structure * just to make it easy to pass into inline functions. */ struct tso_state { /* Output position */ unsigned out_len; unsigned seqnum; unsigned ipv4_id; unsigned packet_space; /* Input position */ dma_addr_t dma_addr; unsigned in_len; unsigned unmap_len; dma_addr_t unmap_addr; bool unmap_single; __be16 protocol; unsigned header_len; int full_packet_size; }; /* * Verify that our various assumptions about sk_buffs and the conditions * under which TSO will be attempted hold true. Return the protocol number. */ static __be16 efx_tso_check_protocol(struct sk_buff *skb) { __be16 protocol = skb->protocol; EFX_BUG_ON_PARANOID(((struct ethhdr *)skb->data)->h_proto != protocol); if (protocol == htons(ETH_P_8021Q)) { /* Find the encapsulated protocol; reset network header * and transport header based on that. */ struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; protocol = veh->h_vlan_encapsulated_proto; skb_set_network_header(skb, sizeof(*veh)); if (protocol == htons(ETH_P_IP)) skb_set_transport_header(skb, sizeof(*veh) + 4 * ip_hdr(skb)->ihl); else if (protocol == htons(ETH_P_IPV6)) skb_set_transport_header(skb, sizeof(*veh) + sizeof(struct ipv6hdr)); } if (protocol == htons(ETH_P_IP)) { EFX_BUG_ON_PARANOID(ip_hdr(skb)->protocol != IPPROTO_TCP); } else { EFX_BUG_ON_PARANOID(protocol != htons(ETH_P_IPV6)); EFX_BUG_ON_PARANOID(ipv6_hdr(skb)->nexthdr != NEXTHDR_TCP); } EFX_BUG_ON_PARANOID((PTR_DIFF(tcp_hdr(skb), skb->data) + (tcp_hdr(skb)->doff << 2u)) > skb_headlen(skb)); return protocol; } /* * Allocate a page worth of efx_tso_header structures, and string them * into the tx_queue->tso_headers_free linked list. Return 0 or -ENOMEM. */ static int efx_tsoh_block_alloc(struct efx_tx_queue *tx_queue) { struct pci_dev *pci_dev = tx_queue->efx->pci_dev; struct efx_tso_header *tsoh; dma_addr_t dma_addr; u8 *base_kva, *kva; base_kva = pci_alloc_consistent(pci_dev, PAGE_SIZE, &dma_addr); if (base_kva == NULL) { netif_err(tx_queue->efx, tx_err, tx_queue->efx->net_dev, "Unable to allocate page for TSO headers\n"); return -ENOMEM; } /* pci_alloc_consistent() allocates pages. */ EFX_BUG_ON_PARANOID(dma_addr & (PAGE_SIZE - 1u)); for (kva = base_kva; kva < base_kva + PAGE_SIZE; kva += TSOH_STD_SIZE) { tsoh = (struct efx_tso_header *)kva; tsoh->dma_addr = dma_addr + (TSOH_BUFFER(tsoh) - base_kva); tsoh->next = tx_queue->tso_headers_free; tx_queue->tso_headers_free = tsoh; } return 0; } /* Free up a TSO header, and all others in the same page. */ static void efx_tsoh_block_free(struct efx_tx_queue *tx_queue, struct efx_tso_header *tsoh, struct pci_dev *pci_dev) { struct efx_tso_header **p; unsigned long base_kva; dma_addr_t base_dma; base_kva = (unsigned long)tsoh & PAGE_MASK; base_dma = tsoh->dma_addr & PAGE_MASK; p = &tx_queue->tso_headers_free; while (*p != NULL) { if (((unsigned long)*p & PAGE_MASK) == base_kva) *p = (*p)->next; else p = &(*p)->next; } pci_free_consistent(pci_dev, PAGE_SIZE, (void *)base_kva, base_dma); } static struct efx_tso_header * efx_tsoh_heap_alloc(struct efx_tx_queue *tx_queue, size_t header_len) { struct efx_tso_header *tsoh; tsoh = kmalloc(TSOH_SIZE(header_len), GFP_ATOMIC | GFP_DMA); if (unlikely(!tsoh)) return NULL; tsoh->dma_addr = pci_map_single(tx_queue->efx->pci_dev, TSOH_BUFFER(tsoh), header_len, PCI_DMA_TODEVICE); if (unlikely(pci_dma_mapping_error(tx_queue->efx->pci_dev, tsoh->dma_addr))) { kfree(tsoh); return NULL; } tsoh->unmap_len = header_len; return tsoh; } static void efx_tsoh_heap_free(struct efx_tx_queue *tx_queue, struct efx_tso_header *tsoh) { pci_unmap_single(tx_queue->efx->pci_dev, tsoh->dma_addr, tsoh->unmap_len, PCI_DMA_TODEVICE); kfree(tsoh); } /** * efx_tx_queue_insert - push descriptors onto the TX queue * @tx_queue: Efx TX queue * @dma_addr: DMA address of fragment * @len: Length of fragment * @final_buffer: The final buffer inserted into the queue * * Push descriptors onto the TX queue. Return 0 on success or 1 if * @tx_queue full. */ static int efx_tx_queue_insert(struct efx_tx_queue *tx_queue, dma_addr_t dma_addr, unsigned len, struct efx_tx_buffer **final_buffer) { struct efx_tx_buffer *buffer; struct efx_nic *efx = tx_queue->efx; unsigned dma_len, fill_level, insert_ptr; int q_space; EFX_BUG_ON_PARANOID(len <= 0); fill_level = tx_queue->insert_count - tx_queue->old_read_count; /* -1 as there is no way to represent all descriptors used */ q_space = efx->txq_entries - 1 - fill_level; while (1) { if (unlikely(q_space-- <= 0)) { /* It might be that completions have happened * since the xmit path last checked. Update * the xmit path's copy of read_count. */ netif_tx_stop_queue(tx_queue->core_txq); /* This memory barrier protects the change of * queue state from the access of read_count. */ smp_mb(); tx_queue->old_read_count = ACCESS_ONCE(tx_queue->read_count); fill_level = (tx_queue->insert_count - tx_queue->old_read_count); q_space = efx->txq_entries - 1 - fill_level; if (unlikely(q_space-- <= 0)) { *final_buffer = NULL; return 1; } smp_mb(); netif_tx_start_queue(tx_queue->core_txq); } insert_ptr = tx_queue->insert_count & tx_queue->ptr_mask; buffer = &tx_queue->buffer[insert_ptr]; ++tx_queue->insert_count; EFX_BUG_ON_PARANOID(tx_queue->insert_count - tx_queue->read_count >= efx->txq_entries); efx_tsoh_free(tx_queue, buffer); EFX_BUG_ON_PARANOID(buffer->len); EFX_BUG_ON_PARANOID(buffer->unmap_len); EFX_BUG_ON_PARANOID(buffer->skb); EFX_BUG_ON_PARANOID(!buffer->continuation); EFX_BUG_ON_PARANOID(buffer->tsoh); buffer->dma_addr = dma_addr; dma_len = efx_max_tx_len(efx, dma_addr); /* If there is enough space to send then do so */ if (dma_len >= len) break; buffer->len = dma_len; /* Don't set the other members */ dma_addr += dma_len; len -= dma_len; } EFX_BUG_ON_PARANOID(!len); buffer->len = len; *final_buffer = buffer; return 0; } /* * Put a TSO header into the TX queue. * * This is special-cased because we know that it is small enough to fit in * a single fragment, and we know it doesn't cross a page boundary. It * also allows us to not worry about end-of-packet etc. */ static void efx_tso_put_header(struct efx_tx_queue *tx_queue, struct efx_tso_header *tsoh, unsigned len) { struct efx_tx_buffer *buffer; buffer = &tx_queue->buffer[tx_queue->insert_count & tx_queue->ptr_mask]; efx_tsoh_free(tx_queue, buffer); EFX_BUG_ON_PARANOID(buffer->len); EFX_BUG_ON_PARANOID(buffer->unmap_len); EFX_BUG_ON_PARANOID(buffer->skb); EFX_BUG_ON_PARANOID(!buffer->continuation); EFX_BUG_ON_PARANOID(buffer->tsoh); buffer->len = len; buffer->dma_addr = tsoh->dma_addr; buffer->tsoh = tsoh; ++tx_queue->insert_count; } /* Remove descriptors put into a tx_queue. */ static void efx_enqueue_unwind(struct efx_tx_queue *tx_queue) { struct efx_tx_buffer *buffer; dma_addr_t unmap_addr; /* Work backwards until we hit the original insert pointer value */ while (tx_queue->insert_count != tx_queue->write_count) { --tx_queue->insert_count; buffer = &tx_queue->buffer[tx_queue->insert_count & tx_queue->ptr_mask]; efx_tsoh_free(tx_queue, buffer); EFX_BUG_ON_PARANOID(buffer->skb); if (buffer->unmap_len) { unmap_addr = (buffer->dma_addr + buffer->len - buffer->unmap_len); if (buffer->unmap_single) pci_unmap_single(tx_queue->efx->pci_dev, unmap_addr, buffer->unmap_len, PCI_DMA_TODEVICE); else pci_unmap_page(tx_queue->efx->pci_dev, unmap_addr, buffer->unmap_len, PCI_DMA_TODEVICE); buffer->unmap_len = 0; } buffer->len = 0; buffer->continuation = true; } } /* Parse the SKB header and initialise state. */ static void tso_start(struct tso_state *st, const struct sk_buff *skb) { /* All ethernet/IP/TCP headers combined size is TCP header size * plus offset of TCP header relative to start of packet. */ st->header_len = ((tcp_hdr(skb)->doff << 2u) + PTR_DIFF(tcp_hdr(skb), skb->data)); st->full_packet_size = st->header_len + skb_shinfo(skb)->gso_size; if (st->protocol == htons(ETH_P_IP)) st->ipv4_id = ntohs(ip_hdr(skb)->id); else st->ipv4_id = 0; st->seqnum = ntohl(tcp_hdr(skb)->seq); EFX_BUG_ON_PARANOID(tcp_hdr(skb)->urg); EFX_BUG_ON_PARANOID(tcp_hdr(skb)->syn); EFX_BUG_ON_PARANOID(tcp_hdr(skb)->rst); st->packet_space = st->full_packet_size; st->out_len = skb->len - st->header_len; st->unmap_len = 0; st->unmap_single = false; } static int tso_get_fragment(struct tso_state *st, struct efx_nic *efx, skb_frag_t *frag) { st->unmap_addr = pci_map_page(efx->pci_dev, frag->page, frag->page_offset, frag->size, PCI_DMA_TODEVICE); if (likely(!pci_dma_mapping_error(efx->pci_dev, st->unmap_addr))) { st->unmap_single = false; st->unmap_len = frag->size; st->in_len = frag->size; st->dma_addr = st->unmap_addr; return 0; } return -ENOMEM; } static int tso_get_head_fragment(struct tso_state *st, struct efx_nic *efx, const struct sk_buff *skb) { int hl = st->header_len; int len = skb_headlen(skb) - hl; st->unmap_addr = pci_map_single(efx->pci_dev, skb->data + hl, len, PCI_DMA_TODEVICE); if (likely(!pci_dma_mapping_error(efx->pci_dev, st->unmap_addr))) { st->unmap_single = true; st->unmap_len = len; st->in_len = len; st->dma_addr = st->unmap_addr; return 0; } return -ENOMEM; } /** * tso_fill_packet_with_fragment - form descriptors for the current fragment * @tx_queue: Efx TX queue * @skb: Socket buffer * @st: TSO state * * Form descriptors for the current fragment, until we reach the end * of fragment or end-of-packet. Return 0 on success, 1 if not enough * space in @tx_queue. */ static int tso_fill_packet_with_fragment(struct efx_tx_queue *tx_queue, const struct sk_buff *skb, struct tso_state *st) { struct efx_tx_buffer *buffer; int n, end_of_packet, rc; if (st->in_len == 0) return 0; if (st->packet_space == 0) return 0; EFX_BUG_ON_PARANOID(st->in_len <= 0); EFX_BUG_ON_PARANOID(st->packet_space <= 0); n = min(st->in_len, st->packet_space); st->packet_space -= n; st->out_len -= n; st->in_len -= n; rc = efx_tx_queue_insert(tx_queue, st->dma_addr, n, &buffer); if (likely(rc == 0)) { if (st->out_len == 0) /* Transfer ownership of the skb */ buffer->skb = skb; end_of_packet = st->out_len == 0 || st->packet_space == 0; buffer->continuation = !end_of_packet; if (st->in_len == 0) { /* Transfer ownership of the pci mapping */ buffer->unmap_len = st->unmap_len; buffer->unmap_single = st->unmap_single; st->unmap_len = 0; } } st->dma_addr += n; return rc; } /** * tso_start_new_packet - generate a new header and prepare for the new packet * @tx_queue: Efx TX queue * @skb: Socket buffer * @st: TSO state * * Generate a new header and prepare for the new packet. Return 0 on * success, or -1 if failed to alloc header. */ static int tso_start_new_packet(struct efx_tx_queue *tx_queue, const struct sk_buff *skb, struct tso_state *st) { struct efx_tso_header *tsoh; struct tcphdr *tsoh_th; unsigned ip_length; u8 *header; /* Allocate a DMA-mapped header buffer. */ if (likely(TSOH_SIZE(st->header_len) <= TSOH_STD_SIZE)) { if (tx_queue->tso_headers_free == NULL) { if (efx_tsoh_block_alloc(tx_queue)) return -1; } EFX_BUG_ON_PARANOID(!tx_queue->tso_headers_free); tsoh = tx_queue->tso_headers_free; tx_queue->tso_headers_free = tsoh->next; tsoh->unmap_len = 0; } else { tx_queue->tso_long_headers++; tsoh = efx_tsoh_heap_alloc(tx_queue, st->header_len); if (unlikely(!tsoh)) return -1; } header = TSOH_BUFFER(tsoh); tsoh_th = (struct tcphdr *)(header + SKB_TCP_OFF(skb)); /* Copy and update the headers. */ memcpy(header, skb->data, st->header_len); tsoh_th->seq = htonl(st->seqnum); st->seqnum += skb_shinfo(skb)->gso_size; if (st->out_len > skb_shinfo(skb)->gso_size) { /* This packet will not finish the TSO burst. */ ip_length = st->full_packet_size - ETH_HDR_LEN(skb); tsoh_th->fin = 0; tsoh_th->psh = 0; } else { /* This packet will be the last in the TSO burst. */ ip_length = st->header_len - ETH_HDR_LEN(skb) + st->out_len; tsoh_th->fin = tcp_hdr(skb)->fin; tsoh_th->psh = tcp_hdr(skb)->psh; } if (st->protocol == htons(ETH_P_IP)) { struct iphdr *tsoh_iph = (struct iphdr *)(header + SKB_IPV4_OFF(skb)); tsoh_iph->tot_len = htons(ip_length); /* Linux leaves suitable gaps in the IP ID space for us to fill. */ tsoh_iph->id = htons(st->ipv4_id); st->ipv4_id++; } else { struct ipv6hdr *tsoh_iph = (struct ipv6hdr *)(header + SKB_IPV6_OFF(skb)); tsoh_iph->payload_len = htons(ip_length - sizeof(*tsoh_iph)); } st->packet_space = skb_shinfo(skb)->gso_size; ++tx_queue->tso_packets; /* Form a descriptor for this header. */ efx_tso_put_header(tx_queue, tsoh, st->header_len); return 0; } /** * efx_enqueue_skb_tso - segment and transmit a TSO socket buffer * @tx_queue: Efx TX queue * @skb: Socket buffer * * Context: You must hold netif_tx_lock() to call this function. * * Add socket buffer @skb to @tx_queue, doing TSO or return != 0 if * @skb was not enqueued. In all cases @skb is consumed. Return * %NETDEV_TX_OK or %NETDEV_TX_BUSY. */ static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue, struct sk_buff *skb) { struct efx_nic *efx = tx_queue->efx; int frag_i, rc, rc2 = NETDEV_TX_OK; struct tso_state state; /* Find the packet protocol and sanity-check it */ state.protocol = efx_tso_check_protocol(skb); EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count); tso_start(&state, skb); /* Assume that skb header area contains exactly the headers, and * all payload is in the frag list. */ if (skb_headlen(skb) == state.header_len) { /* Grab the first payload fragment. */ EFX_BUG_ON_PARANOID(skb_shinfo(skb)->nr_frags < 1); frag_i = 0; rc = tso_get_fragment(&state, efx, skb_shinfo(skb)->frags + frag_i); if (rc) goto mem_err; } else { rc = tso_get_head_fragment(&state, efx, skb); if (rc) goto mem_err; frag_i = -1; } if (tso_start_new_packet(tx_queue, skb, &state) < 0) goto mem_err; while (1) { rc = tso_fill_packet_with_fragment(tx_queue, skb, &state); if (unlikely(rc)) { rc2 = NETDEV_TX_BUSY; goto unwind; } /* Move onto the next fragment? */ if (state.in_len == 0) { if (++frag_i >= skb_shinfo(skb)->nr_frags) /* End of payload reached. */ break; rc = tso_get_fragment(&state, efx, skb_shinfo(skb)->frags + frag_i); if (rc) goto mem_err; } /* Start at new packet? */ if (state.packet_space == 0 && tso_start_new_packet(tx_queue, skb, &state) < 0) goto mem_err; } /* Pass off to hardware */ efx_nic_push_buffers(tx_queue); tx_queue->tso_bursts++; return NETDEV_TX_OK; mem_err: netif_err(efx, tx_err, efx->net_dev, "Out of memory for TSO headers, or PCI mapping error\n"); dev_kfree_skb_any(skb); unwind: /* Free the DMA mapping we were in the process of writing out */ if (state.unmap_len) { if (state.unmap_single) pci_unmap_single(efx->pci_dev, state.unmap_addr, state.unmap_len, PCI_DMA_TODEVICE); else pci_unmap_page(efx->pci_dev, state.unmap_addr, state.unmap_len, PCI_DMA_TODEVICE); } efx_enqueue_unwind(tx_queue); return rc2; } /* * Free up all TSO datastructures associated with tx_queue. This * routine should be called only once the tx_queue is both empty and * will no longer be used. */ static void efx_fini_tso(struct efx_tx_queue *tx_queue) { unsigned i; if (tx_queue->buffer) { for (i = 0; i <= tx_queue->ptr_mask; ++i) efx_tsoh_free(tx_queue, &tx_queue->buffer[i]); } while (tx_queue->tso_headers_free != NULL) efx_tsoh_block_free(tx_queue, tx_queue->tso_headers_free, tx_queue->efx->pci_dev); }
gpl-2.0
hurrian/kernel_samsung_trelte
sound/soc/omap/omap-mcpdm.c
1977
14916
/* * omap-mcpdm.c -- OMAP ALSA SoC DAI driver using McPDM port * * Copyright (C) 2009 - 2011 Texas Instruments * * Author: Misael Lopez Cruz <misael.lopez@ti.com> * Contact: Jorge Eduardo Candelaria <x0107209@ti.com> * Margarita Olaya <magi.olaya@ti.com> * Peter Ujfalusi <peter.ujfalusi@ti.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #include <linux/init.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/interrupt.h> #include <linux/err.h> #include <linux/io.h> #include <linux/irq.h> #include <linux/slab.h> #include <linux/pm_runtime.h> #include <linux/of_device.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/dmaengine_pcm.h> #include "omap-mcpdm.h" struct mcpdm_link_config { u32 link_mask; /* channel mask for the direction */ u32 threshold; /* FIFO threshold */ }; struct omap_mcpdm { struct device *dev; unsigned long phys_base; void __iomem *io_base; int irq; struct mutex mutex; /* Playback/Capture configuration */ struct mcpdm_link_config config[2]; /* McPDM dn offsets for rx1, and 2 channels */ u32 dn_rx_offset; /* McPDM needs to be restarted due to runtime reconfiguration */ bool restart; struct snd_dmaengine_dai_dma_data dma_data[2]; unsigned int dma_req[2]; }; /* * Stream DMA parameters */ static inline void omap_mcpdm_write(struct omap_mcpdm *mcpdm, u16 reg, u32 val) { __raw_writel(val, mcpdm->io_base + reg); } static inline int omap_mcpdm_read(struct omap_mcpdm *mcpdm, u16 reg) { return __raw_readl(mcpdm->io_base + reg); } #ifdef DEBUG static void omap_mcpdm_reg_dump(struct omap_mcpdm *mcpdm) { dev_dbg(mcpdm->dev, "***********************\n"); dev_dbg(mcpdm->dev, "IRQSTATUS_RAW: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS_RAW)); dev_dbg(mcpdm->dev, "IRQSTATUS: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS)); dev_dbg(mcpdm->dev, "IRQENABLE_SET: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_IRQENABLE_SET)); dev_dbg(mcpdm->dev, "IRQENABLE_CLR: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_IRQENABLE_CLR)); dev_dbg(mcpdm->dev, "IRQWAKE_EN: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_IRQWAKE_EN)); dev_dbg(mcpdm->dev, "DMAENABLE_SET: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_DMAENABLE_SET)); dev_dbg(mcpdm->dev, "DMAENABLE_CLR: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_DMAENABLE_CLR)); dev_dbg(mcpdm->dev, "DMAWAKEEN: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_DMAWAKEEN)); dev_dbg(mcpdm->dev, "CTRL: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL)); dev_dbg(mcpdm->dev, "DN_DATA: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_DN_DATA)); dev_dbg(mcpdm->dev, "UP_DATA: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_UP_DATA)); dev_dbg(mcpdm->dev, "FIFO_CTRL_DN: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_FIFO_CTRL_DN)); dev_dbg(mcpdm->dev, "FIFO_CTRL_UP: 0x%04x\n", omap_mcpdm_read(mcpdm, MCPDM_REG_FIFO_CTRL_UP)); dev_dbg(mcpdm->dev, "***********************\n"); } #else static void omap_mcpdm_reg_dump(struct omap_mcpdm *mcpdm) {} #endif /* * Enables the transfer through the PDM interface to/from the Phoenix * codec by enabling the corresponding UP or DN channels. */ static void omap_mcpdm_start(struct omap_mcpdm *mcpdm) { u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL); u32 link_mask = mcpdm->config[0].link_mask | mcpdm->config[1].link_mask; ctrl |= (MCPDM_SW_DN_RST | MCPDM_SW_UP_RST); omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); ctrl |= link_mask; omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); ctrl &= ~(MCPDM_SW_DN_RST | MCPDM_SW_UP_RST); omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); } /* * Disables the transfer through the PDM interface to/from the Phoenix * codec by disabling the corresponding UP or DN channels. */ static void omap_mcpdm_stop(struct omap_mcpdm *mcpdm) { u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL); u32 link_mask = MCPDM_PDM_DN_MASK | MCPDM_PDM_UP_MASK; ctrl |= (MCPDM_SW_DN_RST | MCPDM_SW_UP_RST); omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); ctrl &= ~(link_mask); omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); ctrl &= ~(MCPDM_SW_DN_RST | MCPDM_SW_UP_RST); omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl); } /* * Is the physical McPDM interface active. */ static inline int omap_mcpdm_active(struct omap_mcpdm *mcpdm) { return omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL) & (MCPDM_PDM_DN_MASK | MCPDM_PDM_UP_MASK); } /* * Configures McPDM uplink, and downlink for audio. * This function should be called before omap_mcpdm_start. */ static void omap_mcpdm_open_streams(struct omap_mcpdm *mcpdm) { omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_SET, MCPDM_DN_IRQ_EMPTY | MCPDM_DN_IRQ_FULL | MCPDM_UP_IRQ_EMPTY | MCPDM_UP_IRQ_FULL); /* Enable DN RX1/2 offset cancellation feature, if configured */ if (mcpdm->dn_rx_offset) { u32 dn_offset = mcpdm->dn_rx_offset; omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, dn_offset); dn_offset |= (MCPDM_DN_OFST_RX1_EN | MCPDM_DN_OFST_RX2_EN); omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, dn_offset); } omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_DN, mcpdm->config[SNDRV_PCM_STREAM_PLAYBACK].threshold); omap_mcpdm_write(mcpdm, MCPDM_REG_FIFO_CTRL_UP, mcpdm->config[SNDRV_PCM_STREAM_CAPTURE].threshold); omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_SET, MCPDM_DMA_DN_ENABLE | MCPDM_DMA_UP_ENABLE); } /* * Cleans McPDM uplink, and downlink configuration. * This function should be called when the stream is closed. */ static void omap_mcpdm_close_streams(struct omap_mcpdm *mcpdm) { /* Disable irq request generation for downlink */ omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_CLR, MCPDM_DN_IRQ_EMPTY | MCPDM_DN_IRQ_FULL); /* Disable DMA request generation for downlink */ omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_CLR, MCPDM_DMA_DN_ENABLE); /* Disable irq request generation for uplink */ omap_mcpdm_write(mcpdm, MCPDM_REG_IRQENABLE_CLR, MCPDM_UP_IRQ_EMPTY | MCPDM_UP_IRQ_FULL); /* Disable DMA request generation for uplink */ omap_mcpdm_write(mcpdm, MCPDM_REG_DMAENABLE_CLR, MCPDM_DMA_UP_ENABLE); /* Disable RX1/2 offset cancellation */ if (mcpdm->dn_rx_offset) omap_mcpdm_write(mcpdm, MCPDM_REG_DN_OFFSET, 0); } static irqreturn_t omap_mcpdm_irq_handler(int irq, void *dev_id) { struct omap_mcpdm *mcpdm = dev_id; int irq_status; irq_status = omap_mcpdm_read(mcpdm, MCPDM_REG_IRQSTATUS); /* Acknowledge irq event */ omap_mcpdm_write(mcpdm, MCPDM_REG_IRQSTATUS, irq_status); if (irq_status & MCPDM_DN_IRQ_FULL) dev_dbg(mcpdm->dev, "DN (playback) FIFO Full\n"); if (irq_status & MCPDM_DN_IRQ_EMPTY) dev_dbg(mcpdm->dev, "DN (playback) FIFO Empty\n"); if (irq_status & MCPDM_DN_IRQ) dev_dbg(mcpdm->dev, "DN (playback) write request\n"); if (irq_status & MCPDM_UP_IRQ_FULL) dev_dbg(mcpdm->dev, "UP (capture) FIFO Full\n"); if (irq_status & MCPDM_UP_IRQ_EMPTY) dev_dbg(mcpdm->dev, "UP (capture) FIFO Empty\n"); if (irq_status & MCPDM_UP_IRQ) dev_dbg(mcpdm->dev, "UP (capture) write request\n"); return IRQ_HANDLED; } static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); mutex_lock(&mcpdm->mutex); if (!dai->active) { u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL); omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl | MCPDM_WD_EN); omap_mcpdm_open_streams(mcpdm); } mutex_unlock(&mcpdm->mutex); snd_soc_dai_set_dma_data(dai, substream, &mcpdm->dma_data[substream->stream]); return 0; } static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); mutex_lock(&mcpdm->mutex); if (!dai->active) { if (omap_mcpdm_active(mcpdm)) { omap_mcpdm_stop(mcpdm); omap_mcpdm_close_streams(mcpdm); mcpdm->config[0].link_mask = 0; mcpdm->config[1].link_mask = 0; } } mutex_unlock(&mcpdm->mutex); } static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); int stream = substream->stream; struct snd_dmaengine_dai_dma_data *dma_data; u32 threshold; int channels; int link_mask = 0; channels = params_channels(params); switch (channels) { case 5: if (stream == SNDRV_PCM_STREAM_CAPTURE) /* up to 3 channels for capture */ return -EINVAL; link_mask |= 1 << 4; case 4: if (stream == SNDRV_PCM_STREAM_CAPTURE) /* up to 3 channels for capture */ return -EINVAL; link_mask |= 1 << 3; case 3: link_mask |= 1 << 2; case 2: link_mask |= 1 << 1; case 1: link_mask |= 1 << 0; break; default: /* unsupported number of channels */ return -EINVAL; } dma_data = snd_soc_dai_get_dma_data(dai, substream); threshold = mcpdm->config[stream].threshold; /* Configure McPDM channels, and DMA packet size */ if (stream == SNDRV_PCM_STREAM_PLAYBACK) { link_mask <<= 3; /* If capture is not running assume a stereo stream to come */ if (!mcpdm->config[!stream].link_mask) mcpdm->config[!stream].link_mask = 0x3; dma_data->maxburst = (MCPDM_DN_THRES_MAX - threshold) * channels; } else { /* If playback is not running assume a stereo stream to come */ if (!mcpdm->config[!stream].link_mask) mcpdm->config[!stream].link_mask = (0x3 << 3); dma_data->maxburst = threshold * channels; } /* Check if we need to restart McPDM with this stream */ if (mcpdm->config[stream].link_mask && mcpdm->config[stream].link_mask != link_mask) mcpdm->restart = true; mcpdm->config[stream].link_mask = link_mask; return 0; } static int omap_mcpdm_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); if (!omap_mcpdm_active(mcpdm)) { omap_mcpdm_start(mcpdm); omap_mcpdm_reg_dump(mcpdm); } else if (mcpdm->restart) { omap_mcpdm_stop(mcpdm); omap_mcpdm_start(mcpdm); mcpdm->restart = false; omap_mcpdm_reg_dump(mcpdm); } return 0; } static const struct snd_soc_dai_ops omap_mcpdm_dai_ops = { .startup = omap_mcpdm_dai_startup, .shutdown = omap_mcpdm_dai_shutdown, .hw_params = omap_mcpdm_dai_hw_params, .prepare = omap_mcpdm_prepare, }; static int omap_mcpdm_probe(struct snd_soc_dai *dai) { struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); int ret; pm_runtime_enable(mcpdm->dev); /* Disable lines while request is ongoing */ pm_runtime_get_sync(mcpdm->dev); omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, 0x00); ret = devm_request_irq(mcpdm->dev, mcpdm->irq, omap_mcpdm_irq_handler, 0, "McPDM", (void *)mcpdm); pm_runtime_put_sync(mcpdm->dev); if (ret) { dev_err(mcpdm->dev, "Request for IRQ failed\n"); pm_runtime_disable(mcpdm->dev); } /* Configure McPDM threshold values */ mcpdm->config[SNDRV_PCM_STREAM_PLAYBACK].threshold = 2; mcpdm->config[SNDRV_PCM_STREAM_CAPTURE].threshold = MCPDM_UP_THRES_MAX - 3; return ret; } static int omap_mcpdm_remove(struct snd_soc_dai *dai) { struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); pm_runtime_disable(mcpdm->dev); return 0; } #define OMAP_MCPDM_RATES (SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) #define OMAP_MCPDM_FORMATS SNDRV_PCM_FMTBIT_S32_LE static struct snd_soc_dai_driver omap_mcpdm_dai = { .probe = omap_mcpdm_probe, .remove = omap_mcpdm_remove, .probe_order = SND_SOC_COMP_ORDER_LATE, .remove_order = SND_SOC_COMP_ORDER_EARLY, .playback = { .channels_min = 1, .channels_max = 5, .rates = OMAP_MCPDM_RATES, .formats = OMAP_MCPDM_FORMATS, .sig_bits = 24, }, .capture = { .channels_min = 1, .channels_max = 3, .rates = OMAP_MCPDM_RATES, .formats = OMAP_MCPDM_FORMATS, .sig_bits = 24, }, .ops = &omap_mcpdm_dai_ops, }; static const struct snd_soc_component_driver omap_mcpdm_component = { .name = "omap-mcpdm", }; void omap_mcpdm_configure_dn_offsets(struct snd_soc_pcm_runtime *rtd, u8 rx1, u8 rx2) { struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(rtd->cpu_dai); mcpdm->dn_rx_offset = MCPDM_DNOFST_RX1(rx1) | MCPDM_DNOFST_RX2(rx2); } EXPORT_SYMBOL_GPL(omap_mcpdm_configure_dn_offsets); static int asoc_mcpdm_probe(struct platform_device *pdev) { struct omap_mcpdm *mcpdm; struct resource *res; mcpdm = devm_kzalloc(&pdev->dev, sizeof(struct omap_mcpdm), GFP_KERNEL); if (!mcpdm) return -ENOMEM; platform_set_drvdata(pdev, mcpdm); mutex_init(&mcpdm->mutex); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma"); if (res == NULL) return -ENOMEM; mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA; mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA; res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "dn_link"); if (!res) return -ENODEV; mcpdm->dma_req[0] = res->start; mcpdm->dma_data[0].filter_data = &mcpdm->dma_req[0]; res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "up_link"); if (!res) return -ENODEV; mcpdm->dma_req[1] = res->start; mcpdm->dma_data[1].filter_data = &mcpdm->dma_req[1]; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); if (res == NULL) return -ENOMEM; mcpdm->io_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(mcpdm->io_base)) return PTR_ERR(mcpdm->io_base); mcpdm->irq = platform_get_irq(pdev, 0); if (mcpdm->irq < 0) return mcpdm->irq; mcpdm->dev = &pdev->dev; return snd_soc_register_component(&pdev->dev, &omap_mcpdm_component, &omap_mcpdm_dai, 1); } static int asoc_mcpdm_remove(struct platform_device *pdev) { snd_soc_unregister_component(&pdev->dev); return 0; } static const struct of_device_id omap_mcpdm_of_match[] = { { .compatible = "ti,omap4-mcpdm", }, { } }; MODULE_DEVICE_TABLE(of, omap_mcpdm_of_match); static struct platform_driver asoc_mcpdm_driver = { .driver = { .name = "omap-mcpdm", .owner = THIS_MODULE, .of_match_table = omap_mcpdm_of_match, }, .probe = asoc_mcpdm_probe, .remove = asoc_mcpdm_remove, }; module_platform_driver(asoc_mcpdm_driver); MODULE_ALIAS("platform:omap-mcpdm"); MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>"); MODULE_DESCRIPTION("OMAP PDM SoC Interface"); MODULE_LICENSE("GPL");
gpl-2.0
onejay09/kernel_HTC_msm7x30_KK
drivers/drm/nouveau/nv50_gpio.c
2489
7582
/* * Copyright 2010 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. * * Authors: Ben Skeggs */ #include "drmP.h" #include "nouveau_drv.h" #include "nouveau_hw.h" #include "nv50_display.h" static void nv50_gpio_isr(struct drm_device *dev); static void nv50_gpio_isr_bh(struct work_struct *work); struct nv50_gpio_priv { struct list_head handlers; spinlock_t lock; }; struct nv50_gpio_handler { struct drm_device *dev; struct list_head head; struct work_struct work; bool inhibit; struct dcb_gpio_entry *gpio; void (*handler)(void *data, int state); void *data; }; static int nv50_gpio_location(struct dcb_gpio_entry *gpio, uint32_t *reg, uint32_t *shift) { const uint32_t nv50_gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 }; if (gpio->line >= 32) return -EINVAL; *reg = nv50_gpio_reg[gpio->line >> 3]; *shift = (gpio->line & 7) << 2; return 0; } int nv50_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag) { struct dcb_gpio_entry *gpio; uint32_t r, s, v; gpio = nouveau_bios_gpio_entry(dev, tag); if (!gpio) return -ENOENT; if (nv50_gpio_location(gpio, &r, &s)) return -EINVAL; v = nv_rd32(dev, r) >> (s + 2); return ((v & 1) == (gpio->state[1] & 1)); } int nv50_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state) { struct dcb_gpio_entry *gpio; uint32_t r, s, v; gpio = nouveau_bios_gpio_entry(dev, tag); if (!gpio) return -ENOENT; if (nv50_gpio_location(gpio, &r, &s)) return -EINVAL; v = nv_rd32(dev, r) & ~(0x3 << s); v |= (gpio->state[state] ^ 2) << s; nv_wr32(dev, r, v); return 0; } int nv50_gpio_irq_register(struct drm_device *dev, enum dcb_gpio_tag tag, void (*handler)(void *, int), void *data) { struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_gpio_engine *pgpio = &dev_priv->engine.gpio; struct nv50_gpio_priv *priv = pgpio->priv; struct nv50_gpio_handler *gpioh; struct dcb_gpio_entry *gpio; unsigned long flags; gpio = nouveau_bios_gpio_entry(dev, tag); if (!gpio) return -ENOENT; gpioh = kzalloc(sizeof(*gpioh), GFP_KERNEL); if (!gpioh) return -ENOMEM; INIT_WORK(&gpioh->work, nv50_gpio_isr_bh); gpioh->dev = dev; gpioh->gpio = gpio; gpioh->handler = handler; gpioh->data = data; spin_lock_irqsave(&priv->lock, flags); list_add(&gpioh->head, &priv->handlers); spin_unlock_irqrestore(&priv->lock, flags); return 0; } void nv50_gpio_irq_unregister(struct drm_device *dev, enum dcb_gpio_tag tag, void (*handler)(void *, int), void *data) { struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_gpio_engine *pgpio = &dev_priv->engine.gpio; struct nv50_gpio_priv *priv = pgpio->priv; struct nv50_gpio_handler *gpioh, *tmp; struct dcb_gpio_entry *gpio; LIST_HEAD(tofree); unsigned long flags; gpio = nouveau_bios_gpio_entry(dev, tag); if (!gpio) return; spin_lock_irqsave(&priv->lock, flags); list_for_each_entry_safe(gpioh, tmp, &priv->handlers, head) { if (gpioh->gpio != gpio || gpioh->handler != handler || gpioh->data != data) continue; list_move(&gpioh->head, &tofree); } spin_unlock_irqrestore(&priv->lock, flags); list_for_each_entry_safe(gpioh, tmp, &tofree, head) { flush_work_sync(&gpioh->work); kfree(gpioh); } } bool nv50_gpio_irq_enable(struct drm_device *dev, enum dcb_gpio_tag tag, bool on) { struct dcb_gpio_entry *gpio; u32 reg, mask; gpio = nouveau_bios_gpio_entry(dev, tag); if (!gpio) return false; reg = gpio->line < 16 ? 0xe050 : 0xe070; mask = 0x00010001 << (gpio->line & 0xf); nv_wr32(dev, reg + 4, mask); reg = nv_mask(dev, reg + 0, mask, on ? mask : 0); return (reg & mask) == mask; } static int nv50_gpio_create(struct drm_device *dev) { struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_gpio_engine *pgpio = &dev_priv->engine.gpio; struct nv50_gpio_priv *priv; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; INIT_LIST_HEAD(&priv->handlers); spin_lock_init(&priv->lock); pgpio->priv = priv; return 0; } static void nv50_gpio_destroy(struct drm_device *dev) { struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_gpio_engine *pgpio = &dev_priv->engine.gpio; kfree(pgpio->priv); pgpio->priv = NULL; } int nv50_gpio_init(struct drm_device *dev) { struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_gpio_engine *pgpio = &dev_priv->engine.gpio; int ret; if (!pgpio->priv) { ret = nv50_gpio_create(dev); if (ret) return ret; } /* disable, and ack any pending gpio interrupts */ nv_wr32(dev, 0xe050, 0x00000000); nv_wr32(dev, 0xe054, 0xffffffff); if (dev_priv->chipset >= 0x90) { nv_wr32(dev, 0xe070, 0x00000000); nv_wr32(dev, 0xe074, 0xffffffff); } nouveau_irq_register(dev, 21, nv50_gpio_isr); return 0; } void nv50_gpio_fini(struct drm_device *dev) { struct drm_nouveau_private *dev_priv = dev->dev_private; nv_wr32(dev, 0xe050, 0x00000000); if (dev_priv->chipset >= 0x90) nv_wr32(dev, 0xe070, 0x00000000); nouveau_irq_unregister(dev, 21); nv50_gpio_destroy(dev); } static void nv50_gpio_isr_bh(struct work_struct *work) { struct nv50_gpio_handler *gpioh = container_of(work, struct nv50_gpio_handler, work); struct drm_nouveau_private *dev_priv = gpioh->dev->dev_private; struct nouveau_gpio_engine *pgpio = &dev_priv->engine.gpio; struct nv50_gpio_priv *priv = pgpio->priv; unsigned long flags; int state; state = pgpio->get(gpioh->dev, gpioh->gpio->tag); if (state < 0) return; gpioh->handler(gpioh->data, state); spin_lock_irqsave(&priv->lock, flags); gpioh->inhibit = false; spin_unlock_irqrestore(&priv->lock, flags); } static void nv50_gpio_isr(struct drm_device *dev) { struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_gpio_engine *pgpio = &dev_priv->engine.gpio; struct nv50_gpio_priv *priv = pgpio->priv; struct nv50_gpio_handler *gpioh; u32 intr0, intr1 = 0; u32 hi, lo, ch; intr0 = nv_rd32(dev, 0xe054) & nv_rd32(dev, 0xe050); if (dev_priv->chipset >= 0x90) intr1 = nv_rd32(dev, 0xe074) & nv_rd32(dev, 0xe070); hi = (intr0 & 0x0000ffff) | (intr1 << 16); lo = (intr0 >> 16) | (intr1 & 0xffff0000); ch = hi | lo; nv_wr32(dev, 0xe054, intr0); if (dev_priv->chipset >= 0x90) nv_wr32(dev, 0xe074, intr1); spin_lock(&priv->lock); list_for_each_entry(gpioh, &priv->handlers, head) { if (!(ch & (1 << gpioh->gpio->line))) continue; if (gpioh->inhibit) continue; gpioh->inhibit = true; schedule_work(&gpioh->work); } spin_unlock(&priv->lock); }
gpl-2.0
vic-nation/kernel_goghvmu
sound/pci/emu10k1/emupcm.c
4025
58639
/* * Copyright (c) by Jaroslav Kysela <perex@perex.cz> * Creative Labs, Inc. * Routines for control of EMU10K1 chips / PCM routines * Multichannel PCM support Copyright (c) Lee Revell <rlrevell@joe-job.com> * * BUGS: * -- * * TODO: * -- * * 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/pci.h> #include <linux/delay.h> #include <linux/slab.h> #include <linux/time.h> #include <linux/init.h> #include <sound/core.h> #include <sound/emu10k1.h> static void snd_emu10k1_pcm_interrupt(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *voice) { struct snd_emu10k1_pcm *epcm; if ((epcm = voice->epcm) == NULL) return; if (epcm->substream == NULL) return; #if 0 printk(KERN_DEBUG "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", epcm->substream->runtime->hw->pointer(emu, epcm->substream), snd_pcm_lib_period_bytes(epcm->substream), snd_pcm_lib_buffer_bytes(epcm->substream)); #endif snd_pcm_period_elapsed(epcm->substream); } static void snd_emu10k1_pcm_ac97adc_interrupt(struct snd_emu10k1 *emu, unsigned int status) { #if 0 if (status & IPR_ADCBUFHALFFULL) { if (emu->pcm_capture_substream->runtime->mode == SNDRV_PCM_MODE_FRAME) return; } #endif snd_pcm_period_elapsed(emu->pcm_capture_substream); } static void snd_emu10k1_pcm_ac97mic_interrupt(struct snd_emu10k1 *emu, unsigned int status) { #if 0 if (status & IPR_MICBUFHALFFULL) { if (emu->pcm_capture_mic_substream->runtime->mode == SNDRV_PCM_MODE_FRAME) return; } #endif snd_pcm_period_elapsed(emu->pcm_capture_mic_substream); } static void snd_emu10k1_pcm_efx_interrupt(struct snd_emu10k1 *emu, unsigned int status) { #if 0 if (status & IPR_EFXBUFHALFFULL) { if (emu->pcm_capture_efx_substream->runtime->mode == SNDRV_PCM_MODE_FRAME) return; } #endif snd_pcm_period_elapsed(emu->pcm_capture_efx_substream); } static snd_pcm_uframes_t snd_emu10k1_efx_playback_pointer(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int ptr; if (!epcm->running) return 0; ptr = snd_emu10k1_ptr_read(emu, CCCA, epcm->voices[0]->number) & 0x00ffffff; ptr += runtime->buffer_size; ptr -= epcm->ccca_start_addr; ptr %= runtime->buffer_size; return ptr; } static int snd_emu10k1_pcm_channel_alloc(struct snd_emu10k1_pcm * epcm, int voices) { int err, i; if (epcm->voices[1] != NULL && voices < 2) { snd_emu10k1_voice_free(epcm->emu, epcm->voices[1]); epcm->voices[1] = NULL; } for (i = 0; i < voices; i++) { if (epcm->voices[i] == NULL) break; } if (i == voices) return 0; /* already allocated */ for (i = 0; i < ARRAY_SIZE(epcm->voices); i++) { if (epcm->voices[i]) { snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); epcm->voices[i] = NULL; } } err = snd_emu10k1_voice_alloc(epcm->emu, epcm->type == PLAYBACK_EMUVOICE ? EMU10K1_PCM : EMU10K1_EFX, voices, &epcm->voices[0]); if (err < 0) return err; epcm->voices[0]->epcm = epcm; if (voices > 1) { for (i = 1; i < voices; i++) { epcm->voices[i] = &epcm->emu->voices[epcm->voices[0]->number + i]; epcm->voices[i]->epcm = epcm; } } if (epcm->extra == NULL) { err = snd_emu10k1_voice_alloc(epcm->emu, epcm->type == PLAYBACK_EMUVOICE ? EMU10K1_PCM : EMU10K1_EFX, 1, &epcm->extra); if (err < 0) { /* printk(KERN_DEBUG "pcm_channel_alloc: " "failed extra: voices=%d, frame=%d\n", voices, frame); */ for (i = 0; i < voices; i++) { snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); epcm->voices[i] = NULL; } return err; } epcm->extra->epcm = epcm; epcm->extra->interrupt = snd_emu10k1_pcm_interrupt; } return 0; } static unsigned int capture_period_sizes[31] = { 384, 448, 512, 640, 384*2, 448*2, 512*2, 640*2, 384*4, 448*4, 512*4, 640*4, 384*8, 448*8, 512*8, 640*8, 384*16, 448*16, 512*16, 640*16, 384*32, 448*32, 512*32, 640*32, 384*64, 448*64, 512*64, 640*64, 384*128,448*128,512*128 }; static struct snd_pcm_hw_constraint_list hw_constraints_capture_period_sizes = { .count = 31, .list = capture_period_sizes, .mask = 0 }; static unsigned int capture_rates[8] = { 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000 }; static struct snd_pcm_hw_constraint_list hw_constraints_capture_rates = { .count = 8, .list = capture_rates, .mask = 0 }; static unsigned int snd_emu10k1_capture_rate_reg(unsigned int rate) { switch (rate) { case 8000: return ADCCR_SAMPLERATE_8; case 11025: return ADCCR_SAMPLERATE_11; case 16000: return ADCCR_SAMPLERATE_16; case 22050: return ADCCR_SAMPLERATE_22; case 24000: return ADCCR_SAMPLERATE_24; case 32000: return ADCCR_SAMPLERATE_32; case 44100: return ADCCR_SAMPLERATE_44; case 48000: return ADCCR_SAMPLERATE_48; default: snd_BUG(); return ADCCR_SAMPLERATE_8; } } static unsigned int snd_emu10k1_audigy_capture_rate_reg(unsigned int rate) { switch (rate) { case 8000: return A_ADCCR_SAMPLERATE_8; case 11025: return A_ADCCR_SAMPLERATE_11; case 12000: return A_ADCCR_SAMPLERATE_12; /* really supported? */ case 16000: return ADCCR_SAMPLERATE_16; case 22050: return ADCCR_SAMPLERATE_22; case 24000: return ADCCR_SAMPLERATE_24; case 32000: return ADCCR_SAMPLERATE_32; case 44100: return ADCCR_SAMPLERATE_44; case 48000: return ADCCR_SAMPLERATE_48; default: snd_BUG(); return A_ADCCR_SAMPLERATE_8; } } static unsigned int emu10k1_calc_pitch_target(unsigned int rate) { unsigned int pitch_target; pitch_target = (rate << 8) / 375; pitch_target = (pitch_target >> 1) + (pitch_target & 1); return pitch_target; } #define PITCH_48000 0x00004000 #define PITCH_96000 0x00008000 #define PITCH_85000 0x00007155 #define PITCH_80726 0x00006ba2 #define PITCH_67882 0x00005a82 #define PITCH_57081 0x00004c1c static unsigned int emu10k1_select_interprom(unsigned int pitch_target) { if (pitch_target == PITCH_48000) return CCCA_INTERPROM_0; else if (pitch_target < PITCH_48000) return CCCA_INTERPROM_1; else if (pitch_target >= PITCH_96000) return CCCA_INTERPROM_0; else if (pitch_target >= PITCH_85000) return CCCA_INTERPROM_6; else if (pitch_target >= PITCH_80726) return CCCA_INTERPROM_5; else if (pitch_target >= PITCH_67882) return CCCA_INTERPROM_4; else if (pitch_target >= PITCH_57081) return CCCA_INTERPROM_3; else return CCCA_INTERPROM_2; } /* * calculate cache invalidate size * * stereo: channel is stereo * w_16: using 16bit samples * * returns: cache invalidate size in samples */ static inline int emu10k1_ccis(int stereo, int w_16) { if (w_16) { return stereo ? 24 : 26; } else { return stereo ? 24*2 : 26*2; } } static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu, int master, int extra, struct snd_emu10k1_voice *evoice, unsigned int start_addr, unsigned int end_addr, struct snd_emu10k1_pcm_mixer *mix) { struct snd_pcm_substream *substream = evoice->epcm->substream; struct snd_pcm_runtime *runtime = substream->runtime; unsigned int silent_page, tmp; int voice, stereo, w_16; unsigned char attn, send_amount[8]; unsigned char send_routing[8]; unsigned long flags; unsigned int pitch_target; unsigned int ccis; voice = evoice->number; stereo = runtime->channels == 2; w_16 = snd_pcm_format_width(runtime->format) == 16; if (!extra && stereo) { start_addr >>= 1; end_addr >>= 1; } if (w_16) { start_addr >>= 1; end_addr >>= 1; } spin_lock_irqsave(&emu->reg_lock, flags); /* volume parameters */ if (extra) { attn = 0; memset(send_routing, 0, sizeof(send_routing)); send_routing[0] = 0; send_routing[1] = 1; send_routing[2] = 2; send_routing[3] = 3; memset(send_amount, 0, sizeof(send_amount)); } else { /* mono, left, right (master voice = left) */ tmp = stereo ? (master ? 1 : 2) : 0; memcpy(send_routing, &mix->send_routing[tmp][0], 8); memcpy(send_amount, &mix->send_volume[tmp][0], 8); } ccis = emu10k1_ccis(stereo, w_16); if (master) { evoice->epcm->ccca_start_addr = start_addr + ccis; if (extra) { start_addr += ccis; end_addr += ccis + emu->delay_pcm_irq; } if (stereo && !extra) { snd_emu10k1_ptr_write(emu, CPF, voice, CPF_STEREO_MASK); snd_emu10k1_ptr_write(emu, CPF, (voice + 1), CPF_STEREO_MASK); } else { snd_emu10k1_ptr_write(emu, CPF, voice, 0); } } /* setup routing */ if (emu->audigy) { snd_emu10k1_ptr_write(emu, A_FXRT1, voice, snd_emu10k1_compose_audigy_fxrt1(send_routing)); snd_emu10k1_ptr_write(emu, A_FXRT2, voice, snd_emu10k1_compose_audigy_fxrt2(send_routing)); snd_emu10k1_ptr_write(emu, A_SENDAMOUNTS, voice, ((unsigned int)send_amount[4] << 24) | ((unsigned int)send_amount[5] << 16) | ((unsigned int)send_amount[6] << 8) | (unsigned int)send_amount[7]); } else snd_emu10k1_ptr_write(emu, FXRT, voice, snd_emu10k1_compose_send_routing(send_routing)); /* Stop CA */ /* Assumption that PT is already 0 so no harm overwriting */ snd_emu10k1_ptr_write(emu, PTRX, voice, (send_amount[0] << 8) | send_amount[1]); snd_emu10k1_ptr_write(emu, DSL, voice, end_addr | (send_amount[3] << 24)); snd_emu10k1_ptr_write(emu, PSST, voice, (start_addr + (extra ? emu->delay_pcm_irq : 0)) | (send_amount[2] << 24)); if (emu->card_capabilities->emu_model) pitch_target = PITCH_48000; /* Disable interpolators on emu1010 card */ else pitch_target = emu10k1_calc_pitch_target(runtime->rate); if (extra) snd_emu10k1_ptr_write(emu, CCCA, voice, start_addr | emu10k1_select_interprom(pitch_target) | (w_16 ? 0 : CCCA_8BITSELECT)); else snd_emu10k1_ptr_write(emu, CCCA, voice, (start_addr + ccis) | emu10k1_select_interprom(pitch_target) | (w_16 ? 0 : CCCA_8BITSELECT)); /* Clear filter delay memory */ snd_emu10k1_ptr_write(emu, Z1, voice, 0); snd_emu10k1_ptr_write(emu, Z2, voice, 0); /* invalidate maps */ silent_page = ((unsigned int)emu->silent_page.addr << 1) | MAP_PTI_MASK; snd_emu10k1_ptr_write(emu, MAPA, voice, silent_page); snd_emu10k1_ptr_write(emu, MAPB, voice, silent_page); /* modulation envelope */ snd_emu10k1_ptr_write(emu, CVCF, voice, 0xffff); snd_emu10k1_ptr_write(emu, VTFT, voice, 0xffff); snd_emu10k1_ptr_write(emu, ATKHLDM, voice, 0); snd_emu10k1_ptr_write(emu, DCYSUSM, voice, 0x007f); snd_emu10k1_ptr_write(emu, LFOVAL1, voice, 0x8000); snd_emu10k1_ptr_write(emu, LFOVAL2, voice, 0x8000); snd_emu10k1_ptr_write(emu, FMMOD, voice, 0); snd_emu10k1_ptr_write(emu, TREMFRQ, voice, 0); snd_emu10k1_ptr_write(emu, FM2FRQ2, voice, 0); snd_emu10k1_ptr_write(emu, ENVVAL, voice, 0x8000); /* volume envelope */ snd_emu10k1_ptr_write(emu, ATKHLDV, voice, 0x7f7f); snd_emu10k1_ptr_write(emu, ENVVOL, voice, 0x0000); /* filter envelope */ snd_emu10k1_ptr_write(emu, PEFE_FILTERAMOUNT, voice, 0x7f); /* pitch envelope */ snd_emu10k1_ptr_write(emu, PEFE_PITCHAMOUNT, voice, 0); spin_unlock_irqrestore(&emu->reg_lock, flags); } static int snd_emu10k1_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm = runtime->private_data; int err; if ((err = snd_emu10k1_pcm_channel_alloc(epcm, params_channels(hw_params))) < 0) return err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) return err; if (err > 0) { /* change */ int mapped; if (epcm->memblk != NULL) snd_emu10k1_free_pages(emu, epcm->memblk); epcm->memblk = snd_emu10k1_alloc_pages(emu, substream); epcm->start_addr = 0; if (! epcm->memblk) return -ENOMEM; mapped = ((struct snd_emu10k1_memblk *)epcm->memblk)->mapped_page; if (mapped < 0) return -ENOMEM; epcm->start_addr = mapped << PAGE_SHIFT; } return 0; } static int snd_emu10k1_playback_hw_free(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm; if (runtime->private_data == NULL) return 0; epcm = runtime->private_data; if (epcm->extra) { snd_emu10k1_voice_free(epcm->emu, epcm->extra); epcm->extra = NULL; } if (epcm->voices[1]) { snd_emu10k1_voice_free(epcm->emu, epcm->voices[1]); epcm->voices[1] = NULL; } if (epcm->voices[0]) { snd_emu10k1_voice_free(epcm->emu, epcm->voices[0]); epcm->voices[0] = NULL; } if (epcm->memblk) { snd_emu10k1_free_pages(emu, epcm->memblk); epcm->memblk = NULL; epcm->start_addr = 0; } snd_pcm_lib_free_pages(substream); return 0; } static int snd_emu10k1_efx_playback_hw_free(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm; int i; if (runtime->private_data == NULL) return 0; epcm = runtime->private_data; if (epcm->extra) { snd_emu10k1_voice_free(epcm->emu, epcm->extra); epcm->extra = NULL; } for (i = 0; i < NUM_EFX_PLAYBACK; i++) { if (epcm->voices[i]) { snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); epcm->voices[i] = NULL; } } if (epcm->memblk) { snd_emu10k1_free_pages(emu, epcm->memblk); epcm->memblk = NULL; epcm->start_addr = 0; } snd_pcm_lib_free_pages(substream); return 0; } static int snd_emu10k1_playback_prepare(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int start_addr, end_addr; start_addr = epcm->start_addr; end_addr = snd_pcm_lib_period_bytes(substream); if (runtime->channels == 2) { start_addr >>= 1; end_addr >>= 1; } end_addr += start_addr; snd_emu10k1_pcm_init_voice(emu, 1, 1, epcm->extra, start_addr, end_addr, NULL); start_addr = epcm->start_addr; end_addr = epcm->start_addr + snd_pcm_lib_buffer_bytes(substream); snd_emu10k1_pcm_init_voice(emu, 1, 0, epcm->voices[0], start_addr, end_addr, &emu->pcm_mixer[substream->number]); if (epcm->voices[1]) snd_emu10k1_pcm_init_voice(emu, 0, 0, epcm->voices[1], start_addr, end_addr, &emu->pcm_mixer[substream->number]); return 0; } static int snd_emu10k1_efx_playback_prepare(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int start_addr, end_addr; unsigned int channel_size; int i; start_addr = epcm->start_addr; end_addr = epcm->start_addr + snd_pcm_lib_buffer_bytes(substream); /* * the kX driver leaves some space between voices */ channel_size = ( end_addr - start_addr ) / NUM_EFX_PLAYBACK; snd_emu10k1_pcm_init_voice(emu, 1, 1, epcm->extra, start_addr, start_addr + (channel_size / 2), NULL); /* only difference with the master voice is we use it for the pointer */ snd_emu10k1_pcm_init_voice(emu, 1, 0, epcm->voices[0], start_addr, start_addr + channel_size, &emu->efx_pcm_mixer[0]); start_addr += channel_size; for (i = 1; i < NUM_EFX_PLAYBACK; i++) { snd_emu10k1_pcm_init_voice(emu, 0, 0, epcm->voices[i], start_addr, start_addr + channel_size, &emu->efx_pcm_mixer[i]); start_addr += channel_size; } return 0; } static struct snd_pcm_hardware snd_emu10k1_efx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_NONINTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_48000, .rate_min = 48000, .rate_max = 48000, .channels_min = NUM_EFX_PLAYBACK, .channels_max = NUM_EFX_PLAYBACK, .buffer_bytes_max = (64*1024), .period_bytes_min = 64, .period_bytes_max = (64*1024), .periods_min = 2, .periods_max = 2, .fifo_size = 0, }; static int snd_emu10k1_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } static int snd_emu10k1_capture_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } static int snd_emu10k1_capture_prepare(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm = runtime->private_data; int idx; /* zeroing the buffer size will stop capture */ snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, 0); switch (epcm->type) { case CAPTURE_AC97ADC: snd_emu10k1_ptr_write(emu, ADCCR, 0, 0); break; case CAPTURE_EFX: if (emu->audigy) { snd_emu10k1_ptr_write(emu, A_FXWC1, 0, 0); snd_emu10k1_ptr_write(emu, A_FXWC2, 0, 0); } else snd_emu10k1_ptr_write(emu, FXWC, 0, 0); break; default: break; } snd_emu10k1_ptr_write(emu, epcm->capture_ba_reg, 0, runtime->dma_addr); epcm->capture_bufsize = snd_pcm_lib_buffer_bytes(substream); epcm->capture_bs_val = 0; for (idx = 0; idx < 31; idx++) { if (capture_period_sizes[idx] == epcm->capture_bufsize) { epcm->capture_bs_val = idx + 1; break; } } if (epcm->capture_bs_val == 0) { snd_BUG(); epcm->capture_bs_val++; } if (epcm->type == CAPTURE_AC97ADC) { epcm->capture_cr_val = emu->audigy ? A_ADCCR_LCHANENABLE : ADCCR_LCHANENABLE; if (runtime->channels > 1) epcm->capture_cr_val |= emu->audigy ? A_ADCCR_RCHANENABLE : ADCCR_RCHANENABLE; epcm->capture_cr_val |= emu->audigy ? snd_emu10k1_audigy_capture_rate_reg(runtime->rate) : snd_emu10k1_capture_rate_reg(runtime->rate); } return 0; } static void snd_emu10k1_playback_invalidate_cache(struct snd_emu10k1 *emu, int extra, struct snd_emu10k1_voice *evoice) { struct snd_pcm_runtime *runtime; unsigned int voice, stereo, i, ccis, cra = 64, cs, sample; if (evoice == NULL) return; runtime = evoice->epcm->substream->runtime; voice = evoice->number; stereo = (!extra && runtime->channels == 2); sample = snd_pcm_format_width(runtime->format) == 16 ? 0 : 0x80808080; ccis = emu10k1_ccis(stereo, sample == 0); /* set cs to 2 * number of cache registers beside the invalidated */ cs = (sample == 0) ? (32-ccis) : (64-ccis+1) >> 1; if (cs > 16) cs = 16; for (i = 0; i < cs; i++) { snd_emu10k1_ptr_write(emu, CD0 + i, voice, sample); if (stereo) { snd_emu10k1_ptr_write(emu, CD0 + i, voice + 1, sample); } } /* reset cache */ snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice, 0); snd_emu10k1_ptr_write(emu, CCR_READADDRESS, voice, cra); if (stereo) { snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice + 1, 0); snd_emu10k1_ptr_write(emu, CCR_READADDRESS, voice + 1, cra); } /* fill cache */ snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice, ccis); if (stereo) { snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice+1, ccis); } } static void snd_emu10k1_playback_prepare_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice, int master, int extra, struct snd_emu10k1_pcm_mixer *mix) { struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; unsigned int attn, vattn; unsigned int voice, tmp; if (evoice == NULL) /* skip second voice for mono */ return; substream = evoice->epcm->substream; runtime = substream->runtime; voice = evoice->number; attn = extra ? 0 : 0x00ff; tmp = runtime->channels == 2 ? (master ? 1 : 2) : 0; vattn = mix != NULL ? (mix->attn[tmp] << 16) : 0; snd_emu10k1_ptr_write(emu, IFATN, voice, attn); snd_emu10k1_ptr_write(emu, VTFT, voice, vattn | 0xffff); snd_emu10k1_ptr_write(emu, CVCF, voice, vattn | 0xffff); snd_emu10k1_ptr_write(emu, DCYSUSV, voice, 0x7f7f); snd_emu10k1_voice_clear_loop_stop(emu, voice); } static void snd_emu10k1_playback_trigger_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice, int master, int extra) { struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; unsigned int voice, pitch, pitch_target; if (evoice == NULL) /* skip second voice for mono */ return; substream = evoice->epcm->substream; runtime = substream->runtime; voice = evoice->number; pitch = snd_emu10k1_rate_to_pitch(runtime->rate) >> 8; if (emu->card_capabilities->emu_model) pitch_target = PITCH_48000; /* Disable interpolators on emu1010 card */ else pitch_target = emu10k1_calc_pitch_target(runtime->rate); snd_emu10k1_ptr_write(emu, PTRX_PITCHTARGET, voice, pitch_target); if (master || evoice->epcm->type == PLAYBACK_EFX) snd_emu10k1_ptr_write(emu, CPF_CURRENTPITCH, voice, pitch_target); snd_emu10k1_ptr_write(emu, IP, voice, pitch); if (extra) snd_emu10k1_voice_intr_enable(emu, voice); } static void snd_emu10k1_playback_stop_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice) { unsigned int voice; if (evoice == NULL) return; voice = evoice->number; snd_emu10k1_voice_intr_disable(emu, voice); snd_emu10k1_ptr_write(emu, PTRX_PITCHTARGET, voice, 0); snd_emu10k1_ptr_write(emu, CPF_CURRENTPITCH, voice, 0); snd_emu10k1_ptr_write(emu, IFATN, voice, 0xffff); snd_emu10k1_ptr_write(emu, VTFT, voice, 0xffff); snd_emu10k1_ptr_write(emu, CVCF, voice, 0xffff); snd_emu10k1_ptr_write(emu, IP, voice, 0); } static inline void snd_emu10k1_playback_mangle_extra(struct snd_emu10k1 *emu, struct snd_emu10k1_pcm *epcm, struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime) { unsigned int ptr, period_pos; /* try to sychronize the current position for the interrupt source voice */ period_pos = runtime->status->hw_ptr - runtime->hw_ptr_interrupt; period_pos %= runtime->period_size; ptr = snd_emu10k1_ptr_read(emu, CCCA, epcm->extra->number); ptr &= ~0x00ffffff; ptr |= epcm->ccca_start_addr + period_pos; snd_emu10k1_ptr_write(emu, CCCA, epcm->extra->number, ptr); } static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm = runtime->private_data; struct snd_emu10k1_pcm_mixer *mix; int result = 0; /* printk(KERN_DEBUG "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream)) */ spin_lock(&emu->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); /* do we need this? */ snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[0]); /* follow thru */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_RESUME: if (cmd == SNDRV_PCM_TRIGGER_PAUSE_RELEASE) snd_emu10k1_playback_mangle_extra(emu, epcm, substream, runtime); mix = &emu->pcm_mixer[substream->number]; snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 1, 0, mix); snd_emu10k1_playback_prepare_voice(emu, epcm->voices[1], 0, 0, mix); snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1, NULL); snd_emu10k1_playback_trigger_voice(emu, epcm->voices[0], 1, 0); snd_emu10k1_playback_trigger_voice(emu, epcm->voices[1], 0, 0); snd_emu10k1_playback_trigger_voice(emu, epcm->extra, 1, 1); epcm->running = 1; break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_SUSPEND: epcm->running = 0; snd_emu10k1_playback_stop_voice(emu, epcm->voices[0]); snd_emu10k1_playback_stop_voice(emu, epcm->voices[1]); snd_emu10k1_playback_stop_voice(emu, epcm->extra); break; default: result = -EINVAL; break; } spin_unlock(&emu->reg_lock); return result; } static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm = runtime->private_data; int result = 0; spin_lock(&emu->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: /* hmm this should cause full and half full interrupt to be raised? */ outl(epcm->capture_ipr, emu->port + IPR); snd_emu10k1_intr_enable(emu, epcm->capture_inte); /* printk(KERN_DEBUG "adccr = 0x%x, adcbs = 0x%x\n", epcm->adccr, epcm->adcbs); */ switch (epcm->type) { case CAPTURE_AC97ADC: snd_emu10k1_ptr_write(emu, ADCCR, 0, epcm->capture_cr_val); break; case CAPTURE_EFX: if (emu->audigy) { snd_emu10k1_ptr_write(emu, A_FXWC1, 0, epcm->capture_cr_val); snd_emu10k1_ptr_write(emu, A_FXWC2, 0, epcm->capture_cr_val2); snd_printdd("cr_val=0x%x, cr_val2=0x%x\n", epcm->capture_cr_val, epcm->capture_cr_val2); } else snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val); break; default: break; } snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, epcm->capture_bs_val); epcm->running = 1; epcm->first_ptr = 1; break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: epcm->running = 0; snd_emu10k1_intr_disable(emu, epcm->capture_inte); outl(epcm->capture_ipr, emu->port + IPR); snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, 0); switch (epcm->type) { case CAPTURE_AC97ADC: snd_emu10k1_ptr_write(emu, ADCCR, 0, 0); break; case CAPTURE_EFX: if (emu->audigy) { snd_emu10k1_ptr_write(emu, A_FXWC1, 0, 0); snd_emu10k1_ptr_write(emu, A_FXWC2, 0, 0); } else snd_emu10k1_ptr_write(emu, FXWC, 0, 0); break; default: break; } break; default: result = -EINVAL; } spin_unlock(&emu->reg_lock); return result; } static snd_pcm_uframes_t snd_emu10k1_playback_pointer(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int ptr; if (!epcm->running) return 0; ptr = snd_emu10k1_ptr_read(emu, CCCA, epcm->voices[0]->number) & 0x00ffffff; #if 0 /* Perex's code */ ptr += runtime->buffer_size; ptr -= epcm->ccca_start_addr; ptr %= runtime->buffer_size; #else /* EMU10K1 Open Source code from Creative */ if (ptr < epcm->ccca_start_addr) ptr += runtime->buffer_size - epcm->ccca_start_addr; else { ptr -= epcm->ccca_start_addr; if (ptr >= runtime->buffer_size) ptr -= runtime->buffer_size; } #endif /* printk(KERN_DEBUG "ptr = 0x%lx, buffer_size = 0x%lx, period_size = 0x%lx\n", (long)ptr, (long)runtime->buffer_size, (long)runtime->period_size); */ return ptr; } static int snd_emu10k1_efx_playback_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm = runtime->private_data; int i; int result = 0; spin_lock(&emu->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: /* prepare voices */ for (i = 0; i < NUM_EFX_PLAYBACK; i++) { snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[i]); } snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); /* follow thru */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_RESUME: snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1, NULL); snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 0, 0, &emu->efx_pcm_mixer[0]); for (i = 1; i < NUM_EFX_PLAYBACK; i++) snd_emu10k1_playback_prepare_voice(emu, epcm->voices[i], 0, 0, &emu->efx_pcm_mixer[i]); snd_emu10k1_playback_trigger_voice(emu, epcm->voices[0], 0, 0); snd_emu10k1_playback_trigger_voice(emu, epcm->extra, 1, 1); for (i = 1; i < NUM_EFX_PLAYBACK; i++) snd_emu10k1_playback_trigger_voice(emu, epcm->voices[i], 0, 0); epcm->running = 1; break; case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: epcm->running = 0; for (i = 0; i < NUM_EFX_PLAYBACK; i++) { snd_emu10k1_playback_stop_voice(emu, epcm->voices[i]); } snd_emu10k1_playback_stop_voice(emu, epcm->extra); break; default: result = -EINVAL; break; } spin_unlock(&emu->reg_lock); return result; } static snd_pcm_uframes_t snd_emu10k1_capture_pointer(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int ptr; if (!epcm->running) return 0; if (epcm->first_ptr) { udelay(50); /* hack, it takes awhile until capture is started */ epcm->first_ptr = 0; } ptr = snd_emu10k1_ptr_read(emu, epcm->capture_idx_reg, 0) & 0x0000ffff; return bytes_to_frames(runtime, ptr); } /* * Playback support device description */ static struct snd_pcm_hardware snd_emu10k1_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_96000, .rate_min = 4000, .rate_max = 96000, .channels_min = 1, .channels_max = 2, .buffer_bytes_max = (128*1024), .period_bytes_min = 64, .period_bytes_max = (128*1024), .periods_min = 1, .periods_max = 1024, .fifo_size = 0, }; /* * Capture support device description */ static struct snd_pcm_hardware snd_emu10k1_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_8000_48000, .rate_min = 8000, .rate_max = 48000, .channels_min = 1, .channels_max = 2, .buffer_bytes_max = (64*1024), .period_bytes_min = 384, .period_bytes_max = (64*1024), .periods_min = 2, .periods_max = 2, .fifo_size = 0, }; static struct snd_pcm_hardware snd_emu10k1_capture_efx = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, .rate_min = 44100, .rate_max = 192000, .channels_min = 8, .channels_max = 8, .buffer_bytes_max = (64*1024), .period_bytes_min = 384, .period_bytes_max = (64*1024), .periods_min = 2, .periods_max = 2, .fifo_size = 0, }; /* * */ static void snd_emu10k1_pcm_mixer_notify1(struct snd_emu10k1 *emu, struct snd_kcontrol *kctl, int idx, int activate) { struct snd_ctl_elem_id id; if (! kctl) return; if (activate) kctl->vd[idx].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; else kctl->vd[idx].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; snd_ctl_notify(emu->card, SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO, snd_ctl_build_ioff(&id, kctl, idx)); } static void snd_emu10k1_pcm_mixer_notify(struct snd_emu10k1 *emu, int idx, int activate) { snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_routing, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_volume, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_attn, idx, activate); } static void snd_emu10k1_pcm_efx_mixer_notify(struct snd_emu10k1 *emu, int idx, int activate) { snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_routing, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_volume, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_attn, idx, activate); } static void snd_emu10k1_pcm_free_substream(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } static int snd_emu10k1_efx_playback_close(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_pcm_mixer *mix; int i; for (i = 0; i < NUM_EFX_PLAYBACK; i++) { mix = &emu->efx_pcm_mixer[i]; mix->epcm = NULL; snd_emu10k1_pcm_efx_mixer_notify(emu, i, 0); } return 0; } static int snd_emu10k1_efx_playback_open(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_pcm *epcm; struct snd_emu10k1_pcm_mixer *mix; struct snd_pcm_runtime *runtime = substream->runtime; int i; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = emu; epcm->type = PLAYBACK_EFX; epcm->substream = substream; emu->pcm_playback_efx_substream = substream; runtime->private_data = epcm; runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_efx_playback; for (i = 0; i < NUM_EFX_PLAYBACK; i++) { mix = &emu->efx_pcm_mixer[i]; mix->send_routing[0][0] = i; memset(&mix->send_volume, 0, sizeof(mix->send_volume)); mix->send_volume[0][0] = 255; mix->attn[0] = 0xffff; mix->epcm = epcm; snd_emu10k1_pcm_efx_mixer_notify(emu, i, 1); } return 0; } static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_pcm *epcm; struct snd_emu10k1_pcm_mixer *mix; struct snd_pcm_runtime *runtime = substream->runtime; int i, err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = emu; epcm->type = PLAYBACK_EMUVOICE; epcm->substream = substream; runtime->private_data = epcm; runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_playback; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) { kfree(epcm); return err; } if ((err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX)) < 0) { kfree(epcm); return err; } mix = &emu->pcm_mixer[substream->number]; for (i = 0; i < 4; i++) mix->send_routing[0][i] = mix->send_routing[1][i] = mix->send_routing[2][i] = i; memset(&mix->send_volume, 0, sizeof(mix->send_volume)); mix->send_volume[0][0] = mix->send_volume[0][1] = mix->send_volume[1][0] = mix->send_volume[2][1] = 255; mix->attn[0] = mix->attn[1] = mix->attn[2] = 0xffff; mix->epcm = epcm; snd_emu10k1_pcm_mixer_notify(emu, substream->number, 1); return 0; } static int snd_emu10k1_playback_close(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[substream->number]; mix->epcm = NULL; snd_emu10k1_pcm_mixer_notify(emu, substream->number, 0); return 0; } static int snd_emu10k1_capture_open(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_pcm *epcm; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = emu; epcm->type = CAPTURE_AC97ADC; epcm->substream = substream; epcm->capture_ipr = IPR_ADCBUFFULL|IPR_ADCBUFHALFFULL; epcm->capture_inte = INTE_ADCBUFENABLE; epcm->capture_ba_reg = ADCBA; epcm->capture_bs_reg = ADCBS; epcm->capture_idx_reg = emu->audigy ? A_ADCIDX : ADCIDX; runtime->private_data = epcm; runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_capture; emu->capture_interrupt = snd_emu10k1_pcm_ac97adc_interrupt; emu->pcm_capture_substream = substream; snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_capture_period_sizes); snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_capture_rates); return 0; } static int snd_emu10k1_capture_close(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); emu->capture_interrupt = NULL; emu->pcm_capture_substream = NULL; return 0; } static int snd_emu10k1_capture_mic_open(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_pcm *epcm; struct snd_pcm_runtime *runtime = substream->runtime; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = emu; epcm->type = CAPTURE_AC97MIC; epcm->substream = substream; epcm->capture_ipr = IPR_MICBUFFULL|IPR_MICBUFHALFFULL; epcm->capture_inte = INTE_MICBUFENABLE; epcm->capture_ba_reg = MICBA; epcm->capture_bs_reg = MICBS; epcm->capture_idx_reg = emu->audigy ? A_MICIDX : MICIDX; substream->runtime->private_data = epcm; substream->runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_capture; runtime->hw.rates = SNDRV_PCM_RATE_8000; runtime->hw.rate_min = runtime->hw.rate_max = 8000; runtime->hw.channels_min = 1; emu->capture_mic_interrupt = snd_emu10k1_pcm_ac97mic_interrupt; emu->pcm_capture_mic_substream = substream; snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_capture_period_sizes); return 0; } static int snd_emu10k1_capture_mic_close(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); emu->capture_interrupt = NULL; emu->pcm_capture_mic_substream = NULL; return 0; } static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_pcm *epcm; struct snd_pcm_runtime *runtime = substream->runtime; int nefx = emu->audigy ? 64 : 32; int idx; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = emu; epcm->type = CAPTURE_EFX; epcm->substream = substream; epcm->capture_ipr = IPR_EFXBUFFULL|IPR_EFXBUFHALFFULL; epcm->capture_inte = INTE_EFXBUFENABLE; epcm->capture_ba_reg = FXBA; epcm->capture_bs_reg = FXBS; epcm->capture_idx_reg = FXIDX; substream->runtime->private_data = epcm; substream->runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_capture_efx; runtime->hw.rates = SNDRV_PCM_RATE_48000; runtime->hw.rate_min = runtime->hw.rate_max = 48000; spin_lock_irq(&emu->reg_lock); if (emu->card_capabilities->emu_model) { /* Nb. of channels has been increased to 16 */ /* TODO * SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE * SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | * SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | * SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000 * rate_min = 44100, * rate_max = 192000, * channels_min = 16, * channels_max = 16, * Need to add mixer control to fix sample rate * * There are 32 mono channels of 16bits each. * 24bit Audio uses 2x channels over 16bit * 96kHz uses 2x channels over 48kHz * 192kHz uses 4x channels over 48kHz * So, for 48kHz 24bit, one has 16 channels * for 96kHz 24bit, one has 8 channels * for 192kHz 24bit, one has 4 channels * */ #if 1 switch (emu->emu1010.internal_clock) { case 0: /* For 44.1kHz */ runtime->hw.rates = SNDRV_PCM_RATE_44100; runtime->hw.rate_min = runtime->hw.rate_max = 44100; runtime->hw.channels_min = runtime->hw.channels_max = 16; break; case 1: /* For 48kHz */ runtime->hw.rates = SNDRV_PCM_RATE_48000; runtime->hw.rate_min = runtime->hw.rate_max = 48000; runtime->hw.channels_min = runtime->hw.channels_max = 16; break; }; #endif #if 0 /* For 96kHz */ runtime->hw.rates = SNDRV_PCM_RATE_96000; runtime->hw.rate_min = runtime->hw.rate_max = 96000; runtime->hw.channels_min = runtime->hw.channels_max = 4; #endif #if 0 /* For 192kHz */ runtime->hw.rates = SNDRV_PCM_RATE_192000; runtime->hw.rate_min = runtime->hw.rate_max = 192000; runtime->hw.channels_min = runtime->hw.channels_max = 2; #endif runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE; /* efx_voices_mask[0] is expected to be zero * efx_voices_mask[1] is expected to have 32bits set */ } else { runtime->hw.channels_min = runtime->hw.channels_max = 0; for (idx = 0; idx < nefx; idx++) { if (emu->efx_voices_mask[idx/32] & (1 << (idx%32))) { runtime->hw.channels_min++; runtime->hw.channels_max++; } } } epcm->capture_cr_val = emu->efx_voices_mask[0]; epcm->capture_cr_val2 = emu->efx_voices_mask[1]; spin_unlock_irq(&emu->reg_lock); emu->capture_efx_interrupt = snd_emu10k1_pcm_efx_interrupt; emu->pcm_capture_efx_substream = substream; snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_capture_period_sizes); return 0; } static int snd_emu10k1_capture_efx_close(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); emu->capture_interrupt = NULL; emu->pcm_capture_efx_substream = NULL; return 0; } static struct snd_pcm_ops snd_emu10k1_playback_ops = { .open = snd_emu10k1_playback_open, .close = snd_emu10k1_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_emu10k1_playback_hw_params, .hw_free = snd_emu10k1_playback_hw_free, .prepare = snd_emu10k1_playback_prepare, .trigger = snd_emu10k1_playback_trigger, .pointer = snd_emu10k1_playback_pointer, .page = snd_pcm_sgbuf_ops_page, }; static struct snd_pcm_ops snd_emu10k1_capture_ops = { .open = snd_emu10k1_capture_open, .close = snd_emu10k1_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_emu10k1_capture_hw_params, .hw_free = snd_emu10k1_capture_hw_free, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, }; /* EFX playback */ static struct snd_pcm_ops snd_emu10k1_efx_playback_ops = { .open = snd_emu10k1_efx_playback_open, .close = snd_emu10k1_efx_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_emu10k1_playback_hw_params, .hw_free = snd_emu10k1_efx_playback_hw_free, .prepare = snd_emu10k1_efx_playback_prepare, .trigger = snd_emu10k1_efx_playback_trigger, .pointer = snd_emu10k1_efx_playback_pointer, .page = snd_pcm_sgbuf_ops_page, }; int __devinit snd_emu10k1_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { struct snd_pcm *pcm; struct snd_pcm_substream *substream; int err; if (rpcm) *rpcm = NULL; if ((err = snd_pcm_new(emu->card, "emu10k1", device, 32, 1, &pcm)) < 0) return err; pcm->private_data = emu; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_ops); pcm->info_flags = 0; pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; strcpy(pcm->name, "ADC Capture/Standard PCM Playback"); emu->pcm = pcm; for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) return err; for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); if (rpcm) *rpcm = pcm; return 0; } int __devinit snd_emu10k1_pcm_multi(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { struct snd_pcm *pcm; struct snd_pcm_substream *substream; int err; if (rpcm) *rpcm = NULL; if ((err = snd_pcm_new(emu->card, "emu10k1", device, 1, 0, &pcm)) < 0) return err; pcm->private_data = emu; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_efx_playback_ops); pcm->info_flags = 0; pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; strcpy(pcm->name, "Multichannel Playback"); emu->pcm_multi = pcm; for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) return err; if (rpcm) *rpcm = pcm; return 0; } static struct snd_pcm_ops snd_emu10k1_capture_mic_ops = { .open = snd_emu10k1_capture_mic_open, .close = snd_emu10k1_capture_mic_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_emu10k1_capture_hw_params, .hw_free = snd_emu10k1_capture_hw_free, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, }; int __devinit snd_emu10k1_pcm_mic(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { struct snd_pcm *pcm; int err; if (rpcm) *rpcm = NULL; if ((err = snd_pcm_new(emu->card, "emu10k1 mic", device, 0, 1, &pcm)) < 0) return err; pcm->private_data = emu; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_mic_ops); pcm->info_flags = 0; strcpy(pcm->name, "Mic Capture"); emu->pcm_mic = pcm; snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); if (rpcm) *rpcm = pcm; return 0; } static int snd_emu10k1_pcm_efx_voices_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int nefx = emu->audigy ? 64 : 32; uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = nefx; uinfo->value.integer.min = 0; uinfo->value.integer.max = 1; return 0; } static int snd_emu10k1_pcm_efx_voices_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int nefx = emu->audigy ? 64 : 32; int idx; spin_lock_irq(&emu->reg_lock); for (idx = 0; idx < nefx; idx++) ucontrol->value.integer.value[idx] = (emu->efx_voices_mask[idx / 32] & (1 << (idx % 32))) ? 1 : 0; spin_unlock_irq(&emu->reg_lock); return 0; } static int snd_emu10k1_pcm_efx_voices_mask_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int nval[2], bits; int nefx = emu->audigy ? 64 : 32; int nefxb = emu->audigy ? 7 : 6; int change, idx; nval[0] = nval[1] = 0; for (idx = 0, bits = 0; idx < nefx; idx++) if (ucontrol->value.integer.value[idx]) { nval[idx / 32] |= 1 << (idx % 32); bits++; } for (idx = 0; idx < nefxb; idx++) if (1 << idx == bits) break; if (idx >= nefxb) return -EINVAL; spin_lock_irq(&emu->reg_lock); change = (nval[0] != emu->efx_voices_mask[0]) || (nval[1] != emu->efx_voices_mask[1]); emu->efx_voices_mask[0] = nval[0]; emu->efx_voices_mask[1] = nval[1]; spin_unlock_irq(&emu->reg_lock); return change; } static struct snd_kcontrol_new snd_emu10k1_pcm_efx_voices_mask = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "Captured FX8010 Outputs", .info = snd_emu10k1_pcm_efx_voices_mask_info, .get = snd_emu10k1_pcm_efx_voices_mask_get, .put = snd_emu10k1_pcm_efx_voices_mask_put }; static struct snd_pcm_ops snd_emu10k1_capture_efx_ops = { .open = snd_emu10k1_capture_efx_open, .close = snd_emu10k1_capture_efx_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_emu10k1_capture_hw_params, .hw_free = snd_emu10k1_capture_hw_free, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, }; /* EFX playback */ #define INITIAL_TRAM_SHIFT 14 #define INITIAL_TRAM_POS(size) ((((size) / 2) - INITIAL_TRAM_SHIFT) - 1) static void snd_emu10k1_fx8010_playback_irq(struct snd_emu10k1 *emu, void *private_data) { struct snd_pcm_substream *substream = private_data; snd_pcm_period_elapsed(substream); } static void snd_emu10k1_fx8010_playback_tram_poke1(unsigned short *dst_left, unsigned short *dst_right, unsigned short *src, unsigned int count, unsigned int tram_shift) { /* printk(KERN_DEBUG "tram_poke1: dst_left = 0x%p, dst_right = 0x%p, " "src = 0x%p, count = 0x%x\n", dst_left, dst_right, src, count); */ if ((tram_shift & 1) == 0) { while (count--) { *dst_left-- = *src++; *dst_right-- = *src++; } } else { while (count--) { *dst_right-- = *src++; *dst_left-- = *src++; } } } static void fx8010_pb_trans_copy(struct snd_pcm_substream *substream, struct snd_pcm_indirect *rec, size_t bytes) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; unsigned int tram_size = pcm->buffer_size; unsigned short *src = (unsigned short *)(substream->runtime->dma_area + rec->sw_data); unsigned int frames = bytes >> 2, count; unsigned int tram_pos = pcm->tram_pos; unsigned int tram_shift = pcm->tram_shift; while (frames > tram_pos) { count = tram_pos + 1; snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos, (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2, src, count, tram_shift); src += count * 2; frames -= count; tram_pos = (tram_size / 2) - 1; tram_shift++; } snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos, (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2, src, frames, tram_shift); tram_pos -= frames; pcm->tram_pos = tram_pos; pcm->tram_shift = tram_shift; } static int snd_emu10k1_fx8010_playback_transfer(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; snd_pcm_indirect_playback_transfer(substream, &pcm->pcm_rec, fx8010_pb_trans_copy); return 0; } static int snd_emu10k1_fx8010_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } static int snd_emu10k1_fx8010_playback_hw_free(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; unsigned int i; for (i = 0; i < pcm->channels; i++) snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, 0); snd_pcm_lib_free_pages(substream); return 0; } static int snd_emu10k1_fx8010_playback_prepare(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; unsigned int i; /* printk(KERN_DEBUG "prepare: etram_pages = 0x%p, dma_area = 0x%x, " "buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2); */ memset(&pcm->pcm_rec, 0, sizeof(pcm->pcm_rec)); pcm->pcm_rec.hw_buffer_size = pcm->buffer_size * 2; /* byte size */ pcm->pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream); pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size); pcm->tram_shift = 0; snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_running, 0, 0); /* reset */ snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0); /* reset */ snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_size, 0, runtime->buffer_size); snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_ptr, 0, 0); /* reset ptr number */ snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_count, 0, runtime->period_size); snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_tmpcount, 0, runtime->period_size); for (i = 0; i < pcm->channels; i++) snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, (TANKMEMADDRREG_READ|TANKMEMADDRREG_ALIGN) + i * (runtime->buffer_size / pcm->channels)); return 0; } static int snd_emu10k1_fx8010_playback_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; int result = 0; spin_lock(&emu->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: /* follow thru */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_RESUME: #ifdef EMU10K1_SET_AC3_IEC958 { int i; for (i = 0; i < 3; i++) { unsigned int bits; bits = SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | SPCS_GENERATIONSTATUS | 0x00001200 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT | SPCS_NOTAUDIODATA; snd_emu10k1_ptr_write(emu, SPCS0 + i, 0, bits); } } #endif result = snd_emu10k1_fx8010_register_irq_handler(emu, snd_emu10k1_fx8010_playback_irq, pcm->gpr_running, substream, &pcm->irq); if (result < 0) goto __err; snd_emu10k1_fx8010_playback_transfer(substream); /* roll the ball */ snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 1); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_SUSPEND: snd_emu10k1_fx8010_unregister_irq_handler(emu, pcm->irq); pcm->irq = NULL; snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0); pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size); pcm->tram_shift = 0; break; default: result = -EINVAL; break; } __err: spin_unlock(&emu->reg_lock); return result; } static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; size_t ptr; /* byte pointer */ if (!snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_trigger, 0)) return 0; ptr = snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_ptr, 0) << 2; return snd_pcm_indirect_playback_pointer(substream, &pcm->pcm_rec, ptr); } static struct snd_pcm_hardware snd_emu10k1_fx8010_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | /* SNDRV_PCM_INFO_MMAP_VALID | */ SNDRV_PCM_INFO_PAUSE), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_48000, .rate_min = 48000, .rate_max = 48000, .channels_min = 1, .channels_max = 1, .buffer_bytes_max = (128*1024), .period_bytes_min = 1024, .period_bytes_max = (128*1024), .periods_min = 2, .periods_max = 1024, .fifo_size = 0, }; static int snd_emu10k1_fx8010_playback_open(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; runtime->hw = snd_emu10k1_fx8010_playback; runtime->hw.channels_min = runtime->hw.channels_max = pcm->channels; runtime->hw.period_bytes_max = (pcm->buffer_size * 2) / 2; spin_lock_irq(&emu->reg_lock); if (pcm->valid == 0) { spin_unlock_irq(&emu->reg_lock); return -ENODEV; } pcm->opened = 1; spin_unlock_irq(&emu->reg_lock); return 0; } static int snd_emu10k1_fx8010_playback_close(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; spin_lock_irq(&emu->reg_lock); pcm->opened = 0; spin_unlock_irq(&emu->reg_lock); return 0; } static struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops = { .open = snd_emu10k1_fx8010_playback_open, .close = snd_emu10k1_fx8010_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_emu10k1_fx8010_playback_hw_params, .hw_free = snd_emu10k1_fx8010_playback_hw_free, .prepare = snd_emu10k1_fx8010_playback_prepare, .trigger = snd_emu10k1_fx8010_playback_trigger, .pointer = snd_emu10k1_fx8010_playback_pointer, .ack = snd_emu10k1_fx8010_playback_transfer, }; int __devinit snd_emu10k1_pcm_efx(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { struct snd_pcm *pcm; struct snd_kcontrol *kctl; int err; if (rpcm) *rpcm = NULL; if ((err = snd_pcm_new(emu->card, "emu10k1 efx", device, 8, 1, &pcm)) < 0) return err; pcm->private_data = emu; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_fx8010_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_efx_ops); pcm->info_flags = 0; strcpy(pcm->name, "Multichannel Capture/PT Playback"); emu->pcm_efx = pcm; if (rpcm) *rpcm = pcm; /* EFX capture - record the "FXBUS2" channels, by default we connect the EXTINs * to these */ /* emu->efx_voices_mask[0] = FXWC_DEFAULTROUTE_C | FXWC_DEFAULTROUTE_A; */ if (emu->audigy) { emu->efx_voices_mask[0] = 0; if (emu->card_capabilities->emu_model) /* Pavel Hofman - 32 voices will be used for * capture (write mode) - * each bit = corresponding voice */ emu->efx_voices_mask[1] = 0xffffffff; else emu->efx_voices_mask[1] = 0xffff; } else { emu->efx_voices_mask[0] = 0xffff0000; emu->efx_voices_mask[1] = 0; } /* For emu1010, the control has to set 32 upper bits (voices) * out of the 64 bits (voices) to true for the 16-channels capture * to work correctly. Correct A_FXWC2 initial value (0xffffffff) * is already defined but the snd_emu10k1_pcm_efx_voices_mask * control can override this register's value. */ kctl = snd_ctl_new1(&snd_emu10k1_pcm_efx_voices_mask, emu); if (!kctl) return -ENOMEM; kctl->id.device = device; snd_ctl_add(emu->card, kctl); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); return 0; }
gpl-2.0
AndroidDeveloperAlliance/ZenKernel_TUNA
arch/arm/mach-shark/leds.c
4025
3444
/* * arch/arm/mach-shark/leds.c * by Alexander Schulz * * derived from: * arch/arm/kernel/leds-footbridge.c * Copyright (C) 1998-1999 Russell King * * DIGITAL Shark LED control routines. * * The leds use is as follows: * - Green front - toggles state every 50 timer interrupts * - Amber front - Unused, this is a dual color led (Amber/Green) * - Amber back - On if system is not idle * * Changelog: */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/spinlock.h> #include <linux/ioport.h> #include <linux/io.h> #include <asm/leds.h> #include <asm/system.h> #define LED_STATE_ENABLED 1 #define LED_STATE_CLAIMED 2 #define SEQUOIA_LED_GREEN (1<<6) #define SEQUOIA_LED_AMBER (1<<5) #define SEQUOIA_LED_BACK (1<<7) static char led_state; static short hw_led_state; static short saved_state; static DEFINE_SPINLOCK(leds_lock); short sequoia_read(int addr) { outw(addr,0x24); return inw(0x26); } void sequoia_write(short value,short addr) { outw(addr,0x24); outw(value,0x26); } static void sequoia_leds_event(led_event_t evt) { unsigned long flags; spin_lock_irqsave(&leds_lock, flags); hw_led_state = sequoia_read(0x09); switch (evt) { case led_start: hw_led_state |= SEQUOIA_LED_GREEN; hw_led_state |= SEQUOIA_LED_AMBER; #ifdef CONFIG_LEDS_CPU hw_led_state |= SEQUOIA_LED_BACK; #else hw_led_state &= ~SEQUOIA_LED_BACK; #endif led_state |= LED_STATE_ENABLED; break; case led_stop: hw_led_state &= ~SEQUOIA_LED_BACK; hw_led_state |= SEQUOIA_LED_GREEN; hw_led_state |= SEQUOIA_LED_AMBER; led_state &= ~LED_STATE_ENABLED; break; case led_claim: led_state |= LED_STATE_CLAIMED; saved_state = hw_led_state; hw_led_state &= ~SEQUOIA_LED_BACK; hw_led_state |= SEQUOIA_LED_GREEN; hw_led_state |= SEQUOIA_LED_AMBER; break; case led_release: led_state &= ~LED_STATE_CLAIMED; hw_led_state = saved_state; break; #ifdef CONFIG_LEDS_TIMER case led_timer: if (!(led_state & LED_STATE_CLAIMED)) hw_led_state ^= SEQUOIA_LED_GREEN; break; #endif #ifdef CONFIG_LEDS_CPU case led_idle_start: if (!(led_state & LED_STATE_CLAIMED)) hw_led_state &= ~SEQUOIA_LED_BACK; break; case led_idle_end: if (!(led_state & LED_STATE_CLAIMED)) hw_led_state |= SEQUOIA_LED_BACK; break; #endif case led_green_on: if (led_state & LED_STATE_CLAIMED) hw_led_state &= ~SEQUOIA_LED_GREEN; break; case led_green_off: if (led_state & LED_STATE_CLAIMED) hw_led_state |= SEQUOIA_LED_GREEN; break; case led_amber_on: if (led_state & LED_STATE_CLAIMED) hw_led_state &= ~SEQUOIA_LED_AMBER; break; case led_amber_off: if (led_state & LED_STATE_CLAIMED) hw_led_state |= SEQUOIA_LED_AMBER; break; case led_red_on: if (led_state & LED_STATE_CLAIMED) hw_led_state |= SEQUOIA_LED_BACK; break; case led_red_off: if (led_state & LED_STATE_CLAIMED) hw_led_state &= ~SEQUOIA_LED_BACK; break; default: break; } if (led_state & LED_STATE_ENABLED) sequoia_write(hw_led_state,0x09); spin_unlock_irqrestore(&leds_lock, flags); } static int __init leds_init(void) { extern void (*leds_event)(led_event_t); short temp; leds_event = sequoia_leds_event; /* Make LEDs independent of power-state */ request_region(0x24,4,"sequoia"); temp = sequoia_read(0x09); temp |= 1<<10; sequoia_write(temp,0x09); leds_event(led_start); return 0; } __initcall(leds_init);
gpl-2.0
yank555-lu/N3-KK-faux123-yank555.lu
security/keys/trusted.c
4537
28643
/* * Copyright (C) 2010 IBM Corporation * * Author: * David Safford <safford@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, version 2 of the License. * * See Documentation/security/keys-trusted-encrypted.txt */ #include <linux/uaccess.h> #include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/parser.h> #include <linux/string.h> #include <linux/err.h> #include <keys/user-type.h> #include <keys/trusted-type.h> #include <linux/key-type.h> #include <linux/rcupdate.h> #include <linux/crypto.h> #include <crypto/hash.h> #include <crypto/sha.h> #include <linux/capability.h> #include <linux/tpm.h> #include <linux/tpm_command.h> #include "trusted.h" static const char hmac_alg[] = "hmac(sha1)"; static const char hash_alg[] = "sha1"; struct sdesc { struct shash_desc shash; char ctx[]; }; static struct crypto_shash *hashalg; static struct crypto_shash *hmacalg; static struct sdesc *init_sdesc(struct crypto_shash *alg) { struct sdesc *sdesc; int size; size = sizeof(struct shash_desc) + crypto_shash_descsize(alg); sdesc = kmalloc(size, GFP_KERNEL); if (!sdesc) return ERR_PTR(-ENOMEM); sdesc->shash.tfm = alg; sdesc->shash.flags = 0x0; return sdesc; } static int TSS_sha1(const unsigned char *data, unsigned int datalen, unsigned char *digest) { struct sdesc *sdesc; int ret; sdesc = init_sdesc(hashalg); if (IS_ERR(sdesc)) { pr_info("trusted_key: can't alloc %s\n", hash_alg); return PTR_ERR(sdesc); } ret = crypto_shash_digest(&sdesc->shash, data, datalen, digest); kfree(sdesc); return ret; } static int TSS_rawhmac(unsigned char *digest, const unsigned char *key, unsigned int keylen, ...) { struct sdesc *sdesc; va_list argp; unsigned int dlen; unsigned char *data; int ret; sdesc = init_sdesc(hmacalg); if (IS_ERR(sdesc)) { pr_info("trusted_key: can't alloc %s\n", hmac_alg); return PTR_ERR(sdesc); } ret = crypto_shash_setkey(hmacalg, key, keylen); if (ret < 0) goto out; ret = crypto_shash_init(&sdesc->shash); if (ret < 0) goto out; va_start(argp, keylen); for (;;) { dlen = va_arg(argp, unsigned int); if (dlen == 0) break; data = va_arg(argp, unsigned char *); if (data == NULL) { ret = -EINVAL; break; } ret = crypto_shash_update(&sdesc->shash, data, dlen); if (ret < 0) break; } va_end(argp); if (!ret) ret = crypto_shash_final(&sdesc->shash, digest); out: kfree(sdesc); return ret; } /* * calculate authorization info fields to send to TPM */ static int TSS_authhmac(unsigned char *digest, const unsigned char *key, unsigned int keylen, unsigned char *h1, unsigned char *h2, unsigned char h3, ...) { unsigned char paramdigest[SHA1_DIGEST_SIZE]; struct sdesc *sdesc; unsigned int dlen; unsigned char *data; unsigned char c; int ret; va_list argp; sdesc = init_sdesc(hashalg); if (IS_ERR(sdesc)) { pr_info("trusted_key: can't alloc %s\n", hash_alg); return PTR_ERR(sdesc); } c = h3; ret = crypto_shash_init(&sdesc->shash); if (ret < 0) goto out; va_start(argp, h3); for (;;) { dlen = va_arg(argp, unsigned int); if (dlen == 0) break; data = va_arg(argp, unsigned char *); if (!data) { ret = -EINVAL; break; } ret = crypto_shash_update(&sdesc->shash, data, dlen); if (ret < 0) break; } va_end(argp); if (!ret) ret = crypto_shash_final(&sdesc->shash, paramdigest); if (!ret) ret = TSS_rawhmac(digest, key, keylen, SHA1_DIGEST_SIZE, paramdigest, TPM_NONCE_SIZE, h1, TPM_NONCE_SIZE, h2, 1, &c, 0, 0); out: kfree(sdesc); return ret; } /* * verify the AUTH1_COMMAND (Seal) result from TPM */ static int TSS_checkhmac1(unsigned char *buffer, const uint32_t command, const unsigned char *ononce, const unsigned char *key, unsigned int keylen, ...) { uint32_t bufsize; uint16_t tag; uint32_t ordinal; uint32_t result; unsigned char *enonce; unsigned char *continueflag; unsigned char *authdata; unsigned char testhmac[SHA1_DIGEST_SIZE]; unsigned char paramdigest[SHA1_DIGEST_SIZE]; struct sdesc *sdesc; unsigned int dlen; unsigned int dpos; va_list argp; int ret; bufsize = LOAD32(buffer, TPM_SIZE_OFFSET); tag = LOAD16(buffer, 0); ordinal = command; result = LOAD32N(buffer, TPM_RETURN_OFFSET); if (tag == TPM_TAG_RSP_COMMAND) return 0; if (tag != TPM_TAG_RSP_AUTH1_COMMAND) return -EINVAL; authdata = buffer + bufsize - SHA1_DIGEST_SIZE; continueflag = authdata - 1; enonce = continueflag - TPM_NONCE_SIZE; sdesc = init_sdesc(hashalg); if (IS_ERR(sdesc)) { pr_info("trusted_key: can't alloc %s\n", hash_alg); return PTR_ERR(sdesc); } ret = crypto_shash_init(&sdesc->shash); if (ret < 0) goto out; ret = crypto_shash_update(&sdesc->shash, (const u8 *)&result, sizeof result); if (ret < 0) goto out; ret = crypto_shash_update(&sdesc->shash, (const u8 *)&ordinal, sizeof ordinal); if (ret < 0) goto out; va_start(argp, keylen); for (;;) { dlen = va_arg(argp, unsigned int); if (dlen == 0) break; dpos = va_arg(argp, unsigned int); ret = crypto_shash_update(&sdesc->shash, buffer + dpos, dlen); if (ret < 0) break; } va_end(argp); if (!ret) ret = crypto_shash_final(&sdesc->shash, paramdigest); if (ret < 0) goto out; ret = TSS_rawhmac(testhmac, key, keylen, SHA1_DIGEST_SIZE, paramdigest, TPM_NONCE_SIZE, enonce, TPM_NONCE_SIZE, ononce, 1, continueflag, 0, 0); if (ret < 0) goto out; if (memcmp(testhmac, authdata, SHA1_DIGEST_SIZE)) ret = -EINVAL; out: kfree(sdesc); return ret; } /* * verify the AUTH2_COMMAND (unseal) result from TPM */ static int TSS_checkhmac2(unsigned char *buffer, const uint32_t command, const unsigned char *ononce, const unsigned char *key1, unsigned int keylen1, const unsigned char *key2, unsigned int keylen2, ...) { uint32_t bufsize; uint16_t tag; uint32_t ordinal; uint32_t result; unsigned char *enonce1; unsigned char *continueflag1; unsigned char *authdata1; unsigned char *enonce2; unsigned char *continueflag2; unsigned char *authdata2; unsigned char testhmac1[SHA1_DIGEST_SIZE]; unsigned char testhmac2[SHA1_DIGEST_SIZE]; unsigned char paramdigest[SHA1_DIGEST_SIZE]; struct sdesc *sdesc; unsigned int dlen; unsigned int dpos; va_list argp; int ret; bufsize = LOAD32(buffer, TPM_SIZE_OFFSET); tag = LOAD16(buffer, 0); ordinal = command; result = LOAD32N(buffer, TPM_RETURN_OFFSET); if (tag == TPM_TAG_RSP_COMMAND) return 0; if (tag != TPM_TAG_RSP_AUTH2_COMMAND) return -EINVAL; authdata1 = buffer + bufsize - (SHA1_DIGEST_SIZE + 1 + SHA1_DIGEST_SIZE + SHA1_DIGEST_SIZE); authdata2 = buffer + bufsize - (SHA1_DIGEST_SIZE); continueflag1 = authdata1 - 1; continueflag2 = authdata2 - 1; enonce1 = continueflag1 - TPM_NONCE_SIZE; enonce2 = continueflag2 - TPM_NONCE_SIZE; sdesc = init_sdesc(hashalg); if (IS_ERR(sdesc)) { pr_info("trusted_key: can't alloc %s\n", hash_alg); return PTR_ERR(sdesc); } ret = crypto_shash_init(&sdesc->shash); if (ret < 0) goto out; ret = crypto_shash_update(&sdesc->shash, (const u8 *)&result, sizeof result); if (ret < 0) goto out; ret = crypto_shash_update(&sdesc->shash, (const u8 *)&ordinal, sizeof ordinal); if (ret < 0) goto out; va_start(argp, keylen2); for (;;) { dlen = va_arg(argp, unsigned int); if (dlen == 0) break; dpos = va_arg(argp, unsigned int); ret = crypto_shash_update(&sdesc->shash, buffer + dpos, dlen); if (ret < 0) break; } va_end(argp); if (!ret) ret = crypto_shash_final(&sdesc->shash, paramdigest); if (ret < 0) goto out; ret = TSS_rawhmac(testhmac1, key1, keylen1, SHA1_DIGEST_SIZE, paramdigest, TPM_NONCE_SIZE, enonce1, TPM_NONCE_SIZE, ononce, 1, continueflag1, 0, 0); if (ret < 0) goto out; if (memcmp(testhmac1, authdata1, SHA1_DIGEST_SIZE)) { ret = -EINVAL; goto out; } ret = TSS_rawhmac(testhmac2, key2, keylen2, SHA1_DIGEST_SIZE, paramdigest, TPM_NONCE_SIZE, enonce2, TPM_NONCE_SIZE, ononce, 1, continueflag2, 0, 0); if (ret < 0) goto out; if (memcmp(testhmac2, authdata2, SHA1_DIGEST_SIZE)) ret = -EINVAL; out: kfree(sdesc); return ret; } /* * For key specific tpm requests, we will generate and send our * own TPM command packets using the drivers send function. */ static int trusted_tpm_send(const u32 chip_num, unsigned char *cmd, size_t buflen) { int rc; dump_tpm_buf(cmd); rc = tpm_send(chip_num, cmd, buflen); dump_tpm_buf(cmd); if (rc > 0) /* Can't return positive return codes values to keyctl */ rc = -EPERM; return rc; } /* * get a random value from TPM */ static int tpm_get_random(struct tpm_buf *tb, unsigned char *buf, uint32_t len) { int ret; INIT_BUF(tb); store16(tb, TPM_TAG_RQU_COMMAND); store32(tb, TPM_GETRANDOM_SIZE); store32(tb, TPM_ORD_GETRANDOM); store32(tb, len); ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, sizeof tb->data); if (!ret) memcpy(buf, tb->data + TPM_GETRANDOM_SIZE, len); return ret; } static int my_get_random(unsigned char *buf, int len) { struct tpm_buf *tb; int ret; tb = kmalloc(sizeof *tb, GFP_KERNEL); if (!tb) return -ENOMEM; ret = tpm_get_random(tb, buf, len); kfree(tb); return ret; } /* * Lock a trusted key, by extending a selected PCR. * * Prevents a trusted key that is sealed to PCRs from being accessed. * This uses the tpm driver's extend function. */ static int pcrlock(const int pcrnum) { unsigned char hash[SHA1_DIGEST_SIZE]; int ret; if (!capable(CAP_SYS_ADMIN)) return -EPERM; ret = my_get_random(hash, SHA1_DIGEST_SIZE); if (ret < 0) return ret; return tpm_pcr_extend(TPM_ANY_NUM, pcrnum, hash) ? -EINVAL : 0; } /* * Create an object specific authorisation protocol (OSAP) session */ static int osap(struct tpm_buf *tb, struct osapsess *s, const unsigned char *key, uint16_t type, uint32_t handle) { unsigned char enonce[TPM_NONCE_SIZE]; unsigned char ononce[TPM_NONCE_SIZE]; int ret; ret = tpm_get_random(tb, ononce, TPM_NONCE_SIZE); if (ret < 0) return ret; INIT_BUF(tb); store16(tb, TPM_TAG_RQU_COMMAND); store32(tb, TPM_OSAP_SIZE); store32(tb, TPM_ORD_OSAP); store16(tb, type); store32(tb, handle); storebytes(tb, ononce, TPM_NONCE_SIZE); ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); if (ret < 0) return ret; s->handle = LOAD32(tb->data, TPM_DATA_OFFSET); memcpy(s->enonce, &(tb->data[TPM_DATA_OFFSET + sizeof(uint32_t)]), TPM_NONCE_SIZE); memcpy(enonce, &(tb->data[TPM_DATA_OFFSET + sizeof(uint32_t) + TPM_NONCE_SIZE]), TPM_NONCE_SIZE); return TSS_rawhmac(s->secret, key, SHA1_DIGEST_SIZE, TPM_NONCE_SIZE, enonce, TPM_NONCE_SIZE, ononce, 0, 0); } /* * Create an object independent authorisation protocol (oiap) session */ static int oiap(struct tpm_buf *tb, uint32_t *handle, unsigned char *nonce) { int ret; INIT_BUF(tb); store16(tb, TPM_TAG_RQU_COMMAND); store32(tb, TPM_OIAP_SIZE); store32(tb, TPM_ORD_OIAP); ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); if (ret < 0) return ret; *handle = LOAD32(tb->data, TPM_DATA_OFFSET); memcpy(nonce, &tb->data[TPM_DATA_OFFSET + sizeof(uint32_t)], TPM_NONCE_SIZE); return 0; } struct tpm_digests { unsigned char encauth[SHA1_DIGEST_SIZE]; unsigned char pubauth[SHA1_DIGEST_SIZE]; unsigned char xorwork[SHA1_DIGEST_SIZE * 2]; unsigned char xorhash[SHA1_DIGEST_SIZE]; unsigned char nonceodd[TPM_NONCE_SIZE]; }; /* * Have the TPM seal(encrypt) the trusted key, possibly based on * Platform Configuration Registers (PCRs). AUTH1 for sealing key. */ static int tpm_seal(struct tpm_buf *tb, uint16_t keytype, uint32_t keyhandle, const unsigned char *keyauth, const unsigned char *data, uint32_t datalen, unsigned char *blob, uint32_t *bloblen, const unsigned char *blobauth, const unsigned char *pcrinfo, uint32_t pcrinfosize) { struct osapsess sess; struct tpm_digests *td; unsigned char cont; uint32_t ordinal; uint32_t pcrsize; uint32_t datsize; int sealinfosize; int encdatasize; int storedsize; int ret; int i; /* alloc some work space for all the hashes */ td = kmalloc(sizeof *td, GFP_KERNEL); if (!td) return -ENOMEM; /* get session for sealing key */ ret = osap(tb, &sess, keyauth, keytype, keyhandle); if (ret < 0) goto out; dump_sess(&sess); /* calculate encrypted authorization value */ memcpy(td->xorwork, sess.secret, SHA1_DIGEST_SIZE); memcpy(td->xorwork + SHA1_DIGEST_SIZE, sess.enonce, SHA1_DIGEST_SIZE); ret = TSS_sha1(td->xorwork, SHA1_DIGEST_SIZE * 2, td->xorhash); if (ret < 0) goto out; ret = tpm_get_random(tb, td->nonceodd, TPM_NONCE_SIZE); if (ret < 0) goto out; ordinal = htonl(TPM_ORD_SEAL); datsize = htonl(datalen); pcrsize = htonl(pcrinfosize); cont = 0; /* encrypt data authorization key */ for (i = 0; i < SHA1_DIGEST_SIZE; ++i) td->encauth[i] = td->xorhash[i] ^ blobauth[i]; /* calculate authorization HMAC value */ if (pcrinfosize == 0) { /* no pcr info specified */ ret = TSS_authhmac(td->pubauth, sess.secret, SHA1_DIGEST_SIZE, sess.enonce, td->nonceodd, cont, sizeof(uint32_t), &ordinal, SHA1_DIGEST_SIZE, td->encauth, sizeof(uint32_t), &pcrsize, sizeof(uint32_t), &datsize, datalen, data, 0, 0); } else { /* pcr info specified */ ret = TSS_authhmac(td->pubauth, sess.secret, SHA1_DIGEST_SIZE, sess.enonce, td->nonceodd, cont, sizeof(uint32_t), &ordinal, SHA1_DIGEST_SIZE, td->encauth, sizeof(uint32_t), &pcrsize, pcrinfosize, pcrinfo, sizeof(uint32_t), &datsize, datalen, data, 0, 0); } if (ret < 0) goto out; /* build and send the TPM request packet */ INIT_BUF(tb); store16(tb, TPM_TAG_RQU_AUTH1_COMMAND); store32(tb, TPM_SEAL_SIZE + pcrinfosize + datalen); store32(tb, TPM_ORD_SEAL); store32(tb, keyhandle); storebytes(tb, td->encauth, SHA1_DIGEST_SIZE); store32(tb, pcrinfosize); storebytes(tb, pcrinfo, pcrinfosize); store32(tb, datalen); storebytes(tb, data, datalen); store32(tb, sess.handle); storebytes(tb, td->nonceodd, TPM_NONCE_SIZE); store8(tb, cont); storebytes(tb, td->pubauth, SHA1_DIGEST_SIZE); ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); if (ret < 0) goto out; /* calculate the size of the returned Blob */ sealinfosize = LOAD32(tb->data, TPM_DATA_OFFSET + sizeof(uint32_t)); encdatasize = LOAD32(tb->data, TPM_DATA_OFFSET + sizeof(uint32_t) + sizeof(uint32_t) + sealinfosize); storedsize = sizeof(uint32_t) + sizeof(uint32_t) + sealinfosize + sizeof(uint32_t) + encdatasize; /* check the HMAC in the response */ ret = TSS_checkhmac1(tb->data, ordinal, td->nonceodd, sess.secret, SHA1_DIGEST_SIZE, storedsize, TPM_DATA_OFFSET, 0, 0); /* copy the returned blob to caller */ if (!ret) { memcpy(blob, tb->data + TPM_DATA_OFFSET, storedsize); *bloblen = storedsize; } out: kfree(td); return ret; } /* * use the AUTH2_COMMAND form of unseal, to authorize both key and blob */ static int tpm_unseal(struct tpm_buf *tb, uint32_t keyhandle, const unsigned char *keyauth, const unsigned char *blob, int bloblen, const unsigned char *blobauth, unsigned char *data, unsigned int *datalen) { unsigned char nonceodd[TPM_NONCE_SIZE]; unsigned char enonce1[TPM_NONCE_SIZE]; unsigned char enonce2[TPM_NONCE_SIZE]; unsigned char authdata1[SHA1_DIGEST_SIZE]; unsigned char authdata2[SHA1_DIGEST_SIZE]; uint32_t authhandle1 = 0; uint32_t authhandle2 = 0; unsigned char cont = 0; uint32_t ordinal; uint32_t keyhndl; int ret; /* sessions for unsealing key and data */ ret = oiap(tb, &authhandle1, enonce1); if (ret < 0) { pr_info("trusted_key: oiap failed (%d)\n", ret); return ret; } ret = oiap(tb, &authhandle2, enonce2); if (ret < 0) { pr_info("trusted_key: oiap failed (%d)\n", ret); return ret; } ordinal = htonl(TPM_ORD_UNSEAL); keyhndl = htonl(SRKHANDLE); ret = tpm_get_random(tb, nonceodd, TPM_NONCE_SIZE); if (ret < 0) { pr_info("trusted_key: tpm_get_random failed (%d)\n", ret); return ret; } ret = TSS_authhmac(authdata1, keyauth, TPM_NONCE_SIZE, enonce1, nonceodd, cont, sizeof(uint32_t), &ordinal, bloblen, blob, 0, 0); if (ret < 0) return ret; ret = TSS_authhmac(authdata2, blobauth, TPM_NONCE_SIZE, enonce2, nonceodd, cont, sizeof(uint32_t), &ordinal, bloblen, blob, 0, 0); if (ret < 0) return ret; /* build and send TPM request packet */ INIT_BUF(tb); store16(tb, TPM_TAG_RQU_AUTH2_COMMAND); store32(tb, TPM_UNSEAL_SIZE + bloblen); store32(tb, TPM_ORD_UNSEAL); store32(tb, keyhandle); storebytes(tb, blob, bloblen); store32(tb, authhandle1); storebytes(tb, nonceodd, TPM_NONCE_SIZE); store8(tb, cont); storebytes(tb, authdata1, SHA1_DIGEST_SIZE); store32(tb, authhandle2); storebytes(tb, nonceodd, TPM_NONCE_SIZE); store8(tb, cont); storebytes(tb, authdata2, SHA1_DIGEST_SIZE); ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); if (ret < 0) { pr_info("trusted_key: authhmac failed (%d)\n", ret); return ret; } *datalen = LOAD32(tb->data, TPM_DATA_OFFSET); ret = TSS_checkhmac2(tb->data, ordinal, nonceodd, keyauth, SHA1_DIGEST_SIZE, blobauth, SHA1_DIGEST_SIZE, sizeof(uint32_t), TPM_DATA_OFFSET, *datalen, TPM_DATA_OFFSET + sizeof(uint32_t), 0, 0); if (ret < 0) { pr_info("trusted_key: TSS_checkhmac2 failed (%d)\n", ret); return ret; } memcpy(data, tb->data + TPM_DATA_OFFSET + sizeof(uint32_t), *datalen); return 0; } /* * Have the TPM seal(encrypt) the symmetric key */ static int key_seal(struct trusted_key_payload *p, struct trusted_key_options *o) { struct tpm_buf *tb; int ret; tb = kzalloc(sizeof *tb, GFP_KERNEL); if (!tb) return -ENOMEM; /* include migratable flag at end of sealed key */ p->key[p->key_len] = p->migratable; ret = tpm_seal(tb, o->keytype, o->keyhandle, o->keyauth, p->key, p->key_len + 1, p->blob, &p->blob_len, o->blobauth, o->pcrinfo, o->pcrinfo_len); if (ret < 0) pr_info("trusted_key: srkseal failed (%d)\n", ret); kfree(tb); return ret; } /* * Have the TPM unseal(decrypt) the symmetric key */ static int key_unseal(struct trusted_key_payload *p, struct trusted_key_options *o) { struct tpm_buf *tb; int ret; tb = kzalloc(sizeof *tb, GFP_KERNEL); if (!tb) return -ENOMEM; ret = tpm_unseal(tb, o->keyhandle, o->keyauth, p->blob, p->blob_len, o->blobauth, p->key, &p->key_len); if (ret < 0) pr_info("trusted_key: srkunseal failed (%d)\n", ret); else /* pull migratable flag out of sealed key */ p->migratable = p->key[--p->key_len]; kfree(tb); return ret; } enum { Opt_err = -1, Opt_new, Opt_load, Opt_update, Opt_keyhandle, Opt_keyauth, Opt_blobauth, Opt_pcrinfo, Opt_pcrlock, Opt_migratable }; static const match_table_t key_tokens = { {Opt_new, "new"}, {Opt_load, "load"}, {Opt_update, "update"}, {Opt_keyhandle, "keyhandle=%s"}, {Opt_keyauth, "keyauth=%s"}, {Opt_blobauth, "blobauth=%s"}, {Opt_pcrinfo, "pcrinfo=%s"}, {Opt_pcrlock, "pcrlock=%s"}, {Opt_migratable, "migratable=%s"}, {Opt_err, NULL} }; /* can have zero or more token= options */ static int getoptions(char *c, struct trusted_key_payload *pay, struct trusted_key_options *opt) { substring_t args[MAX_OPT_ARGS]; char *p = c; int token; int res; unsigned long handle; unsigned long lock; while ((p = strsep(&c, " \t"))) { if (*p == '\0' || *p == ' ' || *p == '\t') continue; token = match_token(p, key_tokens, args); switch (token) { case Opt_pcrinfo: opt->pcrinfo_len = strlen(args[0].from) / 2; if (opt->pcrinfo_len > MAX_PCRINFO_SIZE) return -EINVAL; res = hex2bin(opt->pcrinfo, args[0].from, opt->pcrinfo_len); if (res < 0) return -EINVAL; break; case Opt_keyhandle: res = strict_strtoul(args[0].from, 16, &handle); if (res < 0) return -EINVAL; opt->keytype = SEAL_keytype; opt->keyhandle = handle; break; case Opt_keyauth: if (strlen(args[0].from) != 2 * SHA1_DIGEST_SIZE) return -EINVAL; res = hex2bin(opt->keyauth, args[0].from, SHA1_DIGEST_SIZE); if (res < 0) return -EINVAL; break; case Opt_blobauth: if (strlen(args[0].from) != 2 * SHA1_DIGEST_SIZE) return -EINVAL; res = hex2bin(opt->blobauth, args[0].from, SHA1_DIGEST_SIZE); if (res < 0) return -EINVAL; break; case Opt_migratable: if (*args[0].from == '0') pay->migratable = 0; else return -EINVAL; break; case Opt_pcrlock: res = strict_strtoul(args[0].from, 10, &lock); if (res < 0) return -EINVAL; opt->pcrlock = lock; break; default: return -EINVAL; } } return 0; } /* * datablob_parse - parse the keyctl data and fill in the * payload and options structures * * On success returns 0, otherwise -EINVAL. */ static int datablob_parse(char *datablob, struct trusted_key_payload *p, struct trusted_key_options *o) { substring_t args[MAX_OPT_ARGS]; long keylen; int ret = -EINVAL; int key_cmd; char *c; /* main command */ c = strsep(&datablob, " \t"); if (!c) return -EINVAL; key_cmd = match_token(c, key_tokens, args); switch (key_cmd) { case Opt_new: /* first argument is key size */ c = strsep(&datablob, " \t"); if (!c) return -EINVAL; ret = strict_strtol(c, 10, &keylen); if (ret < 0 || keylen < MIN_KEY_SIZE || keylen > MAX_KEY_SIZE) return -EINVAL; p->key_len = keylen; ret = getoptions(datablob, p, o); if (ret < 0) return ret; ret = Opt_new; break; case Opt_load: /* first argument is sealed blob */ c = strsep(&datablob, " \t"); if (!c) return -EINVAL; p->blob_len = strlen(c) / 2; if (p->blob_len > MAX_BLOB_SIZE) return -EINVAL; ret = hex2bin(p->blob, c, p->blob_len); if (ret < 0) return -EINVAL; ret = getoptions(datablob, p, o); if (ret < 0) return ret; ret = Opt_load; break; case Opt_update: /* all arguments are options */ ret = getoptions(datablob, p, o); if (ret < 0) return ret; ret = Opt_update; break; case Opt_err: return -EINVAL; break; } return ret; } static struct trusted_key_options *trusted_options_alloc(void) { struct trusted_key_options *options; options = kzalloc(sizeof *options, GFP_KERNEL); if (options) { /* set any non-zero defaults */ options->keytype = SRK_keytype; options->keyhandle = SRKHANDLE; } return options; } static struct trusted_key_payload *trusted_payload_alloc(struct key *key) { struct trusted_key_payload *p = NULL; int ret; ret = key_payload_reserve(key, sizeof *p); if (ret < 0) return p; p = kzalloc(sizeof *p, GFP_KERNEL); if (p) p->migratable = 1; /* migratable by default */ return p; } /* * trusted_instantiate - create a new trusted key * * Unseal an existing trusted blob or, for a new key, get a * random key, then seal and create a trusted key-type key, * adding it to the specified keyring. * * On success, return 0. Otherwise return errno. */ static int trusted_instantiate(struct key *key, const void *data, size_t datalen) { struct trusted_key_payload *payload = NULL; struct trusted_key_options *options = NULL; char *datablob; int ret = 0; int key_cmd; if (datalen <= 0 || datalen > 32767 || !data) return -EINVAL; datablob = kmalloc(datalen + 1, GFP_KERNEL); if (!datablob) return -ENOMEM; memcpy(datablob, data, datalen); datablob[datalen] = '\0'; options = trusted_options_alloc(); if (!options) { ret = -ENOMEM; goto out; } payload = trusted_payload_alloc(key); if (!payload) { ret = -ENOMEM; goto out; } key_cmd = datablob_parse(datablob, payload, options); if (key_cmd < 0) { ret = key_cmd; goto out; } dump_payload(payload); dump_options(options); switch (key_cmd) { case Opt_load: ret = key_unseal(payload, options); dump_payload(payload); dump_options(options); if (ret < 0) pr_info("trusted_key: key_unseal failed (%d)\n", ret); break; case Opt_new: ret = my_get_random(payload->key, payload->key_len); if (ret < 0) { pr_info("trusted_key: key_create failed (%d)\n", ret); goto out; } ret = key_seal(payload, options); if (ret < 0) pr_info("trusted_key: key_seal failed (%d)\n", ret); break; default: ret = -EINVAL; goto out; } if (!ret && options->pcrlock) ret = pcrlock(options->pcrlock); out: kfree(datablob); kfree(options); if (!ret) rcu_assign_keypointer(key, payload); else kfree(payload); return ret; } static void trusted_rcu_free(struct rcu_head *rcu) { struct trusted_key_payload *p; p = container_of(rcu, struct trusted_key_payload, rcu); memset(p->key, 0, p->key_len); kfree(p); } /* * trusted_update - reseal an existing key with new PCR values */ static int trusted_update(struct key *key, const void *data, size_t datalen) { struct trusted_key_payload *p = key->payload.data; struct trusted_key_payload *new_p; struct trusted_key_options *new_o; char *datablob; int ret = 0; if (!p->migratable) return -EPERM; if (datalen <= 0 || datalen > 32767 || !data) return -EINVAL; datablob = kmalloc(datalen + 1, GFP_KERNEL); if (!datablob) return -ENOMEM; new_o = trusted_options_alloc(); if (!new_o) { ret = -ENOMEM; goto out; } new_p = trusted_payload_alloc(key); if (!new_p) { ret = -ENOMEM; goto out; } memcpy(datablob, data, datalen); datablob[datalen] = '\0'; ret = datablob_parse(datablob, new_p, new_o); if (ret != Opt_update) { ret = -EINVAL; kfree(new_p); goto out; } /* copy old key values, and reseal with new pcrs */ new_p->migratable = p->migratable; new_p->key_len = p->key_len; memcpy(new_p->key, p->key, p->key_len); dump_payload(p); dump_payload(new_p); ret = key_seal(new_p, new_o); if (ret < 0) { pr_info("trusted_key: key_seal failed (%d)\n", ret); kfree(new_p); goto out; } if (new_o->pcrlock) { ret = pcrlock(new_o->pcrlock); if (ret < 0) { pr_info("trusted_key: pcrlock failed (%d)\n", ret); kfree(new_p); goto out; } } rcu_assign_keypointer(key, new_p); call_rcu(&p->rcu, trusted_rcu_free); out: kfree(datablob); kfree(new_o); return ret; } /* * trusted_read - copy the sealed blob data to userspace in hex. * On success, return to userspace the trusted key datablob size. */ static long trusted_read(const struct key *key, char __user *buffer, size_t buflen) { struct trusted_key_payload *p; char *ascii_buf; char *bufp; int i; p = rcu_dereference_key(key); if (!p) return -EINVAL; if (!buffer || buflen <= 0) return 2 * p->blob_len; ascii_buf = kmalloc(2 * p->blob_len, GFP_KERNEL); if (!ascii_buf) return -ENOMEM; bufp = ascii_buf; for (i = 0; i < p->blob_len; i++) bufp = hex_byte_pack(bufp, p->blob[i]); if ((copy_to_user(buffer, ascii_buf, 2 * p->blob_len)) != 0) { kfree(ascii_buf); return -EFAULT; } kfree(ascii_buf); return 2 * p->blob_len; } /* * trusted_destroy - before freeing the key, clear the decrypted data */ static void trusted_destroy(struct key *key) { struct trusted_key_payload *p = key->payload.data; if (!p) return; memset(p->key, 0, p->key_len); kfree(key->payload.data); } struct key_type key_type_trusted = { .name = "trusted", .instantiate = trusted_instantiate, .update = trusted_update, .match = user_match, .destroy = trusted_destroy, .describe = user_describe, .read = trusted_read, }; EXPORT_SYMBOL_GPL(key_type_trusted); static void trusted_shash_release(void) { if (hashalg) crypto_free_shash(hashalg); if (hmacalg) crypto_free_shash(hmacalg); } static int __init trusted_shash_alloc(void) { int ret; hmacalg = crypto_alloc_shash(hmac_alg, 0, CRYPTO_ALG_ASYNC); if (IS_ERR(hmacalg)) { pr_info("trusted_key: could not allocate crypto %s\n", hmac_alg); return PTR_ERR(hmacalg); } hashalg = crypto_alloc_shash(hash_alg, 0, CRYPTO_ALG_ASYNC); if (IS_ERR(hashalg)) { pr_info("trusted_key: could not allocate crypto %s\n", hash_alg); ret = PTR_ERR(hashalg); goto hashalg_fail; } return 0; hashalg_fail: crypto_free_shash(hmacalg); return ret; } static int __init init_trusted(void) { int ret; ret = trusted_shash_alloc(); if (ret < 0) return ret; ret = register_key_type(&key_type_trusted); if (ret < 0) trusted_shash_release(); return ret; } static void __exit cleanup_trusted(void) { trusted_shash_release(); unregister_key_type(&key_type_trusted); } late_initcall(init_trusted); module_exit(cleanup_trusted); MODULE_LICENSE("GPL");
gpl-2.0
boulzordev/android_kernel_motorola_msm8916
drivers/video/atafb.c
10425
91065
/* * linux/drivers/video/atafb.c -- Atari builtin chipset frame buffer device * * Copyright (C) 1994 Martin Schaller & Roman Hodek * * 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. * * History: * - 03 Jan 95: Original version by Martin Schaller: The TT driver and * all the device independent stuff * - 09 Jan 95: Roman: I've added the hardware abstraction (hw_switch) * and wrote the Falcon, ST(E), and External drivers * based on the original TT driver. * - 07 May 95: Martin: Added colormap operations for the external driver * - 21 May 95: Martin: Added support for overscan * Andreas: some bug fixes for this * - Jul 95: Guenther Kelleter <guenther@pool.informatik.rwth-aachen.de>: * Programmable Falcon video modes * (thanks to Christian Cartus for documentation * of VIDEL registers). * - 27 Dec 95: Guenther: Implemented user definable video modes "user[0-7]" * on minor 24...31. "user0" may be set on commandline by * "R<x>;<y>;<depth>". (Makes sense only on Falcon) * Video mode switch on Falcon now done at next VBL interrupt * to avoid the annoying right shift of the screen. * - 23 Sep 97: Juergen: added xres_virtual for cards like ProMST * The external-part is legacy, therefore hardware-specific * functions like panning/hardwarescrolling/blanking isn't * supported. * - 29 Sep 97: Juergen: added Romans suggestion for pan_display * (var->xoffset was changed even if no set_screen_base avail.) * - 05 Oct 97: Juergen: extfb (PACKED_PIXEL) is FB_PSEUDOCOLOR 'cause * we know how to set the colors * ext_*palette: read from ext_colors (former MV300_colors) * write to ext_colors and RAMDAC * * To do: * - For the Falcon it is not possible to set random video modes on * SM124 and SC/TV, only the bootup resolution is supported. * */ #define ATAFB_TT #define ATAFB_STE #define ATAFB_EXT #define ATAFB_FALCON #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/delay.h> #include <linux/init.h> #include <linux/interrupt.h> #include <asm/setup.h> #include <linux/uaccess.h> #include <asm/pgtable.h> #include <asm/irq.h> #include <asm/io.h> #include <asm/atarihw.h> #include <asm/atariints.h> #include <asm/atari_stram.h> #include <linux/fb.h> #include <asm/atarikb.h> #include "c2p.h" #include "atafb.h" #define SWITCH_ACIA 0x01 /* modes for switch on OverScan */ #define SWITCH_SND6 0x40 #define SWITCH_SND7 0x80 #define SWITCH_NONE 0x00 #define up(x, r) (((x) + (r) - 1) & ~((r)-1)) /* * Interface to the world */ static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info); static int atafb_set_par(struct fb_info *info); static int atafb_setcolreg(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, unsigned int transp, struct fb_info *info); static int atafb_blank(int blank, struct fb_info *info); static int atafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info); static void atafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect); static void atafb_copyarea(struct fb_info *info, const struct fb_copyarea *region); static void atafb_imageblit(struct fb_info *info, const struct fb_image *image); static int atafb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg); static int default_par; /* default resolution (0=none) */ static unsigned long default_mem_req; static int hwscroll = -1; static int use_hwscroll = 1; static int sttt_xres = 640, st_yres = 400, tt_yres = 480; static int sttt_xres_virtual = 640, sttt_yres_virtual = 400; static int ovsc_offset, ovsc_addlen; /* * Hardware parameters for current mode */ static struct atafb_par { void *screen_base; int yres_virtual; u_long next_line; #if defined ATAFB_TT || defined ATAFB_STE union { struct { int mode; int sync; } tt, st; #endif #ifdef ATAFB_FALCON struct falcon_hw { /* Here are fields for storing a video mode, as direct * parameters for the hardware. */ short sync; short line_width; short line_offset; short st_shift; short f_shift; short vid_control; short vid_mode; short xoffset; short hht, hbb, hbe, hdb, hde, hss; short vft, vbb, vbe, vdb, vde, vss; /* auxiliary information */ short mono; short ste_mode; short bpp; u32 pseudo_palette[16]; } falcon; #endif /* Nothing needed for external mode */ } hw; } current_par; /* Don't calculate an own resolution, and thus don't change the one found when * booting (currently used for the Falcon to keep settings for internal video * hardware extensions (e.g. ScreenBlaster) */ static int DontCalcRes = 0; #ifdef ATAFB_FALCON #define HHT hw.falcon.hht #define HBB hw.falcon.hbb #define HBE hw.falcon.hbe #define HDB hw.falcon.hdb #define HDE hw.falcon.hde #define HSS hw.falcon.hss #define VFT hw.falcon.vft #define VBB hw.falcon.vbb #define VBE hw.falcon.vbe #define VDB hw.falcon.vdb #define VDE hw.falcon.vde #define VSS hw.falcon.vss #define VCO_CLOCK25 0x04 #define VCO_CSYPOS 0x10 #define VCO_VSYPOS 0x20 #define VCO_HSYPOS 0x40 #define VCO_SHORTOFFS 0x100 #define VMO_DOUBLE 0x01 #define VMO_INTER 0x02 #define VMO_PREMASK 0x0c #endif static struct fb_info fb_info = { .fix = { .id = "Atari ", .visual = FB_VISUAL_PSEUDOCOLOR, .accel = FB_ACCEL_NONE, } }; static void *screen_base; /* base address of screen */ static void *real_screen_base; /* (only for Overscan) */ static int screen_len; static int current_par_valid; static int mono_moni; #ifdef ATAFB_EXT /* external video handling */ static unsigned int external_xres; static unsigned int external_xres_virtual; static unsigned int external_yres; /* * not needed - atafb will never support panning/hardwarescroll with external * static unsigned int external_yres_virtual; */ static unsigned int external_depth; static int external_pmode; static void *external_addr; static unsigned long external_len; static unsigned long external_vgaiobase; static unsigned int external_bitspercol = 6; /* * JOE <joe@amber.dinoco.de>: * added card type for external driver, is only needed for * colormap handling. */ enum cardtype { IS_VGA, IS_MV300 }; static enum cardtype external_card_type = IS_VGA; /* * The MV300 mixes the color registers. So we need an array of munged * indices in order to access the correct reg. */ static int MV300_reg_1bit[2] = { 0, 1 }; static int MV300_reg_4bit[16] = { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 }; static int MV300_reg_8bit[256] = { 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 }; static int *MV300_reg = MV300_reg_8bit; #endif /* ATAFB_EXT */ static int inverse; extern int fontheight_8x8; extern int fontwidth_8x8; extern unsigned char fontdata_8x8[]; extern int fontheight_8x16; extern int fontwidth_8x16; extern unsigned char fontdata_8x16[]; /* * struct fb_ops { * * open/release and usage marking * struct module *owner; * int (*fb_open)(struct fb_info *info, int user); * int (*fb_release)(struct fb_info *info, int user); * * * For framebuffers with strange non linear layouts or that do not * * work with normal memory mapped access * ssize_t (*fb_read)(struct file *file, char __user *buf, size_t count, loff_t *ppos); * ssize_t (*fb_write)(struct file *file, const char __user *buf, size_t count, loff_t *ppos); * * * checks var and eventually tweaks it to something supported, * * DOES NOT MODIFY PAR * * int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info); * * * set the video mode according to info->var * * int (*fb_set_par)(struct fb_info *info); * * * set color register * * int (*fb_setcolreg)(unsigned int regno, unsigned int red, unsigned int green, * unsigned int blue, unsigned int transp, struct fb_info *info); * * * set color registers in batch * * int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info); * * * blank display * * int (*fb_blank)(int blank, struct fb_info *info); * * * pan display * * int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info); * * *** The meat of the drawing engine *** * * Draws a rectangle * * void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect); * * Copy data from area to another * * void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region); * * Draws a image to the display * * void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image); * * * Draws cursor * * int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor); * * * Rotates the display * * void (*fb_rotate)(struct fb_info *info, int angle); * * * wait for blit idle, optional * * int (*fb_sync)(struct fb_info *info); * * * perform fb specific ioctl (optional) * * int (*fb_ioctl)(struct fb_info *info, unsigned int cmd, * unsigned long arg); * * * Handle 32bit compat ioctl (optional) * * int (*fb_compat_ioctl)(struct fb_info *info, unsigned int cmd, * unsigned long arg); * * * perform fb specific mmap * * int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma); * } ; */ /* ++roman: This structure abstracts from the underlying hardware (ST(e), * TT, or Falcon. * * int (*detect)(void) * This function should detect the current video mode settings and * store them in atafb_predefined[0] for later reference by the * user. Return the index+1 of an equivalent predefined mode or 0 * if there is no such. * * int (*encode_fix)(struct fb_fix_screeninfo *fix, * struct atafb_par *par) * This function should fill in the 'fix' structure based on the * values in the 'par' structure. * !!! Obsolete, perhaps !!! * * int (*decode_var)(struct fb_var_screeninfo *var, * struct atafb_par *par) * Get the video params out of 'var'. If a value doesn't fit, round * it up, if it's too big, return EINVAL. * Round up in the following order: bits_per_pixel, xres, yres, * xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, * horizontal timing, vertical timing. * * int (*encode_var)(struct fb_var_screeninfo *var, * struct atafb_par *par); * Fill the 'var' structure based on the values in 'par' and maybe * other values read out of the hardware. * * void (*get_par)(struct atafb_par *par) * Fill the hardware's 'par' structure. * !!! Used only by detect() !!! * * void (*set_par)(struct atafb_par *par) * Set the hardware according to 'par'. * * void (*set_screen_base)(void *s_base) * Set the base address of the displayed frame buffer. Only called * if yres_virtual > yres or xres_virtual > xres. * * int (*blank)(int blank_mode) * Blank the screen if blank_mode != 0, else unblank. If blank == NULL then * the caller blanks by setting the CLUT to all black. Return 0 if blanking * succeeded, !=0 if un-/blanking failed due to e.g. a video mode which * doesn't support it. Implements VESA suspend and powerdown modes on * hardware that supports disabling hsync/vsync: * blank_mode == 2: suspend vsync, 3:suspend hsync, 4: powerdown. */ static struct fb_hwswitch { int (*detect)(void); int (*encode_fix)(struct fb_fix_screeninfo *fix, struct atafb_par *par); int (*decode_var)(struct fb_var_screeninfo *var, struct atafb_par *par); int (*encode_var)(struct fb_var_screeninfo *var, struct atafb_par *par); void (*get_par)(struct atafb_par *par); void (*set_par)(struct atafb_par *par); void (*set_screen_base)(void *s_base); int (*blank)(int blank_mode); int (*pan_display)(struct fb_var_screeninfo *var, struct fb_info *info); } *fbhw; static char *autodetect_names[] = { "autodetect", NULL }; static char *stlow_names[] = { "stlow", NULL }; static char *stmid_names[] = { "stmid", "default5", NULL }; static char *sthigh_names[] = { "sthigh", "default4", NULL }; static char *ttlow_names[] = { "ttlow", NULL }; static char *ttmid_names[] = { "ttmid", "default1", NULL }; static char *tthigh_names[] = { "tthigh", "default2", NULL }; static char *vga2_names[] = { "vga2", NULL }; static char *vga4_names[] = { "vga4", NULL }; static char *vga16_names[] = { "vga16", "default3", NULL }; static char *vga256_names[] = { "vga256", NULL }; static char *falh2_names[] = { "falh2", NULL }; static char *falh16_names[] = { "falh16", NULL }; static char **fb_var_names[] = { autodetect_names, stlow_names, stmid_names, sthigh_names, ttlow_names, ttmid_names, tthigh_names, vga2_names, vga4_names, vga16_names, vga256_names, falh2_names, falh16_names, NULL }; static struct fb_var_screeninfo atafb_predefined[] = { /* * yres_virtual == 0 means use hw-scrolling if possible, else yres */ { /* autodetect */ 0, 0, 0, 0, 0, 0, 0, 0, /* xres-grayscale */ {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, /* red green blue tran*/ 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* st low */ 320, 200, 320, 0, 0, 0, 4, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* st mid */ 640, 200, 640, 0, 0, 0, 2, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* st high */ 640, 400, 640, 0, 0, 0, 1, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* tt low */ 320, 480, 320, 0, 0, 0, 8, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* tt mid */ 640, 480, 640, 0, 0, 0, 4, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* tt high */ 1280, 960, 1280, 0, 0, 0, 1, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* vga2 */ 640, 480, 640, 0, 0, 0, 1, 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* vga4 */ 640, 480, 640, 0, 0, 0, 2, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* vga16 */ 640, 480, 640, 0, 0, 0, 4, 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* vga256 */ 640, 480, 640, 0, 0, 0, 8, 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* falh2 */ 896, 608, 896, 0, 0, 0, 1, 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* falh16 */ 896, 608, 896, 0, 0, 0, 4, 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, }; static int num_atafb_predefined = ARRAY_SIZE(atafb_predefined); static struct fb_videomode atafb_modedb[] __initdata = { /* * Atari Video Modes * * If you change these, make sure to update DEFMODE_* as well! */ /* * ST/TT Video Modes */ { /* 320x200, 15 kHz, 60 Hz (ST low) */ "st-low", 60, 320, 200, 32000, 32, 16, 31, 14, 96, 4, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x200, 15 kHz, 60 Hz (ST medium) */ "st-mid", 60, 640, 200, 32000, 32, 16, 31, 14, 96, 4, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x400, 30.25 kHz, 63.5 Hz (ST high) */ "st-high", 63, 640, 400, 32000, 128, 0, 40, 14, 128, 4, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 320x480, 15 kHz, 60 Hz (TT low) */ "tt-low", 60, 320, 480, 31041, 120, 100, 8, 16, 140, 30, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x480, 29 kHz, 57 Hz (TT medium) */ "tt-mid", 60, 640, 480, 31041, 120, 100, 8, 16, 140, 30, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 1280x960, 29 kHz, 60 Hz (TT high) */ "tt-high", 57, 640, 960, 31041, 120, 100, 8, 16, 140, 30, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, /* * VGA Video Modes */ { /* 640x480, 31 kHz, 60 Hz (VGA) */ "vga", 63.5, 640, 480, 32000, 18, 42, 31, 11, 96, 3, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x400, 31 kHz, 70 Hz (VGA) */ "vga70", 70, 640, 400, 32000, 18, 42, 31, 11, 96, 3, FB_SYNC_VERT_HIGH_ACT | FB_SYNC_COMP_HIGH_ACT, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, /* * Falcon HiRes Video Modes */ { /* 896x608, 31 kHz, 60 Hz (Falcon High) */ "falh", 60, 896, 608, 32000, 18, 42, 31, 1, 96,3, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, }; #define NUM_TOTAL_MODES ARRAY_SIZE(atafb_modedb) static char *mode_option __initdata = NULL; /* default modes */ #define DEFMODE_TT 5 /* "tt-high" for TT */ #define DEFMODE_F30 7 /* "vga70" for Falcon */ #define DEFMODE_STE 2 /* "st-high" for ST/E */ #define DEFMODE_EXT 6 /* "vga" for external */ static int get_video_mode(char *vname) { char ***name_list; char **name; int i; name_list = fb_var_names; for (i = 0; i < num_atafb_predefined; i++) { name = *name_list++; if (!name || !*name) break; while (*name) { if (!strcmp(vname, *name)) return i + 1; name++; } } return 0; } /* ------------------- TT specific functions ---------------------- */ #ifdef ATAFB_TT static int tt_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par) { int mode; strcpy(fix->id, "Atari Builtin"); fix->smem_start = (unsigned long)real_screen_base; fix->smem_len = screen_len; fix->type = FB_TYPE_INTERLEAVED_PLANES; fix->type_aux = 2; fix->visual = FB_VISUAL_PSEUDOCOLOR; mode = par->hw.tt.mode & TT_SHIFTER_MODEMASK; if (mode == TT_SHIFTER_TTHIGH || mode == TT_SHIFTER_STHIGH) { fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; if (mode == TT_SHIFTER_TTHIGH) fix->visual = FB_VISUAL_MONO01; } fix->xpanstep = 0; fix->ypanstep = 1; fix->ywrapstep = 0; fix->line_length = par->next_line; fix->accel = FB_ACCEL_ATARIBLITT; return 0; } static int tt_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par) { int xres = var->xres; int yres = var->yres; int bpp = var->bits_per_pixel; int linelen; int yres_virtual = var->yres_virtual; if (mono_moni) { if (bpp > 1 || xres > sttt_xres * 2 || yres > tt_yres * 2) return -EINVAL; par->hw.tt.mode = TT_SHIFTER_TTHIGH; xres = sttt_xres * 2; yres = tt_yres * 2; bpp = 1; } else { if (bpp > 8 || xres > sttt_xres || yres > tt_yres) return -EINVAL; if (bpp > 4) { if (xres > sttt_xres / 2 || yres > tt_yres) return -EINVAL; par->hw.tt.mode = TT_SHIFTER_TTLOW; xres = sttt_xres / 2; yres = tt_yres; bpp = 8; } else if (bpp > 2) { if (xres > sttt_xres || yres > tt_yres) return -EINVAL; if (xres > sttt_xres / 2 || yres > st_yres / 2) { par->hw.tt.mode = TT_SHIFTER_TTMID; xres = sttt_xres; yres = tt_yres; bpp = 4; } else { par->hw.tt.mode = TT_SHIFTER_STLOW; xres = sttt_xres / 2; yres = st_yres / 2; bpp = 4; } } else if (bpp > 1) { if (xres > sttt_xres || yres > st_yres / 2) return -EINVAL; par->hw.tt.mode = TT_SHIFTER_STMID; xres = sttt_xres; yres = st_yres / 2; bpp = 2; } else if (var->xres > sttt_xres || var->yres > st_yres) { return -EINVAL; } else { par->hw.tt.mode = TT_SHIFTER_STHIGH; xres = sttt_xres; yres = st_yres; bpp = 1; } } if (yres_virtual <= 0) yres_virtual = 0; else if (yres_virtual < yres) yres_virtual = yres; if (var->sync & FB_SYNC_EXT) par->hw.tt.sync = 0; else par->hw.tt.sync = 1; linelen = xres * bpp / 8; if (yres_virtual * linelen > screen_len && screen_len) return -EINVAL; if (yres * linelen > screen_len && screen_len) return -EINVAL; if (var->yoffset + yres > yres_virtual && yres_virtual) return -EINVAL; par->yres_virtual = yres_virtual; par->screen_base = screen_base + var->yoffset * linelen; par->next_line = linelen; return 0; } static int tt_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) { int linelen; memset(var, 0, sizeof(struct fb_var_screeninfo)); var->red.offset = 0; var->red.length = 4; var->red.msb_right = 0; var->grayscale = 0; var->pixclock = 31041; var->left_margin = 120; /* these may be incorrect */ var->right_margin = 100; var->upper_margin = 8; var->lower_margin = 16; var->hsync_len = 140; var->vsync_len = 30; var->height = -1; var->width = -1; if (par->hw.tt.sync & 1) var->sync = 0; else var->sync = FB_SYNC_EXT; switch (par->hw.tt.mode & TT_SHIFTER_MODEMASK) { case TT_SHIFTER_STLOW: var->xres = sttt_xres / 2; var->xres_virtual = sttt_xres_virtual / 2; var->yres = st_yres / 2; var->bits_per_pixel = 4; break; case TT_SHIFTER_STMID: var->xres = sttt_xres; var->xres_virtual = sttt_xres_virtual; var->yres = st_yres / 2; var->bits_per_pixel = 2; break; case TT_SHIFTER_STHIGH: var->xres = sttt_xres; var->xres_virtual = sttt_xres_virtual; var->yres = st_yres; var->bits_per_pixel = 1; break; case TT_SHIFTER_TTLOW: var->xres = sttt_xres / 2; var->xres_virtual = sttt_xres_virtual / 2; var->yres = tt_yres; var->bits_per_pixel = 8; break; case TT_SHIFTER_TTMID: var->xres = sttt_xres; var->xres_virtual = sttt_xres_virtual; var->yres = tt_yres; var->bits_per_pixel = 4; break; case TT_SHIFTER_TTHIGH: var->red.length = 0; var->xres = sttt_xres * 2; var->xres_virtual = sttt_xres_virtual * 2; var->yres = tt_yres * 2; var->bits_per_pixel = 1; break; } var->blue = var->green = var->red; var->transp.offset = 0; var->transp.length = 0; var->transp.msb_right = 0; linelen = var->xres_virtual * var->bits_per_pixel / 8; if (!use_hwscroll) var->yres_virtual = var->yres; else if (screen_len) { if (par->yres_virtual) var->yres_virtual = par->yres_virtual; else /* yres_virtual == 0 means use maximum */ var->yres_virtual = screen_len / linelen; } else { if (hwscroll < 0) var->yres_virtual = 2 * var->yres; else var->yres_virtual = var->yres + hwscroll * 16; } var->xoffset = 0; if (screen_base) var->yoffset = (par->screen_base - screen_base) / linelen; else var->yoffset = 0; var->nonstd = 0; var->activate = 0; var->vmode = FB_VMODE_NONINTERLACED; return 0; } static void tt_get_par(struct atafb_par *par) { unsigned long addr; par->hw.tt.mode = shifter_tt.tt_shiftmode; par->hw.tt.sync = shifter.syncmode; addr = ((shifter.bas_hi & 0xff) << 16) | ((shifter.bas_md & 0xff) << 8) | ((shifter.bas_lo & 0xff)); par->screen_base = phys_to_virt(addr); } static void tt_set_par(struct atafb_par *par) { shifter_tt.tt_shiftmode = par->hw.tt.mode; shifter.syncmode = par->hw.tt.sync; /* only set screen_base if really necessary */ if (current_par.screen_base != par->screen_base) fbhw->set_screen_base(par->screen_base); } static int tt_setcolreg(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, unsigned int transp, struct fb_info *info) { if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH) regno += 254; if (regno > 255) return 1; tt_palette[regno] = (((red >> 12) << 8) | ((green >> 12) << 4) | (blue >> 12)); if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH && regno == 254) tt_palette[0] = 0; return 0; } static int tt_detect(void) { struct atafb_par par; /* Determine the connected monitor: The DMA sound must be * disabled before reading the MFP GPIP, because the Sound * Done Signal and the Monochrome Detect are XORed together! * * Even on a TT, we should look if there is a DMA sound. It was * announced that the Eagle is TT compatible, but only the PCM is * missing... */ if (ATARIHW_PRESENT(PCM_8BIT)) { tt_dmasnd.ctrl = DMASND_CTRL_OFF; udelay(20); /* wait a while for things to settle down */ } mono_moni = (st_mfp.par_dt_reg & 0x80) == 0; tt_get_par(&par); tt_encode_var(&atafb_predefined[0], &par); return 1; } #endif /* ATAFB_TT */ /* ------------------- Falcon specific functions ---------------------- */ #ifdef ATAFB_FALCON static int mon_type; /* Falcon connected monitor */ static int f030_bus_width; /* Falcon ram bus width (for vid_control) */ #define F_MON_SM 0 #define F_MON_SC 1 #define F_MON_VGA 2 #define F_MON_TV 3 static struct pixel_clock { unsigned long f; /* f/[Hz] */ unsigned long t; /* t/[ps] (=1/f) */ int right, hsync, left; /* standard timing in clock cycles, not pixel */ /* hsync initialized in falcon_detect() */ int sync_mask; /* or-mask for hw.falcon.sync to set this clock */ int control_mask; /* ditto, for hw.falcon.vid_control */ } f25 = { 25175000, 39721, 18, 0, 42, 0x0, VCO_CLOCK25 }, f32 = { 32000000, 31250, 18, 0, 42, 0x0, 0 }, fext = { 0, 0, 18, 0, 42, 0x1, 0 }; /* VIDEL-prescale values [mon_type][pixel_length from VCO] */ static int vdl_prescale[4][3] = { { 4,2,1 }, { 4,2,1 }, { 4,2,2 }, { 4,2,1 } }; /* Default hsync timing [mon_type] in picoseconds */ static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 }; static inline int hxx_prescale(struct falcon_hw *hw) { return hw->ste_mode ? 16 : vdl_prescale[mon_type][hw->vid_mode >> 2 & 0x3]; } static int falcon_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par) { strcpy(fix->id, "Atari Builtin"); fix->smem_start = (unsigned long)real_screen_base; fix->smem_len = screen_len; fix->type = FB_TYPE_INTERLEAVED_PLANES; fix->type_aux = 2; fix->visual = FB_VISUAL_PSEUDOCOLOR; fix->xpanstep = 1; fix->ypanstep = 1; fix->ywrapstep = 0; if (par->hw.falcon.mono) { fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; /* no smooth scrolling with longword aligned video mem */ fix->xpanstep = 32; } else if (par->hw.falcon.f_shift & 0x100) { fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; /* Is this ok or should it be DIRECTCOLOR? */ fix->visual = FB_VISUAL_TRUECOLOR; fix->xpanstep = 2; } fix->line_length = par->next_line; fix->accel = FB_ACCEL_ATARIBLITT; return 0; } static int falcon_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par) { int bpp = var->bits_per_pixel; int xres = var->xres; int yres = var->yres; int xres_virtual = var->xres_virtual; int yres_virtual = var->yres_virtual; int left_margin, right_margin, hsync_len; int upper_margin, lower_margin, vsync_len; int linelen; int interlace = 0, doubleline = 0; struct pixel_clock *pclock; int plen; /* width of pixel in clock cycles */ int xstretch; int prescale; int longoffset = 0; int hfreq, vfreq; int hdb_off, hde_off, base_off; int gstart, gend1, gend2, align; /* Get the video params out of 'var'. If a value doesn't fit, round it up, if it's too big, return EINVAL. Round up in the following order: bits_per_pixel, xres, yres, xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, horizontal timing, vertical timing. There is a maximum of screen resolution determined by pixelclock and minimum frame rate -- (X+hmarg.)*(Y+vmarg.)*vfmin <= pixelclock. In interlace mode this is " * " *vfmin <= pixelclock. Additional constraints: hfreq. Frequency range for multisync monitors is given via command line. For TV and SM124 both frequencies are fixed. X % 16 == 0 to fit 8x?? font (except 1 bitplane modes must use X%32 == 0) Y % 16 == 0 to fit 8x16 font Y % 8 == 0 if Y<400 Currently interlace and doubleline mode in var are ignored. On SM124 and TV only the standard resolutions can be used. */ /* Reject uninitialized mode */ if (!xres || !yres || !bpp) return -EINVAL; if (mon_type == F_MON_SM && bpp != 1) return -EINVAL; if (bpp <= 1) { bpp = 1; par->hw.falcon.f_shift = 0x400; par->hw.falcon.st_shift = 0x200; } else if (bpp <= 2) { bpp = 2; par->hw.falcon.f_shift = 0x000; par->hw.falcon.st_shift = 0x100; } else if (bpp <= 4) { bpp = 4; par->hw.falcon.f_shift = 0x000; par->hw.falcon.st_shift = 0x000; } else if (bpp <= 8) { bpp = 8; par->hw.falcon.f_shift = 0x010; } else if (bpp <= 16) { bpp = 16; /* packed pixel mode */ par->hw.falcon.f_shift = 0x100; /* hicolor, no overlay */ } else return -EINVAL; par->hw.falcon.bpp = bpp; if (mon_type == F_MON_SM || DontCalcRes) { /* Skip all calculations. VGA/TV/SC1224 only supported. */ struct fb_var_screeninfo *myvar = &atafb_predefined[0]; if (bpp > myvar->bits_per_pixel || var->xres > myvar->xres || var->yres > myvar->yres) return -EINVAL; fbhw->get_par(par); /* Current par will be new par */ goto set_screen_base; /* Don't forget this */ } /* Only some fixed resolutions < 640x400 */ if (xres <= 320) xres = 320; else if (xres <= 640 && bpp != 16) xres = 640; if (yres <= 200) yres = 200; else if (yres <= 240) yres = 240; else if (yres <= 400) yres = 400; /* 2 planes must use STE compatibility mode */ par->hw.falcon.ste_mode = bpp == 2; par->hw.falcon.mono = bpp == 1; /* Total and visible scanline length must be a multiple of one longword, * this and the console fontwidth yields the alignment for xres and * xres_virtual. * TODO: this way "odd" fontheights are not supported * * Special case in STE mode: blank and graphic positions don't align, * avoid trash at right margin */ if (par->hw.falcon.ste_mode) xres = (xres + 63) & ~63; else if (bpp == 1) xres = (xres + 31) & ~31; else xres = (xres + 15) & ~15; if (yres >= 400) yres = (yres + 15) & ~15; else yres = (yres + 7) & ~7; if (xres_virtual < xres) xres_virtual = xres; else if (bpp == 1) xres_virtual = (xres_virtual + 31) & ~31; else xres_virtual = (xres_virtual + 15) & ~15; if (yres_virtual <= 0) yres_virtual = 0; else if (yres_virtual < yres) yres_virtual = yres; /* backward bug-compatibility */ if (var->pixclock > 1) var->pixclock -= 1; par->hw.falcon.line_width = bpp * xres / 16; par->hw.falcon.line_offset = bpp * (xres_virtual - xres) / 16; /* single or double pixel width */ xstretch = (xres < 640) ? 2 : 1; #if 0 /* SM124 supports only 640x400, this is rejected above */ if (mon_type == F_MON_SM) { if (xres != 640 && yres != 400) return -EINVAL; plen = 1; pclock = &f32; /* SM124-mode is special */ par->hw.falcon.ste_mode = 1; par->hw.falcon.f_shift = 0x000; par->hw.falcon.st_shift = 0x200; left_margin = hsync_len = 128 / plen; right_margin = 0; /* TODO set all margins */ } else #endif if (mon_type == F_MON_SC || mon_type == F_MON_TV) { plen = 2 * xstretch; if (var->pixclock > f32.t * plen) return -EINVAL; pclock = &f32; if (yres > 240) interlace = 1; if (var->pixclock == 0) { /* set some minimal margins which center the screen */ left_margin = 32; right_margin = 18; hsync_len = pclock->hsync / plen; upper_margin = 31; lower_margin = 14; vsync_len = interlace ? 3 : 4; } else { left_margin = var->left_margin; right_margin = var->right_margin; hsync_len = var->hsync_len; upper_margin = var->upper_margin; lower_margin = var->lower_margin; vsync_len = var->vsync_len; if (var->vmode & FB_VMODE_INTERLACED) { upper_margin = (upper_margin + 1) / 2; lower_margin = (lower_margin + 1) / 2; vsync_len = (vsync_len + 1) / 2; } else if (var->vmode & FB_VMODE_DOUBLE) { upper_margin *= 2; lower_margin *= 2; vsync_len *= 2; } } } else { /* F_MON_VGA */ if (bpp == 16) xstretch = 2; /* Double pixel width only for hicolor */ /* Default values are used for vert./hor. timing if no pixelclock given. */ if (var->pixclock == 0) { int linesize; /* Choose master pixelclock depending on hor. timing */ plen = 1 * xstretch; if ((plen * xres + f25.right + f25.hsync + f25.left) * fb_info.monspecs.hfmin < f25.f) pclock = &f25; else if ((plen * xres + f32.right + f32.hsync + f32.left) * fb_info.monspecs.hfmin < f32.f) pclock = &f32; else if ((plen * xres + fext.right + fext.hsync + fext.left) * fb_info.monspecs.hfmin < fext.f && fext.f) pclock = &fext; else return -EINVAL; left_margin = pclock->left / plen; right_margin = pclock->right / plen; hsync_len = pclock->hsync / plen; linesize = left_margin + xres + right_margin + hsync_len; upper_margin = 31; lower_margin = 11; vsync_len = 3; } else { /* Choose largest pixelclock <= wanted clock */ int i; unsigned long pcl = ULONG_MAX; pclock = 0; for (i = 1; i <= 4; i *= 2) { if (f25.t * i >= var->pixclock && f25.t * i < pcl) { pcl = f25.t * i; pclock = &f25; } if (f32.t * i >= var->pixclock && f32.t * i < pcl) { pcl = f32.t * i; pclock = &f32; } if (fext.t && fext.t * i >= var->pixclock && fext.t * i < pcl) { pcl = fext.t * i; pclock = &fext; } } if (!pclock) return -EINVAL; plen = pcl / pclock->t; left_margin = var->left_margin; right_margin = var->right_margin; hsync_len = var->hsync_len; upper_margin = var->upper_margin; lower_margin = var->lower_margin; vsync_len = var->vsync_len; /* Internal unit is [single lines per (half-)frame] */ if (var->vmode & FB_VMODE_INTERLACED) { /* # lines in half frame */ /* External unit is [lines per full frame] */ upper_margin = (upper_margin + 1) / 2; lower_margin = (lower_margin + 1) / 2; vsync_len = (vsync_len + 1) / 2; } else if (var->vmode & FB_VMODE_DOUBLE) { /* External unit is [double lines per frame] */ upper_margin *= 2; lower_margin *= 2; vsync_len *= 2; } } if (pclock == &fext) longoffset = 1; /* VIDEL doesn't synchronize on short offset */ } /* Is video bus bandwidth (32MB/s) too low for this resolution? */ /* this is definitely wrong if bus clock != 32MHz */ if (pclock->f / plen / 8 * bpp > 32000000L) return -EINVAL; if (vsync_len < 1) vsync_len = 1; /* include sync lengths in right/lower margin for all calculations */ right_margin += hsync_len; lower_margin += vsync_len; /* ! In all calculations of margins we use # of lines in half frame * (which is a full frame in non-interlace mode), so we can switch * between interlace and non-interlace without messing around * with these. */ again: /* Set base_offset 128 and video bus width */ par->hw.falcon.vid_control = mon_type | f030_bus_width; if (!longoffset) par->hw.falcon.vid_control |= VCO_SHORTOFFS; /* base_offset 64 */ if (var->sync & FB_SYNC_HOR_HIGH_ACT) par->hw.falcon.vid_control |= VCO_HSYPOS; if (var->sync & FB_SYNC_VERT_HIGH_ACT) par->hw.falcon.vid_control |= VCO_VSYPOS; /* Pixelclock */ par->hw.falcon.vid_control |= pclock->control_mask; /* External or internal clock */ par->hw.falcon.sync = pclock->sync_mask | 0x2; /* Pixellength and prescale */ par->hw.falcon.vid_mode = (2 / plen) << 2; if (doubleline) par->hw.falcon.vid_mode |= VMO_DOUBLE; if (interlace) par->hw.falcon.vid_mode |= VMO_INTER; /********************* * Horizontal timing: unit = [master clock cycles] * unit of hxx-registers: [master clock cycles * prescale] * Hxx-registers are 9 bit wide * * 1 line = ((hht + 2) * 2 * prescale) clock cycles * * graphic output = hdb & 0x200 ? * ((hht + 2) * 2 - hdb + hde) * prescale - hdboff + hdeoff: * (hht + 2 - hdb + hde) * prescale - hdboff + hdeoff * (this must be a multiple of plen*128/bpp, on VGA pixels * to the right may be cut off with a bigger right margin) * * start of graphics relative to start of 1st halfline = hdb & 0x200 ? * (hdb - hht - 2) * prescale + hdboff : * hdb * prescale + hdboff * * end of graphics relative to start of 1st halfline = * (hde + hht + 2) * prescale + hdeoff *********************/ /* Calculate VIDEL registers */ { prescale = hxx_prescale(&par->hw.falcon); base_off = par->hw.falcon.vid_control & VCO_SHORTOFFS ? 64 : 128; /* Offsets depend on video mode */ /* Offsets are in clock cycles, divide by prescale to * calculate hd[be]-registers */ if (par->hw.falcon.f_shift & 0x100) { align = 1; hde_off = 0; hdb_off = (base_off + 16 * plen) + prescale; } else { align = 128 / bpp; hde_off = ((128 / bpp + 2) * plen); if (par->hw.falcon.ste_mode) hdb_off = (64 + base_off + (128 / bpp + 2) * plen) + prescale; else hdb_off = (base_off + (128 / bpp + 18) * plen) + prescale; } gstart = (prescale / 2 + plen * left_margin) / prescale; /* gend1 is for hde (gend-gstart multiple of align), shifter's xres */ gend1 = gstart + roundup(xres, align) * plen / prescale; /* gend2 is for hbb, visible xres (rest to gend1 is cut off by hblank) */ gend2 = gstart + xres * plen / prescale; par->HHT = plen * (left_margin + xres + right_margin) / (2 * prescale) - 2; /* par->HHT = (gend2 + plen * right_margin / prescale) / 2 - 2;*/ par->HDB = gstart - hdb_off / prescale; par->HBE = gstart; if (par->HDB < 0) par->HDB += par->HHT + 2 + 0x200; par->HDE = gend1 - par->HHT - 2 - hde_off / prescale; par->HBB = gend2 - par->HHT - 2; #if 0 /* One more Videl constraint: data fetch of two lines must not overlap */ if ((par->HDB & 0x200) && (par->HDB & ~0x200) - par->HDE <= 5) { /* if this happens increase margins, decrease hfreq. */ } #endif if (hde_off % prescale) par->HBB++; /* compensate for non matching hde and hbb */ par->HSS = par->HHT + 2 - plen * hsync_len / prescale; if (par->HSS < par->HBB) par->HSS = par->HBB; } /* check hor. frequency */ hfreq = pclock->f / ((par->HHT + 2) * prescale * 2); if (hfreq > fb_info.monspecs.hfmax && mon_type != F_MON_VGA) { /* ++guenther: ^^^^^^^^^^^^^^^^^^^ can't remember why I did this */ /* Too high -> enlarge margin */ left_margin += 1; right_margin += 1; goto again; } if (hfreq > fb_info.monspecs.hfmax || hfreq < fb_info.monspecs.hfmin) return -EINVAL; /* Vxx-registers */ /* All Vxx must be odd in non-interlace, since frame starts in the middle * of the first displayed line! * One frame consists of VFT+1 half lines. VFT+1 must be even in * non-interlace, odd in interlace mode for synchronisation. * Vxx-registers are 11 bit wide */ par->VBE = (upper_margin * 2 + 1); /* must begin on odd halfline */ par->VDB = par->VBE; par->VDE = yres; if (!interlace) par->VDE <<= 1; if (doubleline) par->VDE <<= 1; /* VDE now half lines per (half-)frame */ par->VDE += par->VDB; par->VBB = par->VDE; par->VFT = par->VBB + (lower_margin * 2 - 1) - 1; par->VSS = par->VFT + 1 - (vsync_len * 2 - 1); /* vbb,vss,vft must be even in interlace mode */ if (interlace) { par->VBB++; par->VSS++; par->VFT++; } /* V-frequency check, hope I didn't create any loop here. */ /* Interlace and doubleline are mutually exclusive. */ vfreq = (hfreq * 2) / (par->VFT + 1); if (vfreq > fb_info.monspecs.vfmax && !doubleline && !interlace) { /* Too high -> try again with doubleline */ doubleline = 1; goto again; } else if (vfreq < fb_info.monspecs.vfmin && !interlace && !doubleline) { /* Too low -> try again with interlace */ interlace = 1; goto again; } else if (vfreq < fb_info.monspecs.vfmin && doubleline) { /* Doubleline too low -> clear doubleline and enlarge margins */ int lines; doubleline = 0; for (lines = 0; (hfreq * 2) / (par->VFT + 1 + 4 * lines - 2 * yres) > fb_info.monspecs.vfmax; lines++) ; upper_margin += lines; lower_margin += lines; goto again; } else if (vfreq > fb_info.monspecs.vfmax && doubleline) { /* Doubleline too high -> enlarge margins */ int lines; for (lines = 0; (hfreq * 2) / (par->VFT + 1 + 4 * lines) > fb_info.monspecs.vfmax; lines += 2) ; upper_margin += lines; lower_margin += lines; goto again; } else if (vfreq > fb_info.monspecs.vfmax && interlace) { /* Interlace, too high -> enlarge margins */ int lines; for (lines = 0; (hfreq * 2) / (par->VFT + 1 + 4 * lines) > fb_info.monspecs.vfmax; lines++) ; upper_margin += lines; lower_margin += lines; goto again; } else if (vfreq < fb_info.monspecs.vfmin || vfreq > fb_info.monspecs.vfmax) return -EINVAL; set_screen_base: linelen = xres_virtual * bpp / 8; if (yres_virtual * linelen > screen_len && screen_len) return -EINVAL; if (yres * linelen > screen_len && screen_len) return -EINVAL; if (var->yoffset + yres > yres_virtual && yres_virtual) return -EINVAL; par->yres_virtual = yres_virtual; par->screen_base = screen_base + var->yoffset * linelen; par->hw.falcon.xoffset = 0; par->next_line = linelen; return 0; } static int falcon_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) { /* !!! only for VGA !!! */ int linelen; int prescale, plen; int hdb_off, hde_off, base_off; struct falcon_hw *hw = &par->hw.falcon; memset(var, 0, sizeof(struct fb_var_screeninfo)); /* possible frequencies: 25.175 or 32MHz */ var->pixclock = hw->sync & 0x1 ? fext.t : hw->vid_control & VCO_CLOCK25 ? f25.t : f32.t; var->height = -1; var->width = -1; var->sync = 0; if (hw->vid_control & VCO_HSYPOS) var->sync |= FB_SYNC_HOR_HIGH_ACT; if (hw->vid_control & VCO_VSYPOS) var->sync |= FB_SYNC_VERT_HIGH_ACT; var->vmode = FB_VMODE_NONINTERLACED; if (hw->vid_mode & VMO_INTER) var->vmode |= FB_VMODE_INTERLACED; if (hw->vid_mode & VMO_DOUBLE) var->vmode |= FB_VMODE_DOUBLE; /* visible y resolution: * Graphics display starts at line VDB and ends at line * VDE. If interlace mode off unit of VC-registers is * half lines, else lines. */ var->yres = hw->vde - hw->vdb; if (!(var->vmode & FB_VMODE_INTERLACED)) var->yres >>= 1; if (var->vmode & FB_VMODE_DOUBLE) var->yres >>= 1; /* * to get bpp, we must examine f_shift and st_shift. * f_shift is valid if any of bits no. 10, 8 or 4 * is set. Priority in f_shift is: 10 ">" 8 ">" 4, i.e. * if bit 10 set then bit 8 and bit 4 don't care... * If all these bits are 0 get display depth from st_shift * (as for ST and STE) */ if (hw->f_shift & 0x400) /* 2 colors */ var->bits_per_pixel = 1; else if (hw->f_shift & 0x100) /* hicolor */ var->bits_per_pixel = 16; else if (hw->f_shift & 0x010) /* 8 bitplanes */ var->bits_per_pixel = 8; else if (hw->st_shift == 0) var->bits_per_pixel = 4; else if (hw->st_shift == 0x100) var->bits_per_pixel = 2; else /* if (hw->st_shift == 0x200) */ var->bits_per_pixel = 1; var->xres = hw->line_width * 16 / var->bits_per_pixel; var->xres_virtual = var->xres + hw->line_offset * 16 / var->bits_per_pixel; if (hw->xoffset) var->xres_virtual += 16; if (var->bits_per_pixel == 16) { var->red.offset = 11; var->red.length = 5; var->red.msb_right = 0; var->green.offset = 5; var->green.length = 6; var->green.msb_right = 0; var->blue.offset = 0; var->blue.length = 5; var->blue.msb_right = 0; } else { var->red.offset = 0; var->red.length = hw->ste_mode ? 4 : 6; if (var->red.length > var->bits_per_pixel) var->red.length = var->bits_per_pixel; var->red.msb_right = 0; var->grayscale = 0; var->blue = var->green = var->red; } var->transp.offset = 0; var->transp.length = 0; var->transp.msb_right = 0; linelen = var->xres_virtual * var->bits_per_pixel / 8; if (screen_len) { if (par->yres_virtual) var->yres_virtual = par->yres_virtual; else /* yres_virtual == 0 means use maximum */ var->yres_virtual = screen_len / linelen; } else { if (hwscroll < 0) var->yres_virtual = 2 * var->yres; else var->yres_virtual = var->yres + hwscroll * 16; } var->xoffset = 0; /* TODO change this */ /* hdX-offsets */ prescale = hxx_prescale(hw); plen = 4 >> (hw->vid_mode >> 2 & 0x3); base_off = hw->vid_control & VCO_SHORTOFFS ? 64 : 128; if (hw->f_shift & 0x100) { hde_off = 0; hdb_off = (base_off + 16 * plen) + prescale; } else { hde_off = ((128 / var->bits_per_pixel + 2) * plen); if (hw->ste_mode) hdb_off = (64 + base_off + (128 / var->bits_per_pixel + 2) * plen) + prescale; else hdb_off = (base_off + (128 / var->bits_per_pixel + 18) * plen) + prescale; } /* Right margin includes hsync */ var->left_margin = hdb_off + prescale * ((hw->hdb & 0x1ff) - (hw->hdb & 0x200 ? 2 + hw->hht : 0)); if (hw->ste_mode || mon_type != F_MON_VGA) var->right_margin = prescale * (hw->hht + 2 - hw->hde) - hde_off; else /* can't use this in ste_mode, because hbb is +1 off */ var->right_margin = prescale * (hw->hht + 2 - hw->hbb); var->hsync_len = prescale * (hw->hht + 2 - hw->hss); /* Lower margin includes vsync */ var->upper_margin = hw->vdb / 2; /* round down to full lines */ var->lower_margin = (hw->vft + 1 - hw->vde + 1) / 2; /* round up */ var->vsync_len = (hw->vft + 1 - hw->vss + 1) / 2; /* round up */ if (var->vmode & FB_VMODE_INTERLACED) { var->upper_margin *= 2; var->lower_margin *= 2; var->vsync_len *= 2; } else if (var->vmode & FB_VMODE_DOUBLE) { var->upper_margin = (var->upper_margin + 1) / 2; var->lower_margin = (var->lower_margin + 1) / 2; var->vsync_len = (var->vsync_len + 1) / 2; } var->pixclock *= plen; var->left_margin /= plen; var->right_margin /= plen; var->hsync_len /= plen; var->right_margin -= var->hsync_len; var->lower_margin -= var->vsync_len; if (screen_base) var->yoffset = (par->screen_base - screen_base) / linelen; else var->yoffset = 0; var->nonstd = 0; /* what is this for? */ var->activate = 0; return 0; } static int f_change_mode; static struct falcon_hw f_new_mode; static int f_pan_display; static void falcon_get_par(struct atafb_par *par) { unsigned long addr; struct falcon_hw *hw = &par->hw.falcon; hw->line_width = shifter_f030.scn_width; hw->line_offset = shifter_f030.off_next; hw->st_shift = videl.st_shift & 0x300; hw->f_shift = videl.f_shift; hw->vid_control = videl.control; hw->vid_mode = videl.mode; hw->sync = shifter.syncmode & 0x1; hw->xoffset = videl.xoffset & 0xf; hw->hht = videl.hht; hw->hbb = videl.hbb; hw->hbe = videl.hbe; hw->hdb = videl.hdb; hw->hde = videl.hde; hw->hss = videl.hss; hw->vft = videl.vft; hw->vbb = videl.vbb; hw->vbe = videl.vbe; hw->vdb = videl.vdb; hw->vde = videl.vde; hw->vss = videl.vss; addr = (shifter.bas_hi & 0xff) << 16 | (shifter.bas_md & 0xff) << 8 | (shifter.bas_lo & 0xff); par->screen_base = phys_to_virt(addr); /* derived parameters */ hw->ste_mode = (hw->f_shift & 0x510) == 0 && hw->st_shift == 0x100; hw->mono = (hw->f_shift & 0x400) || ((hw->f_shift & 0x510) == 0 && hw->st_shift == 0x200); } static void falcon_set_par(struct atafb_par *par) { f_change_mode = 0; /* only set screen_base if really necessary */ if (current_par.screen_base != par->screen_base) fbhw->set_screen_base(par->screen_base); /* Don't touch any other registers if we keep the default resolution */ if (DontCalcRes) return; /* Tell vbl-handler to change video mode. * We change modes only on next VBL, to avoid desynchronisation * (a shift to the right and wrap around by a random number of pixels * in all monochrome modes). * This seems to work on my Falcon. */ f_new_mode = par->hw.falcon; f_change_mode = 1; } static irqreturn_t falcon_vbl_switcher(int irq, void *dummy) { struct falcon_hw *hw = &f_new_mode; if (f_change_mode) { f_change_mode = 0; if (hw->sync & 0x1) { /* Enable external pixelclock. This code only for ScreenWonder */ *(volatile unsigned short *)0xffff9202 = 0xffbf; } else { /* Turn off external clocks. Read sets all output bits to 1. */ *(volatile unsigned short *)0xffff9202; } shifter.syncmode = hw->sync; videl.hht = hw->hht; videl.hbb = hw->hbb; videl.hbe = hw->hbe; videl.hdb = hw->hdb; videl.hde = hw->hde; videl.hss = hw->hss; videl.vft = hw->vft; videl.vbb = hw->vbb; videl.vbe = hw->vbe; videl.vdb = hw->vdb; videl.vde = hw->vde; videl.vss = hw->vss; videl.f_shift = 0; /* write enables Falcon palette, 0: 4 planes */ if (hw->ste_mode) { videl.st_shift = hw->st_shift; /* write enables STE palette */ } else { /* IMPORTANT: * set st_shift 0, so we can tell the screen-depth if f_shift == 0. * Writing 0 to f_shift enables 4 plane Falcon mode but * doesn't set st_shift. st_shift != 0 (!= 4planes) is impossible * with Falcon palette. */ videl.st_shift = 0; /* now back to Falcon palette mode */ videl.f_shift = hw->f_shift; } /* writing to st_shift changed scn_width and vid_mode */ videl.xoffset = hw->xoffset; shifter_f030.scn_width = hw->line_width; shifter_f030.off_next = hw->line_offset; videl.control = hw->vid_control; videl.mode = hw->vid_mode; } if (f_pan_display) { f_pan_display = 0; videl.xoffset = current_par.hw.falcon.xoffset; shifter_f030.off_next = current_par.hw.falcon.line_offset; } return IRQ_HANDLED; } static int falcon_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { struct atafb_par *par = (struct atafb_par *)info->par; int xoffset; int bpp = info->var.bits_per_pixel; if (bpp == 1) var->xoffset = up(var->xoffset, 32); if (bpp != 16) par->hw.falcon.xoffset = var->xoffset & 15; else { par->hw.falcon.xoffset = 0; var->xoffset = up(var->xoffset, 2); } par->hw.falcon.line_offset = bpp * (info->var.xres_virtual - info->var.xres) / 16; if (par->hw.falcon.xoffset) par->hw.falcon.line_offset -= bpp; xoffset = var->xoffset - par->hw.falcon.xoffset; par->screen_base = screen_base + (var->yoffset * info->var.xres_virtual + xoffset) * bpp / 8; if (fbhw->set_screen_base) fbhw->set_screen_base(par->screen_base); else return -EINVAL; /* shouldn't happen */ f_pan_display = 1; return 0; } static int falcon_setcolreg(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, unsigned int transp, struct fb_info *info) { if (regno > 255) return 1; f030_col[regno] = (((red & 0xfc00) << 16) | ((green & 0xfc00) << 8) | ((blue & 0xfc00) >> 8)); if (regno < 16) { shifter_tt.color_reg[regno] = (((red & 0xe000) >> 13) | ((red & 0x1000) >> 12) << 8) | (((green & 0xe000) >> 13) | ((green & 0x1000) >> 12) << 4) | ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12); ((u32 *)info->pseudo_palette)[regno] = ((red & 0xf800) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11)); } return 0; } static int falcon_blank(int blank_mode) { /* ++guenther: we can switch off graphics by changing VDB and VDE, * so VIDEL doesn't hog the bus while saving. * (this may affect usleep()). */ int vdb, vss, hbe, hss; if (mon_type == F_MON_SM) /* this doesn't work on SM124 */ return 1; vdb = current_par.VDB; vss = current_par.VSS; hbe = current_par.HBE; hss = current_par.HSS; if (blank_mode >= 1) { /* disable graphics output (this speeds up the CPU) ... */ vdb = current_par.VFT + 1; /* ... and blank all lines */ hbe = current_par.HHT + 2; } /* use VESA suspend modes on VGA monitors */ if (mon_type == F_MON_VGA) { if (blank_mode == 2 || blank_mode == 4) vss = current_par.VFT + 1; if (blank_mode == 3 || blank_mode == 4) hss = current_par.HHT + 2; } videl.vdb = vdb; videl.vss = vss; videl.hbe = hbe; videl.hss = hss; return 0; } static int falcon_detect(void) { struct atafb_par par; unsigned char fhw; /* Determine connected monitor and set monitor parameters */ fhw = *(unsigned char *)0xffff8006; mon_type = fhw >> 6 & 0x3; /* bit 1 of fhw: 1=32 bit ram bus, 0=16 bit */ f030_bus_width = fhw << 6 & 0x80; switch (mon_type) { case F_MON_SM: fb_info.monspecs.vfmin = 70; fb_info.monspecs.vfmax = 72; fb_info.monspecs.hfmin = 35713; fb_info.monspecs.hfmax = 35715; break; case F_MON_SC: case F_MON_TV: /* PAL...NTSC */ fb_info.monspecs.vfmin = 49; /* not 50, since TOS defaults to 49.9x Hz */ fb_info.monspecs.vfmax = 60; fb_info.monspecs.hfmin = 15620; fb_info.monspecs.hfmax = 15755; break; } /* initialize hsync-len */ f25.hsync = h_syncs[mon_type] / f25.t; f32.hsync = h_syncs[mon_type] / f32.t; if (fext.t) fext.hsync = h_syncs[mon_type] / fext.t; falcon_get_par(&par); falcon_encode_var(&atafb_predefined[0], &par); /* Detected mode is always the "autodetect" slot */ return 1; } #endif /* ATAFB_FALCON */ /* ------------------- ST(E) specific functions ---------------------- */ #ifdef ATAFB_STE static int stste_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par) { int mode; strcpy(fix->id, "Atari Builtin"); fix->smem_start = (unsigned long)real_screen_base; fix->smem_len = screen_len; fix->type = FB_TYPE_INTERLEAVED_PLANES; fix->type_aux = 2; fix->visual = FB_VISUAL_PSEUDOCOLOR; mode = par->hw.st.mode & 3; if (mode == ST_HIGH) { fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; fix->visual = FB_VISUAL_MONO10; } if (ATARIHW_PRESENT(EXTD_SHIFTER)) { fix->xpanstep = 16; fix->ypanstep = 1; } else { fix->xpanstep = 0; fix->ypanstep = 0; } fix->ywrapstep = 0; fix->line_length = par->next_line; fix->accel = FB_ACCEL_ATARIBLITT; return 0; } static int stste_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par) { int xres = var->xres; int yres = var->yres; int bpp = var->bits_per_pixel; int linelen; int yres_virtual = var->yres_virtual; if (mono_moni) { if (bpp > 1 || xres > sttt_xres || yres > st_yres) return -EINVAL; par->hw.st.mode = ST_HIGH; xres = sttt_xres; yres = st_yres; bpp = 1; } else { if (bpp > 4 || xres > sttt_xres || yres > st_yres) return -EINVAL; if (bpp > 2) { if (xres > sttt_xres / 2 || yres > st_yres / 2) return -EINVAL; par->hw.st.mode = ST_LOW; xres = sttt_xres / 2; yres = st_yres / 2; bpp = 4; } else if (bpp > 1) { if (xres > sttt_xres || yres > st_yres / 2) return -EINVAL; par->hw.st.mode = ST_MID; xres = sttt_xres; yres = st_yres / 2; bpp = 2; } else return -EINVAL; } if (yres_virtual <= 0) yres_virtual = 0; else if (yres_virtual < yres) yres_virtual = yres; if (var->sync & FB_SYNC_EXT) par->hw.st.sync = (par->hw.st.sync & ~1) | 1; else par->hw.st.sync = (par->hw.st.sync & ~1); linelen = xres * bpp / 8; if (yres_virtual * linelen > screen_len && screen_len) return -EINVAL; if (yres * linelen > screen_len && screen_len) return -EINVAL; if (var->yoffset + yres > yres_virtual && yres_virtual) return -EINVAL; par->yres_virtual = yres_virtual; par->screen_base = screen_base + var->yoffset * linelen; par->next_line = linelen; return 0; } static int stste_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) { int linelen; memset(var, 0, sizeof(struct fb_var_screeninfo)); var->red.offset = 0; var->red.length = ATARIHW_PRESENT(EXTD_SHIFTER) ? 4 : 3; var->red.msb_right = 0; var->grayscale = 0; var->pixclock = 31041; var->left_margin = 120; /* these are incorrect */ var->right_margin = 100; var->upper_margin = 8; var->lower_margin = 16; var->hsync_len = 140; var->vsync_len = 30; var->height = -1; var->width = -1; if (!(par->hw.st.sync & 1)) var->sync = 0; else var->sync = FB_SYNC_EXT; switch (par->hw.st.mode & 3) { case ST_LOW: var->xres = sttt_xres / 2; var->yres = st_yres / 2; var->bits_per_pixel = 4; break; case ST_MID: var->xres = sttt_xres; var->yres = st_yres / 2; var->bits_per_pixel = 2; break; case ST_HIGH: var->xres = sttt_xres; var->yres = st_yres; var->bits_per_pixel = 1; break; } var->blue = var->green = var->red; var->transp.offset = 0; var->transp.length = 0; var->transp.msb_right = 0; var->xres_virtual = sttt_xres_virtual; linelen = var->xres_virtual * var->bits_per_pixel / 8; ovsc_addlen = linelen * (sttt_yres_virtual - st_yres); if (!use_hwscroll) var->yres_virtual = var->yres; else if (screen_len) { if (par->yres_virtual) var->yres_virtual = par->yres_virtual; else /* yres_virtual == 0 means use maximum */ var->yres_virtual = screen_len / linelen; } else { if (hwscroll < 0) var->yres_virtual = 2 * var->yres; else var->yres_virtual = var->yres + hwscroll * 16; } var->xoffset = 0; if (screen_base) var->yoffset = (par->screen_base - screen_base) / linelen; else var->yoffset = 0; var->nonstd = 0; var->activate = 0; var->vmode = FB_VMODE_NONINTERLACED; return 0; } static void stste_get_par(struct atafb_par *par) { unsigned long addr; par->hw.st.mode = shifter_tt.st_shiftmode; par->hw.st.sync = shifter.syncmode; addr = ((shifter.bas_hi & 0xff) << 16) | ((shifter.bas_md & 0xff) << 8); if (ATARIHW_PRESENT(EXTD_SHIFTER)) addr |= (shifter.bas_lo & 0xff); par->screen_base = phys_to_virt(addr); } static void stste_set_par(struct atafb_par *par) { shifter_tt.st_shiftmode = par->hw.st.mode; shifter.syncmode = par->hw.st.sync; /* only set screen_base if really necessary */ if (current_par.screen_base != par->screen_base) fbhw->set_screen_base(par->screen_base); } static int stste_setcolreg(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, unsigned int transp, struct fb_info *info) { if (regno > 15) return 1; red >>= 12; blue >>= 12; green >>= 12; if (ATARIHW_PRESENT(EXTD_SHIFTER)) shifter_tt.color_reg[regno] = (((red & 0xe) >> 1) | ((red & 1) << 3) << 8) | (((green & 0xe) >> 1) | ((green & 1) << 3) << 4) | ((blue & 0xe) >> 1) | ((blue & 1) << 3); else shifter_tt.color_reg[regno] = ((red & 0xe) << 7) | ((green & 0xe) << 3) | ((blue & 0xe) >> 1); return 0; } static int stste_detect(void) { struct atafb_par par; /* Determine the connected monitor: The DMA sound must be * disabled before reading the MFP GPIP, because the Sound * Done Signal and the Monochrome Detect are XORed together! */ if (ATARIHW_PRESENT(PCM_8BIT)) { tt_dmasnd.ctrl = DMASND_CTRL_OFF; udelay(20); /* wait a while for things to settle down */ } mono_moni = (st_mfp.par_dt_reg & 0x80) == 0; stste_get_par(&par); stste_encode_var(&atafb_predefined[0], &par); if (!ATARIHW_PRESENT(EXTD_SHIFTER)) use_hwscroll = 0; return 1; } static void stste_set_screen_base(void *s_base) { unsigned long addr; addr = virt_to_phys(s_base); /* Setup Screen Memory */ shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16); shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8); if (ATARIHW_PRESENT(EXTD_SHIFTER)) shifter.bas_lo = (unsigned char)(addr & 0x0000ff); } #endif /* ATAFB_STE */ /* Switching the screen size should be done during vsync, otherwise * the margins may get messed up. This is a well known problem of * the ST's video system. * * Unfortunately there is hardly any way to find the vsync, as the * vertical blank interrupt is no longer in time on machines with * overscan type modifications. * * We can, however, use Timer B to safely detect the black shoulder, * but then we've got to guess an appropriate delay to find the vsync. * This might not work on every machine. * * martin_rogge @ ki.maus.de, 8th Aug 1995 */ #define LINE_DELAY (mono_moni ? 30 : 70) #define SYNC_DELAY (mono_moni ? 1500 : 2000) /* SWITCH_ACIA may be used for Falcon (ScreenBlaster III internal!) */ static void st_ovsc_switch(void) { unsigned long flags; register unsigned char old, new; if (!(atari_switches & ATARI_SWITCH_OVSC_MASK)) return; local_irq_save(flags); st_mfp.tim_ct_b = 0x10; st_mfp.active_edge |= 8; st_mfp.tim_ct_b = 0; st_mfp.tim_dt_b = 0xf0; st_mfp.tim_ct_b = 8; while (st_mfp.tim_dt_b > 1) /* TOS does it this way, don't ask why */ ; new = st_mfp.tim_dt_b; do { udelay(LINE_DELAY); old = new; new = st_mfp.tim_dt_b; } while (old != new); st_mfp.tim_ct_b = 0x10; udelay(SYNC_DELAY); if (atari_switches & ATARI_SWITCH_OVSC_IKBD) acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID | ACIA_RIE; if (atari_switches & ATARI_SWITCH_OVSC_MIDI) acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID; if (atari_switches & (ATARI_SWITCH_OVSC_SND6|ATARI_SWITCH_OVSC_SND7)) { sound_ym.rd_data_reg_sel = 14; sound_ym.wd_data = sound_ym.rd_data_reg_sel | ((atari_switches & ATARI_SWITCH_OVSC_SND6) ? 0x40:0) | ((atari_switches & ATARI_SWITCH_OVSC_SND7) ? 0x80:0); } local_irq_restore(flags); } /* ------------------- External Video ---------------------- */ #ifdef ATAFB_EXT static int ext_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par) { strcpy(fix->id, "Unknown Extern"); fix->smem_start = (unsigned long)external_addr; fix->smem_len = PAGE_ALIGN(external_len); if (external_depth == 1) { fix->type = FB_TYPE_PACKED_PIXELS; /* The letters 'n' and 'i' in the "atavideo=external:" stand * for "normal" and "inverted", rsp., in the monochrome case */ fix->visual = (external_pmode == FB_TYPE_INTERLEAVED_PLANES || external_pmode == FB_TYPE_PACKED_PIXELS) ? FB_VISUAL_MONO10 : FB_VISUAL_MONO01; } else { /* Use STATIC if we don't know how to access color registers */ int visual = external_vgaiobase ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_STATIC_PSEUDOCOLOR; switch (external_pmode) { case -1: /* truecolor */ fix->type = FB_TYPE_PACKED_PIXELS; fix->visual = FB_VISUAL_TRUECOLOR; break; case FB_TYPE_PACKED_PIXELS: fix->type = FB_TYPE_PACKED_PIXELS; fix->visual = visual; break; case FB_TYPE_PLANES: fix->type = FB_TYPE_PLANES; fix->visual = visual; break; case FB_TYPE_INTERLEAVED_PLANES: fix->type = FB_TYPE_INTERLEAVED_PLANES; fix->type_aux = 2; fix->visual = visual; break; } } fix->xpanstep = 0; fix->ypanstep = 0; fix->ywrapstep = 0; fix->line_length = par->next_line; return 0; } static int ext_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par) { struct fb_var_screeninfo *myvar = &atafb_predefined[0]; if (var->bits_per_pixel > myvar->bits_per_pixel || var->xres > myvar->xres || var->xres_virtual > myvar->xres_virtual || var->yres > myvar->yres || var->xoffset > 0 || var->yoffset > 0) return -EINVAL; par->next_line = external_xres_virtual * external_depth / 8; return 0; } static int ext_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) { memset(var, 0, sizeof(struct fb_var_screeninfo)); var->red.offset = 0; var->red.length = (external_pmode == -1) ? external_depth / 3 : (external_vgaiobase ? external_bitspercol : 0); var->red.msb_right = 0; var->grayscale = 0; var->pixclock = 31041; var->left_margin = 120; /* these are surely incorrect */ var->right_margin = 100; var->upper_margin = 8; var->lower_margin = 16; var->hsync_len = 140; var->vsync_len = 30; var->height = -1; var->width = -1; var->sync = 0; var->xres = external_xres; var->yres = external_yres; var->xres_virtual = external_xres_virtual; var->bits_per_pixel = external_depth; var->blue = var->green = var->red; var->transp.offset = 0; var->transp.length = 0; var->transp.msb_right = 0; var->yres_virtual = var->yres; var->xoffset = 0; var->yoffset = 0; var->nonstd = 0; var->activate = 0; var->vmode = FB_VMODE_NONINTERLACED; return 0; } static void ext_get_par(struct atafb_par *par) { par->screen_base = external_addr; } static void ext_set_par(struct atafb_par *par) { } #define OUTB(port,val) \ *((unsigned volatile char *) ((port)+external_vgaiobase)) = (val) #define INB(port) \ (*((unsigned volatile char *) ((port)+external_vgaiobase))) #define DACDelay \ do { \ unsigned char tmp = INB(0x3da); \ tmp = INB(0x3da); \ } while (0) static int ext_setcolreg(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, unsigned int transp, struct fb_info *info) { unsigned char colmask = (1 << external_bitspercol) - 1; if (!external_vgaiobase) return 1; if (regno > 255) return 1; switch (external_card_type) { case IS_VGA: OUTB(0x3c8, regno); DACDelay; OUTB(0x3c9, red & colmask); DACDelay; OUTB(0x3c9, green & colmask); DACDelay; OUTB(0x3c9, blue & colmask); DACDelay; return 0; case IS_MV300: OUTB((MV300_reg[regno] << 2) + 1, red); OUTB((MV300_reg[regno] << 2) + 1, green); OUTB((MV300_reg[regno] << 2) + 1, blue); return 0; default: return 1; } } static int ext_detect(void) { struct fb_var_screeninfo *myvar = &atafb_predefined[0]; struct atafb_par dummy_par; myvar->xres = external_xres; myvar->xres_virtual = external_xres_virtual; myvar->yres = external_yres; myvar->bits_per_pixel = external_depth; ext_encode_var(myvar, &dummy_par); return 1; } #endif /* ATAFB_EXT */ /* ------ This is the same for most hardware types -------- */ static void set_screen_base(void *s_base) { unsigned long addr; addr = virt_to_phys(s_base); /* Setup Screen Memory */ shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16); shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8); shifter.bas_lo = (unsigned char)(addr & 0x0000ff); } static int pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { struct atafb_par *par = (struct atafb_par *)info->par; if (!fbhw->set_screen_base || (!ATARIHW_PRESENT(EXTD_SHIFTER) && var->xoffset)) return -EINVAL; var->xoffset = up(var->xoffset, 16); par->screen_base = screen_base + (var->yoffset * info->var.xres_virtual + var->xoffset) * info->var.bits_per_pixel / 8; fbhw->set_screen_base(par->screen_base); return 0; } /* ------------ Interfaces to hardware functions ------------ */ #ifdef ATAFB_TT static struct fb_hwswitch tt_switch = { .detect = tt_detect, .encode_fix = tt_encode_fix, .decode_var = tt_decode_var, .encode_var = tt_encode_var, .get_par = tt_get_par, .set_par = tt_set_par, .set_screen_base = set_screen_base, .pan_display = pan_display, }; #endif #ifdef ATAFB_FALCON static struct fb_hwswitch falcon_switch = { .detect = falcon_detect, .encode_fix = falcon_encode_fix, .decode_var = falcon_decode_var, .encode_var = falcon_encode_var, .get_par = falcon_get_par, .set_par = falcon_set_par, .set_screen_base = set_screen_base, .blank = falcon_blank, .pan_display = falcon_pan_display, }; #endif #ifdef ATAFB_STE static struct fb_hwswitch st_switch = { .detect = stste_detect, .encode_fix = stste_encode_fix, .decode_var = stste_decode_var, .encode_var = stste_encode_var, .get_par = stste_get_par, .set_par = stste_set_par, .set_screen_base = stste_set_screen_base, .pan_display = pan_display }; #endif #ifdef ATAFB_EXT static struct fb_hwswitch ext_switch = { .detect = ext_detect, .encode_fix = ext_encode_fix, .decode_var = ext_decode_var, .encode_var = ext_encode_var, .get_par = ext_get_par, .set_par = ext_set_par, }; #endif static void ata_get_par(struct atafb_par *par) { if (current_par_valid) *par = current_par; else fbhw->get_par(par); } static void ata_set_par(struct atafb_par *par) { fbhw->set_par(par); current_par = *par; current_par_valid = 1; } /* =========================================================== */ /* ============== Hardware Independent Functions ============= */ /* =========================================================== */ /* used for hardware scrolling */ static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive) { int err, activate; struct atafb_par par; err = fbhw->decode_var(var, &par); if (err) return err; activate = var->activate; if (((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) && isactive) ata_set_par(&par); fbhw->encode_var(var, &par); var->activate = activate; return 0; } /* fbhw->encode_fix() must be called with fb_info->mm_lock held * if it is called after the register_framebuffer() - not a case here */ static int atafb_get_fix(struct fb_fix_screeninfo *fix, struct fb_info *info) { struct atafb_par par; int err; // Get fix directly (case con == -1 before)?? err = fbhw->decode_var(&info->var, &par); if (err) return err; memset(fix, 0, sizeof(struct fb_fix_screeninfo)); err = fbhw->encode_fix(fix, &par); return err; } static int atafb_get_var(struct fb_var_screeninfo *var, struct fb_info *info) { struct atafb_par par; ata_get_par(&par); fbhw->encode_var(var, &par); return 0; } // No longer called by fbcon! // Still called by set_var internally static void atafb_set_disp(struct fb_info *info) { atafb_get_var(&info->var, info); atafb_get_fix(&info->fix, info); info->screen_base = (void *)info->fix.smem_start; } static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info) { red >>= 8; green >>= 8; blue >>= 8; return info->fbops->fb_setcolreg(regno, red, green, blue, transp, info); } static int atafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { int xoffset = var->xoffset; int yoffset = var->yoffset; int err; if (var->vmode & FB_VMODE_YWRAP) { if (yoffset < 0 || yoffset >= info->var.yres_virtual || xoffset) return -EINVAL; } else { if (xoffset + info->var.xres > info->var.xres_virtual || yoffset + info->var.yres > info->var.yres_virtual) return -EINVAL; } if (fbhw->pan_display) { err = fbhw->pan_display(var, info); if (err) return err; } else return -EINVAL; info->var.xoffset = xoffset; info->var.yoffset = yoffset; if (var->vmode & FB_VMODE_YWRAP) info->var.vmode |= FB_VMODE_YWRAP; else info->var.vmode &= ~FB_VMODE_YWRAP; return 0; } /* * generic drawing routines; imageblit needs updating for image depth > 1 */ #if BITS_PER_LONG == 32 #define BYTES_PER_LONG 4 #define SHIFT_PER_LONG 5 #elif BITS_PER_LONG == 64 #define BYTES_PER_LONG 8 #define SHIFT_PER_LONG 6 #else #define Please update me #endif static void atafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { struct atafb_par *par = (struct atafb_par *)info->par; int x2, y2; u32 width, height; if (!rect->width || !rect->height) return; #ifdef ATAFB_FALCON if (info->var.bits_per_pixel == 16) { cfb_fillrect(info, rect); return; } #endif /* * We could use hardware clipping but on many cards you get around * hardware clipping by writing to framebuffer directly. * */ x2 = rect->dx + rect->width; y2 = rect->dy + rect->height; x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; width = x2 - rect->dx; height = y2 - rect->dy; if (info->var.bits_per_pixel == 1) atafb_mfb_fillrect(info, par->next_line, rect->color, rect->dy, rect->dx, height, width); else if (info->var.bits_per_pixel == 2) atafb_iplan2p2_fillrect(info, par->next_line, rect->color, rect->dy, rect->dx, height, width); else if (info->var.bits_per_pixel == 4) atafb_iplan2p4_fillrect(info, par->next_line, rect->color, rect->dy, rect->dx, height, width); else atafb_iplan2p8_fillrect(info, par->next_line, rect->color, rect->dy, rect->dx, height, width); return; } static void atafb_copyarea(struct fb_info *info, const struct fb_copyarea *area) { struct atafb_par *par = (struct atafb_par *)info->par; int x2, y2; u32 dx, dy, sx, sy, width, height; int rev_copy = 0; #ifdef ATAFB_FALCON if (info->var.bits_per_pixel == 16) { cfb_copyarea(info, area); return; } #endif /* clip the destination */ x2 = area->dx + area->width; y2 = area->dy + area->height; dx = area->dx > 0 ? area->dx : 0; dy = area->dy > 0 ? area->dy : 0; x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; width = x2 - dx; height = y2 - dy; if (area->sx + dx < area->dx || area->sy + dy < area->dy) return; /* update sx,sy */ sx = area->sx + (dx - area->dx); sy = area->sy + (dy - area->dy); /* the source must be completely inside the virtual screen */ if (sx + width > info->var.xres_virtual || sy + height > info->var.yres_virtual) return; if (dy > sy || (dy == sy && dx > sx)) { dy += height; sy += height; rev_copy = 1; } if (info->var.bits_per_pixel == 1) atafb_mfb_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); else if (info->var.bits_per_pixel == 2) atafb_iplan2p2_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); else if (info->var.bits_per_pixel == 4) atafb_iplan2p4_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); else atafb_iplan2p8_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); return; } static void atafb_imageblit(struct fb_info *info, const struct fb_image *image) { struct atafb_par *par = (struct atafb_par *)info->par; int x2, y2; unsigned long *dst; int dst_idx; const char *src; u32 dx, dy, width, height, pitch; #ifdef ATAFB_FALCON if (info->var.bits_per_pixel == 16) { cfb_imageblit(info, image); return; } #endif /* * We could use hardware clipping but on many cards you get around * hardware clipping by writing to framebuffer directly like we are * doing here. */ x2 = image->dx + image->width; y2 = image->dy + image->height; dx = image->dx; dy = image->dy; x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; width = x2 - dx; height = y2 - dy; if (image->depth == 1) { // used for font data dst = (unsigned long *) ((unsigned long)info->screen_base & ~(BYTES_PER_LONG - 1)); dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG - 1)) * 8; dst_idx += dy * par->next_line * 8 + dx; src = image->data; pitch = (image->width + 7) / 8; while (height--) { if (info->var.bits_per_pixel == 1) atafb_mfb_linefill(info, par->next_line, dy, dx, width, src, image->bg_color, image->fg_color); else if (info->var.bits_per_pixel == 2) atafb_iplan2p2_linefill(info, par->next_line, dy, dx, width, src, image->bg_color, image->fg_color); else if (info->var.bits_per_pixel == 4) atafb_iplan2p4_linefill(info, par->next_line, dy, dx, width, src, image->bg_color, image->fg_color); else atafb_iplan2p8_linefill(info, par->next_line, dy, dx, width, src, image->bg_color, image->fg_color); dy++; src += pitch; } } else { c2p_iplan2(info->screen_base, image->data, dx, dy, width, height, par->next_line, image->width, info->var.bits_per_pixel); } } static int atafb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) { switch (cmd) { #ifdef FBCMD_GET_CURRENTPAR case FBCMD_GET_CURRENTPAR: if (copy_to_user((void *)arg, (void *)&current_par, sizeof(struct atafb_par))) return -EFAULT; return 0; #endif #ifdef FBCMD_SET_CURRENTPAR case FBCMD_SET_CURRENTPAR: if (copy_from_user((void *)&current_par, (void *)arg, sizeof(struct atafb_par))) return -EFAULT; ata_set_par(&current_par); return 0; #endif } return -EINVAL; } /* (un)blank/poweroff * 0 = unblank * 1 = blank * 2 = suspend vsync * 3 = suspend hsync * 4 = off */ static int atafb_blank(int blank, struct fb_info *info) { unsigned short black[16]; struct fb_cmap cmap; if (fbhw->blank && !fbhw->blank(blank)) return 1; if (blank) { memset(black, 0, 16 * sizeof(unsigned short)); cmap.red = black; cmap.green = black; cmap.blue = black; cmap.transp = NULL; cmap.start = 0; cmap.len = 16; fb_set_cmap(&cmap, info); } #if 0 else do_install_cmap(info); #endif return 0; } /* * New fbcon interface ... */ /* check var by decoding var into hw par, rounding if necessary, * then encoding hw par back into new, validated var */ static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { int err; struct atafb_par par; /* Validate wanted screen parameters */ // if ((err = ata_decode_var(var, &par))) err = fbhw->decode_var(var, &par); if (err) return err; /* Encode (possibly rounded) screen parameters */ fbhw->encode_var(var, &par); return 0; } /* actually set hw par by decoding var, then setting hardware from * hw par just decoded */ static int atafb_set_par(struct fb_info *info) { struct atafb_par *par = (struct atafb_par *)info->par; /* Decode wanted screen parameters */ fbhw->decode_var(&info->var, par); mutex_lock(&info->mm_lock); fbhw->encode_fix(&info->fix, par); mutex_unlock(&info->mm_lock); /* Set new videomode */ ata_set_par(par); return 0; } static struct fb_ops atafb_ops = { .owner = THIS_MODULE, .fb_check_var = atafb_check_var, .fb_set_par = atafb_set_par, .fb_setcolreg = atafb_setcolreg, .fb_blank = atafb_blank, .fb_pan_display = atafb_pan_display, .fb_fillrect = atafb_fillrect, .fb_copyarea = atafb_copyarea, .fb_imageblit = atafb_imageblit, .fb_ioctl = atafb_ioctl, }; static void check_default_par(int detected_mode) { char default_name[10]; int i; struct fb_var_screeninfo var; unsigned long min_mem; /* First try the user supplied mode */ if (default_par) { var = atafb_predefined[default_par - 1]; var.activate = FB_ACTIVATE_TEST; if (do_fb_set_var(&var, 1)) default_par = 0; /* failed */ } /* Next is the autodetected one */ if (!default_par) { var = atafb_predefined[detected_mode - 1]; /* autodetect */ var.activate = FB_ACTIVATE_TEST; if (!do_fb_set_var(&var, 1)) default_par = detected_mode; } /* If that also failed, try some default modes... */ if (!default_par) { /* try default1, default2... */ for (i = 1; i < 10; i++) { sprintf(default_name,"default%d", i); default_par = get_video_mode(default_name); if (!default_par) panic("can't set default video mode"); var = atafb_predefined[default_par - 1]; var.activate = FB_ACTIVATE_TEST; if (!do_fb_set_var(&var,1)) break; /* ok */ } } min_mem = var.xres_virtual * var.yres_virtual * var.bits_per_pixel / 8; if (default_mem_req < min_mem) default_mem_req = min_mem; } #ifdef ATAFB_EXT static void __init atafb_setup_ext(char *spec) { int xres, xres_virtual, yres, depth, planes; unsigned long addr, len; char *p; /* Format is: <xres>;<yres>;<depth>;<plane organ.>; * <screen mem addr> * [;<screen mem length>[;<vgaiobase>[;<bits-per-col>[;<colorreg-type> * [;<xres-virtual>]]]]] * * 09/23/97 Juergen * <xres_virtual>: hardware's x-resolution (f.e. ProMST) * * Even xres_virtual is available, we neither support panning nor hw-scrolling! */ p = strsep(&spec, ";"); if (!p || !*p) return; xres_virtual = xres = simple_strtoul(p, NULL, 10); if (xres <= 0) return; p = strsep(&spec, ";"); if (!p || !*p) return; yres = simple_strtoul(p, NULL, 10); if (yres <= 0) return; p = strsep(&spec, ";"); if (!p || !*p) return; depth = simple_strtoul(p, NULL, 10); if (depth != 1 && depth != 2 && depth != 4 && depth != 8 && depth != 16 && depth != 24) return; p = strsep(&spec, ";"); if (!p || !*p) return; if (*p == 'i') planes = FB_TYPE_INTERLEAVED_PLANES; else if (*p == 'p') planes = FB_TYPE_PACKED_PIXELS; else if (*p == 'n') planes = FB_TYPE_PLANES; else if (*p == 't') planes = -1; /* true color */ else return; p = strsep(&spec, ";"); if (!p || !*p) return; addr = simple_strtoul(p, NULL, 0); p = strsep(&spec, ";"); if (!p || !*p) len = xres * yres * depth / 8; else len = simple_strtoul(p, NULL, 0); p = strsep(&spec, ";"); if (p && *p) external_vgaiobase = simple_strtoul(p, NULL, 0); p = strsep(&spec, ";"); if (p && *p) { external_bitspercol = simple_strtoul(p, NULL, 0); if (external_bitspercol > 8) external_bitspercol = 8; else if (external_bitspercol < 1) external_bitspercol = 1; } p = strsep(&spec, ";"); if (p && *p) { if (!strcmp(p, "vga")) external_card_type = IS_VGA; if (!strcmp(p, "mv300")) external_card_type = IS_MV300; } p = strsep(&spec, ";"); if (p && *p) { xres_virtual = simple_strtoul(p, NULL, 10); if (xres_virtual < xres) xres_virtual = xres; if (xres_virtual * yres * depth / 8 > len) len = xres_virtual * yres * depth / 8; } external_xres = xres; external_xres_virtual = xres_virtual; external_yres = yres; external_depth = depth; external_pmode = planes; external_addr = (void *)addr; external_len = len; if (external_card_type == IS_MV300) { switch (external_depth) { case 1: MV300_reg = MV300_reg_1bit; break; case 4: MV300_reg = MV300_reg_4bit; break; case 8: MV300_reg = MV300_reg_8bit; break; } } } #endif /* ATAFB_EXT */ static void __init atafb_setup_int(char *spec) { /* Format to config extended internal video hardware like OverScan: * "internal:<xres>;<yres>;<xres_max>;<yres_max>;<offset>" * Explanation: * <xres>: x-resolution * <yres>: y-resolution * The following are only needed if you have an overscan which * needs a black border: * <xres_max>: max. length of a line in pixels your OverScan hardware would allow * <yres_max>: max. number of lines your OverScan hardware would allow * <offset>: Offset from physical beginning to visible beginning * of screen in bytes */ int xres; char *p; if (!(p = strsep(&spec, ";")) || !*p) return; xres = simple_strtoul(p, NULL, 10); if (!(p = strsep(&spec, ";")) || !*p) return; sttt_xres = xres; tt_yres = st_yres = simple_strtoul(p, NULL, 10); if ((p = strsep(&spec, ";")) && *p) sttt_xres_virtual = simple_strtoul(p, NULL, 10); if ((p = strsep(&spec, ";")) && *p) sttt_yres_virtual = simple_strtoul(p, NULL, 0); if ((p = strsep(&spec, ";")) && *p) ovsc_offset = simple_strtoul(p, NULL, 0); if (ovsc_offset || (sttt_yres_virtual != st_yres)) use_hwscroll = 0; } #ifdef ATAFB_FALCON static void __init atafb_setup_mcap(char *spec) { char *p; int vmin, vmax, hmin, hmax; /* Format for monitor capabilities is: <Vmin>;<Vmax>;<Hmin>;<Hmax> * <V*> vertical freq. in Hz * <H*> horizontal freq. in kHz */ if (!(p = strsep(&spec, ";")) || !*p) return; vmin = simple_strtoul(p, NULL, 10); if (vmin <= 0) return; if (!(p = strsep(&spec, ";")) || !*p) return; vmax = simple_strtoul(p, NULL, 10); if (vmax <= 0 || vmax <= vmin) return; if (!(p = strsep(&spec, ";")) || !*p) return; hmin = 1000 * simple_strtoul(p, NULL, 10); if (hmin <= 0) return; if (!(p = strsep(&spec, "")) || !*p) return; hmax = 1000 * simple_strtoul(p, NULL, 10); if (hmax <= 0 || hmax <= hmin) return; fb_info.monspecs.vfmin = vmin; fb_info.monspecs.vfmax = vmax; fb_info.monspecs.hfmin = hmin; fb_info.monspecs.hfmax = hmax; } #endif /* ATAFB_FALCON */ static void __init atafb_setup_user(char *spec) { /* Format of user defined video mode is: <xres>;<yres>;<depth> */ char *p; int xres, yres, depth, temp; p = strsep(&spec, ";"); if (!p || !*p) return; xres = simple_strtoul(p, NULL, 10); p = strsep(&spec, ";"); if (!p || !*p) return; yres = simple_strtoul(p, NULL, 10); p = strsep(&spec, ""); if (!p || !*p) return; depth = simple_strtoul(p, NULL, 10); temp = get_video_mode("user0"); if (temp) { default_par = temp; atafb_predefined[default_par - 1].xres = xres; atafb_predefined[default_par - 1].yres = yres; atafb_predefined[default_par - 1].bits_per_pixel = depth; } } int __init atafb_setup(char *options) { char *this_opt; int temp; if (!options || !*options) return 0; while ((this_opt = strsep(&options, ",")) != NULL) { if (!*this_opt) continue; if ((temp = get_video_mode(this_opt))) { default_par = temp; mode_option = this_opt; } else if (!strcmp(this_opt, "inverse")) inverse = 1; else if (!strncmp(this_opt, "hwscroll_", 9)) { hwscroll = simple_strtoul(this_opt + 9, NULL, 10); if (hwscroll < 0) hwscroll = 0; if (hwscroll > 200) hwscroll = 200; } #ifdef ATAFB_EXT else if (!strcmp(this_opt, "mv300")) { external_bitspercol = 8; external_card_type = IS_MV300; } else if (!strncmp(this_opt, "external:", 9)) atafb_setup_ext(this_opt + 9); #endif else if (!strncmp(this_opt, "internal:", 9)) atafb_setup_int(this_opt + 9); #ifdef ATAFB_FALCON else if (!strncmp(this_opt, "eclock:", 7)) { fext.f = simple_strtoul(this_opt + 7, NULL, 10); /* external pixelclock in kHz --> ps */ fext.t = 1000000000 / fext.f; fext.f *= 1000; } else if (!strncmp(this_opt, "monitorcap:", 11)) atafb_setup_mcap(this_opt + 11); #endif else if (!strcmp(this_opt, "keep")) DontCalcRes = 1; else if (!strncmp(this_opt, "R", 1)) atafb_setup_user(this_opt + 1); } return 0; } int __init atafb_init(void) { int pad, detected_mode, error; unsigned int defmode = 0; unsigned long mem_req; #ifndef MODULE char *option = NULL; if (fb_get_options("atafb", &option)) return -ENODEV; atafb_setup(option); #endif printk("atafb_init: start\n"); if (!MACH_IS_ATARI) return -ENODEV; do { #ifdef ATAFB_EXT if (external_addr) { printk("atafb_init: initializing external hw\n"); fbhw = &ext_switch; atafb_ops.fb_setcolreg = &ext_setcolreg; defmode = DEFMODE_EXT; break; } #endif #ifdef ATAFB_TT if (ATARIHW_PRESENT(TT_SHIFTER)) { printk("atafb_init: initializing TT hw\n"); fbhw = &tt_switch; atafb_ops.fb_setcolreg = &tt_setcolreg; defmode = DEFMODE_TT; break; } #endif #ifdef ATAFB_FALCON if (ATARIHW_PRESENT(VIDEL_SHIFTER)) { printk("atafb_init: initializing Falcon hw\n"); fbhw = &falcon_switch; atafb_ops.fb_setcolreg = &falcon_setcolreg; error = request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO, "framebuffer:modeswitch", falcon_vbl_switcher); if (error) return error; defmode = DEFMODE_F30; break; } #endif #ifdef ATAFB_STE if (ATARIHW_PRESENT(STND_SHIFTER) || ATARIHW_PRESENT(EXTD_SHIFTER)) { printk("atafb_init: initializing ST/E hw\n"); fbhw = &st_switch; atafb_ops.fb_setcolreg = &stste_setcolreg; defmode = DEFMODE_STE; break; } fbhw = &st_switch; atafb_ops.fb_setcolreg = &stste_setcolreg; printk("Cannot determine video hardware; defaulting to ST(e)\n"); #else /* ATAFB_STE */ /* no default driver included */ /* Nobody will ever see this message :-) */ panic("Cannot initialize video hardware"); #endif } while (0); /* Multisync monitor capabilities */ /* Atari-TOS defaults if no boot option present */ if (fb_info.monspecs.hfmin == 0) { fb_info.monspecs.hfmin = 31000; fb_info.monspecs.hfmax = 32000; fb_info.monspecs.vfmin = 58; fb_info.monspecs.vfmax = 62; } detected_mode = fbhw->detect(); check_default_par(detected_mode); #ifdef ATAFB_EXT if (!external_addr) { #endif /* ATAFB_EXT */ mem_req = default_mem_req + ovsc_offset + ovsc_addlen; mem_req = PAGE_ALIGN(mem_req) + PAGE_SIZE; screen_base = atari_stram_alloc(mem_req, "atafb"); if (!screen_base) panic("Cannot allocate screen memory"); memset(screen_base, 0, mem_req); pad = -(unsigned long)screen_base & (PAGE_SIZE - 1); screen_base += pad; real_screen_base = screen_base + ovsc_offset; screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK; st_ovsc_switch(); if (CPU_IS_040_OR_060) { /* On a '040+, the cache mode of video RAM must be set to * write-through also for internal video hardware! */ cache_push(virt_to_phys(screen_base), screen_len); kernel_set_cachemode(screen_base, screen_len, IOMAP_WRITETHROUGH); } printk("atafb: screen_base %p real_screen_base %p screen_len %d\n", screen_base, real_screen_base, screen_len); #ifdef ATAFB_EXT } else { /* Map the video memory (physical address given) to somewhere * in the kernel address space. */ external_addr = ioremap_writethrough((unsigned long)external_addr, external_len); if (external_vgaiobase) external_vgaiobase = (unsigned long)ioremap(external_vgaiobase, 0x10000); screen_base = real_screen_base = external_addr; screen_len = external_len & PAGE_MASK; memset (screen_base, 0, external_len); } #endif /* ATAFB_EXT */ // strcpy(fb_info.mode->name, "Atari Builtin "); fb_info.fbops = &atafb_ops; // try to set default (detected; requested) var do_fb_set_var(&atafb_predefined[default_par - 1], 1); // reads hw state into current par, which may not be sane yet ata_get_par(&current_par); fb_info.par = &current_par; // tries to read from HW which may not be initialized yet // so set sane var first, then call atafb_set_par atafb_get_var(&fb_info.var, &fb_info); #ifdef ATAFB_FALCON fb_info.pseudo_palette = current_par.hw.falcon.pseudo_palette; #endif fb_info.flags = FBINFO_FLAG_DEFAULT; if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb, NUM_TOTAL_MODES, &atafb_modedb[defmode], fb_info.var.bits_per_pixel)) { return -EINVAL; } fb_videomode_to_modelist(atafb_modedb, NUM_TOTAL_MODES, &fb_info.modelist); atafb_set_disp(&fb_info); fb_alloc_cmap(&(fb_info.cmap), 1 << fb_info.var.bits_per_pixel, 0); printk("Determined %dx%d, depth %d\n", fb_info.var.xres, fb_info.var.yres, fb_info.var.bits_per_pixel); if ((fb_info.var.xres != fb_info.var.xres_virtual) || (fb_info.var.yres != fb_info.var.yres_virtual)) printk(" virtual %dx%d\n", fb_info.var.xres_virtual, fb_info.var.yres_virtual); if (register_framebuffer(&fb_info) < 0) { #ifdef ATAFB_EXT if (external_addr) { iounmap(external_addr); external_addr = NULL; } if (external_vgaiobase) { iounmap((void*)external_vgaiobase); external_vgaiobase = 0; } #endif return -EINVAL; } // FIXME: mode needs setting! //printk("fb%d: %s frame buffer device, using %dK of video memory\n", // fb_info.node, fb_info.mode->name, screen_len>>10); printk("fb%d: frame buffer device, using %dK of video memory\n", fb_info.node, screen_len >> 10); /* TODO: This driver cannot be unloaded yet */ return 0; } module_init(atafb_init); #ifdef MODULE MODULE_LICENSE("GPL"); int cleanup_module(void) { unregister_framebuffer(&fb_info); return atafb_deinit(); } #endif /* MODULE */
gpl-2.0
jfvelte-dev/android_kernel_samsung_jf
sound/pci/nm256/nm256_coef.c
14777
308064
#define NM_TOTAL_COEFF_COUNT 0x3158 static char coefficients[NM_TOTAL_COEFF_COUNT * 4] = { 0xFF, 0xFF, 0x2F, 0x00, 0x4B, 0xFF, 0xA5, 0x01, 0xEF, 0xFC, 0x21, 0x05, 0x87, 0xF7, 0x62, 0x11, 0xE9, 0x45, 0x5E, 0xF9, 0xB5, 0x01, 0xDE, 0xFF, 0xA4, 0xFF, 0x60, 0x00, 0xCA, 0xFF, 0x0D, 0x00, 0xFD, 0xFF, 0x36, 0x00, 0x36, 0xFF, 0xE6, 0x01, 0x3D, 0xFC, 0xD6, 0x06, 0x4C, 0xF3, 0xED, 0x20, 0x3D, 0x3D, 0x4A, 0xF3, 0x4E, 0x05, 0xB1, 0xFD, 0xE1, 0x00, 0xC3, 0xFF, 0x05, 0x00, 0x02, 0x00, 0xFD, 0xFF, 0x2A, 0x00, 0x5C, 0xFF, 0xAA, 0x01, 0x71, 0xFC, 0x07, 0x07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, 0xFC, 0x5F, 0x01, 0x9A, 0xFF, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xAD, 0xFF, 0x48, 0x01, 0xE2, 0xFC, 0xDA, 0x05, 0x97, 0xF6, 0x0B, 0x0F, 0x79, 0x42, 0xC7, 0x03, 0x9E, 0xFA, 0x71, 0x04, 0x28, 0xFD, 0x63, 0x01, 0x8D, 0xFF, 0x0F, 0x00 }; static u16 coefficient_sizes[8 * 2] = { /* Playback */ 0x00C0, 0x5000, 0x0060, 0x2800, 0x0040, 0x0060, 0x1400, 0x0000, /* capture */ 0x0020, 0x1260, 0x0020, 0x1260, 0x0000, 0x0040, 0x1260, 0x0000, };
gpl-2.0
babybearsg/huawei_s7_kernel
drivers/crypto/padlock-sha.c
186
8033
/* * Cryptographic API. * * Support for VIA PadLock hardware crypto engine. * * Copyright (c) 2006 Michal Ludvig <michal@logix.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; either version 2 of the License, or * (at your option) any later version. * */ #include <crypto/algapi.h> #include <crypto/sha.h> #include <linux/err.h> #include <linux/module.h> #include <linux/init.h> #include <linux/errno.h> #include <linux/cryptohash.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/scatterlist.h> #include <asm/i387.h> #include "padlock.h" #define SHA1_DEFAULT_FALLBACK "sha1-generic" #define SHA256_DEFAULT_FALLBACK "sha256-generic" struct padlock_sha_ctx { char *data; size_t used; int bypass; void (*f_sha_padlock)(const char *in, char *out, int count); struct hash_desc fallback; }; static inline struct padlock_sha_ctx *ctx(struct crypto_tfm *tfm) { return crypto_tfm_ctx(tfm); } /* We'll need aligned address on the stack */ #define NEAREST_ALIGNED(ptr) \ ((void *)ALIGN((size_t)(ptr), PADLOCK_ALIGNMENT)) static struct crypto_alg sha1_alg, sha256_alg; static void padlock_sha_bypass(struct crypto_tfm *tfm) { if (ctx(tfm)->bypass) return; crypto_hash_init(&ctx(tfm)->fallback); if (ctx(tfm)->data && ctx(tfm)->used) { struct scatterlist sg; sg_init_one(&sg, ctx(tfm)->data, ctx(tfm)->used); crypto_hash_update(&ctx(tfm)->fallback, &sg, sg.length); } ctx(tfm)->used = 0; ctx(tfm)->bypass = 1; } static void padlock_sha_init(struct crypto_tfm *tfm) { ctx(tfm)->used = 0; ctx(tfm)->bypass = 0; } static void padlock_sha_update(struct crypto_tfm *tfm, const uint8_t *data, unsigned int length) { /* Our buffer is always one page. */ if (unlikely(!ctx(tfm)->bypass && (ctx(tfm)->used + length > PAGE_SIZE))) padlock_sha_bypass(tfm); if (unlikely(ctx(tfm)->bypass)) { struct scatterlist sg; sg_init_one(&sg, (uint8_t *)data, length); crypto_hash_update(&ctx(tfm)->fallback, &sg, length); return; } memcpy(ctx(tfm)->data + ctx(tfm)->used, data, length); ctx(tfm)->used += length; } static inline void padlock_output_block(uint32_t *src, uint32_t *dst, size_t count) { while (count--) *dst++ = swab32(*src++); } static void padlock_do_sha1(const char *in, char *out, int count) { /* We can't store directly to *out as it may be unaligned. */ /* BTW Don't reduce the buffer size below 128 Bytes! * PadLock microcode needs it that big. */ char buf[128+16]; char *result = NEAREST_ALIGNED(buf); int ts_state; ((uint32_t *)result)[0] = SHA1_H0; ((uint32_t *)result)[1] = SHA1_H1; ((uint32_t *)result)[2] = SHA1_H2; ((uint32_t *)result)[3] = SHA1_H3; ((uint32_t *)result)[4] = SHA1_H4; /* prevent taking the spurious DNA fault with padlock. */ ts_state = irq_ts_save(); asm volatile (".byte 0xf3,0x0f,0xa6,0xc8" /* rep xsha1 */ : "+S"(in), "+D"(result) : "c"(count), "a"(0)); irq_ts_restore(ts_state); padlock_output_block((uint32_t *)result, (uint32_t *)out, 5); } static void padlock_do_sha256(const char *in, char *out, int count) { /* We can't store directly to *out as it may be unaligned. */ /* BTW Don't reduce the buffer size below 128 Bytes! * PadLock microcode needs it that big. */ char buf[128+16]; char *result = NEAREST_ALIGNED(buf); int ts_state; ((uint32_t *)result)[0] = SHA256_H0; ((uint32_t *)result)[1] = SHA256_H1; ((uint32_t *)result)[2] = SHA256_H2; ((uint32_t *)result)[3] = SHA256_H3; ((uint32_t *)result)[4] = SHA256_H4; ((uint32_t *)result)[5] = SHA256_H5; ((uint32_t *)result)[6] = SHA256_H6; ((uint32_t *)result)[7] = SHA256_H7; /* prevent taking the spurious DNA fault with padlock. */ ts_state = irq_ts_save(); asm volatile (".byte 0xf3,0x0f,0xa6,0xd0" /* rep xsha256 */ : "+S"(in), "+D"(result) : "c"(count), "a"(0)); irq_ts_restore(ts_state); padlock_output_block((uint32_t *)result, (uint32_t *)out, 8); } static void padlock_sha_final(struct crypto_tfm *tfm, uint8_t *out) { if (unlikely(ctx(tfm)->bypass)) { crypto_hash_final(&ctx(tfm)->fallback, out); ctx(tfm)->bypass = 0; return; } /* Pass the input buffer to PadLock microcode... */ ctx(tfm)->f_sha_padlock(ctx(tfm)->data, out, ctx(tfm)->used); ctx(tfm)->used = 0; } static int padlock_cra_init(struct crypto_tfm *tfm) { const char *fallback_driver_name = tfm->__crt_alg->cra_name; struct crypto_hash *fallback_tfm; /* For now we'll allocate one page. This * could eventually be configurable one day. */ ctx(tfm)->data = (char *)__get_free_page(GFP_KERNEL); if (!ctx(tfm)->data) return -ENOMEM; /* Allocate a fallback and abort if it failed. */ fallback_tfm = crypto_alloc_hash(fallback_driver_name, 0, CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK); if (IS_ERR(fallback_tfm)) { printk(KERN_WARNING PFX "Fallback driver '%s' could not be loaded!\n", fallback_driver_name); free_page((unsigned long)(ctx(tfm)->data)); return PTR_ERR(fallback_tfm); } ctx(tfm)->fallback.tfm = fallback_tfm; return 0; } static int padlock_sha1_cra_init(struct crypto_tfm *tfm) { ctx(tfm)->f_sha_padlock = padlock_do_sha1; return padlock_cra_init(tfm); } static int padlock_sha256_cra_init(struct crypto_tfm *tfm) { ctx(tfm)->f_sha_padlock = padlock_do_sha256; return padlock_cra_init(tfm); } static void padlock_cra_exit(struct crypto_tfm *tfm) { if (ctx(tfm)->data) { free_page((unsigned long)(ctx(tfm)->data)); ctx(tfm)->data = NULL; } crypto_free_hash(ctx(tfm)->fallback.tfm); ctx(tfm)->fallback.tfm = NULL; } static struct crypto_alg sha1_alg = { .cra_name = "sha1", .cra_driver_name = "sha1-padlock", .cra_priority = PADLOCK_CRA_PRIORITY, .cra_flags = CRYPTO_ALG_TYPE_DIGEST | CRYPTO_ALG_NEED_FALLBACK, .cra_blocksize = SHA1_BLOCK_SIZE, .cra_ctxsize = sizeof(struct padlock_sha_ctx), .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(sha1_alg.cra_list), .cra_init = padlock_sha1_cra_init, .cra_exit = padlock_cra_exit, .cra_u = { .digest = { .dia_digestsize = SHA1_DIGEST_SIZE, .dia_init = padlock_sha_init, .dia_update = padlock_sha_update, .dia_final = padlock_sha_final, } } }; static struct crypto_alg sha256_alg = { .cra_name = "sha256", .cra_driver_name = "sha256-padlock", .cra_priority = PADLOCK_CRA_PRIORITY, .cra_flags = CRYPTO_ALG_TYPE_DIGEST | CRYPTO_ALG_NEED_FALLBACK, .cra_blocksize = SHA256_BLOCK_SIZE, .cra_ctxsize = sizeof(struct padlock_sha_ctx), .cra_module = THIS_MODULE, .cra_list = LIST_HEAD_INIT(sha256_alg.cra_list), .cra_init = padlock_sha256_cra_init, .cra_exit = padlock_cra_exit, .cra_u = { .digest = { .dia_digestsize = SHA256_DIGEST_SIZE, .dia_init = padlock_sha_init, .dia_update = padlock_sha_update, .dia_final = padlock_sha_final, } } }; static int __init padlock_init(void) { int rc = -ENODEV; if (!cpu_has_phe) { printk(KERN_NOTICE PFX "VIA PadLock Hash Engine not detected.\n"); return -ENODEV; } if (!cpu_has_phe_enabled) { printk(KERN_NOTICE PFX "VIA PadLock detected, but not enabled. Hmm, strange...\n"); return -ENODEV; } rc = crypto_register_alg(&sha1_alg); if (rc) goto out; rc = crypto_register_alg(&sha256_alg); if (rc) goto out_unreg1; printk(KERN_NOTICE PFX "Using VIA PadLock ACE for SHA1/SHA256 algorithms.\n"); return 0; out_unreg1: crypto_unregister_alg(&sha1_alg); out: printk(KERN_ERR PFX "VIA PadLock SHA1/SHA256 initialization failed.\n"); return rc; } static void __exit padlock_fini(void) { crypto_unregister_alg(&sha1_alg); crypto_unregister_alg(&sha256_alg); } module_init(padlock_init); module_exit(padlock_fini); MODULE_DESCRIPTION("VIA PadLock SHA1/SHA256 algorithms support."); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Michal Ludvig"); MODULE_ALIAS("sha1-all"); MODULE_ALIAS("sha256-all"); MODULE_ALIAS("sha1-padlock"); MODULE_ALIAS("sha256-padlock");
gpl-2.0
abeobk/sam9x35
net/mac802154/main.c
186
6275
/* * Copyright (C) 2007-2012 Siemens AG * * Written by: * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/netdevice.h> #include <net/netlink.h> #include <net/nl802154.h> #include <net/mac802154.h> #include <net/ieee802154_netdev.h> #include <net/route.h> #include <net/cfg802154.h> #include "ieee802154_i.h" #include "cfg.h" static void ieee802154_tasklet_handler(unsigned long data) { struct ieee802154_local *local = (struct ieee802154_local *)data; struct sk_buff *skb; while ((skb = skb_dequeue(&local->skb_queue))) { switch (skb->pkt_type) { case IEEE802154_RX_MSG: /* Clear skb->pkt_type in order to not confuse kernel * netstack. */ skb->pkt_type = 0; ieee802154_rx(&local->hw, skb); break; default: WARN(1, "mac802154: Packet is of unknown type %d\n", skb->pkt_type); kfree_skb(skb); break; } } } struct ieee802154_hw * ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops) { struct wpan_phy *phy; struct ieee802154_local *local; size_t priv_size; if (!ops || !(ops->xmit_async || ops->xmit_sync) || !ops->ed || !ops->start || !ops->stop || !ops->set_channel) { pr_err("undefined IEEE802.15.4 device operations\n"); return NULL; } /* Ensure 32-byte alignment of our private data and hw private data. * We use the wpan_phy priv data for both our ieee802154_local and for * the driver's private data * * in memory it'll be like this: * * +-------------------------+ * | struct wpan_phy | * +-------------------------+ * | struct ieee802154_local | * +-------------------------+ * | driver's private data | * +-------------------------+ * * Due to ieee802154 layer isn't aware of driver and MAC structures, * so lets align them here. */ priv_size = ALIGN(sizeof(*local), NETDEV_ALIGN) + priv_data_len; phy = wpan_phy_new(&mac802154_config_ops, priv_size); if (!phy) { pr_err("failure to allocate master IEEE802.15.4 device\n"); return NULL; } phy->privid = mac802154_wpan_phy_privid; local = wpan_phy_priv(phy); local->phy = phy; local->hw.phy = local->phy; local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN); local->ops = ops; INIT_LIST_HEAD(&local->interfaces); mutex_init(&local->iflist_mtx); tasklet_init(&local->tasklet, ieee802154_tasklet_handler, (unsigned long)local); skb_queue_head_init(&local->skb_queue); /* init supported flags with 802.15.4 default ranges */ phy->supported.max_minbe = 8; phy->supported.min_maxbe = 3; phy->supported.max_maxbe = 8; phy->supported.min_frame_retries = -1; phy->supported.max_frame_retries = 7; phy->supported.max_csma_backoffs = 5; phy->supported.lbt = NL802154_SUPPORTED_BOOL_FALSE; /* always supported */ phy->supported.iftypes = BIT(NL802154_IFTYPE_NODE); return &local->hw; } EXPORT_SYMBOL(ieee802154_alloc_hw); void ieee802154_free_hw(struct ieee802154_hw *hw) { struct ieee802154_local *local = hw_to_local(hw); BUG_ON(!list_empty(&local->interfaces)); mutex_destroy(&local->iflist_mtx); wpan_phy_free(local->phy); } EXPORT_SYMBOL(ieee802154_free_hw); static void ieee802154_setup_wpan_phy_pib(struct wpan_phy *wpan_phy) { /* TODO warn on empty symbol_duration * Should be done when all drivers sets this value. */ wpan_phy->lifs_period = IEEE802154_LIFS_PERIOD * wpan_phy->symbol_duration; wpan_phy->sifs_period = IEEE802154_SIFS_PERIOD * wpan_phy->symbol_duration; } int ieee802154_register_hw(struct ieee802154_hw *hw) { struct ieee802154_local *local = hw_to_local(hw); struct net_device *dev; int rc = -ENOSYS; local->workqueue = create_singlethread_workqueue(wpan_phy_name(local->phy)); if (!local->workqueue) { rc = -ENOMEM; goto out; } hrtimer_init(&local->ifs_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); local->ifs_timer.function = ieee802154_xmit_ifs_timer; wpan_phy_set_dev(local->phy, local->hw.parent); ieee802154_setup_wpan_phy_pib(local->phy); if (!(hw->flags & IEEE802154_HW_CSMA_PARAMS)) { local->phy->supported.min_csma_backoffs = 4; local->phy->supported.max_csma_backoffs = 4; local->phy->supported.min_maxbe = 5; local->phy->supported.max_maxbe = 5; local->phy->supported.min_minbe = 3; local->phy->supported.max_minbe = 3; } if (!(hw->flags & IEEE802154_HW_FRAME_RETRIES)) { /* TODO should be 3, but our default value is -1 which means * no ARET handling. */ local->phy->supported.min_frame_retries = -1; local->phy->supported.max_frame_retries = -1; } if (hw->flags & IEEE802154_HW_PROMISCUOUS) local->phy->supported.iftypes |= BIT(NL802154_IFTYPE_MONITOR); rc = wpan_phy_register(local->phy); if (rc < 0) goto out_wq; rtnl_lock(); dev = ieee802154_if_add(local, "wpan%d", NET_NAME_ENUM, NL802154_IFTYPE_NODE, cpu_to_le64(0x0000000000000000ULL)); if (IS_ERR(dev)) { rtnl_unlock(); rc = PTR_ERR(dev); goto out_phy; } rtnl_unlock(); return 0; out_phy: wpan_phy_unregister(local->phy); out_wq: destroy_workqueue(local->workqueue); out: return rc; } EXPORT_SYMBOL(ieee802154_register_hw); void ieee802154_unregister_hw(struct ieee802154_hw *hw) { struct ieee802154_local *local = hw_to_local(hw); tasklet_kill(&local->tasklet); flush_workqueue(local->workqueue); destroy_workqueue(local->workqueue); rtnl_lock(); ieee802154_remove_interfaces(local); rtnl_unlock(); wpan_phy_unregister(local->phy); } EXPORT_SYMBOL(ieee802154_unregister_hw); static int __init ieee802154_init(void) { return ieee802154_iface_init(); } static void __exit ieee802154_exit(void) { ieee802154_iface_exit(); rcu_barrier(); } subsys_initcall(ieee802154_init); module_exit(ieee802154_exit); MODULE_DESCRIPTION("IEEE 802.15.4 subsystem"); MODULE_LICENSE("GPL v2");
gpl-2.0
lg-devs/android_kernel_lge_msm8994
kernel/trace/blktrace.c
698
44914
/* * Copyright (C) 2006 Jens Axboe <axboe@kernel.dk> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include <linux/kernel.h> #include <linux/blkdev.h> #include <linux/blktrace_api.h> #include <linux/percpu.h> #include <linux/init.h> #include <linux/mutex.h> #include <linux/slab.h> #include <linux/debugfs.h> #include <linux/export.h> #include <linux/time.h> #include <linux/uaccess.h> #include <trace/events/block.h> #include "trace_output.h" #ifdef CONFIG_BLK_DEV_IO_TRACE static unsigned int blktrace_seq __read_mostly = 1; static struct trace_array *blk_tr; static bool blk_tracer_enabled __read_mostly; /* Select an alternative, minimalistic output than the original one */ #define TRACE_BLK_OPT_CLASSIC 0x1 static struct tracer_opt blk_tracer_opts[] = { /* Default disable the minimalistic output */ { TRACER_OPT(blk_classic, TRACE_BLK_OPT_CLASSIC) }, { } }; static struct tracer_flags blk_tracer_flags = { .val = 0, .opts = blk_tracer_opts, }; /* Global reference count of probes */ static atomic_t blk_probes_ref = ATOMIC_INIT(0); static void blk_register_tracepoints(void); static void blk_unregister_tracepoints(void); /* * Send out a notify message. */ static void trace_note(struct blk_trace *bt, pid_t pid, int action, const void *data, size_t len) { struct blk_io_trace *t; struct ring_buffer_event *event = NULL; struct ring_buffer *buffer = NULL; int pc = 0; int cpu = smp_processor_id(); bool blk_tracer = blk_tracer_enabled; if (blk_tracer) { buffer = blk_tr->trace_buffer.buffer; pc = preempt_count(); event = trace_buffer_lock_reserve(buffer, TRACE_BLK, sizeof(*t) + len, 0, pc); if (!event) return; t = ring_buffer_event_data(event); goto record_it; } if (!bt->rchan) return; t = relay_reserve(bt->rchan, sizeof(*t) + len); if (t) { t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION; t->time = ktime_to_ns(ktime_get()); record_it: t->device = bt->dev; t->action = action; t->pid = pid; t->cpu = cpu; t->pdu_len = len; memcpy((void *) t + sizeof(*t), data, len); if (blk_tracer) trace_buffer_unlock_commit(buffer, event, 0, pc); } } /* * Send out a notify for this process, if we haven't done so since a trace * started */ static void trace_note_tsk(struct blk_trace *bt, struct task_struct *tsk) { tsk->btrace_seq = blktrace_seq; trace_note(bt, tsk->pid, BLK_TN_PROCESS, tsk->comm, sizeof(tsk->comm)); } static void trace_note_time(struct blk_trace *bt) { struct timespec now; unsigned long flags; u32 words[2]; getnstimeofday(&now); words[0] = now.tv_sec; words[1] = now.tv_nsec; local_irq_save(flags); trace_note(bt, 0, BLK_TN_TIMESTAMP, words, sizeof(words)); local_irq_restore(flags); } void __trace_note_message(struct blk_trace *bt, const char *fmt, ...) { int n; va_list args; unsigned long flags; char *buf; if (unlikely(bt->trace_state != Blktrace_running && !blk_tracer_enabled)) return; /* * If the BLK_TC_NOTIFY action mask isn't set, don't send any note * message to the trace. */ if (!(bt->act_mask & BLK_TC_NOTIFY)) return; local_irq_save(flags); buf = this_cpu_ptr(bt->msg_data); va_start(args, fmt); n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args); va_end(args); trace_note(bt, 0, BLK_TN_MESSAGE, buf, n); local_irq_restore(flags); } EXPORT_SYMBOL_GPL(__trace_note_message); static int act_log_check(struct blk_trace *bt, u32 what, sector_t sector, pid_t pid) { if (((bt->act_mask << BLK_TC_SHIFT) & what) == 0) return 1; if (sector && (sector < bt->start_lba || sector > bt->end_lba)) return 1; if (bt->pid && pid != bt->pid) return 1; return 0; } /* * Data direction bit lookup */ static const u32 ddir_act[2] = { BLK_TC_ACT(BLK_TC_READ), BLK_TC_ACT(BLK_TC_WRITE) }; #define BLK_TC_RAHEAD BLK_TC_AHEAD /* The ilog2() calls fall out because they're constant */ #define MASK_TC_BIT(rw, __name) ((rw & REQ_ ## __name) << \ (ilog2(BLK_TC_ ## __name) + BLK_TC_SHIFT - __REQ_ ## __name)) /* * The worker for the various blk_add_trace*() types. Fills out a * blk_io_trace structure and places it in a per-cpu subbuffer. */ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, int rw, u32 what, int error, int pdu_len, void *pdu_data, struct task_struct *tsk) { struct ring_buffer_event *event = NULL; struct ring_buffer *buffer = NULL; struct blk_io_trace *t; unsigned long flags = 0; unsigned long *sequence; pid_t pid; int cpu, pc = 0; bool blk_tracer = blk_tracer_enabled; if (unlikely(bt->trace_state != Blktrace_running && !blk_tracer)) return; what |= ddir_act[rw & WRITE]; what |= MASK_TC_BIT(rw, SYNC); what |= MASK_TC_BIT(rw, RAHEAD); what |= MASK_TC_BIT(rw, META); what |= MASK_TC_BIT(rw, DISCARD); what |= MASK_TC_BIT(rw, FLUSH); what |= MASK_TC_BIT(rw, FUA); pid = tsk->pid; if (act_log_check(bt, what, sector, pid)) return; cpu = raw_smp_processor_id(); if (blk_tracer) { tracing_record_cmdline(current); buffer = blk_tr->trace_buffer.buffer; pc = preempt_count(); event = trace_buffer_lock_reserve(buffer, TRACE_BLK, sizeof(*t) + pdu_len, 0, pc); if (!event) return; t = ring_buffer_event_data(event); goto record_it; } /* * A word about the locking here - we disable interrupts to reserve * some space in the relay per-cpu buffer, to prevent an irq * from coming in and stepping on our toes. */ local_irq_save(flags); if (unlikely(tsk->btrace_seq != blktrace_seq)) trace_note_tsk(bt, tsk); t = relay_reserve(bt->rchan, sizeof(*t) + pdu_len); if (t) { sequence = per_cpu_ptr(bt->sequence, cpu); t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION; t->sequence = ++(*sequence); t->time = ktime_to_ns(ktime_get()); record_it: /* * These two are not needed in ftrace as they are in the * generic trace_entry, filled by tracing_generic_entry_update, * but for the trace_event->bin() synthesizer benefit we do it * here too. */ t->cpu = cpu; t->pid = pid; t->sector = sector; t->bytes = bytes; t->action = what; t->device = bt->dev; t->error = error; t->pdu_len = pdu_len; if (pdu_len) memcpy((void *) t + sizeof(*t), pdu_data, pdu_len); if (blk_tracer) { trace_buffer_unlock_commit(buffer, event, 0, pc); return; } } local_irq_restore(flags); } static struct dentry *blk_tree_root; static DEFINE_MUTEX(blk_tree_mutex); static void blk_trace_free(struct blk_trace *bt) { debugfs_remove(bt->msg_file); debugfs_remove(bt->dropped_file); relay_close(bt->rchan); debugfs_remove(bt->dir); free_percpu(bt->sequence); free_percpu(bt->msg_data); kfree(bt); } static void blk_trace_cleanup(struct blk_trace *bt) { blk_trace_free(bt); if (atomic_dec_and_test(&blk_probes_ref)) blk_unregister_tracepoints(); } int blk_trace_remove(struct request_queue *q) { struct blk_trace *bt; bt = xchg(&q->blk_trace, NULL); if (!bt) return -EINVAL; if (bt->trace_state != Blktrace_running) blk_trace_cleanup(bt); return 0; } EXPORT_SYMBOL_GPL(blk_trace_remove); static ssize_t blk_dropped_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos) { struct blk_trace *bt = filp->private_data; char buf[16]; snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped)); return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf)); } static const struct file_operations blk_dropped_fops = { .owner = THIS_MODULE, .open = simple_open, .read = blk_dropped_read, .llseek = default_llseek, }; static ssize_t blk_msg_write(struct file *filp, const char __user *buffer, size_t count, loff_t *ppos) { char *msg; struct blk_trace *bt; if (count >= BLK_TN_MAX_MSG) return -EINVAL; msg = kmalloc(count + 1, GFP_KERNEL); if (msg == NULL) return -ENOMEM; if (copy_from_user(msg, buffer, count)) { kfree(msg); return -EFAULT; } msg[count] = '\0'; bt = filp->private_data; __trace_note_message(bt, "%s", msg); kfree(msg); return count; } static const struct file_operations blk_msg_fops = { .owner = THIS_MODULE, .open = simple_open, .write = blk_msg_write, .llseek = noop_llseek, }; /* * Keep track of how many times we encountered a full subbuffer, to aid * the user space app in telling how many lost events there were. */ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf, void *prev_subbuf, size_t prev_padding) { struct blk_trace *bt; if (!relay_buf_full(buf)) return 1; bt = buf->chan->private_data; atomic_inc(&bt->dropped); return 0; } static int blk_remove_buf_file_callback(struct dentry *dentry) { debugfs_remove(dentry); return 0; } static struct dentry *blk_create_buf_file_callback(const char *filename, struct dentry *parent, umode_t mode, struct rchan_buf *buf, int *is_global) { return debugfs_create_file(filename, mode, parent, buf, &relay_file_operations); } static struct rchan_callbacks blk_relay_callbacks = { .subbuf_start = blk_subbuf_start_callback, .create_buf_file = blk_create_buf_file_callback, .remove_buf_file = blk_remove_buf_file_callback, }; static void blk_trace_setup_lba(struct blk_trace *bt, struct block_device *bdev) { struct hd_struct *part = NULL; if (bdev) part = bdev->bd_part; if (part) { bt->start_lba = part->start_sect; bt->end_lba = part->start_sect + part->nr_sects; } else { bt->start_lba = 0; bt->end_lba = -1ULL; } } /* * Setup everything required to start tracing */ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, struct block_device *bdev, struct blk_user_trace_setup *buts) { struct blk_trace *old_bt, *bt = NULL; struct dentry *dir = NULL; int ret, i; if (!buts->buf_size || !buts->buf_nr) return -EINVAL; strncpy(buts->name, name, BLKTRACE_BDEV_SIZE); buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0'; /* * some device names have larger paths - convert the slashes * to underscores for this to work as expected */ for (i = 0; i < strlen(buts->name); i++) if (buts->name[i] == '/') buts->name[i] = '_'; bt = kzalloc(sizeof(*bt), GFP_KERNEL); if (!bt) return -ENOMEM; ret = -ENOMEM; bt->sequence = alloc_percpu(unsigned long); if (!bt->sequence) goto err; bt->msg_data = __alloc_percpu(BLK_TN_MAX_MSG, __alignof__(char)); if (!bt->msg_data) goto err; ret = -ENOENT; mutex_lock(&blk_tree_mutex); if (!blk_tree_root) { blk_tree_root = debugfs_create_dir("block", NULL); if (!blk_tree_root) { mutex_unlock(&blk_tree_mutex); goto err; } } mutex_unlock(&blk_tree_mutex); dir = debugfs_create_dir(buts->name, blk_tree_root); if (!dir) goto err; bt->dir = dir; bt->dev = dev; atomic_set(&bt->dropped, 0); ret = -EIO; bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt, &blk_dropped_fops); if (!bt->dropped_file) goto err; bt->msg_file = debugfs_create_file("msg", 0222, dir, bt, &blk_msg_fops); if (!bt->msg_file) goto err; bt->rchan = relay_open("trace", dir, buts->buf_size, buts->buf_nr, &blk_relay_callbacks, bt); if (!bt->rchan) goto err; bt->act_mask = buts->act_mask; if (!bt->act_mask) bt->act_mask = (u16) -1; blk_trace_setup_lba(bt, bdev); /* overwrite with user settings */ if (buts->start_lba) bt->start_lba = buts->start_lba; if (buts->end_lba) bt->end_lba = buts->end_lba; bt->pid = buts->pid; bt->trace_state = Blktrace_setup; ret = -EBUSY; old_bt = xchg(&q->blk_trace, bt); if (old_bt) { (void) xchg(&q->blk_trace, old_bt); goto err; } if (atomic_inc_return(&blk_probes_ref) == 1) blk_register_tracepoints(); return 0; err: blk_trace_free(bt); return ret; } int blk_trace_setup(struct request_queue *q, char *name, dev_t dev, struct block_device *bdev, char __user *arg) { struct blk_user_trace_setup buts; int ret; ret = copy_from_user(&buts, arg, sizeof(buts)); if (ret) return -EFAULT; ret = do_blk_trace_setup(q, name, dev, bdev, &buts); if (ret) return ret; if (copy_to_user(arg, &buts, sizeof(buts))) { blk_trace_remove(q); return -EFAULT; } return 0; } EXPORT_SYMBOL_GPL(blk_trace_setup); #if defined(CONFIG_COMPAT) && defined(CONFIG_X86_64) static int compat_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, struct block_device *bdev, char __user *arg) { struct blk_user_trace_setup buts; struct compat_blk_user_trace_setup cbuts; int ret; if (copy_from_user(&cbuts, arg, sizeof(cbuts))) return -EFAULT; buts = (struct blk_user_trace_setup) { .act_mask = cbuts.act_mask, .buf_size = cbuts.buf_size, .buf_nr = cbuts.buf_nr, .start_lba = cbuts.start_lba, .end_lba = cbuts.end_lba, .pid = cbuts.pid, }; memcpy(&buts.name, &cbuts.name, 32); ret = do_blk_trace_setup(q, name, dev, bdev, &buts); if (ret) return ret; if (copy_to_user(arg, &buts.name, 32)) { blk_trace_remove(q); return -EFAULT; } return 0; } #endif int blk_trace_startstop(struct request_queue *q, int start) { int ret; struct blk_trace *bt = q->blk_trace; if (bt == NULL) return -EINVAL; /* * For starting a trace, we can transition from a setup or stopped * trace. For stopping a trace, the state must be running */ ret = -EINVAL; if (start) { if (bt->trace_state == Blktrace_setup || bt->trace_state == Blktrace_stopped) { blktrace_seq++; smp_mb(); bt->trace_state = Blktrace_running; trace_note_time(bt); ret = 0; } } else { if (bt->trace_state == Blktrace_running) { bt->trace_state = Blktrace_stopped; relay_flush(bt->rchan); ret = 0; } } return ret; } EXPORT_SYMBOL_GPL(blk_trace_startstop); /** * blk_trace_ioctl: - handle the ioctls associated with tracing * @bdev: the block device * @cmd: the ioctl cmd * @arg: the argument data, if any * **/ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg) { struct request_queue *q; int ret, start = 0; char b[BDEVNAME_SIZE]; q = bdev_get_queue(bdev); if (!q) return -ENXIO; mutex_lock(&bdev->bd_mutex); switch (cmd) { case BLKTRACESETUP: bdevname(bdev, b); ret = blk_trace_setup(q, b, bdev->bd_dev, bdev, arg); break; #if defined(CONFIG_COMPAT) && defined(CONFIG_X86_64) case BLKTRACESETUP32: bdevname(bdev, b); ret = compat_blk_trace_setup(q, b, bdev->bd_dev, bdev, arg); break; #endif case BLKTRACESTART: start = 1; case BLKTRACESTOP: ret = blk_trace_startstop(q, start); break; case BLKTRACETEARDOWN: ret = blk_trace_remove(q); break; default: ret = -ENOTTY; break; } mutex_unlock(&bdev->bd_mutex); return ret; } /** * blk_trace_shutdown: - stop and cleanup trace structures * @q: the request queue associated with the device * **/ void blk_trace_shutdown(struct request_queue *q) { if (q->blk_trace) { blk_trace_startstop(q, 0); blk_trace_remove(q); } } /* * blktrace probes */ /** * blk_add_trace_rq - Add a trace for a request oriented action * @q: queue the io is for * @rq: the source request * @nr_bytes: number of completed bytes * @what: the action * * Description: * Records an action against a request. Will log the bio offset + size. * **/ static void blk_add_trace_rq(struct request_queue *q, struct request *rq, unsigned int nr_bytes, u32 what) { struct blk_trace *bt = q->blk_trace; struct task_struct *tsk = current; if (likely(!bt)) return; /* * Use the bio context for all events except ISSUE and * COMPLETE events. * * Not all the pages in the bio are dirtied by the same task but * most likely it will be, since the sectors accessed on the device * must be adjacent. */ if (!((what == BLK_TA_ISSUE) || (what == BLK_TA_COMPLETE)) && bio_has_data(rq->bio) && rq->bio->bi_io_vec && rq->bio->bi_io_vec->bv_page && rq->bio->bi_io_vec->bv_page->tsk_dirty) tsk = rq->bio->bi_io_vec->bv_page->tsk_dirty; if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { what |= BLK_TC_ACT(BLK_TC_PC); __blk_add_trace(bt, 0, nr_bytes, rq->cmd_flags, what, rq->errors, rq->cmd_len, rq->cmd, tsk); } else { what |= BLK_TC_ACT(BLK_TC_FS); __blk_add_trace(bt, blk_rq_pos(rq), nr_bytes, rq->cmd_flags, what, rq->errors, 0, NULL, tsk); } } static void blk_add_trace_rq_abort(void *ignore, struct request_queue *q, struct request *rq) { blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_ABORT); } static void blk_add_trace_rq_insert(void *ignore, struct request_queue *q, struct request *rq) { blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_INSERT); } static void blk_add_trace_rq_issue(void *ignore, struct request_queue *q, struct request *rq) { blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_ISSUE); } static void blk_add_trace_rq_requeue(void *ignore, struct request_queue *q, struct request *rq) { blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_REQUEUE); } static void blk_add_trace_rq_complete(void *ignore, struct request_queue *q, struct request *rq, unsigned int nr_bytes) { blk_add_trace_rq(q, rq, nr_bytes, BLK_TA_COMPLETE); } /** * blk_add_trace_bio - Add a trace for a bio oriented action * @q: queue the io is for * @bio: the source bio * @what: the action * @error: error, if any * * Description: * Records an action against a bio. Will log the bio offset + size. * **/ static void blk_add_trace_bio(struct request_queue *q, struct bio *bio, u32 what, int error) { struct blk_trace *bt = q->blk_trace; struct task_struct *tsk = current; if (likely(!bt)) return; /* * Not all the pages in the bio are dirtied by the same task but * most likely it will be, since the sectors accessed on the device * must be adjacent. */ if (bio_has_data(bio) && bio->bi_io_vec && bio->bi_io_vec->bv_page && bio->bi_io_vec->bv_page->tsk_dirty) tsk = bio->bi_io_vec->bv_page->tsk_dirty; if (!error && !bio_flagged(bio, BIO_UPTODATE)) error = EIO; __blk_add_trace(bt, bio->bi_sector, bio->bi_size, bio->bi_rw, what, error, 0, NULL, tsk); } static void blk_add_trace_bio_bounce(void *ignore, struct request_queue *q, struct bio *bio) { blk_add_trace_bio(q, bio, BLK_TA_BOUNCE, 0); } static void blk_add_trace_bio_complete(void *ignore, struct request_queue *q, struct bio *bio, int error) { blk_add_trace_bio(q, bio, BLK_TA_COMPLETE, error); } static void blk_add_trace_bio_backmerge(void *ignore, struct request_queue *q, struct request *rq, struct bio *bio) { blk_add_trace_bio(q, bio, BLK_TA_BACKMERGE, 0); } static void blk_add_trace_bio_frontmerge(void *ignore, struct request_queue *q, struct request *rq, struct bio *bio) { blk_add_trace_bio(q, bio, BLK_TA_FRONTMERGE, 0); } static void blk_add_trace_bio_queue(void *ignore, struct request_queue *q, struct bio *bio) { blk_add_trace_bio(q, bio, BLK_TA_QUEUE, 0); } static void blk_add_trace_getrq(void *ignore, struct request_queue *q, struct bio *bio, int rw) { if (bio) blk_add_trace_bio(q, bio, BLK_TA_GETRQ, 0); else { struct blk_trace *bt = q->blk_trace; if (bt) __blk_add_trace(bt, 0, 0, rw, BLK_TA_GETRQ, 0, 0, NULL, current); } } static void blk_add_trace_sleeprq(void *ignore, struct request_queue *q, struct bio *bio, int rw) { if (bio) blk_add_trace_bio(q, bio, BLK_TA_SLEEPRQ, 0); else { struct blk_trace *bt = q->blk_trace; if (bt) __blk_add_trace(bt, 0, 0, rw, BLK_TA_SLEEPRQ, 0, 0, NULL, current); } } static void blk_add_trace_plug(void *ignore, struct request_queue *q) { struct blk_trace *bt = q->blk_trace; if (bt) __blk_add_trace(bt, 0, 0, 0, BLK_TA_PLUG, 0, 0, NULL, current); } static void blk_add_trace_unplug(void *ignore, struct request_queue *q, unsigned int depth, bool explicit) { struct blk_trace *bt = q->blk_trace; if (bt) { __be64 rpdu = cpu_to_be64(depth); u32 what; if (explicit) what = BLK_TA_UNPLUG_IO; else what = BLK_TA_UNPLUG_TIMER; __blk_add_trace(bt, 0, 0, 0, what, 0, sizeof(rpdu), &rpdu, current); } } static void blk_add_trace_split(void *ignore, struct request_queue *q, struct bio *bio, unsigned int pdu) { struct blk_trace *bt = q->blk_trace; struct task_struct *tsk = current; if (bt) { __be64 rpdu = cpu_to_be64(pdu); if (bio_has_data(bio) && bio->bi_io_vec && bio->bi_io_vec->bv_page && bio->bi_io_vec->bv_page->tsk_dirty) tsk = bio->bi_io_vec->bv_page->tsk_dirty; __blk_add_trace(bt, bio->bi_sector, bio->bi_size, bio->bi_rw, BLK_TA_SPLIT, !bio_flagged(bio, BIO_UPTODATE), sizeof(rpdu), &rpdu, tsk); } } /** * blk_add_trace_bio_remap - Add a trace for a bio-remap operation * @ignore: trace callback data parameter (not used) * @q: queue the io is for * @bio: the source bio * @dev: target device * @from: source sector * * Description: * Device mapper or raid target sometimes need to split a bio because * it spans a stripe (or similar). Add a trace for that action. * **/ static void blk_add_trace_bio_remap(void *ignore, struct request_queue *q, struct bio *bio, dev_t dev, sector_t from) { struct blk_trace *bt = q->blk_trace; struct blk_io_trace_remap r; struct task_struct *tsk = current; if (likely(!bt)) return; r.device_from = cpu_to_be32(dev); r.device_to = cpu_to_be32(bio->bi_bdev->bd_dev); r.sector_from = cpu_to_be64(from); if (bio_has_data(bio) && bio->bi_io_vec && bio->bi_io_vec->bv_page && bio->bi_io_vec->bv_page->tsk_dirty) tsk = bio->bi_io_vec->bv_page->tsk_dirty; __blk_add_trace(bt, bio->bi_sector, bio->bi_size, bio->bi_rw, BLK_TA_REMAP, !bio_flagged(bio, BIO_UPTODATE), sizeof(r), &r, tsk); } /** * blk_add_trace_rq_remap - Add a trace for a request-remap operation * @ignore: trace callback data parameter (not used) * @q: queue the io is for * @rq: the source request * @dev: target device * @from: source sector * * Description: * Device mapper remaps request to other devices. * Add a trace for that action. * **/ static void blk_add_trace_rq_remap(void *ignore, struct request_queue *q, struct request *rq, dev_t dev, sector_t from) { struct blk_trace *bt = q->blk_trace; struct blk_io_trace_remap r; struct task_struct *tsk = current; if (likely(!bt)) return; r.device_from = cpu_to_be32(dev); r.device_to = cpu_to_be32(disk_devt(rq->rq_disk)); r.sector_from = cpu_to_be64(from); if (bio_has_data(rq->bio) && rq->bio->bi_io_vec && rq->bio->bi_io_vec->bv_page && rq->bio->bi_io_vec->bv_page->tsk_dirty) tsk = rq->bio->bi_io_vec->bv_page->tsk_dirty; __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq), rq_data_dir(rq), BLK_TA_REMAP, !!rq->errors, sizeof(r), &r, tsk); } /** * blk_add_driver_data - Add binary message with driver-specific data * @q: queue the io is for * @rq: io request * @data: driver-specific data * @len: length of driver-specific data * * Description: * Some drivers might want to write driver-specific data per request. * **/ void blk_add_driver_data(struct request_queue *q, struct request *rq, void *data, size_t len) { struct blk_trace *bt = q->blk_trace; struct task_struct *tsk = current; if (likely(!bt)) return; if (bio_has_data(rq->bio) && rq->bio->bi_io_vec && rq->bio->bi_io_vec->bv_page && rq->bio->bi_io_vec->bv_page->tsk_dirty) tsk = rq->bio->bi_io_vec->bv_page->tsk_dirty; if (rq->cmd_type == REQ_TYPE_BLOCK_PC) __blk_add_trace(bt, 0, blk_rq_bytes(rq), 0, BLK_TA_DRV_DATA, rq->errors, len, data, tsk); else __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq), 0, BLK_TA_DRV_DATA, rq->errors, len, data, tsk); } EXPORT_SYMBOL_GPL(blk_add_driver_data); static void blk_register_tracepoints(void) { int ret; ret = register_trace_block_rq_abort(blk_add_trace_rq_abort, NULL); WARN_ON(ret); ret = register_trace_block_rq_insert(blk_add_trace_rq_insert, NULL); WARN_ON(ret); ret = register_trace_block_rq_issue(blk_add_trace_rq_issue, NULL); WARN_ON(ret); ret = register_trace_block_rq_requeue(blk_add_trace_rq_requeue, NULL); WARN_ON(ret); ret = register_trace_block_rq_complete(blk_add_trace_rq_complete, NULL); WARN_ON(ret); ret = register_trace_block_bio_bounce(blk_add_trace_bio_bounce, NULL); WARN_ON(ret); ret = register_trace_block_bio_complete(blk_add_trace_bio_complete, NULL); WARN_ON(ret); ret = register_trace_block_bio_backmerge(blk_add_trace_bio_backmerge, NULL); WARN_ON(ret); ret = register_trace_block_bio_frontmerge(blk_add_trace_bio_frontmerge, NULL); WARN_ON(ret); ret = register_trace_block_bio_queue(blk_add_trace_bio_queue, NULL); WARN_ON(ret); ret = register_trace_block_getrq(blk_add_trace_getrq, NULL); WARN_ON(ret); ret = register_trace_block_sleeprq(blk_add_trace_sleeprq, NULL); WARN_ON(ret); ret = register_trace_block_plug(blk_add_trace_plug, NULL); WARN_ON(ret); ret = register_trace_block_unplug(blk_add_trace_unplug, NULL); WARN_ON(ret); ret = register_trace_block_split(blk_add_trace_split, NULL); WARN_ON(ret); ret = register_trace_block_bio_remap(blk_add_trace_bio_remap, NULL); WARN_ON(ret); ret = register_trace_block_rq_remap(blk_add_trace_rq_remap, NULL); WARN_ON(ret); } static void blk_unregister_tracepoints(void) { unregister_trace_block_rq_remap(blk_add_trace_rq_remap, NULL); unregister_trace_block_bio_remap(blk_add_trace_bio_remap, NULL); unregister_trace_block_split(blk_add_trace_split, NULL); unregister_trace_block_unplug(blk_add_trace_unplug, NULL); unregister_trace_block_plug(blk_add_trace_plug, NULL); unregister_trace_block_sleeprq(blk_add_trace_sleeprq, NULL); unregister_trace_block_getrq(blk_add_trace_getrq, NULL); unregister_trace_block_bio_queue(blk_add_trace_bio_queue, NULL); unregister_trace_block_bio_frontmerge(blk_add_trace_bio_frontmerge, NULL); unregister_trace_block_bio_backmerge(blk_add_trace_bio_backmerge, NULL); unregister_trace_block_bio_complete(blk_add_trace_bio_complete, NULL); unregister_trace_block_bio_bounce(blk_add_trace_bio_bounce, NULL); unregister_trace_block_rq_complete(blk_add_trace_rq_complete, NULL); unregister_trace_block_rq_requeue(blk_add_trace_rq_requeue, NULL); unregister_trace_block_rq_issue(blk_add_trace_rq_issue, NULL); unregister_trace_block_rq_insert(blk_add_trace_rq_insert, NULL); unregister_trace_block_rq_abort(blk_add_trace_rq_abort, NULL); tracepoint_synchronize_unregister(); } /* * struct blk_io_tracer formatting routines */ static void fill_rwbs(char *rwbs, const struct blk_io_trace *t) { int i = 0; int tc = t->action >> BLK_TC_SHIFT; if (t->action == BLK_TN_MESSAGE) { rwbs[i++] = 'N'; goto out; } if (tc & BLK_TC_FLUSH) rwbs[i++] = 'F'; if (tc & BLK_TC_DISCARD) rwbs[i++] = 'D'; else if (tc & BLK_TC_WRITE) rwbs[i++] = 'W'; else if (t->bytes) rwbs[i++] = 'R'; else rwbs[i++] = 'N'; if (tc & BLK_TC_FUA) rwbs[i++] = 'F'; if (tc & BLK_TC_AHEAD) rwbs[i++] = 'A'; if (tc & BLK_TC_SYNC) rwbs[i++] = 'S'; if (tc & BLK_TC_META) rwbs[i++] = 'M'; out: rwbs[i] = '\0'; } static inline const struct blk_io_trace *te_blk_io_trace(const struct trace_entry *ent) { return (const struct blk_io_trace *)ent; } static inline const void *pdu_start(const struct trace_entry *ent) { return te_blk_io_trace(ent) + 1; } static inline u32 t_action(const struct trace_entry *ent) { return te_blk_io_trace(ent)->action; } static inline u32 t_bytes(const struct trace_entry *ent) { return te_blk_io_trace(ent)->bytes; } static inline u32 t_sec(const struct trace_entry *ent) { return te_blk_io_trace(ent)->bytes >> 9; } static inline unsigned long long t_sector(const struct trace_entry *ent) { return te_blk_io_trace(ent)->sector; } static inline __u16 t_error(const struct trace_entry *ent) { return te_blk_io_trace(ent)->error; } static __u64 get_pdu_int(const struct trace_entry *ent) { const __u64 *val = pdu_start(ent); return be64_to_cpu(*val); } static void get_pdu_remap(const struct trace_entry *ent, struct blk_io_trace_remap *r) { const struct blk_io_trace_remap *__r = pdu_start(ent); __u64 sector_from = __r->sector_from; r->device_from = be32_to_cpu(__r->device_from); r->device_to = be32_to_cpu(__r->device_to); r->sector_from = be64_to_cpu(sector_from); } typedef int (blk_log_action_t) (struct trace_iterator *iter, const char *act); static int blk_log_action_classic(struct trace_iterator *iter, const char *act) { char rwbs[RWBS_LEN]; unsigned long long ts = iter->ts; unsigned long nsec_rem = do_div(ts, NSEC_PER_SEC); unsigned secs = (unsigned long)ts; const struct blk_io_trace *t = te_blk_io_trace(iter->ent); fill_rwbs(rwbs, t); return trace_seq_printf(&iter->seq, "%3d,%-3d %2d %5d.%09lu %5u %2s %3s ", MAJOR(t->device), MINOR(t->device), iter->cpu, secs, nsec_rem, iter->ent->pid, act, rwbs); } static int blk_log_action(struct trace_iterator *iter, const char *act) { char rwbs[RWBS_LEN]; const struct blk_io_trace *t = te_blk_io_trace(iter->ent); fill_rwbs(rwbs, t); return trace_seq_printf(&iter->seq, "%3d,%-3d %2s %3s ", MAJOR(t->device), MINOR(t->device), act, rwbs); } static int blk_log_dump_pdu(struct trace_seq *s, const struct trace_entry *ent) { const unsigned char *pdu_buf; int pdu_len; int i, end, ret; pdu_buf = pdu_start(ent); pdu_len = te_blk_io_trace(ent)->pdu_len; if (!pdu_len) return 1; /* find the last zero that needs to be printed */ for (end = pdu_len - 1; end >= 0; end--) if (pdu_buf[end]) break; end++; if (!trace_seq_putc(s, '(')) return 0; for (i = 0; i < pdu_len; i++) { ret = trace_seq_printf(s, "%s%02x", i == 0 ? "" : " ", pdu_buf[i]); if (!ret) return ret; /* * stop when the rest is just zeroes and indicate so * with a ".." appended */ if (i == end && end != pdu_len - 1) return trace_seq_puts(s, " ..) "); } return trace_seq_puts(s, ") "); } static int blk_log_generic(struct trace_seq *s, const struct trace_entry *ent) { char cmd[TASK_COMM_LEN]; trace_find_cmdline(ent->pid, cmd); if (t_action(ent) & BLK_TC_ACT(BLK_TC_PC)) { int ret; ret = trace_seq_printf(s, "%u ", t_bytes(ent)); if (!ret) return 0; ret = blk_log_dump_pdu(s, ent); if (!ret) return 0; return trace_seq_printf(s, "[%s]\n", cmd); } else { if (t_sec(ent)) return trace_seq_printf(s, "%llu + %u [%s]\n", t_sector(ent), t_sec(ent), cmd); return trace_seq_printf(s, "[%s]\n", cmd); } } static int blk_log_with_error(struct trace_seq *s, const struct trace_entry *ent) { if (t_action(ent) & BLK_TC_ACT(BLK_TC_PC)) { int ret; ret = blk_log_dump_pdu(s, ent); if (ret) return trace_seq_printf(s, "[%d]\n", t_error(ent)); return 0; } else { if (t_sec(ent)) return trace_seq_printf(s, "%llu + %u [%d]\n", t_sector(ent), t_sec(ent), t_error(ent)); return trace_seq_printf(s, "%llu [%d]\n", t_sector(ent), t_error(ent)); } } static int blk_log_remap(struct trace_seq *s, const struct trace_entry *ent) { struct blk_io_trace_remap r = { .device_from = 0, }; get_pdu_remap(ent, &r); return trace_seq_printf(s, "%llu + %u <- (%d,%d) %llu\n", t_sector(ent), t_sec(ent), MAJOR(r.device_from), MINOR(r.device_from), (unsigned long long)r.sector_from); } static int blk_log_plug(struct trace_seq *s, const struct trace_entry *ent) { char cmd[TASK_COMM_LEN]; trace_find_cmdline(ent->pid, cmd); return trace_seq_printf(s, "[%s]\n", cmd); } static int blk_log_unplug(struct trace_seq *s, const struct trace_entry *ent) { char cmd[TASK_COMM_LEN]; trace_find_cmdline(ent->pid, cmd); return trace_seq_printf(s, "[%s] %llu\n", cmd, get_pdu_int(ent)); } static int blk_log_split(struct trace_seq *s, const struct trace_entry *ent) { char cmd[TASK_COMM_LEN]; trace_find_cmdline(ent->pid, cmd); return trace_seq_printf(s, "%llu / %llu [%s]\n", t_sector(ent), get_pdu_int(ent), cmd); } static int blk_log_msg(struct trace_seq *s, const struct trace_entry *ent) { int ret; const struct blk_io_trace *t = te_blk_io_trace(ent); ret = trace_seq_putmem(s, t + 1, t->pdu_len); if (ret) return trace_seq_putc(s, '\n'); return ret; } /* * struct tracer operations */ static void blk_tracer_print_header(struct seq_file *m) { if (!(blk_tracer_flags.val & TRACE_BLK_OPT_CLASSIC)) return; seq_puts(m, "# DEV CPU TIMESTAMP PID ACT FLG\n" "# | | | | | |\n"); } static void blk_tracer_start(struct trace_array *tr) { blk_tracer_enabled = true; } static int blk_tracer_init(struct trace_array *tr) { blk_tr = tr; blk_tracer_start(tr); return 0; } static void blk_tracer_stop(struct trace_array *tr) { blk_tracer_enabled = false; } static void blk_tracer_reset(struct trace_array *tr) { blk_tracer_stop(tr); } static const struct { const char *act[2]; int (*print)(struct trace_seq *s, const struct trace_entry *ent); } what2act[] = { [__BLK_TA_QUEUE] = {{ "Q", "queue" }, blk_log_generic }, [__BLK_TA_BACKMERGE] = {{ "M", "backmerge" }, blk_log_generic }, [__BLK_TA_FRONTMERGE] = {{ "F", "frontmerge" }, blk_log_generic }, [__BLK_TA_GETRQ] = {{ "G", "getrq" }, blk_log_generic }, [__BLK_TA_SLEEPRQ] = {{ "S", "sleeprq" }, blk_log_generic }, [__BLK_TA_REQUEUE] = {{ "R", "requeue" }, blk_log_with_error }, [__BLK_TA_ISSUE] = {{ "D", "issue" }, blk_log_generic }, [__BLK_TA_COMPLETE] = {{ "C", "complete" }, blk_log_with_error }, [__BLK_TA_PLUG] = {{ "P", "plug" }, blk_log_plug }, [__BLK_TA_UNPLUG_IO] = {{ "U", "unplug_io" }, blk_log_unplug }, [__BLK_TA_UNPLUG_TIMER] = {{ "UT", "unplug_timer" }, blk_log_unplug }, [__BLK_TA_INSERT] = {{ "I", "insert" }, blk_log_generic }, [__BLK_TA_SPLIT] = {{ "X", "split" }, blk_log_split }, [__BLK_TA_BOUNCE] = {{ "B", "bounce" }, blk_log_generic }, [__BLK_TA_REMAP] = {{ "A", "remap" }, blk_log_remap }, }; static enum print_line_t print_one_line(struct trace_iterator *iter, bool classic) { struct trace_seq *s = &iter->seq; const struct blk_io_trace *t; u16 what; int ret; bool long_act; blk_log_action_t *log_action; t = te_blk_io_trace(iter->ent); what = t->action & ((1 << BLK_TC_SHIFT) - 1); long_act = !!(trace_flags & TRACE_ITER_VERBOSE); log_action = classic ? &blk_log_action_classic : &blk_log_action; if (t->action == BLK_TN_MESSAGE) { ret = log_action(iter, long_act ? "message" : "m"); if (ret) ret = blk_log_msg(s, iter->ent); goto out; } if (unlikely(what == 0 || what >= ARRAY_SIZE(what2act))) ret = trace_seq_printf(s, "Unknown action %x\n", what); else { ret = log_action(iter, what2act[what].act[long_act]); if (ret) ret = what2act[what].print(s, iter->ent); } out: return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; } static enum print_line_t blk_trace_event_print(struct trace_iterator *iter, int flags, struct trace_event *event) { return print_one_line(iter, false); } static int blk_trace_synthesize_old_trace(struct trace_iterator *iter) { struct trace_seq *s = &iter->seq; struct blk_io_trace *t = (struct blk_io_trace *)iter->ent; const int offset = offsetof(struct blk_io_trace, sector); struct blk_io_trace old = { .magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION, .time = iter->ts, }; if (!trace_seq_putmem(s, &old, offset)) return 0; return trace_seq_putmem(s, &t->sector, sizeof(old) - offset + t->pdu_len); } static enum print_line_t blk_trace_event_print_binary(struct trace_iterator *iter, int flags, struct trace_event *event) { return blk_trace_synthesize_old_trace(iter) ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; } static enum print_line_t blk_tracer_print_line(struct trace_iterator *iter) { if (!(blk_tracer_flags.val & TRACE_BLK_OPT_CLASSIC)) return TRACE_TYPE_UNHANDLED; return print_one_line(iter, true); } static int blk_tracer_set_flag(u32 old_flags, u32 bit, int set) { /* don't output context-info for blk_classic output */ if (bit == TRACE_BLK_OPT_CLASSIC) { if (set) trace_flags &= ~TRACE_ITER_CONTEXT_INFO; else trace_flags |= TRACE_ITER_CONTEXT_INFO; } return 0; } static struct tracer blk_tracer __read_mostly = { .name = "blk", .init = blk_tracer_init, .reset = blk_tracer_reset, .start = blk_tracer_start, .stop = blk_tracer_stop, .print_header = blk_tracer_print_header, .print_line = blk_tracer_print_line, .flags = &blk_tracer_flags, .set_flag = blk_tracer_set_flag, }; static struct trace_event_functions trace_blk_event_funcs = { .trace = blk_trace_event_print, .binary = blk_trace_event_print_binary, }; static struct trace_event trace_blk_event = { .type = TRACE_BLK, .funcs = &trace_blk_event_funcs, }; static int __init init_blk_tracer(void) { if (!register_ftrace_event(&trace_blk_event)) { pr_warning("Warning: could not register block events\n"); return 1; } if (register_tracer(&blk_tracer) != 0) { pr_warning("Warning: could not register the block tracer\n"); unregister_ftrace_event(&trace_blk_event); return 1; } return 0; } device_initcall(init_blk_tracer); static int blk_trace_remove_queue(struct request_queue *q) { struct blk_trace *bt; bt = xchg(&q->blk_trace, NULL); if (bt == NULL) return -EINVAL; if (atomic_dec_and_test(&blk_probes_ref)) blk_unregister_tracepoints(); blk_trace_free(bt); return 0; } /* * Setup everything required to start tracing */ static int blk_trace_setup_queue(struct request_queue *q, struct block_device *bdev) { struct blk_trace *old_bt, *bt = NULL; int ret = -ENOMEM; bt = kzalloc(sizeof(*bt), GFP_KERNEL); if (!bt) return -ENOMEM; bt->msg_data = __alloc_percpu(BLK_TN_MAX_MSG, __alignof__(char)); if (!bt->msg_data) goto free_bt; bt->dev = bdev->bd_dev; bt->act_mask = (u16)-1; blk_trace_setup_lba(bt, bdev); old_bt = xchg(&q->blk_trace, bt); if (old_bt != NULL) { (void)xchg(&q->blk_trace, old_bt); ret = -EBUSY; goto free_bt; } if (atomic_inc_return(&blk_probes_ref) == 1) blk_register_tracepoints(); return 0; free_bt: blk_trace_free(bt); return ret; } /* * sysfs interface to enable and configure tracing */ static ssize_t sysfs_blk_trace_attr_show(struct device *dev, struct device_attribute *attr, char *buf); static ssize_t sysfs_blk_trace_attr_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); #define BLK_TRACE_DEVICE_ATTR(_name) \ DEVICE_ATTR(_name, S_IRUGO | S_IWUSR, \ sysfs_blk_trace_attr_show, \ sysfs_blk_trace_attr_store) static BLK_TRACE_DEVICE_ATTR(enable); static BLK_TRACE_DEVICE_ATTR(act_mask); static BLK_TRACE_DEVICE_ATTR(pid); static BLK_TRACE_DEVICE_ATTR(start_lba); static BLK_TRACE_DEVICE_ATTR(end_lba); static struct attribute *blk_trace_attrs[] = { &dev_attr_enable.attr, &dev_attr_act_mask.attr, &dev_attr_pid.attr, &dev_attr_start_lba.attr, &dev_attr_end_lba.attr, NULL }; struct attribute_group blk_trace_attr_group = { .name = "trace", .attrs = blk_trace_attrs, }; static const struct { int mask; const char *str; } mask_maps[] = { { BLK_TC_READ, "read" }, { BLK_TC_WRITE, "write" }, { BLK_TC_FLUSH, "flush" }, { BLK_TC_SYNC, "sync" }, { BLK_TC_QUEUE, "queue" }, { BLK_TC_REQUEUE, "requeue" }, { BLK_TC_ISSUE, "issue" }, { BLK_TC_COMPLETE, "complete" }, { BLK_TC_FS, "fs" }, { BLK_TC_PC, "pc" }, { BLK_TC_AHEAD, "ahead" }, { BLK_TC_META, "meta" }, { BLK_TC_DISCARD, "discard" }, { BLK_TC_DRV_DATA, "drv_data" }, { BLK_TC_FUA, "fua" }, }; static int blk_trace_str2mask(const char *str) { int i; int mask = 0; char *buf, *s, *token; buf = kstrdup(str, GFP_KERNEL); if (buf == NULL) return -ENOMEM; s = strstrip(buf); while (1) { token = strsep(&s, ","); if (token == NULL) break; if (*token == '\0') continue; for (i = 0; i < ARRAY_SIZE(mask_maps); i++) { if (strcasecmp(token, mask_maps[i].str) == 0) { mask |= mask_maps[i].mask; break; } } if (i == ARRAY_SIZE(mask_maps)) { mask = -EINVAL; break; } } kfree(buf); return mask; } static ssize_t blk_trace_mask2str(char *buf, int mask) { int i; char *p = buf; for (i = 0; i < ARRAY_SIZE(mask_maps); i++) { if (mask & mask_maps[i].mask) { p += sprintf(p, "%s%s", (p == buf) ? "" : ",", mask_maps[i].str); } } *p++ = '\n'; return p - buf; } static struct request_queue *blk_trace_get_queue(struct block_device *bdev) { if (bdev->bd_disk == NULL) return NULL; return bdev_get_queue(bdev); } static ssize_t sysfs_blk_trace_attr_show(struct device *dev, struct device_attribute *attr, char *buf) { struct hd_struct *p = dev_to_part(dev); struct request_queue *q; struct block_device *bdev; ssize_t ret = -ENXIO; bdev = bdget(part_devt(p)); if (bdev == NULL) goto out; q = blk_trace_get_queue(bdev); if (q == NULL) goto out_bdput; mutex_lock(&bdev->bd_mutex); if (attr == &dev_attr_enable) { ret = sprintf(buf, "%u\n", !!q->blk_trace); goto out_unlock_bdev; } if (q->blk_trace == NULL) ret = sprintf(buf, "disabled\n"); else if (attr == &dev_attr_act_mask) ret = blk_trace_mask2str(buf, q->blk_trace->act_mask); else if (attr == &dev_attr_pid) ret = sprintf(buf, "%u\n", q->blk_trace->pid); else if (attr == &dev_attr_start_lba) ret = sprintf(buf, "%llu\n", q->blk_trace->start_lba); else if (attr == &dev_attr_end_lba) ret = sprintf(buf, "%llu\n", q->blk_trace->end_lba); out_unlock_bdev: mutex_unlock(&bdev->bd_mutex); out_bdput: bdput(bdev); out: return ret; } static ssize_t sysfs_blk_trace_attr_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct block_device *bdev; struct request_queue *q; struct hd_struct *p; u64 value; ssize_t ret = -EINVAL; if (count == 0) goto out; if (attr == &dev_attr_act_mask) { if (sscanf(buf, "%llx", &value) != 1) { /* Assume it is a list of trace category names */ ret = blk_trace_str2mask(buf); if (ret < 0) goto out; value = ret; } } else if (sscanf(buf, "%llu", &value) != 1) goto out; ret = -ENXIO; p = dev_to_part(dev); bdev = bdget(part_devt(p)); if (bdev == NULL) goto out; q = blk_trace_get_queue(bdev); if (q == NULL) goto out_bdput; mutex_lock(&bdev->bd_mutex); if (attr == &dev_attr_enable) { if (value) ret = blk_trace_setup_queue(q, bdev); else ret = blk_trace_remove_queue(q); goto out_unlock_bdev; } ret = 0; if (q->blk_trace == NULL) ret = blk_trace_setup_queue(q, bdev); if (ret == 0) { if (attr == &dev_attr_act_mask) q->blk_trace->act_mask = value; else if (attr == &dev_attr_pid) q->blk_trace->pid = value; else if (attr == &dev_attr_start_lba) q->blk_trace->start_lba = value; else if (attr == &dev_attr_end_lba) q->blk_trace->end_lba = value; } out_unlock_bdev: mutex_unlock(&bdev->bd_mutex); out_bdput: bdput(bdev); out: return ret ? ret : count; } int blk_trace_init_sysfs(struct device *dev) { return sysfs_create_group(&dev->kobj, &blk_trace_attr_group); } void blk_trace_remove_sysfs(struct device *dev) { sysfs_remove_group(&dev->kobj, &blk_trace_attr_group); } #endif /* CONFIG_BLK_DEV_IO_TRACE */ #ifdef CONFIG_EVENT_TRACING void blk_dump_cmd(char *buf, struct request *rq) { int i, end; int len = rq->cmd_len; unsigned char *cmd = rq->cmd; if (rq->cmd_type != REQ_TYPE_BLOCK_PC) { buf[0] = '\0'; return; } for (end = len - 1; end >= 0; end--) if (cmd[end]) break; end++; for (i = 0; i < len; i++) { buf += sprintf(buf, "%s%02x", i == 0 ? "" : " ", cmd[i]); if (i == end && end != len - 1) { sprintf(buf, " .."); break; } } } void blk_fill_rwbs(char *rwbs, u32 rw, int bytes) { int i = 0; if (rw & REQ_FLUSH) rwbs[i++] = 'F'; if (rw & WRITE) rwbs[i++] = 'W'; else if (rw & REQ_DISCARD) rwbs[i++] = 'D'; else if (bytes) rwbs[i++] = 'R'; else rwbs[i++] = 'N'; if (rw & REQ_FUA) rwbs[i++] = 'F'; if (rw & REQ_RAHEAD) rwbs[i++] = 'A'; if (rw & REQ_SYNC) rwbs[i++] = 'S'; if (rw & REQ_META) rwbs[i++] = 'M'; if (rw & REQ_SECURE) rwbs[i++] = 'E'; rwbs[i] = '\0'; } EXPORT_SYMBOL_GPL(blk_fill_rwbs); #endif /* CONFIG_EVENT_TRACING */
gpl-2.0
Aayushya/kernel_motorola_msm8226
drivers/usb/serial/garmin_gps.c
1466
39883
/* * Garmin GPS driver * * Copyright (C) 2006-2011 Hermann Kneissel herkne@gmx.de * * The latest version of the driver can be found at * http://sourceforge.net/projects/garmin-gps/ * * This driver has been derived from v2.1 of the visor 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 USA */ #include <linux/kernel.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/timer.h> #include <linux/tty.h> #include <linux/tty_driver.h> #include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> #include <linux/uaccess.h> #include <linux/atomic.h> #include <linux/usb.h> #include <linux/usb/serial.h> /* the mode to be set when the port ist opened */ static int initial_mode = 1; /* debug flag */ static bool debug; #define GARMIN_VENDOR_ID 0x091E /* * Version Information */ #define VERSION_MAJOR 0 #define VERSION_MINOR 36 #define _STR(s) #s #define _DRIVER_VERSION(a, b) "v" _STR(a) "." _STR(b) #define DRIVER_VERSION _DRIVER_VERSION(VERSION_MAJOR, VERSION_MINOR) #define DRIVER_AUTHOR "hermann kneissel" #define DRIVER_DESC "garmin gps driver" /* error codes returned by the driver */ #define EINVPKT 1000 /* invalid packet structure */ /* size of the header of a packet using the usb protocol */ #define GARMIN_PKTHDR_LENGTH 12 /* max. possible size of a packet using the serial protocol */ #define MAX_SERIAL_PKT_SIZ (3 + 255 + 3) /* max. possible size of a packet with worst case stuffing */ #define MAX_SERIAL_PKT_SIZ_STUFFED (MAX_SERIAL_PKT_SIZ + 256) /* size of a buffer able to hold a complete (no stuffing) packet * (the document protocol does not contain packets with a larger * size, but in theory a packet may be 64k+12 bytes - if in * later protocol versions larger packet sizes occur, this value * should be increased accordingly, so the input buffer is always * large enough the store a complete packet inclusive header) */ #define GPS_IN_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ) /* size of a buffer able to hold a complete (incl. stuffing) packet */ #define GPS_OUT_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ_STUFFED) /* where to place the packet id of a serial packet, so we can * prepend the usb-packet header without the need to move the * packets data */ #define GSP_INITIAL_OFFSET (GARMIN_PKTHDR_LENGTH-2) /* max. size of incoming private packets (header+1 param) */ #define PRIVPKTSIZ (GARMIN_PKTHDR_LENGTH+4) #define GARMIN_LAYERID_TRANSPORT 0 #define GARMIN_LAYERID_APPL 20 /* our own layer-id to use for some control mechanisms */ #define GARMIN_LAYERID_PRIVATE 0x01106E4B #define GARMIN_PKTID_PVT_DATA 51 #define GARMIN_PKTID_L001_COMMAND_DATA 10 #define CMND_ABORT_TRANSFER 0 /* packet ids used in private layer */ #define PRIV_PKTID_SET_DEBUG 1 #define PRIV_PKTID_SET_MODE 2 #define PRIV_PKTID_INFO_REQ 3 #define PRIV_PKTID_INFO_RESP 4 #define PRIV_PKTID_RESET_REQ 5 #define PRIV_PKTID_SET_DEF_MODE 6 #define ETX 0x03 #define DLE 0x10 #define ACK 0x06 #define NAK 0x15 /* structure used to queue incoming packets */ struct garmin_packet { struct list_head list; int seq; /* the real size of the data array, always > 0 */ int size; __u8 data[1]; }; /* structure used to keep the current state of the driver */ struct garmin_data { __u8 state; __u16 flags; __u8 mode; __u8 count; __u8 pkt_id; __u32 serial_num; struct timer_list timer; struct usb_serial_port *port; int seq_counter; int insize; int outsize; __u8 inbuffer [GPS_IN_BUFSIZ]; /* tty -> usb */ __u8 outbuffer[GPS_OUT_BUFSIZ]; /* usb -> tty */ __u8 privpkt[4*6]; spinlock_t lock; struct list_head pktlist; }; #define STATE_NEW 0 #define STATE_INITIAL_DELAY 1 #define STATE_TIMEOUT 2 #define STATE_SESSION_REQ1 3 #define STATE_SESSION_REQ2 4 #define STATE_ACTIVE 5 #define STATE_RESET 8 #define STATE_DISCONNECTED 9 #define STATE_WAIT_TTY_ACK 10 #define STATE_GSP_WAIT_DATA 11 #define MODE_NATIVE 0 #define MODE_GARMIN_SERIAL 1 /* Flags used in garmin_data.flags: */ #define FLAGS_SESSION_REPLY_MASK 0x00C0 #define FLAGS_SESSION_REPLY1_SEEN 0x0080 #define FLAGS_SESSION_REPLY2_SEEN 0x0040 #define FLAGS_BULK_IN_ACTIVE 0x0020 #define FLAGS_BULK_IN_RESTART 0x0010 #define FLAGS_THROTTLED 0x0008 #define APP_REQ_SEEN 0x0004 #define APP_RESP_SEEN 0x0002 #define CLEAR_HALT_REQUIRED 0x0001 #define FLAGS_QUEUING 0x0100 #define FLAGS_DROP_DATA 0x0800 #define FLAGS_GSP_SKIP 0x1000 #define FLAGS_GSP_DLESEEN 0x2000 /* function prototypes */ static int gsp_next_packet(struct garmin_data *garmin_data_p); static int garmin_write_bulk(struct usb_serial_port *port, const unsigned char *buf, int count, int dismiss_ack); /* some special packets to be send or received */ static unsigned char const GARMIN_START_SESSION_REQ[] = { 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0 }; static unsigned char const GARMIN_START_SESSION_REPLY[] = { 0, 0, 0, 0, 6, 0, 0, 0, 4, 0, 0, 0 }; static unsigned char const GARMIN_BULK_IN_AVAIL_REPLY[] = { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0 }; static unsigned char const GARMIN_APP_LAYER_REPLY[] = { 0x14, 0, 0, 0 }; static unsigned char const GARMIN_START_PVT_REQ[] = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 49, 0 }; static unsigned char const GARMIN_STOP_PVT_REQ[] = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 50, 0 }; static unsigned char const GARMIN_STOP_TRANSFER_REQ[] = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 0, 0 }; static unsigned char const GARMIN_STOP_TRANSFER_REQ_V2[] = { 20, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 0 }; static unsigned char const PRIVATE_REQ[] = { 0x4B, 0x6E, 0x10, 0x01, 0xFF, 0, 0, 0, 0xFF, 0, 0, 0 }; static const struct usb_device_id id_table[] = { /* the same device id seems to be used by all usb enabled GPS devices */ { USB_DEVICE(GARMIN_VENDOR_ID, 3) }, { } /* Terminating entry */ }; MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver garmin_driver = { .name = "garmin_gps", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, }; static inline int getLayerId(const __u8 *usbPacket) { return __le32_to_cpup((__le32 *)(usbPacket)); } static inline int getPacketId(const __u8 *usbPacket) { return __le32_to_cpup((__le32 *)(usbPacket+4)); } static inline int getDataLength(const __u8 *usbPacket) { return __le32_to_cpup((__le32 *)(usbPacket+8)); } /* * check if the usb-packet in buf contains an abort-transfer command. * (if yes, all queued data will be dropped) */ static inline int isAbortTrfCmnd(const unsigned char *buf) { if (0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ, sizeof(GARMIN_STOP_TRANSFER_REQ)) || 0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2, sizeof(GARMIN_STOP_TRANSFER_REQ_V2))) return 1; else return 0; } static void send_to_tty(struct usb_serial_port *port, char *data, unsigned int actual_length) { struct tty_struct *tty = tty_port_tty_get(&port->port); if (tty && actual_length) { usb_serial_debug_data(debug, &port->dev, __func__, actual_length, data); tty_insert_flip_string(tty, data, actual_length); tty_flip_buffer_push(tty); } tty_kref_put(tty); } /****************************************************************************** * packet queue handling ******************************************************************************/ /* * queue a received (usb-)packet for later processing */ static int pkt_add(struct garmin_data *garmin_data_p, unsigned char *data, unsigned int data_length) { int state = 0; int result = 0; unsigned long flags; struct garmin_packet *pkt; /* process only packets containg data ... */ if (data_length) { pkt = kmalloc(sizeof(struct garmin_packet)+data_length, GFP_ATOMIC); if (pkt == NULL) { dev_err(&garmin_data_p->port->dev, "out of memory\n"); return 0; } pkt->size = data_length; memcpy(pkt->data, data, data_length); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= FLAGS_QUEUING; result = list_empty(&garmin_data_p->pktlist); pkt->seq = garmin_data_p->seq_counter++; list_add_tail(&pkt->list, &garmin_data_p->pktlist); state = garmin_data_p->state; spin_unlock_irqrestore(&garmin_data_p->lock, flags); dbg("%s - added: pkt: %d - %d bytes", __func__, pkt->seq, data_length); /* in serial mode, if someone is waiting for data from the device, convert and send the next packet to tty. */ if (result && (state == STATE_GSP_WAIT_DATA)) gsp_next_packet(garmin_data_p); } return result; } /* get the next pending packet */ static struct garmin_packet *pkt_pop(struct garmin_data *garmin_data_p) { unsigned long flags; struct garmin_packet *result = NULL; spin_lock_irqsave(&garmin_data_p->lock, flags); if (!list_empty(&garmin_data_p->pktlist)) { result = (struct garmin_packet *)garmin_data_p->pktlist.next; list_del(&result->list); } spin_unlock_irqrestore(&garmin_data_p->lock, flags); return result; } /* free up all queued data */ static void pkt_clear(struct garmin_data *garmin_data_p) { unsigned long flags; struct garmin_packet *result = NULL; dbg("%s", __func__); spin_lock_irqsave(&garmin_data_p->lock, flags); while (!list_empty(&garmin_data_p->pktlist)) { result = (struct garmin_packet *)garmin_data_p->pktlist.next; list_del(&result->list); kfree(result); } spin_unlock_irqrestore(&garmin_data_p->lock, flags); } /****************************************************************************** * garmin serial protocol handling handling ******************************************************************************/ /* send an ack packet back to the tty */ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id) { __u8 pkt[10]; __u8 cksum = 0; __u8 *ptr = pkt; unsigned l = 0; dbg("%s - pkt-id: 0x%X.", __func__, 0xFF & pkt_id); *ptr++ = DLE; *ptr++ = ACK; cksum += ACK; *ptr++ = 2; cksum += 2; *ptr++ = pkt_id; cksum += pkt_id; if (pkt_id == DLE) *ptr++ = DLE; *ptr++ = 0; *ptr++ = 0xFF & (-cksum); *ptr++ = DLE; *ptr++ = ETX; l = ptr-pkt; send_to_tty(garmin_data_p->port, pkt, l); return 0; } /* * called for a complete packet received from tty layer * * the complete packet (pktid ... cksum) is in garmin_data_p->inbuf starting * at GSP_INITIAL_OFFSET. * * count - number of bytes in the input buffer including space reserved for * the usb header: GSP_INITIAL_OFFSET + number of bytes in packet * (including pkt-id, data-length a. cksum) */ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) { unsigned long flags; const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET; __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer; int cksum = 0; int n = 0; int pktid = recpkt[0]; int size = recpkt[1]; usb_serial_debug_data(debug, &garmin_data_p->port->dev, __func__, count-GSP_INITIAL_OFFSET, recpkt); if (size != (count-GSP_INITIAL_OFFSET-3)) { dbg("%s - invalid size, expected %d bytes, got %d", __func__, size, (count-GSP_INITIAL_OFFSET-3)); return -EINVPKT; } cksum += *recpkt++; cksum += *recpkt++; /* sanity check, remove after test ... */ if ((__u8 *)&(usbdata[3]) != recpkt) { dbg("%s - ptr mismatch %p - %p", __func__, &(usbdata[4]), recpkt); return -EINVPKT; } while (n < size) { cksum += *recpkt++; n++; } if ((0xff & (cksum + *recpkt)) != 0) { dbg("%s - invalid checksum, expected %02x, got %02x", __func__, 0xff & -cksum, 0xff & *recpkt); return -EINVPKT; } usbdata[0] = __cpu_to_le32(GARMIN_LAYERID_APPL); usbdata[1] = __cpu_to_le32(pktid); usbdata[2] = __cpu_to_le32(size); garmin_write_bulk(garmin_data_p->port, garmin_data_p->inbuffer, GARMIN_PKTHDR_LENGTH+size, 0); /* if this was an abort-transfer command, flush all queued data. */ if (isAbortTrfCmnd(garmin_data_p->inbuffer)) { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= FLAGS_DROP_DATA; spin_unlock_irqrestore(&garmin_data_p->lock, flags); pkt_clear(garmin_data_p); } return count; } /* * Called for data received from tty * * buf contains the data read, it may span more than one packet or even * incomplete packets * * input record should be a serial-record, but it may not be complete. * Copy it into our local buffer, until an etx is seen (or an error * occurs). * Once the record is complete, convert into a usb packet and send it * to the bulk pipe, send an ack back to the tty. * * If the input is an ack, just send the last queued packet to the * tty layer. * * if the input is an abort command, drop all queued data. */ static int gsp_receive(struct garmin_data *garmin_data_p, const unsigned char *buf, int count) { unsigned long flags; int offs = 0; int ack_or_nak_seen = 0; __u8 *dest; int size; /* dleSeen: set if last byte read was a DLE */ int dleSeen; /* skip: if set, skip incoming data until possible start of * new packet */ int skip; __u8 data; spin_lock_irqsave(&garmin_data_p->lock, flags); dest = garmin_data_p->inbuffer; size = garmin_data_p->insize; dleSeen = garmin_data_p->flags & FLAGS_GSP_DLESEEN; skip = garmin_data_p->flags & FLAGS_GSP_SKIP; spin_unlock_irqrestore(&garmin_data_p->lock, flags); /* dbg("%s - dle=%d skip=%d size=%d count=%d", __func__, dleSeen, skip, size, count); */ if (size == 0) size = GSP_INITIAL_OFFSET; while (offs < count) { data = *(buf+offs); offs++; if (data == DLE) { if (skip) { /* start of a new pkt */ skip = 0; size = GSP_INITIAL_OFFSET; dleSeen = 1; } else if (dleSeen) { dest[size++] = data; dleSeen = 0; } else { dleSeen = 1; } } else if (data == ETX) { if (dleSeen) { /* packet complete */ data = dest[GSP_INITIAL_OFFSET]; if (data == ACK) { ack_or_nak_seen = ACK; dbg("ACK packet complete."); } else if (data == NAK) { ack_or_nak_seen = NAK; dbg("NAK packet complete."); } else { dbg("packet complete - id=0x%X.", 0xFF & data); gsp_rec_packet(garmin_data_p, size); } skip = 1; size = GSP_INITIAL_OFFSET; dleSeen = 0; } else { dest[size++] = data; } } else if (!skip) { if (dleSeen) { size = GSP_INITIAL_OFFSET; dleSeen = 0; } dest[size++] = data; } if (size >= GPS_IN_BUFSIZ) { dbg("%s - packet too large.", __func__); skip = 1; size = GSP_INITIAL_OFFSET; dleSeen = 0; } } spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->insize = size; /* copy flags back to structure */ if (skip) garmin_data_p->flags |= FLAGS_GSP_SKIP; else garmin_data_p->flags &= ~FLAGS_GSP_SKIP; if (dleSeen) garmin_data_p->flags |= FLAGS_GSP_DLESEEN; else garmin_data_p->flags &= ~FLAGS_GSP_DLESEEN; spin_unlock_irqrestore(&garmin_data_p->lock, flags); if (ack_or_nak_seen) { if (gsp_next_packet(garmin_data_p) > 0) garmin_data_p->state = STATE_ACTIVE; else garmin_data_p->state = STATE_GSP_WAIT_DATA; } return count; } /* * Sends a usb packet to the tty * * Assumes, that all packages and at an usb-packet boundary. * * return <0 on error, 0 if packet is incomplete or > 0 if packet was sent */ static int gsp_send(struct garmin_data *garmin_data_p, const unsigned char *buf, int count) { const unsigned char *src; unsigned char *dst; int pktid = 0; int datalen = 0; int cksum = 0; int i = 0; int k; dbg("%s - state %d - %d bytes.", __func__, garmin_data_p->state, count); k = garmin_data_p->outsize; if ((k+count) > GPS_OUT_BUFSIZ) { dbg("packet too large"); garmin_data_p->outsize = 0; return -4; } memcpy(garmin_data_p->outbuffer+k, buf, count); k += count; garmin_data_p->outsize = k; if (k >= GARMIN_PKTHDR_LENGTH) { pktid = getPacketId(garmin_data_p->outbuffer); datalen = getDataLength(garmin_data_p->outbuffer); i = GARMIN_PKTHDR_LENGTH + datalen; if (k < i) return 0; } else { return 0; } dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__, k, i); /* garmin_data_p->outbuffer now contains a complete packet */ usb_serial_debug_data(debug, &garmin_data_p->port->dev, __func__, k, garmin_data_p->outbuffer); garmin_data_p->outsize = 0; if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) { dbg("not an application packet (%d)", getLayerId(garmin_data_p->outbuffer)); return -1; } if (pktid > 255) { dbg("packet-id %d too large", pktid); return -2; } if (datalen > 255) { dbg("packet-size %d too large", datalen); return -3; } /* the serial protocol should be able to handle this packet */ k = 0; src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH; for (i = 0; i < datalen; i++) { if (*src++ == DLE) k++; } src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH; if (k > (GARMIN_PKTHDR_LENGTH-2)) { /* can't add stuffing DLEs in place, move data to end of buffer ... */ dst = garmin_data_p->outbuffer+GPS_OUT_BUFSIZ-datalen; memcpy(dst, src, datalen); src = dst; } dst = garmin_data_p->outbuffer; *dst++ = DLE; *dst++ = pktid; cksum += pktid; *dst++ = datalen; cksum += datalen; if (datalen == DLE) *dst++ = DLE; for (i = 0; i < datalen; i++) { __u8 c = *src++; *dst++ = c; cksum += c; if (c == DLE) *dst++ = DLE; } cksum = 0xFF & -cksum; *dst++ = cksum; if (cksum == DLE) *dst++ = DLE; *dst++ = DLE; *dst++ = ETX; i = dst-garmin_data_p->outbuffer; send_to_tty(garmin_data_p->port, garmin_data_p->outbuffer, i); garmin_data_p->pkt_id = pktid; garmin_data_p->state = STATE_WAIT_TTY_ACK; return i; } /* * Process the next pending data packet - if there is one */ static int gsp_next_packet(struct garmin_data *garmin_data_p) { int result = 0; struct garmin_packet *pkt = NULL; while ((pkt = pkt_pop(garmin_data_p)) != NULL) { dbg("%s - next pkt: %d", __func__, pkt->seq); result = gsp_send(garmin_data_p, pkt->data, pkt->size); if (result > 0) { kfree(pkt); return result; } kfree(pkt); } return result; } /****************************************************************************** * garmin native mode ******************************************************************************/ /* * Called for data received from tty * * The input data is expected to be in garmin usb-packet format. * * buf contains the data read, it may span more than one packet * or even incomplete packets */ static int nat_receive(struct garmin_data *garmin_data_p, const unsigned char *buf, int count) { unsigned long flags; __u8 *dest; int offs = 0; int result = count; int len; while (offs < count) { /* if buffer contains header, copy rest of data */ if (garmin_data_p->insize >= GARMIN_PKTHDR_LENGTH) len = GARMIN_PKTHDR_LENGTH +getDataLength(garmin_data_p->inbuffer); else len = GARMIN_PKTHDR_LENGTH; if (len >= GPS_IN_BUFSIZ) { /* seems to be an invalid packet, ignore rest of input */ dbg("%s - packet size too large: %d", __func__, len); garmin_data_p->insize = 0; count = 0; result = -EINVPKT; } else { len -= garmin_data_p->insize; if (len > (count-offs)) len = (count-offs); if (len > 0) { dest = garmin_data_p->inbuffer + garmin_data_p->insize; memcpy(dest, buf+offs, len); garmin_data_p->insize += len; offs += len; } } /* do we have a complete packet ? */ if (garmin_data_p->insize >= GARMIN_PKTHDR_LENGTH) { len = GARMIN_PKTHDR_LENGTH+ getDataLength(garmin_data_p->inbuffer); if (garmin_data_p->insize >= len) { garmin_write_bulk(garmin_data_p->port, garmin_data_p->inbuffer, len, 0); garmin_data_p->insize = 0; /* if this was an abort-transfer command, flush all queued data. */ if (isAbortTrfCmnd(garmin_data_p->inbuffer)) { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= FLAGS_DROP_DATA; spin_unlock_irqrestore( &garmin_data_p->lock, flags); pkt_clear(garmin_data_p); } } } } return result; } /****************************************************************************** * private packets ******************************************************************************/ static void priv_status_resp(struct usb_serial_port *port) { struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); __le32 *pkt = (__le32 *)garmin_data_p->privpkt; pkt[0] = __cpu_to_le32(GARMIN_LAYERID_PRIVATE); pkt[1] = __cpu_to_le32(PRIV_PKTID_INFO_RESP); pkt[2] = __cpu_to_le32(12); pkt[3] = __cpu_to_le32(VERSION_MAJOR << 16 | VERSION_MINOR); pkt[4] = __cpu_to_le32(garmin_data_p->mode); pkt[5] = __cpu_to_le32(garmin_data_p->serial_num); send_to_tty(port, (__u8 *)pkt, 6 * 4); } /****************************************************************************** * Garmin specific driver functions ******************************************************************************/ static int process_resetdev_request(struct usb_serial_port *port) { unsigned long flags; int status; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags &= ~(CLEAR_HALT_REQUIRED); garmin_data_p->state = STATE_RESET; garmin_data_p->serial_num = 0; spin_unlock_irqrestore(&garmin_data_p->lock, flags); usb_kill_urb(port->interrupt_in_urb); dbg("%s - usb_reset_device", __func__); status = usb_reset_device(port->serial->dev); if (status) dbg("%s - usb_reset_device failed: %d", __func__, status); return status; } /* * clear all cached data */ static int garmin_clear(struct garmin_data *garmin_data_p) { unsigned long flags; int status = 0; /* flush all queued data */ pkt_clear(garmin_data_p); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->insize = 0; garmin_data_p->outsize = 0; spin_unlock_irqrestore(&garmin_data_p->lock, flags); return status; } static int garmin_init_session(struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); int status = 0; int i = 0; if (status == 0) { usb_kill_urb(port->interrupt_in_urb); dbg("%s - adding interrupt input", __func__); status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (status) dev_err(&serial->dev->dev, "%s - failed submitting interrupt urb, error %d\n", __func__, status); } /* * using the initialization method from gpsbabel. See comments in * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles() */ if (status == 0) { dbg("%s - starting session ...", __func__); garmin_data_p->state = STATE_ACTIVE; for (i = 0; i < 3; i++) { status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ, sizeof(GARMIN_START_SESSION_REQ), 0); if (status < 0) break; } if (status > 0) status = 0; } return status; } static int garmin_open(struct tty_struct *tty, struct usb_serial_port *port) { unsigned long flags; int status = 0; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->mode = initial_mode; garmin_data_p->count = 0; garmin_data_p->flags &= FLAGS_SESSION_REPLY1_SEEN; spin_unlock_irqrestore(&garmin_data_p->lock, flags); /* shutdown any bulk reads that might be going on */ usb_kill_urb(port->write_urb); usb_kill_urb(port->read_urb); if (garmin_data_p->state == STATE_RESET) status = garmin_init_session(port); garmin_data_p->state = STATE_ACTIVE; return status; } static void garmin_close(struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); dbg("%s - port %d - mode=%d state=%d flags=0x%X", __func__, port->number, garmin_data_p->mode, garmin_data_p->state, garmin_data_p->flags); if (!serial) return; garmin_clear(garmin_data_p); /* shutdown our urbs */ usb_kill_urb(port->read_urb); usb_kill_urb(port->write_urb); /* keep reset state so we know that we must start a new session */ if (garmin_data_p->state != STATE_RESET) garmin_data_p->state = STATE_DISCONNECTED; } static void garmin_write_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; if (port) { struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); dbg("%s - port %d", __func__, port->number); if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer)) { if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { gsp_send_ack(garmin_data_p, ((__u8 *)urb->transfer_buffer)[4]); } } usb_serial_port_softint(port); } /* Ignore errors that resulted from garmin_write_bulk with dismiss_ack = 1 */ /* free up the transfer buffer, as usb_free_urb() does not do this */ kfree(urb->transfer_buffer); } static int garmin_write_bulk(struct usb_serial_port *port, const unsigned char *buf, int count, int dismiss_ack) { unsigned long flags; struct usb_serial *serial = port->serial; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); struct urb *urb; unsigned char *buffer; int status; dbg("%s - port %d, state %d", __func__, port->number, garmin_data_p->state); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags &= ~FLAGS_DROP_DATA; spin_unlock_irqrestore(&garmin_data_p->lock, flags); buffer = kmalloc(count, GFP_ATOMIC); if (!buffer) { dev_err(&port->dev, "out of memory\n"); return -ENOMEM; } urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urb) { dev_err(&port->dev, "no more free urbs\n"); kfree(buffer); return -ENOMEM; } memcpy(buffer, buf, count); usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); usb_fill_bulk_urb(urb, serial->dev, usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), buffer, count, garmin_write_bulk_callback, dismiss_ack ? NULL : port); urb->transfer_flags |= URB_ZERO_PACKET; if (GARMIN_LAYERID_APPL == getLayerId(buffer)) { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= APP_REQ_SEEN; spin_unlock_irqrestore(&garmin_data_p->lock, flags); if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { pkt_clear(garmin_data_p); garmin_data_p->state = STATE_GSP_WAIT_DATA; } } /* send it down the pipe */ status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", __func__, status); count = status; } /* we are done with this urb, so let the host driver * really free it when it is finished with it */ usb_free_urb(urb); return count; } static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { int pktid, pktsiz, len; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; usb_serial_debug_data(debug, &port->dev, __func__, count, buf); if (garmin_data_p->state == STATE_RESET) return -EIO; /* check for our private packets */ if (count >= GARMIN_PKTHDR_LENGTH) { len = PRIVPKTSIZ; if (count < len) len = count; memcpy(garmin_data_p->privpkt, buf, len); pktsiz = getDataLength(garmin_data_p->privpkt); pktid = getPacketId(garmin_data_p->privpkt); if (count == (GARMIN_PKTHDR_LENGTH+pktsiz) && GARMIN_LAYERID_PRIVATE == getLayerId(garmin_data_p->privpkt)) { dbg("%s - processing private request %d", __func__, pktid); /* drop all unfinished transfers */ garmin_clear(garmin_data_p); switch (pktid) { case PRIV_PKTID_SET_DEBUG: if (pktsiz != 4) return -EINVPKT; debug = __le32_to_cpu(privpkt[3]); dbg("%s - debug level set to 0x%X", __func__, debug); break; case PRIV_PKTID_SET_MODE: if (pktsiz != 4) return -EINVPKT; garmin_data_p->mode = __le32_to_cpu(privpkt[3]); dbg("%s - mode set to %d", __func__, garmin_data_p->mode); break; case PRIV_PKTID_INFO_REQ: priv_status_resp(port); break; case PRIV_PKTID_RESET_REQ: process_resetdev_request(port); break; case PRIV_PKTID_SET_DEF_MODE: if (pktsiz != 4) return -EINVPKT; initial_mode = __le32_to_cpu(privpkt[3]); dbg("%s - initial_mode set to %d", __func__, garmin_data_p->mode); break; } return count; } } if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { return gsp_receive(garmin_data_p, buf, count); } else { /* MODE_NATIVE */ return nat_receive(garmin_data_p, buf, count); } } static int garmin_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; /* * Report back the bytes currently available in the output buffer. */ struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); return GPS_OUT_BUFSIZ-garmin_data_p->outsize; } static void garmin_read_process(struct garmin_data *garmin_data_p, unsigned char *data, unsigned data_length, int bulk_data) { unsigned long flags; if (garmin_data_p->flags & FLAGS_DROP_DATA) { /* abort-transfer cmd is actice */ dbg("%s - pkt dropped", __func__); } else if (garmin_data_p->state != STATE_DISCONNECTED && garmin_data_p->state != STATE_RESET) { /* if throttling is active or postprecessing is required put the received data in the input queue, otherwise send it directly to the tty port */ if (garmin_data_p->flags & FLAGS_QUEUING) { pkt_add(garmin_data_p, data, data_length); } else if (bulk_data || getLayerId(data) == GARMIN_LAYERID_APPL) { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= APP_RESP_SEEN; spin_unlock_irqrestore(&garmin_data_p->lock, flags); if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { pkt_add(garmin_data_p, data, data_length); } else { send_to_tty(garmin_data_p->port, data, data_length); } } /* ignore system layer packets ... */ } } static void garmin_read_bulk_callback(struct urb *urb) { unsigned long flags; struct usb_serial_port *port = urb->context; struct usb_serial *serial = port->serial; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; int status = urb->status; int retval; dbg("%s - port %d", __func__, port->number); if (!serial) { dbg("%s - bad serial pointer, exiting", __func__); return; } if (status) { dbg("%s - nonzero read bulk status received: %d", __func__, status); return; } usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); garmin_read_process(garmin_data_p, data, urb->actual_length, 1); if (urb->actual_length == 0 && 0 != (garmin_data_p->flags & FLAGS_BULK_IN_RESTART)) { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags &= ~FLAGS_BULK_IN_RESTART; spin_unlock_irqrestore(&garmin_data_p->lock, flags); retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (retval) dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, retval); } else if (urb->actual_length > 0) { /* Continue trying to read until nothing more is received */ if (0 == (garmin_data_p->flags & FLAGS_THROTTLED)) { retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (retval) dev_err(&port->dev, "%s - failed resubmitting read urb, " "error %d\n", __func__, retval); } } else { dbg("%s - end of bulk data", __func__); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE; spin_unlock_irqrestore(&garmin_data_p->lock, flags); } } static void garmin_read_int_callback(struct urb *urb) { unsigned long flags; int retval; struct usb_serial_port *port = urb->context; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; int status = urb->status; switch (status) { case 0: /* success */ break; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", __func__, status); return; default: dbg("%s - nonzero urb status received: %d", __func__, status); return; } usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, urb->transfer_buffer); if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { dbg("%s - bulk data available.", __func__); if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { /* bulk data available */ retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (retval) { dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, retval); } else { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE; spin_unlock_irqrestore(&garmin_data_p->lock, flags); } } else { /* bulk-in transfer still active */ spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= FLAGS_BULK_IN_RESTART; spin_unlock_irqrestore(&garmin_data_p->lock, flags); } } else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY)) && 0 == memcmp(data, GARMIN_START_SESSION_REPLY, sizeof(GARMIN_START_SESSION_REPLY))) { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN; spin_unlock_irqrestore(&garmin_data_p->lock, flags); /* save the serial number */ garmin_data_p->serial_num = __le32_to_cpup( (__le32 *)(data+GARMIN_PKTHDR_LENGTH)); dbg("%s - start-of-session reply seen - serial %u.", __func__, garmin_data_p->serial_num); } garmin_read_process(garmin_data_p, data, urb->actual_length, 0); retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", __func__, retval); } /* * Sends the next queued packt to the tty port (garmin native mode only) * and then sets a timer to call itself again until all queued data * is sent. */ static int garmin_flush_queue(struct garmin_data *garmin_data_p) { unsigned long flags; struct garmin_packet *pkt; if ((garmin_data_p->flags & FLAGS_THROTTLED) == 0) { pkt = pkt_pop(garmin_data_p); if (pkt != NULL) { send_to_tty(garmin_data_p->port, pkt->data, pkt->size); kfree(pkt); mod_timer(&garmin_data_p->timer, (1)+jiffies); } else { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags &= ~FLAGS_QUEUING; spin_unlock_irqrestore(&garmin_data_p->lock, flags); } } return 0; } static void garmin_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); dbg("%s - port %d", __func__, port->number); /* set flag, data received will be put into a queue for later processing */ spin_lock_irq(&garmin_data_p->lock); garmin_data_p->flags |= FLAGS_QUEUING|FLAGS_THROTTLED; spin_unlock_irq(&garmin_data_p->lock); } static void garmin_unthrottle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); int status; dbg("%s - port %d", __func__, port->number); spin_lock_irq(&garmin_data_p->lock); garmin_data_p->flags &= ~FLAGS_THROTTLED; spin_unlock_irq(&garmin_data_p->lock); /* in native mode send queued data to tty, in serial mode nothing needs to be done here */ if (garmin_data_p->mode == MODE_NATIVE) garmin_flush_queue(garmin_data_p); if (0 != (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { status = usb_submit_urb(port->read_urb, GFP_KERNEL); if (status) dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, status); } } /* * The timer is currently only used to send queued packets to * the tty in cases where the protocol provides no own handshaking * to initiate the transfer. */ static void timeout_handler(unsigned long data) { struct garmin_data *garmin_data_p = (struct garmin_data *) data; /* send the next queued packet to the tty port */ if (garmin_data_p->mode == MODE_NATIVE) if (garmin_data_p->flags & FLAGS_QUEUING) garmin_flush_queue(garmin_data_p); } static int garmin_attach(struct usb_serial *serial) { int status = 0; struct usb_serial_port *port = serial->port[0]; struct garmin_data *garmin_data_p = NULL; dbg("%s", __func__); garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL); if (garmin_data_p == NULL) { dev_err(&port->dev, "%s - Out of memory\n", __func__); return -ENOMEM; } init_timer(&garmin_data_p->timer); spin_lock_init(&garmin_data_p->lock); INIT_LIST_HEAD(&garmin_data_p->pktlist); /* garmin_data_p->timer.expires = jiffies + session_timeout; */ garmin_data_p->timer.data = (unsigned long)garmin_data_p; garmin_data_p->timer.function = timeout_handler; garmin_data_p->port = port; garmin_data_p->state = 0; garmin_data_p->flags = 0; garmin_data_p->count = 0; usb_set_serial_port_data(port, garmin_data_p); status = garmin_init_session(port); return status; } static void garmin_disconnect(struct usb_serial *serial) { struct usb_serial_port *port = serial->port[0]; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); dbg("%s", __func__); usb_kill_urb(port->interrupt_in_urb); del_timer_sync(&garmin_data_p->timer); } static void garmin_release(struct usb_serial *serial) { struct usb_serial_port *port = serial->port[0]; struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); dbg("%s", __func__); kfree(garmin_data_p); } /* All of the device info needed */ static struct usb_serial_driver garmin_device = { .driver = { .owner = THIS_MODULE, .name = "garmin_gps", }, .description = "Garmin GPS usb/tty", .id_table = id_table, .num_ports = 1, .open = garmin_open, .close = garmin_close, .throttle = garmin_throttle, .unthrottle = garmin_unthrottle, .attach = garmin_attach, .disconnect = garmin_disconnect, .release = garmin_release, .write = garmin_write, .write_room = garmin_write_room, .write_bulk_callback = garmin_write_bulk_callback, .read_bulk_callback = garmin_read_bulk_callback, .read_int_callback = garmin_read_int_callback, }; static struct usb_serial_driver * const serial_drivers[] = { &garmin_device, NULL }; module_usb_serial_driver(garmin_driver, serial_drivers); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IWUSR | S_IRUGO); MODULE_PARM_DESC(debug, "Debug enabled or not"); module_param(initial_mode, int, S_IRUGO); MODULE_PARM_DESC(initial_mode, "Initial mode");
gpl-2.0
alban/linux
arch/arm/mach-omap2/omap_phy_internal.c
1466
4027
/* * This file configures the internal USB PHY in OMAP4430. Used * with TWL6030 transceiver and MUSB on OMAP4430. * * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.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. * * Author: Hema HK <hemahk@ti.com> * * 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. * */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/types.h> #include <linux/delay.h> #include <linux/clk.h> #include <linux/io.h> #include <linux/err.h> #include <linux/usb.h> #include <linux/usb/musb.h> #include "soc.h" #include "control.h" #include "usb.h" #define CONTROL_DEV_CONF 0x300 #define PHY_PD 0x1 /** * omap4430_phy_power_down: disable MUSB PHY during early init * * OMAP4 MUSB PHY module is enabled by default on reset, but this will * prevent core retention if not disabled by SW. USB driver will * later on enable this, once and if the driver needs it. */ static int __init omap4430_phy_power_down(void) { void __iomem *ctrl_base; if (!cpu_is_omap44xx()) return 0; ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K); if (!ctrl_base) { pr_err("control module ioremap failed\n"); return -ENOMEM; } /* Power down the phy */ writel_relaxed(PHY_PD, ctrl_base + CONTROL_DEV_CONF); iounmap(ctrl_base); return 0; } omap_early_initcall(omap4430_phy_power_down); void am35x_musb_reset(void) { u32 regval; /* Reset the musb interface */ regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); regval |= AM35XX_USBOTGSS_SW_RST; omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET); regval &= ~AM35XX_USBOTGSS_SW_RST; omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET); regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); } void am35x_musb_phy_power(u8 on) { unsigned long timeout = jiffies + msecs_to_jiffies(100); u32 devconf2; if (on) { /* * Start the on-chip PHY and its PLL. */ devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); devconf2 &= ~(CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN); devconf2 |= CONF2_PHY_PLLON; omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2); pr_info("Waiting for PHY clock good...\n"); while (!(omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2) & CONF2_PHYCLKGD)) { cpu_relax(); if (time_after(jiffies, timeout)) { pr_err("musb PHY clock good timed out\n"); break; } } } else { /* * Power down the on-chip PHY. */ devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); devconf2 &= ~CONF2_PHY_PLLON; devconf2 |= CONF2_PHYPWRDN | CONF2_OTGPWRDN; omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2); } } void am35x_musb_clear_irq(void) { u32 regval; regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); regval |= AM35XX_USBOTGSS_INT_CLR; omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR); regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); } void am35x_set_mode(u8 musb_mode) { u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); devconf2 &= ~CONF2_OTGMODE; switch (musb_mode) { case MUSB_HOST: /* Force VBUS valid, ID = 0 */ devconf2 |= CONF2_FORCE_HOST; break; case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */ devconf2 |= CONF2_FORCE_DEVICE; break; case MUSB_OTG: /* Don't override the VBUS/ID comparators */ devconf2 |= CONF2_NO_OVERRIDE; break; default: pr_info("Unsupported mode %u\n", musb_mode); } omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2); }
gpl-2.0
aps243/kernel-imx
drivers/media/usb/dvb-usb/ttusb2.c
2746
18524
/* DVB USB compliant linux driver for Technotrend DVB USB boxes and clones * (e.g. Pinnacle 400e DVB-S USB2.0). * * The Pinnacle 400e uses the same protocol as the Technotrend USB1.1 boxes. * * TDA8263 + TDA10086 * * I2C addresses: * 0x08 - LNBP21PD - LNB power supply * 0x0e - TDA10086 - Demodulator * 0x50 - FX2 eeprom * 0x60 - TDA8263 - Tuner * 0x78 ??? * * Copyright (c) 2002 Holger Waechtler <holger@convergence.de> * Copyright (c) 2003 Felix Domke <tmbinc@elitedvb.net> * Copyright (C) 2005-6 Patrick Boettcher <pb@linuxtv.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, version 2. * * see Documentation/dvb/README.dvb-usb for more information */ #define DVB_USB_LOG_PREFIX "ttusb2" #include "dvb-usb.h" #include "ttusb2.h" #include "tda826x.h" #include "tda10086.h" #include "tda1002x.h" #include "tda10048.h" #include "tda827x.h" #include "lnbp21.h" /* CA */ #include "dvb_ca_en50221.h" /* debug */ static int dvb_usb_ttusb2_debug; #define deb_info(args...) dprintk(dvb_usb_ttusb2_debug,0x01,args) module_param_named(debug,dvb_usb_ttusb2_debug, int, 0644); MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able))." DVB_USB_DEBUG_STATUS); static int dvb_usb_ttusb2_debug_ci; module_param_named(debug_ci,dvb_usb_ttusb2_debug_ci, int, 0644); MODULE_PARM_DESC(debug_ci, "set debugging ci." DVB_USB_DEBUG_STATUS); DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); #define ci_dbg(format, arg...) \ do { \ if (dvb_usb_ttusb2_debug_ci) \ printk(KERN_DEBUG DVB_USB_LOG_PREFIX \ ": %s " format "\n" , __func__, ## arg); \ } while (0) enum { TT3650_CMD_CI_TEST = 0x40, TT3650_CMD_CI_RD_CTRL, TT3650_CMD_CI_WR_CTRL, TT3650_CMD_CI_RD_ATTR, TT3650_CMD_CI_WR_ATTR, TT3650_CMD_CI_RESET, TT3650_CMD_CI_SET_VIDEO_PORT }; struct ttusb2_state { struct dvb_ca_en50221 ca; struct mutex ca_mutex; u8 id; u16 last_rc_key; }; static int ttusb2_msg(struct dvb_usb_device *d, u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen) { struct ttusb2_state *st = d->priv; u8 *s, *r = NULL; int ret = 0; s = kzalloc(wlen+4, GFP_KERNEL); if (!s) return -ENOMEM; r = kzalloc(64, GFP_KERNEL); if (!r) { kfree(s); return -ENOMEM; } s[0] = 0xaa; s[1] = ++st->id; s[2] = cmd; s[3] = wlen; memcpy(&s[4],wbuf,wlen); ret = dvb_usb_generic_rw(d, s, wlen+4, r, 64, 0); if (ret != 0 || r[0] != 0x55 || r[1] != s[1] || r[2] != cmd || (rlen > 0 && r[3] != rlen)) { warn("there might have been an error during control message transfer. (rlen = %d, was %d)",rlen,r[3]); kfree(s); kfree(r); return -EIO; } if (rlen > 0) memcpy(rbuf, &r[4], rlen); kfree(s); kfree(r); return 0; } /* ci */ static int tt3650_ci_msg(struct dvb_usb_device *d, u8 cmd, u8 *data, unsigned int write_len, unsigned int read_len) { int ret; u8 rx[60];/* (64 -4) */ ret = ttusb2_msg(d, cmd, data, write_len, rx, read_len); if (!ret) memcpy(data, rx, read_len); return ret; } static int tt3650_ci_msg_locked(struct dvb_ca_en50221 *ca, u8 cmd, u8 *data, unsigned int write_len, unsigned int read_len) { struct dvb_usb_device *d = ca->data; struct ttusb2_state *state = d->priv; int ret; mutex_lock(&state->ca_mutex); ret = tt3650_ci_msg(d, cmd, data, write_len, read_len); mutex_unlock(&state->ca_mutex); return ret; } static int tt3650_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address) { u8 buf[3]; int ret = 0; if (slot) return -EINVAL; buf[0] = (address >> 8) & 0x0F; buf[1] = address; ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_RD_ATTR, buf, 2, 3); ci_dbg("%04x -> %d 0x%02x", address, ret, buf[2]); if (ret < 0) return ret; return buf[2]; } static int tt3650_ci_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value) { u8 buf[3]; ci_dbg("%d 0x%04x 0x%02x", slot, address, value); if (slot) return -EINVAL; buf[0] = (address >> 8) & 0x0F; buf[1] = address; buf[2] = value; return tt3650_ci_msg_locked(ca, TT3650_CMD_CI_WR_ATTR, buf, 3, 3); } static int tt3650_ci_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address) { u8 buf[2]; int ret; if (slot) return -EINVAL; buf[0] = address & 3; ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_RD_CTRL, buf, 1, 2); ci_dbg("0x%02x -> %d 0x%02x", address, ret, buf[1]); if (ret < 0) return ret; return buf[1]; } static int tt3650_ci_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value) { u8 buf[2]; ci_dbg("%d 0x%02x 0x%02x", slot, address, value); if (slot) return -EINVAL; buf[0] = address; buf[1] = value; return tt3650_ci_msg_locked(ca, TT3650_CMD_CI_WR_CTRL, buf, 2, 2); } static int tt3650_ci_set_video_port(struct dvb_ca_en50221 *ca, int slot, int enable) { u8 buf[1]; int ret; ci_dbg("%d %d", slot, enable); if (slot) return -EINVAL; buf[0] = enable; ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_SET_VIDEO_PORT, buf, 1, 1); if (ret < 0) return ret; if (enable != buf[0]) { err("CI not %sabled.", enable ? "en" : "dis"); return -EIO; } return 0; } static int tt3650_ci_slot_shutdown(struct dvb_ca_en50221 *ca, int slot) { return tt3650_ci_set_video_port(ca, slot, 0); } static int tt3650_ci_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot) { return tt3650_ci_set_video_port(ca, slot, 1); } static int tt3650_ci_slot_reset(struct dvb_ca_en50221 *ca, int slot) { struct dvb_usb_device *d = ca->data; struct ttusb2_state *state = d->priv; u8 buf[1]; int ret; ci_dbg("%d", slot); if (slot) return -EINVAL; buf[0] = 0; mutex_lock(&state->ca_mutex); ret = tt3650_ci_msg(d, TT3650_CMD_CI_RESET, buf, 1, 1); if (ret) goto failed; msleep(500); buf[0] = 1; ret = tt3650_ci_msg(d, TT3650_CMD_CI_RESET, buf, 1, 1); if (ret) goto failed; msleep(500); buf[0] = 0; /* FTA */ ret = tt3650_ci_msg(d, TT3650_CMD_CI_SET_VIDEO_PORT, buf, 1, 1); msleep(1100); failed: mutex_unlock(&state->ca_mutex); return ret; } static int tt3650_ci_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open) { u8 buf[1]; int ret; if (slot) return -EINVAL; ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_TEST, buf, 0, 1); if (ret) return ret; if (1 == buf[0]) { return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY; } return 0; } static void tt3650_ci_uninit(struct dvb_usb_device *d) { struct ttusb2_state *state; ci_dbg(""); if (NULL == d) return; state = d->priv; if (NULL == state) return; if (NULL == state->ca.data) return; dvb_ca_en50221_release(&state->ca); memset(&state->ca, 0, sizeof(state->ca)); } static int tt3650_ci_init(struct dvb_usb_adapter *a) { struct dvb_usb_device *d = a->dev; struct ttusb2_state *state = d->priv; int ret; ci_dbg(""); mutex_init(&state->ca_mutex); state->ca.owner = THIS_MODULE; state->ca.read_attribute_mem = tt3650_ci_read_attribute_mem; state->ca.write_attribute_mem = tt3650_ci_write_attribute_mem; state->ca.read_cam_control = tt3650_ci_read_cam_control; state->ca.write_cam_control = tt3650_ci_write_cam_control; state->ca.slot_reset = tt3650_ci_slot_reset; state->ca.slot_shutdown = tt3650_ci_slot_shutdown; state->ca.slot_ts_enable = tt3650_ci_slot_ts_enable; state->ca.poll_slot_status = tt3650_ci_poll_slot_status; state->ca.data = d; ret = dvb_ca_en50221_init(&a->dvb_adap, &state->ca, /* flags */ 0, /* n_slots */ 1); if (ret) { err("Cannot initialize CI: Error %d.", ret); memset(&state->ca, 0, sizeof(state->ca)); return ret; } info("CI initialized."); return 0; } static int ttusb2_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) { struct dvb_usb_device *d = i2c_get_adapdata(adap); static u8 obuf[60], ibuf[60]; int i, write_read, read; if (mutex_lock_interruptible(&d->i2c_mutex) < 0) return -EAGAIN; if (num > 2) warn("more than 2 i2c messages at a time is not handled yet. TODO."); for (i = 0; i < num; i++) { write_read = i+1 < num && (msg[i+1].flags & I2C_M_RD); read = msg[i].flags & I2C_M_RD; obuf[0] = (msg[i].addr << 1) | (write_read | read); if (read) obuf[1] = 0; else obuf[1] = msg[i].len; /* read request */ if (write_read) obuf[2] = msg[i+1].len; else if (read) obuf[2] = msg[i].len; else obuf[2] = 0; memcpy(&obuf[3], msg[i].buf, msg[i].len); if (ttusb2_msg(d, CMD_I2C_XFER, obuf, obuf[1]+3, ibuf, obuf[2] + 3) < 0) { err("i2c transfer failed."); break; } if (write_read) { memcpy(msg[i+1].buf, &ibuf[3], msg[i+1].len); i++; } else if (read) memcpy(msg[i].buf, &ibuf[3], msg[i].len); } mutex_unlock(&d->i2c_mutex); return i; } static u32 ttusb2_i2c_func(struct i2c_adapter *adapter) { return I2C_FUNC_I2C; } static struct i2c_algorithm ttusb2_i2c_algo = { .master_xfer = ttusb2_i2c_xfer, .functionality = ttusb2_i2c_func, }; /* command to poll IR receiver (copied from pctv452e.c) */ #define CMD_GET_IR_CODE 0x1b /* IR */ static int tt3650_rc_query(struct dvb_usb_device *d) { int ret; u8 rx[9]; /* A CMD_GET_IR_CODE reply is 9 bytes long */ struct ttusb2_state *st = d->priv; ret = ttusb2_msg(d, CMD_GET_IR_CODE, NULL, 0, rx, sizeof(rx)); if (ret != 0) return ret; if (rx[8] & 0x01) { /* got a "press" event */ st->last_rc_key = (rx[3] << 8) | rx[2]; deb_info("%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]); rc_keydown(d->rc_dev, st->last_rc_key, rx[1]); } else if (st->last_rc_key) { rc_keyup(d->rc_dev); st->last_rc_key = 0; } return 0; } /* Callbacks for DVB USB */ static int ttusb2_identify_state (struct usb_device *udev, struct dvb_usb_device_properties *props, struct dvb_usb_device_description **desc, int *cold) { *cold = udev->descriptor.iManufacturer == 0 && udev->descriptor.iProduct == 0; return 0; } static int ttusb2_power_ctrl(struct dvb_usb_device *d, int onoff) { u8 b = onoff; ttusb2_msg(d, CMD_POWER, &b, 0, NULL, 0); return ttusb2_msg(d, CMD_POWER, &b, 1, NULL, 0); } static struct tda10086_config tda10086_config = { .demod_address = 0x0e, .invert = 0, .diseqc_tone = 1, .xtal_freq = TDA10086_XTAL_16M, }; static struct tda10023_config tda10023_config = { .demod_address = 0x0c, .invert = 0, .xtal = 16000000, .pll_m = 11, .pll_p = 3, .pll_n = 1, .deltaf = 0xa511, }; static struct tda10048_config tda10048_config = { .demod_address = 0x10 >> 1, .output_mode = TDA10048_PARALLEL_OUTPUT, .inversion = TDA10048_INVERSION_ON, .dtv6_if_freq_khz = TDA10048_IF_4000, .dtv7_if_freq_khz = TDA10048_IF_4500, .dtv8_if_freq_khz = TDA10048_IF_5000, .clk_freq_khz = TDA10048_CLK_16000, .no_firmware = 1, .set_pll = true , .pll_m = 5, .pll_n = 3, .pll_p = 0, }; static struct tda827x_config tda827x_config = { .config = 0, }; static int ttusb2_frontend_tda10086_attach(struct dvb_usb_adapter *adap) { if (usb_set_interface(adap->dev->udev,0,3) < 0) err("set interface to alts=3 failed"); if ((adap->fe_adap[0].fe = dvb_attach(tda10086_attach, &tda10086_config, &adap->dev->i2c_adap)) == NULL) { deb_info("TDA10086 attach failed\n"); return -ENODEV; } return 0; } static int ttusb2_ct3650_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) { struct dvb_usb_adapter *adap = fe->dvb->priv; return adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, enable); } static int ttusb2_frontend_tda10023_attach(struct dvb_usb_adapter *adap) { if (usb_set_interface(adap->dev->udev, 0, 3) < 0) err("set interface to alts=3 failed"); if (adap->fe_adap[0].fe == NULL) { /* FE 0 DVB-C */ adap->fe_adap[0].fe = dvb_attach(tda10023_attach, &tda10023_config, &adap->dev->i2c_adap, 0x48); if (adap->fe_adap[0].fe == NULL) { deb_info("TDA10023 attach failed\n"); return -ENODEV; } tt3650_ci_init(adap); } else { adap->fe_adap[1].fe = dvb_attach(tda10048_attach, &tda10048_config, &adap->dev->i2c_adap); if (adap->fe_adap[1].fe == NULL) { deb_info("TDA10048 attach failed\n"); return -ENODEV; } /* tuner is behind TDA10023 I2C-gate */ adap->fe_adap[1].fe->ops.i2c_gate_ctrl = ttusb2_ct3650_i2c_gate_ctrl; } return 0; } static int ttusb2_tuner_tda827x_attach(struct dvb_usb_adapter *adap) { struct dvb_frontend *fe; /* MFE: select correct FE to attach tuner since that's called twice */ if (adap->fe_adap[1].fe == NULL) fe = adap->fe_adap[0].fe; else fe = adap->fe_adap[1].fe; /* attach tuner */ if (dvb_attach(tda827x_attach, fe, 0x61, &adap->dev->i2c_adap, &tda827x_config) == NULL) { printk(KERN_ERR "%s: No tda827x found!\n", __func__); return -ENODEV; } return 0; } static int ttusb2_tuner_tda826x_attach(struct dvb_usb_adapter *adap) { if (dvb_attach(tda826x_attach, adap->fe_adap[0].fe, 0x60, &adap->dev->i2c_adap, 0) == NULL) { deb_info("TDA8263 attach failed\n"); return -ENODEV; } if (dvb_attach(lnbp21_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap, 0, 0) == NULL) { deb_info("LNBP21 attach failed\n"); return -ENODEV; } return 0; } /* DVB USB Driver stuff */ static struct dvb_usb_device_properties ttusb2_properties; static struct dvb_usb_device_properties ttusb2_properties_s2400; static struct dvb_usb_device_properties ttusb2_properties_ct3650; static void ttusb2_usb_disconnect(struct usb_interface *intf) { struct dvb_usb_device *d = usb_get_intfdata(intf); tt3650_ci_uninit(d); dvb_usb_device_exit(intf); } static int ttusb2_probe(struct usb_interface *intf, const struct usb_device_id *id) { if (0 == dvb_usb_device_init(intf, &ttusb2_properties, THIS_MODULE, NULL, adapter_nr) || 0 == dvb_usb_device_init(intf, &ttusb2_properties_s2400, THIS_MODULE, NULL, adapter_nr) || 0 == dvb_usb_device_init(intf, &ttusb2_properties_ct3650, THIS_MODULE, NULL, adapter_nr)) return 0; return -ENODEV; } static struct usb_device_id ttusb2_table [] = { { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_400E) }, { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_450E) }, { USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_CONNECT_S2400) }, { USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_CONNECT_CT3650) }, { USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM) }, {} /* Terminating entry */ }; MODULE_DEVICE_TABLE (usb, ttusb2_table); static struct dvb_usb_device_properties ttusb2_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-pctv-400e-01.fw", .size_of_priv = sizeof(struct ttusb2_state), .num_adapters = 1, .adapter = { { .num_frontends = 1, .fe = {{ .streaming_ctrl = NULL, // ttusb2_streaming_ctrl, .frontend_attach = ttusb2_frontend_tda10086_attach, .tuner_attach = ttusb2_tuner_tda826x_attach, /* parameter for the MPEG2-data transfer */ .stream = { .type = USB_ISOC, .count = 5, .endpoint = 0x02, .u = { .isoc = { .framesperurb = 4, .framesize = 940, .interval = 1, } } } }}, } }, .power_ctrl = ttusb2_power_ctrl, .identify_state = ttusb2_identify_state, .i2c_algo = &ttusb2_i2c_algo, .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 2, .devices = { { "Pinnacle 400e DVB-S USB2.0", { &ttusb2_table[0], NULL }, { NULL }, }, { "Pinnacle 450e DVB-S USB2.0", { &ttusb2_table[1], NULL }, { NULL }, }, } }; static struct dvb_usb_device_properties ttusb2_properties_s2400 = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-tt-s2400-01.fw", .size_of_priv = sizeof(struct ttusb2_state), .num_adapters = 1, .adapter = { { .num_frontends = 1, .fe = {{ .streaming_ctrl = NULL, .frontend_attach = ttusb2_frontend_tda10086_attach, .tuner_attach = ttusb2_tuner_tda826x_attach, /* parameter for the MPEG2-data transfer */ .stream = { .type = USB_ISOC, .count = 5, .endpoint = 0x02, .u = { .isoc = { .framesperurb = 4, .framesize = 940, .interval = 1, } } } }}, } }, .power_ctrl = ttusb2_power_ctrl, .identify_state = ttusb2_identify_state, .i2c_algo = &ttusb2_i2c_algo, .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 2, .devices = { { "Technotrend TT-connect S-2400", { &ttusb2_table[2], NULL }, { NULL }, }, { "Technotrend TT-connect S-2400 (8kB EEPROM)", { &ttusb2_table[4], NULL }, { NULL }, }, } }; static struct dvb_usb_device_properties ttusb2_properties_ct3650 = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .size_of_priv = sizeof(struct ttusb2_state), .rc.core = { .rc_interval = 150, /* Less than IR_KEYPRESS_TIMEOUT */ .rc_codes = RC_MAP_TT_1500, .rc_query = tt3650_rc_query, .allowed_protos = RC_BIT_UNKNOWN, }, .num_adapters = 1, .adapter = { { .num_frontends = 2, .fe = {{ .streaming_ctrl = NULL, .frontend_attach = ttusb2_frontend_tda10023_attach, .tuner_attach = ttusb2_tuner_tda827x_attach, /* parameter for the MPEG2-data transfer */ .stream = { .type = USB_ISOC, .count = 5, .endpoint = 0x02, .u = { .isoc = { .framesperurb = 4, .framesize = 940, .interval = 1, } } } }, { .streaming_ctrl = NULL, .frontend_attach = ttusb2_frontend_tda10023_attach, .tuner_attach = ttusb2_tuner_tda827x_attach, /* parameter for the MPEG2-data transfer */ .stream = { .type = USB_ISOC, .count = 5, .endpoint = 0x02, .u = { .isoc = { .framesperurb = 4, .framesize = 940, .interval = 1, } } } }}, }, }, .power_ctrl = ttusb2_power_ctrl, .identify_state = ttusb2_identify_state, .i2c_algo = &ttusb2_i2c_algo, .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { { "Technotrend TT-connect CT-3650", .warm_ids = { &ttusb2_table[3], NULL }, }, } }; static struct usb_driver ttusb2_driver = { .name = "dvb_usb_ttusb2", .probe = ttusb2_probe, .disconnect = ttusb2_usb_disconnect, .id_table = ttusb2_table, }; module_usb_driver(ttusb2_driver); MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); MODULE_DESCRIPTION("Driver for Pinnacle PCTV 400e DVB-S USB2.0"); MODULE_VERSION("1.0"); MODULE_LICENSE("GPL");
gpl-2.0
syhost/android_kernel_pantech_ef62l
net/rds/message.c
3770
10361
/* * Copyright (c) 2006 Oracle. 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/kernel.h> #include <linux/slab.h> #include <linux/export.h> #include "rds.h" static unsigned int rds_exthdr_size[__RDS_EXTHDR_MAX] = { [RDS_EXTHDR_NONE] = 0, [RDS_EXTHDR_VERSION] = sizeof(struct rds_ext_header_version), [RDS_EXTHDR_RDMA] = sizeof(struct rds_ext_header_rdma), [RDS_EXTHDR_RDMA_DEST] = sizeof(struct rds_ext_header_rdma_dest), }; void rds_message_addref(struct rds_message *rm) { rdsdebug("addref rm %p ref %d\n", rm, atomic_read(&rm->m_refcount)); atomic_inc(&rm->m_refcount); } EXPORT_SYMBOL_GPL(rds_message_addref); /* * This relies on dma_map_sg() not touching sg[].page during merging. */ static void rds_message_purge(struct rds_message *rm) { unsigned long i; if (unlikely(test_bit(RDS_MSG_PAGEVEC, &rm->m_flags))) return; for (i = 0; i < rm->data.op_nents; i++) { rdsdebug("putting data page %p\n", (void *)sg_page(&rm->data.op_sg[i])); /* XXX will have to put_page for page refs */ __free_page(sg_page(&rm->data.op_sg[i])); } rm->data.op_nents = 0; if (rm->rdma.op_active) rds_rdma_free_op(&rm->rdma); if (rm->rdma.op_rdma_mr) rds_mr_put(rm->rdma.op_rdma_mr); if (rm->atomic.op_active) rds_atomic_free_op(&rm->atomic); if (rm->atomic.op_rdma_mr) rds_mr_put(rm->atomic.op_rdma_mr); } void rds_message_put(struct rds_message *rm) { rdsdebug("put rm %p ref %d\n", rm, atomic_read(&rm->m_refcount)); if (atomic_read(&rm->m_refcount) == 0) { printk(KERN_CRIT "danger refcount zero on %p\n", rm); WARN_ON(1); } if (atomic_dec_and_test(&rm->m_refcount)) { BUG_ON(!list_empty(&rm->m_sock_item)); BUG_ON(!list_empty(&rm->m_conn_item)); rds_message_purge(rm); kfree(rm); } } EXPORT_SYMBOL_GPL(rds_message_put); void rds_message_populate_header(struct rds_header *hdr, __be16 sport, __be16 dport, u64 seq) { hdr->h_flags = 0; hdr->h_sport = sport; hdr->h_dport = dport; hdr->h_sequence = cpu_to_be64(seq); hdr->h_exthdr[0] = RDS_EXTHDR_NONE; } EXPORT_SYMBOL_GPL(rds_message_populate_header); int rds_message_add_extension(struct rds_header *hdr, unsigned int type, const void *data, unsigned int len) { unsigned int ext_len = sizeof(u8) + len; unsigned char *dst; /* For now, refuse to add more than one extension header */ if (hdr->h_exthdr[0] != RDS_EXTHDR_NONE) return 0; if (type >= __RDS_EXTHDR_MAX || len != rds_exthdr_size[type]) return 0; if (ext_len >= RDS_HEADER_EXT_SPACE) return 0; dst = hdr->h_exthdr; *dst++ = type; memcpy(dst, data, len); dst[len] = RDS_EXTHDR_NONE; return 1; } EXPORT_SYMBOL_GPL(rds_message_add_extension); /* * If a message has extension headers, retrieve them here. * Call like this: * * unsigned int pos = 0; * * while (1) { * buflen = sizeof(buffer); * type = rds_message_next_extension(hdr, &pos, buffer, &buflen); * if (type == RDS_EXTHDR_NONE) * break; * ... * } */ int rds_message_next_extension(struct rds_header *hdr, unsigned int *pos, void *buf, unsigned int *buflen) { unsigned int offset, ext_type, ext_len; u8 *src = hdr->h_exthdr; offset = *pos; if (offset >= RDS_HEADER_EXT_SPACE) goto none; /* Get the extension type and length. For now, the * length is implied by the extension type. */ ext_type = src[offset++]; if (ext_type == RDS_EXTHDR_NONE || ext_type >= __RDS_EXTHDR_MAX) goto none; ext_len = rds_exthdr_size[ext_type]; if (offset + ext_len > RDS_HEADER_EXT_SPACE) goto none; *pos = offset + ext_len; if (ext_len < *buflen) *buflen = ext_len; memcpy(buf, src + offset, *buflen); return ext_type; none: *pos = RDS_HEADER_EXT_SPACE; *buflen = 0; return RDS_EXTHDR_NONE; } int rds_message_add_rdma_dest_extension(struct rds_header *hdr, u32 r_key, u32 offset) { struct rds_ext_header_rdma_dest ext_hdr; ext_hdr.h_rdma_rkey = cpu_to_be32(r_key); ext_hdr.h_rdma_offset = cpu_to_be32(offset); return rds_message_add_extension(hdr, RDS_EXTHDR_RDMA_DEST, &ext_hdr, sizeof(ext_hdr)); } EXPORT_SYMBOL_GPL(rds_message_add_rdma_dest_extension); /* * Each rds_message is allocated with extra space for the scatterlist entries * rds ops will need. This is to minimize memory allocation count. Then, each rds op * can grab SGs when initializing its part of the rds_message. */ struct rds_message *rds_message_alloc(unsigned int extra_len, gfp_t gfp) { struct rds_message *rm; rm = kzalloc(sizeof(struct rds_message) + extra_len, gfp); if (!rm) goto out; rm->m_used_sgs = 0; rm->m_total_sgs = extra_len / sizeof(struct scatterlist); atomic_set(&rm->m_refcount, 1); INIT_LIST_HEAD(&rm->m_sock_item); INIT_LIST_HEAD(&rm->m_conn_item); spin_lock_init(&rm->m_rs_lock); init_waitqueue_head(&rm->m_flush_wait); out: return rm; } /* * RDS ops use this to grab SG entries from the rm's sg pool. */ struct scatterlist *rds_message_alloc_sgs(struct rds_message *rm, int nents) { struct scatterlist *sg_first = (struct scatterlist *) &rm[1]; struct scatterlist *sg_ret; WARN_ON(rm->m_used_sgs + nents > rm->m_total_sgs); WARN_ON(!nents); if (rm->m_used_sgs + nents > rm->m_total_sgs) return NULL; sg_ret = &sg_first[rm->m_used_sgs]; sg_init_table(sg_ret, nents); rm->m_used_sgs += nents; return sg_ret; } struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned int total_len) { struct rds_message *rm; unsigned int i; int num_sgs = ceil(total_len, PAGE_SIZE); int extra_bytes = num_sgs * sizeof(struct scatterlist); rm = rds_message_alloc(extra_bytes, GFP_NOWAIT); if (!rm) return ERR_PTR(-ENOMEM); set_bit(RDS_MSG_PAGEVEC, &rm->m_flags); rm->m_inc.i_hdr.h_len = cpu_to_be32(total_len); rm->data.op_nents = ceil(total_len, PAGE_SIZE); rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs); if (!rm->data.op_sg) { rds_message_put(rm); return ERR_PTR(-ENOMEM); } for (i = 0; i < rm->data.op_nents; ++i) { sg_set_page(&rm->data.op_sg[i], virt_to_page(page_addrs[i]), PAGE_SIZE, 0); } return rm; } int rds_message_copy_from_user(struct rds_message *rm, struct iovec *first_iov, size_t total_len) { unsigned long to_copy; unsigned long iov_off; unsigned long sg_off; struct iovec *iov; struct scatterlist *sg; int ret = 0; rm->m_inc.i_hdr.h_len = cpu_to_be32(total_len); /* * now allocate and copy in the data payload. */ sg = rm->data.op_sg; iov = first_iov; iov_off = 0; sg_off = 0; /* Dear gcc, sg->page will be null from kzalloc. */ while (total_len) { if (!sg_page(sg)) { ret = rds_page_remainder_alloc(sg, total_len, GFP_HIGHUSER); if (ret) goto out; rm->data.op_nents++; sg_off = 0; } while (iov_off == iov->iov_len) { iov_off = 0; iov++; } to_copy = min(iov->iov_len - iov_off, sg->length - sg_off); to_copy = min_t(size_t, to_copy, total_len); rdsdebug("copying %lu bytes from user iov [%p, %zu] + %lu to " "sg [%p, %u, %u] + %lu\n", to_copy, iov->iov_base, iov->iov_len, iov_off, (void *)sg_page(sg), sg->offset, sg->length, sg_off); ret = rds_page_copy_from_user(sg_page(sg), sg->offset + sg_off, iov->iov_base + iov_off, to_copy); if (ret) goto out; iov_off += to_copy; total_len -= to_copy; sg_off += to_copy; if (sg_off == sg->length) sg++; } out: return ret; } int rds_message_inc_copy_to_user(struct rds_incoming *inc, struct iovec *first_iov, size_t size) { struct rds_message *rm; struct iovec *iov; struct scatterlist *sg; unsigned long to_copy; unsigned long iov_off; unsigned long vec_off; int copied; int ret; u32 len; rm = container_of(inc, struct rds_message, m_inc); len = be32_to_cpu(rm->m_inc.i_hdr.h_len); iov = first_iov; iov_off = 0; sg = rm->data.op_sg; vec_off = 0; copied = 0; while (copied < size && copied < len) { while (iov_off == iov->iov_len) { iov_off = 0; iov++; } to_copy = min(iov->iov_len - iov_off, sg->length - vec_off); to_copy = min_t(size_t, to_copy, size - copied); to_copy = min_t(unsigned long, to_copy, len - copied); rdsdebug("copying %lu bytes to user iov [%p, %zu] + %lu to " "sg [%p, %u, %u] + %lu\n", to_copy, iov->iov_base, iov->iov_len, iov_off, sg_page(sg), sg->offset, sg->length, vec_off); ret = rds_page_copy_to_user(sg_page(sg), sg->offset + vec_off, iov->iov_base + iov_off, to_copy); if (ret) { copied = ret; break; } iov_off += to_copy; vec_off += to_copy; copied += to_copy; if (vec_off == sg->length) { vec_off = 0; sg++; } } return copied; } /* * If the message is still on the send queue, wait until the transport * is done with it. This is particularly important for RDMA operations. */ void rds_message_wait(struct rds_message *rm) { wait_event_interruptible(rm->m_flush_wait, !test_bit(RDS_MSG_MAPPED, &rm->m_flags)); } void rds_message_unmapped(struct rds_message *rm) { clear_bit(RDS_MSG_MAPPED, &rm->m_flags); wake_up_interruptible(&rm->m_flush_wait); } EXPORT_SYMBOL_GPL(rds_message_unmapped);
gpl-2.0
cmenard/kernel_smdk4412
drivers/ide/ide-ioctls.c
4026
6835
/* * IDE ioctls handling. */ #include <linux/hdreg.h> #include <linux/ide.h> #include <linux/slab.h> static const struct ide_ioctl_devset ide_ioctl_settings[] = { { HDIO_GET_32BIT, HDIO_SET_32BIT, &ide_devset_io_32bit }, { HDIO_GET_KEEPSETTINGS, HDIO_SET_KEEPSETTINGS, &ide_devset_keepsettings }, { HDIO_GET_UNMASKINTR, HDIO_SET_UNMASKINTR, &ide_devset_unmaskirq }, { HDIO_GET_DMA, HDIO_SET_DMA, &ide_devset_using_dma }, { -1, HDIO_SET_PIO_MODE, &ide_devset_pio_mode }, { 0 } }; int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev, unsigned int cmd, unsigned long arg, const struct ide_ioctl_devset *s) { const struct ide_devset *ds; int err = -EOPNOTSUPP; for (; (ds = s->setting); s++) { if (ds->get && s->get_ioctl == cmd) goto read_val; else if (ds->set && s->set_ioctl == cmd) goto set_val; } return err; read_val: mutex_lock(&ide_setting_mtx); err = ds->get(drive); mutex_unlock(&ide_setting_mtx); return err >= 0 ? put_user(err, (long __user *)arg) : err; set_val: if (bdev != bdev->bd_contains) err = -EINVAL; else { if (!capable(CAP_SYS_ADMIN)) err = -EACCES; else { mutex_lock(&ide_setting_mtx); err = ide_devset_execute(drive, ds, arg); mutex_unlock(&ide_setting_mtx); } } return err; } EXPORT_SYMBOL_GPL(ide_setting_ioctl); static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned long arg) { u16 *id = NULL; int size = (cmd == HDIO_GET_IDENTITY) ? (ATA_ID_WORDS * 2) : 142; int rc = 0; if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { rc = -ENOMSG; goto out; } /* ata_id_to_hd_driveid() relies on 'id' to be fully allocated. */ id = kmalloc(ATA_ID_WORDS * 2, GFP_KERNEL); if (id == NULL) { rc = -ENOMEM; goto out; } memcpy(id, drive->id, size); ata_id_to_hd_driveid(id); if (copy_to_user((void __user *)arg, id, size)) rc = -EFAULT; kfree(id); out: return rc; } static int ide_get_nice_ioctl(ide_drive_t *drive, unsigned long arg) { return put_user((!!(drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) << IDE_NICE_DSC_OVERLAP) | (!!(drive->dev_flags & IDE_DFLAG_NICE1) << IDE_NICE_1), (long __user *)arg); } static int ide_set_nice_ioctl(ide_drive_t *drive, unsigned long arg) { if (arg != (arg & ((1 << IDE_NICE_DSC_OVERLAP) | (1 << IDE_NICE_1)))) return -EPERM; if (((arg >> IDE_NICE_DSC_OVERLAP) & 1) && (drive->media != ide_tape)) return -EPERM; if ((arg >> IDE_NICE_DSC_OVERLAP) & 1) drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; else drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; if ((arg >> IDE_NICE_1) & 1) drive->dev_flags |= IDE_DFLAG_NICE1; else drive->dev_flags &= ~IDE_DFLAG_NICE1; return 0; } static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg) { u8 *buf = NULL; int bufsize = 0, err = 0; u8 args[4], xfer_rate = 0; struct ide_cmd cmd; struct ide_taskfile *tf = &cmd.tf; if (NULL == (void *) arg) { struct request *rq; rq = blk_get_request(drive->queue, READ, __GFP_WAIT); rq->cmd_type = REQ_TYPE_ATA_TASKFILE; err = blk_execute_rq(drive->queue, NULL, rq, 0); blk_put_request(rq); return err; } if (copy_from_user(args, (void __user *)arg, 4)) return -EFAULT; memset(&cmd, 0, sizeof(cmd)); tf->feature = args[2]; if (args[0] == ATA_CMD_SMART) { tf->nsect = args[3]; tf->lbal = args[1]; tf->lbam = 0x4f; tf->lbah = 0xc2; cmd.valid.out.tf = IDE_VALID_OUT_TF; cmd.valid.in.tf = IDE_VALID_NSECT; } else { tf->nsect = args[1]; cmd.valid.out.tf = IDE_VALID_FEATURE | IDE_VALID_NSECT; cmd.valid.in.tf = IDE_VALID_NSECT; } tf->command = args[0]; cmd.protocol = args[3] ? ATA_PROT_PIO : ATA_PROT_NODATA; if (args[3]) { cmd.tf_flags |= IDE_TFLAG_IO_16BIT; bufsize = SECTOR_SIZE * args[3]; buf = kzalloc(bufsize, GFP_KERNEL); if (buf == NULL) return -ENOMEM; } if (tf->command == ATA_CMD_SET_FEATURES && tf->feature == SETFEATURES_XFER && tf->nsect >= XFER_SW_DMA_0) { xfer_rate = ide_find_dma_mode(drive, tf->nsect); if (xfer_rate != tf->nsect) { err = -EINVAL; goto abort; } cmd.tf_flags |= IDE_TFLAG_SET_XFER; } err = ide_raw_taskfile(drive, &cmd, buf, args[3]); args[0] = tf->status; args[1] = tf->error; args[2] = tf->nsect; abort: if (copy_to_user((void __user *)arg, &args, 4)) err = -EFAULT; if (buf) { if (copy_to_user((void __user *)(arg + 4), buf, bufsize)) err = -EFAULT; kfree(buf); } return err; } static int ide_task_ioctl(ide_drive_t *drive, unsigned long arg) { void __user *p = (void __user *)arg; int err = 0; u8 args[7]; struct ide_cmd cmd; if (copy_from_user(args, p, 7)) return -EFAULT; memset(&cmd, 0, sizeof(cmd)); memcpy(&cmd.tf.feature, &args[1], 6); cmd.tf.command = args[0]; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; err = ide_no_data_taskfile(drive, &cmd); args[0] = cmd.tf.command; memcpy(&args[1], &cmd.tf.feature, 6); if (copy_to_user(p, args, 7)) err = -EFAULT; return err; } static int generic_drive_reset(ide_drive_t *drive) { struct request *rq; int ret = 0; rq = blk_get_request(drive->queue, READ, __GFP_WAIT); rq->cmd_type = REQ_TYPE_SPECIAL; rq->cmd_len = 1; rq->cmd[0] = REQ_DRIVE_RESET; if (blk_execute_rq(drive->queue, NULL, rq, 1)) ret = rq->errors; blk_put_request(rq); return ret; } int generic_ide_ioctl(ide_drive_t *drive, struct block_device *bdev, unsigned int cmd, unsigned long arg) { int err; err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_ioctl_settings); if (err != -EOPNOTSUPP) return err; switch (cmd) { case HDIO_OBSOLETE_IDENTITY: case HDIO_GET_IDENTITY: if (bdev != bdev->bd_contains) return -EINVAL; return ide_get_identity_ioctl(drive, cmd, arg); case HDIO_GET_NICE: return ide_get_nice_ioctl(drive, arg); case HDIO_SET_NICE: if (!capable(CAP_SYS_ADMIN)) return -EACCES; return ide_set_nice_ioctl(drive, arg); #ifdef CONFIG_IDE_TASK_IOCTL case HDIO_DRIVE_TASKFILE: if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) return -EACCES; if (drive->media == ide_disk) return ide_taskfile_ioctl(drive, arg); return -ENOMSG; #endif case HDIO_DRIVE_CMD: if (!capable(CAP_SYS_RAWIO)) return -EACCES; return ide_cmd_ioctl(drive, arg); case HDIO_DRIVE_TASK: if (!capable(CAP_SYS_RAWIO)) return -EACCES; return ide_task_ioctl(drive, arg); case HDIO_DRIVE_RESET: if (!capable(CAP_SYS_ADMIN)) return -EACCES; return generic_drive_reset(drive); case HDIO_GET_BUSSTATE: if (!capable(CAP_SYS_ADMIN)) return -EACCES; if (put_user(BUSSTATE_ON, (long __user *)arg)) return -EFAULT; return 0; case HDIO_SET_BUSSTATE: if (!capable(CAP_SYS_ADMIN)) return -EACCES; return -EOPNOTSUPP; default: return -EINVAL; } } EXPORT_SYMBOL(generic_ide_ioctl);
gpl-2.0
Pillar1989/linux-a80-3.4
drivers/w1/w1_int.c
4794
6465
/* * w1_int.c * * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net> * * * 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/list.h> #include <linux/delay.h> #include <linux/kthread.h> #include <linux/slab.h> #include <linux/export.h> #include <linux/moduleparam.h> #include "w1.h" #include "w1_log.h" #include "w1_netlink.h" #include "w1_int.h" static int w1_search_count = -1; /* Default is continual scan */ module_param_named(search_count, w1_search_count, int, 0); static int w1_enable_pullup = 1; module_param_named(enable_pullup, w1_enable_pullup, int, 0); static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, struct device_driver *driver, struct device *device) { struct w1_master *dev; int err; /* * We are in process context(kernel thread), so can sleep. */ dev = kzalloc(sizeof(struct w1_master) + sizeof(struct w1_bus_master), GFP_KERNEL); if (!dev) { printk(KERN_ERR "Failed to allocate %zd bytes for new w1 device.\n", sizeof(struct w1_master)); return NULL; } dev->bus_master = (struct w1_bus_master *)(dev + 1); dev->owner = THIS_MODULE; dev->max_slave_count = slave_count; dev->slave_count = 0; dev->attempts = 0; dev->initialized = 0; dev->id = id; dev->slave_ttl = slave_ttl; dev->search_count = w1_search_count; dev->enable_pullup = w1_enable_pullup; /* 1 for w1_process to decrement * 1 for __w1_remove_master_device to decrement */ atomic_set(&dev->refcnt, 2); INIT_LIST_HEAD(&dev->slist); mutex_init(&dev->mutex); memcpy(&dev->dev, device, sizeof(struct device)); dev_set_name(&dev->dev, "w1_bus_master%u", dev->id); snprintf(dev->name, sizeof(dev->name), "w1_bus_master%u", dev->id); dev->dev.init_name = dev->name; dev->driver = driver; dev->seq = 1; err = device_register(&dev->dev); if (err) { printk(KERN_ERR "Failed to register master device. err=%d\n", err); memset(dev, 0, sizeof(struct w1_master)); kfree(dev); dev = NULL; } return dev; } static void w1_free_dev(struct w1_master *dev) { device_unregister(&dev->dev); } int w1_add_master_device(struct w1_bus_master *master) { struct w1_master *dev, *entry; int retval = 0; struct w1_netlink_msg msg; int id, found; /* validate minimum functionality */ if (!(master->touch_bit && master->reset_bus) && !(master->write_bit && master->read_bit) && !(master->write_byte && master->read_byte && master->reset_bus)) { printk(KERN_ERR "w1_add_master_device: invalid function set\n"); return(-EINVAL); } /* While it would be electrically possible to make a device that * generated a strong pullup in bit bang mode, only hardare that * controls 1-wire time frames are even expected to support a strong * pullup. w1_io.c would need to support calling set_pullup before * the last write_bit operation of a w1_write_8 which it currently * doesn't. */ if (!master->write_byte && !master->touch_bit && master->set_pullup) { printk(KERN_ERR "w1_add_master_device: set_pullup requires " "write_byte or touch_bit, disabling\n"); master->set_pullup = NULL; } /* Lock until the device is added (or not) to w1_masters. */ mutex_lock(&w1_mlock); /* Search for the first available id (starting at 1). */ id = 0; do { ++id; found = 0; list_for_each_entry(entry, &w1_masters, w1_master_entry) { if (entry->id == id) { found = 1; break; } } } while (found); dev = w1_alloc_dev(id, w1_max_slave_count, w1_max_slave_ttl, &w1_master_driver, &w1_master_device); if (!dev) { mutex_unlock(&w1_mlock); return -ENOMEM; } retval = w1_create_master_attributes(dev); if (retval) { mutex_unlock(&w1_mlock); goto err_out_free_dev; } memcpy(dev->bus_master, master, sizeof(struct w1_bus_master)); dev->initialized = 1; dev->thread = kthread_run(&w1_process, dev, "%s", dev->name); if (IS_ERR(dev->thread)) { retval = PTR_ERR(dev->thread); dev_err(&dev->dev, "Failed to create new kernel thread. err=%d\n", retval); mutex_unlock(&w1_mlock); goto err_out_rm_attr; } list_add(&dev->w1_master_entry, &w1_masters); mutex_unlock(&w1_mlock); memset(&msg, 0, sizeof(msg)); msg.id.mst.id = dev->id; msg.type = W1_MASTER_ADD; w1_netlink_send(dev, &msg); return 0; #if 0 /* Thread cleanup code, not required currently. */ err_out_kill_thread: kthread_stop(dev->thread); #endif err_out_rm_attr: w1_destroy_master_attributes(dev); err_out_free_dev: w1_free_dev(dev); return retval; } void __w1_remove_master_device(struct w1_master *dev) { struct w1_netlink_msg msg; struct w1_slave *sl, *sln; kthread_stop(dev->thread); mutex_lock(&w1_mlock); list_del(&dev->w1_master_entry); mutex_unlock(&w1_mlock); mutex_lock(&dev->mutex); list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) w1_slave_detach(sl); w1_destroy_master_attributes(dev); mutex_unlock(&dev->mutex); atomic_dec(&dev->refcnt); while (atomic_read(&dev->refcnt)) { dev_info(&dev->dev, "Waiting for %s to become free: refcnt=%d.\n", dev->name, atomic_read(&dev->refcnt)); if (msleep_interruptible(1000)) flush_signals(current); } memset(&msg, 0, sizeof(msg)); msg.id.mst.id = dev->id; msg.type = W1_MASTER_REMOVE; w1_netlink_send(dev, &msg); w1_free_dev(dev); } void w1_remove_master_device(struct w1_bus_master *bm) { struct w1_master *dev, *found = NULL; list_for_each_entry(dev, &w1_masters, w1_master_entry) { if (!dev->initialized) continue; if (dev->bus_master->data == bm->data) { found = dev; break; } } if (!found) { printk(KERN_ERR "Device doesn't exist.\n"); return; } __w1_remove_master_device(found); } EXPORT_SYMBOL(w1_add_master_device); EXPORT_SYMBOL(w1_remove_master_device);
gpl-2.0
lexmar93/Siyah-i777
fs/afs/inode.c
5050
12514
/* * Copyright (c) 2002 Red Hat, Inc. All rights reserved. * * This software may be freely redistributed under the terms of the * GNU General Public License. * * 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. * * Authors: David Woodhouse <dwmw2@infradead.org> * David Howells <dhowells@redhat.com> * */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/pagemap.h> #include <linux/sched.h> #include <linux/mount.h> #include <linux/namei.h> #include "internal.h" struct afs_iget_data { struct afs_fid fid; struct afs_volume *volume; /* volume on which resides */ }; /* * map the AFS file status to the inode member variables */ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key) { struct inode *inode = AFS_VNODE_TO_I(vnode); _debug("FS: ft=%d lk=%d sz=%llu ver=%Lu mod=%hu", vnode->status.type, vnode->status.nlink, (unsigned long long) vnode->status.size, vnode->status.data_version, vnode->status.mode); switch (vnode->status.type) { case AFS_FTYPE_FILE: inode->i_mode = S_IFREG | vnode->status.mode; inode->i_op = &afs_file_inode_operations; inode->i_fop = &afs_file_operations; break; case AFS_FTYPE_DIR: inode->i_mode = S_IFDIR | vnode->status.mode; inode->i_op = &afs_dir_inode_operations; inode->i_fop = &afs_dir_file_operations; break; case AFS_FTYPE_SYMLINK: inode->i_mode = S_IFLNK | vnode->status.mode; inode->i_op = &page_symlink_inode_operations; break; default: printk("kAFS: AFS vnode with undefined type\n"); return -EBADMSG; } #ifdef CONFIG_AFS_FSCACHE if (vnode->status.size != inode->i_size) fscache_attr_changed(vnode->cache); #endif set_nlink(inode, vnode->status.nlink); inode->i_uid = vnode->status.owner; inode->i_gid = 0; inode->i_size = vnode->status.size; inode->i_ctime.tv_sec = vnode->status.mtime_server; inode->i_ctime.tv_nsec = 0; inode->i_atime = inode->i_mtime = inode->i_ctime; inode->i_blocks = 0; inode->i_generation = vnode->fid.unique; inode->i_version = vnode->status.data_version; inode->i_mapping->a_ops = &afs_fs_aops; /* check to see whether a symbolic link is really a mountpoint */ if (vnode->status.type == AFS_FTYPE_SYMLINK) { afs_mntpt_check_symlink(vnode, key); if (test_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags)) { inode->i_mode = S_IFDIR | vnode->status.mode; inode->i_op = &afs_mntpt_inode_operations; inode->i_fop = &afs_mntpt_file_operations; } } return 0; } /* * iget5() comparator */ static int afs_iget5_test(struct inode *inode, void *opaque) { struct afs_iget_data *data = opaque; return inode->i_ino == data->fid.vnode && inode->i_generation == data->fid.unique; } /* * iget5() comparator for inode created by autocell operations * * These pseudo inodes don't match anything. */ static int afs_iget5_autocell_test(struct inode *inode, void *opaque) { return 0; } /* * iget5() inode initialiser */ static int afs_iget5_set(struct inode *inode, void *opaque) { struct afs_iget_data *data = opaque; struct afs_vnode *vnode = AFS_FS_I(inode); inode->i_ino = data->fid.vnode; inode->i_generation = data->fid.unique; vnode->fid = data->fid; vnode->volume = data->volume; return 0; } /* * inode retrieval for autocell */ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name, int namesz, struct key *key) { struct afs_iget_data data; struct afs_super_info *as; struct afs_vnode *vnode; struct super_block *sb; struct inode *inode; static atomic_t afs_autocell_ino; _enter("{%x:%u},%*.*s,", AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode, namesz, namesz, dev_name ?: ""); sb = dir->i_sb; as = sb->s_fs_info; data.volume = as->volume; data.fid.vid = as->volume->vid; data.fid.unique = 0; data.fid.vnode = 0; inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino), afs_iget5_autocell_test, afs_iget5_set, &data); if (!inode) { _leave(" = -ENOMEM"); return ERR_PTR(-ENOMEM); } _debug("GOT INODE %p { ino=%lu, vl=%x, vn=%x, u=%x }", inode, inode->i_ino, data.fid.vid, data.fid.vnode, data.fid.unique); vnode = AFS_FS_I(inode); /* there shouldn't be an existing inode */ BUG_ON(!(inode->i_state & I_NEW)); inode->i_size = 0; inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; inode->i_op = &afs_autocell_inode_operations; set_nlink(inode, 2); inode->i_uid = 0; inode->i_gid = 0; inode->i_ctime.tv_sec = get_seconds(); inode->i_ctime.tv_nsec = 0; inode->i_atime = inode->i_mtime = inode->i_ctime; inode->i_blocks = 0; inode->i_version = 0; inode->i_generation = 0; set_bit(AFS_VNODE_PSEUDODIR, &vnode->flags); set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags); inode->i_flags |= S_AUTOMOUNT | S_NOATIME; unlock_new_inode(inode); _leave(" = %p", inode); return inode; } /* * inode retrieval */ struct inode *afs_iget(struct super_block *sb, struct key *key, struct afs_fid *fid, struct afs_file_status *status, struct afs_callback *cb) { struct afs_iget_data data = { .fid = *fid }; struct afs_super_info *as; struct afs_vnode *vnode; struct inode *inode; int ret; _enter(",{%x:%u.%u},,", fid->vid, fid->vnode, fid->unique); as = sb->s_fs_info; data.volume = as->volume; inode = iget5_locked(sb, fid->vnode, afs_iget5_test, afs_iget5_set, &data); if (!inode) { _leave(" = -ENOMEM"); return ERR_PTR(-ENOMEM); } _debug("GOT INODE %p { vl=%x vn=%x, u=%x }", inode, fid->vid, fid->vnode, fid->unique); vnode = AFS_FS_I(inode); /* deal with an existing inode */ if (!(inode->i_state & I_NEW)) { _leave(" = %p", inode); return inode; } if (!status) { /* it's a remotely extant inode */ set_bit(AFS_VNODE_CB_BROKEN, &vnode->flags); ret = afs_vnode_fetch_status(vnode, NULL, key); if (ret < 0) goto bad_inode; } else { /* it's an inode we just created */ memcpy(&vnode->status, status, sizeof(vnode->status)); if (!cb) { /* it's a symlink we just created (the fileserver * didn't give us a callback) */ vnode->cb_version = 0; vnode->cb_expiry = 0; vnode->cb_type = 0; vnode->cb_expires = get_seconds(); } else { vnode->cb_version = cb->version; vnode->cb_expiry = cb->expiry; vnode->cb_type = cb->type; vnode->cb_expires = vnode->cb_expiry + get_seconds(); } } /* set up caching before mapping the status, as map-status reads the * first page of symlinks to see if they're really mountpoints */ inode->i_size = vnode->status.size; #ifdef CONFIG_AFS_FSCACHE vnode->cache = fscache_acquire_cookie(vnode->volume->cache, &afs_vnode_cache_index_def, vnode); #endif ret = afs_inode_map_status(vnode, key); if (ret < 0) goto bad_inode; /* success */ clear_bit(AFS_VNODE_UNSET, &vnode->flags); inode->i_flags |= S_NOATIME; unlock_new_inode(inode); _leave(" = %p [CB { v=%u t=%u }]", inode, vnode->cb_version, vnode->cb_type); return inode; /* failure */ bad_inode: #ifdef CONFIG_AFS_FSCACHE fscache_relinquish_cookie(vnode->cache, 0); vnode->cache = NULL; #endif iget_failed(inode); _leave(" = %d [bad]", ret); return ERR_PTR(ret); } /* * mark the data attached to an inode as obsolete due to a write on the server * - might also want to ditch all the outstanding writes and dirty pages */ void afs_zap_data(struct afs_vnode *vnode) { _enter("{%x:%u}", vnode->fid.vid, vnode->fid.vnode); /* nuke all the non-dirty pages that aren't locked, mapped or being * written back in a regular file and completely discard the pages in a * directory or symlink */ if (S_ISREG(vnode->vfs_inode.i_mode)) invalidate_remote_inode(&vnode->vfs_inode); else invalidate_inode_pages2(vnode->vfs_inode.i_mapping); } /* * validate a vnode/inode * - there are several things we need to check * - parent dir data changes (rm, rmdir, rename, mkdir, create, link, * symlink) * - parent dir metadata changed (security changes) * - dentry data changed (write, truncate) * - dentry metadata changed (security changes) */ int afs_validate(struct afs_vnode *vnode, struct key *key) { int ret; _enter("{v={%x:%u} fl=%lx},%x", vnode->fid.vid, vnode->fid.vnode, vnode->flags, key_serial(key)); if (vnode->cb_promised && !test_bit(AFS_VNODE_CB_BROKEN, &vnode->flags) && !test_bit(AFS_VNODE_MODIFIED, &vnode->flags) && !test_bit(AFS_VNODE_ZAP_DATA, &vnode->flags)) { if (vnode->cb_expires < get_seconds() + 10) { _debug("callback expired"); set_bit(AFS_VNODE_CB_BROKEN, &vnode->flags); } else { goto valid; } } if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) goto valid; mutex_lock(&vnode->validate_lock); /* if the promise has expired, we need to check the server again to get * a new promise - note that if the (parent) directory's metadata was * changed then the security may be different and we may no longer have * access */ if (!vnode->cb_promised || test_bit(AFS_VNODE_CB_BROKEN, &vnode->flags)) { _debug("not promised"); ret = afs_vnode_fetch_status(vnode, NULL, key); if (ret < 0) goto error_unlock; _debug("new promise [fl=%lx]", vnode->flags); } if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) { _debug("file already deleted"); ret = -ESTALE; goto error_unlock; } /* if the vnode's data version number changed then its contents are * different */ if (test_and_clear_bit(AFS_VNODE_ZAP_DATA, &vnode->flags)) afs_zap_data(vnode); clear_bit(AFS_VNODE_MODIFIED, &vnode->flags); mutex_unlock(&vnode->validate_lock); valid: _leave(" = 0"); return 0; error_unlock: mutex_unlock(&vnode->validate_lock); _leave(" = %d", ret); return ret; } /* * read the attributes of an inode */ int afs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { struct inode *inode; inode = dentry->d_inode; _enter("{ ino=%lu v=%u }", inode->i_ino, inode->i_generation); generic_fillattr(inode, stat); return 0; } /* * discard an AFS inode */ int afs_drop_inode(struct inode *inode) { _enter(""); if (test_bit(AFS_VNODE_PSEUDODIR, &AFS_FS_I(inode)->flags)) return generic_delete_inode(inode); else return generic_drop_inode(inode); } /* * clear an AFS inode */ void afs_evict_inode(struct inode *inode) { struct afs_permits *permits; struct afs_vnode *vnode; vnode = AFS_FS_I(inode); _enter("{%x:%u.%d} v=%u x=%u t=%u }", vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique, vnode->cb_version, vnode->cb_expiry, vnode->cb_type); _debug("CLEAR INODE %p", inode); ASSERTCMP(inode->i_ino, ==, vnode->fid.vnode); truncate_inode_pages(&inode->i_data, 0); end_writeback(inode); afs_give_up_callback(vnode); if (vnode->server) { spin_lock(&vnode->server->fs_lock); rb_erase(&vnode->server_rb, &vnode->server->fs_vnodes); spin_unlock(&vnode->server->fs_lock); afs_put_server(vnode->server); vnode->server = NULL; } ASSERT(list_empty(&vnode->writebacks)); ASSERT(!vnode->cb_promised); #ifdef CONFIG_AFS_FSCACHE fscache_relinquish_cookie(vnode->cache, 0); vnode->cache = NULL; #endif mutex_lock(&vnode->permits_lock); permits = vnode->permits; rcu_assign_pointer(vnode->permits, NULL); mutex_unlock(&vnode->permits_lock); if (permits) call_rcu(&permits->rcu, afs_zap_permits); _leave(""); } /* * set the attributes of an inode */ int afs_setattr(struct dentry *dentry, struct iattr *attr) { struct afs_vnode *vnode = AFS_FS_I(dentry->d_inode); struct key *key; int ret; _enter("{%x:%u},{n=%s},%x", vnode->fid.vid, vnode->fid.vnode, dentry->d_name.name, attr->ia_valid); if (!(attr->ia_valid & (ATTR_SIZE | ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_MTIME))) { _leave(" = 0 [unsupported]"); return 0; } /* flush any dirty data outstanding on a regular file */ if (S_ISREG(vnode->vfs_inode.i_mode)) { filemap_write_and_wait(vnode->vfs_inode.i_mapping); afs_writeback_all(vnode); } if (attr->ia_valid & ATTR_FILE) { key = attr->ia_file->private_data; } else { key = afs_request_key(vnode->volume->cell); if (IS_ERR(key)) { ret = PTR_ERR(key); goto error; } } ret = afs_vnode_setattr(vnode, key, attr); if (!(attr->ia_valid & ATTR_FILE)) key_put(key); error: _leave(" = %d", ret); return ret; }
gpl-2.0
Kalashnikitty/Aurora_D802
drivers/net/irda/toim3232-sir.c
8890
12466
/********************************************************************* * * Filename: toim3232-sir.c * Version: 1.0 * Description: Implementation of dongles based on the Vishay/Temic * TOIM3232 SIR Endec chipset. Currently only the * IRWave IR320ST-2 is tested, although it should work * with any TOIM3232 or TOIM4232 chipset based RS232 * dongle with minimal modification. * Based heavily on the Tekram driver (tekram.c), * with thanks to Dag Brattli and Martin Diehl. * Status: Experimental. * Author: David Basden <davidb-irda@rcpt.to> * Created at: Thu Feb 09 23:47:32 2006 * * Copyright (c) 2006 David Basden. * Copyright (c) 1998-1999 Dag Brattli, * Copyright (c) 2002 Martin Diehl, * 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. * * Neither Dag Brattli nor University of Tromsø admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ /* * This driver has currently only been tested on the IRWave IR320ST-2 * * PROTOCOL: * * The protocol for talking to the TOIM3232 is quite easy, and is * designed to interface with RS232 with only level convertors. The * BR/~D line on the chip is brought high to signal 'command mode', * where a command byte is sent to select the baudrate of the RS232 * interface and the pulse length of the IRDA output. When BR/~D * is brought low, the dongle then changes to the selected baudrate, * and the RS232 interface is used for data until BR/~D is brought * high again. The initial speed for the TOIMx323 after RESET is * 9600 baud. The baudrate for command-mode is the last selected * baud-rate, or 9600 after a RESET. * * The dongle I have (below) adds some extra hardware on the front end, * but this is mostly directed towards pariasitic power from the RS232 * line rather than changing very much about how to communicate with * the TOIM3232. * * The protocol to talk to the TOIM4232 chipset seems to be almost * identical to the TOIM3232 (and the 4232 datasheet is more detailed) * so this code will probably work on that as well, although I haven't * tested it on that hardware. * * Target dongle variations that might be common: * * DTR and RTS function: * The data sheet for the 4232 has a sample implementation that hooks the * DTR and RTS lines to the RESET and BaudRate/~Data lines of the * chip (through line-converters). Given both DTR and RTS would have to * be held low in normal operation, and the TOIMx232 requires +5V to * signal ground, most dongle designers would almost certainly choose * an implementation that kept at least one of DTR or RTS high in * normal operation to provide power to the dongle, but will likely * vary between designs. * * User specified command bits: * There are two user-controllable output lines from the TOIMx232 that * can be set low or high by setting the appropriate bits in the * high-nibble of the command byte (when setting speed and pulse length). * These might be used to switch on and off added hardware or extra * dongle features. * * * Target hardware: IRWave IR320ST-2 * * The IRWave IR320ST-2 is a simple dongle based on the Vishay/Temic * TOIM3232 SIR Endec and the Vishay/Temic TFDS4500 SIR IRDA transceiver. * It uses a hex inverter and some discrete components to buffer and * line convert the RS232 down to 5V. * * The dongle is powered through a voltage regulator, fed by a large * capacitor. To switch the dongle on, DTR is brought high to charge * the capacitor and drive the voltage regulator. DTR isn't associated * with any control lines on the TOIM3232. Parisitic power is also taken * from the RTS, TD and RD lines when brought high, but through resistors. * When DTR is low, the circuit might lose power even with RTS high. * * RTS is inverted and attached to the BR/~D input pin. When RTS * is high, BR/~D is low, and the TOIM3232 is in the normal 'data' mode. * RTS is brought low, BR/~D is high, and the TOIM3232 is in 'command * mode'. * * For some unknown reason, the RESET line isn't actually connected * to anything. This means to reset the dongle to get it to a known * state (9600 baud) you must drop DTR and RTS low, wait for the power * capacitor to discharge, and then bring DTR (and RTS for data mode) * high again, and wait for the capacitor to charge, the power supply * to stabilise, and the oscillator clock to stabilise. * * Fortunately, if the current baudrate is known, the chipset can * easily change speed by entering command mode without having to * reset the dongle first. * * Major Components: * * - Vishay/Temic TOIM3232 SIR Endec to change RS232 pulse timings * to IRDA pulse timings * - 3.6864MHz crystal to drive TOIM3232 clock oscillator * - DM74lS04M Inverting Hex line buffer for RS232 input buffering * and level conversion * - PJ2951AC 150mA voltage regulator * - Vishay/Temic TFDS4500 SIR IRDA front-end transceiver * */ #include <linux/module.h> #include <linux/delay.h> #include <linux/init.h> #include <linux/sched.h> #include <net/irda/irda.h> #include "sir-dev.h" static int toim3232delay = 150; /* default is 150 ms */ module_param(toim3232delay, int, 0); MODULE_PARM_DESC(toim3232delay, "toim3232 dongle write complete delay"); #if 0 static int toim3232flipdtr = 0; /* default is DTR high to reset */ module_param(toim3232flipdtr, int, 0); MODULE_PARM_DESC(toim3232flipdtr, "toim3232 dongle invert DTR (Reset)"); static int toim3232fliprts = 0; /* default is RTS high for baud change */ module_param(toim3232fliptrs, int, 0); MODULE_PARM_DESC(toim3232fliprts, "toim3232 dongle invert RTS (BR/D)"); #endif static int toim3232_open(struct sir_dev *); static int toim3232_close(struct sir_dev *); static int toim3232_change_speed(struct sir_dev *, unsigned); static int toim3232_reset(struct sir_dev *); #define TOIM3232_115200 0x00 #define TOIM3232_57600 0x01 #define TOIM3232_38400 0x02 #define TOIM3232_19200 0x03 #define TOIM3232_9600 0x06 #define TOIM3232_2400 0x0A #define TOIM3232_PW 0x10 /* Pulse select bit */ static struct dongle_driver toim3232 = { .owner = THIS_MODULE, .driver_name = "Vishay TOIM3232", .type = IRDA_TOIM3232_DONGLE, .open = toim3232_open, .close = toim3232_close, .reset = toim3232_reset, .set_speed = toim3232_change_speed, }; static int __init toim3232_sir_init(void) { if (toim3232delay < 1 || toim3232delay > 500) toim3232delay = 200; IRDA_DEBUG(1, "%s - using %d ms delay\n", toim3232.driver_name, toim3232delay); return irda_register_dongle(&toim3232); } static void __exit toim3232_sir_cleanup(void) { irda_unregister_dongle(&toim3232); } static int toim3232_open(struct sir_dev *dev) { struct qos_info *qos = &dev->qos; IRDA_DEBUG(2, "%s()\n", __func__); /* Pull the lines high to start with. * * For the IR320ST-2, we need to charge the main supply capacitor to * switch the device on. We keep DTR high throughout to do this. * When RTS, TD and RD are high, they will also trickle-charge the * cap. RTS is high for data transmission, and low for baud rate select. * -- DGB */ sirdev_set_dtr_rts(dev, TRUE, TRUE); /* The TOI3232 supports many speeds between 1200bps and 115000bps. * We really only care about those supported by the IRDA spec, but * 38400 seems to be implemented in many places */ qos->baud_rate.bits &= IR_2400|IR_9600|IR_19200|IR_38400|IR_57600|IR_115200; /* From the tekram driver. Not sure what a reasonable value is -- DGB */ qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */ irda_qos_bits_to_value(qos); /* irda thread waits 50 msec for power settling */ return 0; } static int toim3232_close(struct sir_dev *dev) { IRDA_DEBUG(2, "%s()\n", __func__); /* Power off dongle */ sirdev_set_dtr_rts(dev, FALSE, FALSE); return 0; } /* * Function toim3232change_speed (dev, state, speed) * * Set the speed for the TOIM3232 based dongle. Warning, this * function must be called with a process context! * * Algorithm * 1. keep DTR high but clear RTS to bring into baud programming mode * 2. wait at least 7us to enter programming mode * 3. send control word to set baud rate and timing * 4. wait at least 1us * 5. bring RTS high to enter DATA mode (RS232 is passed through to transceiver) * 6. should take effect immediately (although probably worth waiting) */ #define TOIM3232_STATE_WAIT_SPEED (SIRDEV_STATE_DONGLE_SPEED + 1) static int toim3232_change_speed(struct sir_dev *dev, unsigned speed) { unsigned state = dev->fsm.substate; unsigned delay = 0; u8 byte; static int ret = 0; IRDA_DEBUG(2, "%s()\n", __func__); switch(state) { case SIRDEV_STATE_DONGLE_SPEED: /* Figure out what we are going to send as a control byte */ switch (speed) { case 2400: byte = TOIM3232_PW|TOIM3232_2400; break; default: speed = 9600; ret = -EINVAL; /* fall thru */ case 9600: byte = TOIM3232_PW|TOIM3232_9600; break; case 19200: byte = TOIM3232_PW|TOIM3232_19200; break; case 38400: byte = TOIM3232_PW|TOIM3232_38400; break; case 57600: byte = TOIM3232_PW|TOIM3232_57600; break; case 115200: byte = TOIM3232_115200; break; } /* Set DTR, Clear RTS: Go into baud programming mode */ sirdev_set_dtr_rts(dev, TRUE, FALSE); /* Wait at least 7us */ udelay(14); /* Write control byte */ sirdev_raw_write(dev, &byte, 1); dev->speed = speed; state = TOIM3232_STATE_WAIT_SPEED; delay = toim3232delay; break; case TOIM3232_STATE_WAIT_SPEED: /* Have transmitted control byte * Wait for 'at least 1us' */ udelay(14); /* Set DTR, Set RTS: Go into normal data mode */ sirdev_set_dtr_rts(dev, TRUE, TRUE); /* Wait (TODO: check this is needed) */ udelay(50); break; default: printk(KERN_ERR "%s - undefined state %d\n", __func__, state); ret = -EINVAL; break; } dev->fsm.substate = state; return (delay > 0) ? delay : ret; } /* * Function toim3232reset (driver) * * This function resets the toim3232 dongle. Warning, this function * must be called with a process context!! * * What we should do is: * 0. Pull RESET high * 1. Wait for at least 7us * 2. Pull RESET low * 3. Wait for at least 7us * 4. Pull BR/~D high * 5. Wait for at least 7us * 6. Send control byte to set baud rate * 7. Wait at least 1us after stop bit * 8. Pull BR/~D low * 9. Should then be in data mode * * Because the IR320ST-2 doesn't have the RESET line connected for some reason, * we'll have to do something else. * * The default speed after a RESET is 9600, so lets try just bringing it up in * data mode after switching it off, waiting for the supply capacitor to * discharge, and then switch it back on. This isn't actually pulling RESET * high, but it seems to have the same effect. * * This behaviour will probably work on dongles that have the RESET line connected, * but if not, add a flag for the IR320ST-2, and implment the above-listed proper * behaviour. * * RTS is inverted and then fed to BR/~D, so to put it in programming mode, we * need to have pull RTS low */ static int toim3232_reset(struct sir_dev *dev) { IRDA_DEBUG(2, "%s()\n", __func__); /* Switch off both DTR and RTS to switch off dongle */ sirdev_set_dtr_rts(dev, FALSE, FALSE); /* Should sleep a while. This might be evil doing it this way.*/ set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(msecs_to_jiffies(50)); /* Set DTR, Set RTS (data mode) */ sirdev_set_dtr_rts(dev, TRUE, TRUE); /* Wait at least 10 ms for power to stabilize again */ set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(msecs_to_jiffies(10)); /* Speed should now be 9600 */ dev->speed = 9600; return 0; } MODULE_AUTHOR("David Basden <davidb-linux@rcpt.to>"); MODULE_DESCRIPTION("Vishay/Temic TOIM3232 based dongle driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("irda-dongle-12"); /* IRDA_TOIM3232_DONGLE */ module_init(toim3232_sir_init); module_exit(toim3232_sir_cleanup);
gpl-2.0
CandyDevices/kernel_lge_msm8974
fs/fscache/proc.c
14522
1933
/* FS-Cache statistics viewing interface * * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.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. */ #define FSCACHE_DEBUG_LEVEL OPERATION #include <linux/module.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> #include "internal.h" /* * initialise the /proc/fs/fscache/ directory */ int __init fscache_proc_init(void) { _enter(""); if (!proc_mkdir("fs/fscache", NULL)) goto error_dir; #ifdef CONFIG_FSCACHE_STATS if (!proc_create("fs/fscache/stats", S_IFREG | 0444, NULL, &fscache_stats_fops)) goto error_stats; #endif #ifdef CONFIG_FSCACHE_HISTOGRAM if (!proc_create("fs/fscache/histogram", S_IFREG | 0444, NULL, &fscache_histogram_fops)) goto error_histogram; #endif #ifdef CONFIG_FSCACHE_OBJECT_LIST if (!proc_create("fs/fscache/objects", S_IFREG | 0444, NULL, &fscache_objlist_fops)) goto error_objects; #endif _leave(" = 0"); return 0; #ifdef CONFIG_FSCACHE_OBJECT_LIST error_objects: #endif #ifdef CONFIG_FSCACHE_HISTOGRAM remove_proc_entry("fs/fscache/histogram", NULL); error_histogram: #endif #ifdef CONFIG_FSCACHE_STATS remove_proc_entry("fs/fscache/stats", NULL); error_stats: #endif remove_proc_entry("fs/fscache", NULL); error_dir: _leave(" = -ENOMEM"); return -ENOMEM; } /* * clean up the /proc/fs/fscache/ directory */ void fscache_proc_cleanup(void) { #ifdef CONFIG_FSCACHE_OBJECT_LIST remove_proc_entry("fs/fscache/objects", NULL); #endif #ifdef CONFIG_FSCACHE_HISTOGRAM remove_proc_entry("fs/fscache/histogram", NULL); #endif #ifdef CONFIG_FSCACHE_STATS remove_proc_entry("fs/fscache/stats", NULL); #endif remove_proc_entry("fs/fscache", NULL); }
gpl-2.0
urumican/linux-3.8.8
mm/readahead.c
187
16451
/* * mm/readahead.c - address_space-level file readahead. * * Copyright (C) 2002, Linus Torvalds * * 09Apr2002 Andrew Morton * Initial version. */ #include <linux/kernel.h> #include <linux/fs.h> #include <linux/gfp.h> #include <linux/mm.h> #include <linux/export.h> #include <linux/blkdev.h> #include <linux/backing-dev.h> #include <linux/task_io_accounting_ops.h> #include <linux/pagevec.h> #include <linux/pagemap.h> #include <linux/syscalls.h> #include <linux/file.h> /* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero. */ void file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping) { ra->ra_pages = mapping->backing_dev_info->ra_pages; ra->prev_pos = -1; } EXPORT_SYMBOL_GPL(file_ra_state_init); #define list_to_page(head) (list_entry((head)->prev, struct page, lru)) /* * see if a page needs releasing upon read_cache_pages() failure * - the caller of read_cache_pages() may have set PG_private or PG_fscache * before calling, such as the NFS fs marking pages that are cached locally * on disk, thus we need to give the fs a chance to clean up in the event of * an error */ static void read_cache_pages_invalidate_page(struct address_space *mapping, struct page *page) { if (page_has_private(page)) { if (!trylock_page(page)) BUG(); page->mapping = mapping; do_invalidatepage(page, 0); page->mapping = NULL; unlock_page(page); } page_cache_release(page); } /* * release a list of pages, invalidating them first if need be */ static void read_cache_pages_invalidate_pages(struct address_space *mapping, struct list_head *pages) { struct page *victim; while (!list_empty(pages)) { victim = list_to_page(pages); list_del(&victim->lru); read_cache_pages_invalidate_page(mapping, victim); } } /** * read_cache_pages - populate an address space with some pages & start reads against them * @mapping: the address_space * @pages: The address of a list_head which contains the target pages. These * pages have their ->index populated and are otherwise uninitialised. * @filler: callback routine for filling a single page. * @data: private data for the callback routine. * * Hides the details of the LRU cache etc from the filesystems. */ int read_cache_pages(struct address_space *mapping, struct list_head *pages, int (*filler)(void *, struct page *), void *data) { struct page *page; int ret = 0; while (!list_empty(pages)) { page = list_to_page(pages); list_del(&page->lru); if (add_to_page_cache_lru(page, mapping, page->index, GFP_KERNEL)) { read_cache_pages_invalidate_page(mapping, page); continue; } page_cache_release(page); ret = filler(data, page); if (unlikely(ret)) { read_cache_pages_invalidate_pages(mapping, pages); break; } task_io_account_read(PAGE_CACHE_SIZE); } return ret; } EXPORT_SYMBOL(read_cache_pages); static int read_pages(struct address_space *mapping, struct file *filp, struct list_head *pages, unsigned nr_pages) { struct blk_plug plug; unsigned page_idx; int ret; blk_start_plug(&plug); if (mapping->a_ops->readpages) { ret = mapping->a_ops->readpages(filp, mapping, pages, nr_pages); /* Clean up the remaining pages */ put_pages_list(pages); goto out; } for (page_idx = 0; page_idx < nr_pages; page_idx++) { struct page *page = list_to_page(pages); list_del(&page->lru); if (!add_to_page_cache_lru(page, mapping, page->index, GFP_KERNEL)) { mapping->a_ops->readpage(filp, page); } page_cache_release(page); } ret = 0; out: blk_finish_plug(&plug); return ret; } /* * __do_page_cache_readahead() actually reads a chunk of disk. It allocates all * the pages first, then submits them all for I/O. This avoids the very bad * behaviour which would occur if page allocations are causing VM writeback. * We really don't want to intermingle reads and writes like that. * * Returns the number of pages requested, or the maximum amount of I/O allowed. */ static int __do_page_cache_readahead(struct address_space *mapping, struct file *filp, pgoff_t offset, unsigned long nr_to_read, unsigned long lookahead_size) { struct inode *inode = mapping->host; struct page *page; unsigned long end_index; /* The last page we want to read */ LIST_HEAD(page_pool); int page_idx; int ret = 0; loff_t isize = i_size_read(inode); if (isize == 0) goto out; end_index = ((isize - 1) >> PAGE_CACHE_SHIFT); /* * Preallocate as many pages as we will need. */ for (page_idx = 0; page_idx < nr_to_read; page_idx++) { pgoff_t page_offset = offset + page_idx; if (page_offset > end_index) break; rcu_read_lock(); page = radix_tree_lookup(&mapping->page_tree, page_offset); rcu_read_unlock(); if (page) continue; page = page_cache_alloc_readahead(mapping); if (!page) break; page->index = page_offset; list_add(&page->lru, &page_pool); if (page_idx == nr_to_read - lookahead_size) SetPageReadahead(page); ret++; } /* * Now start the IO. We ignore I/O errors - if the page is not * uptodate then the caller will launch readpage again, and * will then handle the error. */ if (ret) read_pages(mapping, filp, &page_pool, ret); BUG_ON(!list_empty(&page_pool)); out: return ret; } /* * Chunk the readahead into 2 megabyte units, so that we don't pin too much * memory at once. */ int force_page_cache_readahead(struct address_space *mapping, struct file *filp, pgoff_t offset, unsigned long nr_to_read) { int ret = 0; if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages)) return -EINVAL; nr_to_read = max_sane_readahead(nr_to_read); while (nr_to_read) { int err; unsigned long this_chunk = (2 * 1024 * 1024) / PAGE_CACHE_SIZE; if (this_chunk > nr_to_read) this_chunk = nr_to_read; err = __do_page_cache_readahead(mapping, filp, offset, this_chunk, 0); if (err < 0) { ret = err; break; } ret += err; offset += this_chunk; nr_to_read -= this_chunk; } return ret; } /* * Given a desired number of PAGE_CACHE_SIZE readahead pages, return a * sensible upper limit. */ unsigned long max_sane_readahead(unsigned long nr) { return min(nr, (node_page_state(numa_node_id(), NR_INACTIVE_FILE) + node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2); } /* * Submit IO for the read-ahead request in file_ra_state. */ unsigned long ra_submit(struct file_ra_state *ra, struct address_space *mapping, struct file *filp) { int actual; actual = __do_page_cache_readahead(mapping, filp, ra->start, ra->size, ra->async_size); return actual; } /* * Set the initial window size, round to next power of 2 and square * for small size, x 4 for medium, and x 2 for large * for 128k (32 page) max ra * 1-8 page = 32k initial, > 8 page = 128k initial */ static unsigned long get_init_ra_size(unsigned long size, unsigned long max) { unsigned long newsize = roundup_pow_of_two(size); if (newsize <= max / 32) newsize = newsize * 4; else if (newsize <= max / 4) newsize = newsize * 2; else newsize = max; return newsize; } /* * Get the previous window size, ramp it up, and * return it as the new window size. */ static unsigned long get_next_ra_size(struct file_ra_state *ra, unsigned long max) { unsigned long cur = ra->size; unsigned long newsize; if (cur < max / 16) newsize = 4 * cur; else newsize = 2 * cur; return min(newsize, max); } /* * On-demand readahead design. * * The fields in struct file_ra_state represent the most-recently-executed * readahead attempt: * * |<----- async_size ---------| * |------------------- size -------------------->| * |==================#===========================| * ^start ^page marked with PG_readahead * * To overlap application thinking time and disk I/O time, we do * `readahead pipelining': Do not wait until the application consumed all * readahead pages and stalled on the missing page at readahead_index; * Instead, submit an asynchronous readahead I/O as soon as there are * only async_size pages left in the readahead window. Normally async_size * will be equal to size, for maximum pipelining. * * In interleaved sequential reads, concurrent streams on the same fd can * be invalidating each other's readahead state. So we flag the new readahead * page at (start+size-async_size) with PG_readahead, and use it as readahead * indicator. The flag won't be set on already cached pages, to avoid the * readahead-for-nothing fuss, saving pointless page cache lookups. * * prev_pos tracks the last visited byte in the _previous_ read request. * It should be maintained by the caller, and will be used for detecting * small random reads. Note that the readahead algorithm checks loosely * for sequential patterns. Hence interleaved reads might be served as * sequential ones. * * There is a special-case: if the first page which the application tries to * read happens to be the first page of the file, it is assumed that a linear * read is about to happen and the window is immediately set to the initial size * based on I/O request size and the max_readahead. * * The code ramps up the readahead size aggressively at first, but slow down as * it approaches max_readhead. */ /* * Count contiguously cached pages from @offset-1 to @offset-@max, * this count is a conservative estimation of * - length of the sequential read sequence, or * - thrashing threshold in memory tight systems */ static pgoff_t count_history_pages(struct address_space *mapping, struct file_ra_state *ra, pgoff_t offset, unsigned long max) { pgoff_t head; rcu_read_lock(); head = radix_tree_prev_hole(&mapping->page_tree, offset - 1, max); rcu_read_unlock(); return offset - 1 - head; } /* * page cache context based read-ahead */ static int try_context_readahead(struct address_space *mapping, struct file_ra_state *ra, pgoff_t offset, unsigned long req_size, unsigned long max) { pgoff_t size; size = count_history_pages(mapping, ra, offset, max); /* * no history pages: * it could be a random read */ if (!size) return 0; /* * starts from beginning of file: * it is a strong indication of long-run stream (or whole-file-read) */ if (size >= offset) size *= 2; ra->start = offset; ra->size = get_init_ra_size(size + req_size, max); ra->async_size = ra->size; return 1; } /* * A minimal readahead algorithm for trivial sequential/random reads. */ static unsigned long ondemand_readahead(struct address_space *mapping, struct file_ra_state *ra, struct file *filp, bool hit_readahead_marker, pgoff_t offset, unsigned long req_size) { unsigned long max = max_sane_readahead(ra->ra_pages); /* * start of file */ if (!offset) goto initial_readahead; /* * It's the expected callback offset, assume sequential access. * Ramp up sizes, and push forward the readahead window. */ if ((offset == (ra->start + ra->size - ra->async_size) || offset == (ra->start + ra->size))) { ra->start += ra->size; ra->size = get_next_ra_size(ra, max); ra->async_size = ra->size; goto readit; } /* * Hit a marked page without valid readahead state. * E.g. interleaved reads. * Query the pagecache for async_size, which normally equals to * readahead size. Ramp it up and use it as the new readahead size. */ if (hit_readahead_marker) { pgoff_t start; rcu_read_lock(); start = radix_tree_next_hole(&mapping->page_tree, offset+1,max); rcu_read_unlock(); if (!start || start - offset > max) return 0; ra->start = start; ra->size = start - offset; /* old async_size */ ra->size += req_size; ra->size = get_next_ra_size(ra, max); ra->async_size = ra->size; goto readit; } /* * oversize read */ if (req_size > max) goto initial_readahead; /* * sequential cache miss */ if (offset - (ra->prev_pos >> PAGE_CACHE_SHIFT) <= 1UL) goto initial_readahead; /* * Query the page cache and look for the traces(cached history pages) * that a sequential stream would leave behind. */ if (try_context_readahead(mapping, ra, offset, req_size, max)) goto readit; /* * standalone, small random read * Read as is, and do not pollute the readahead state. */ return __do_page_cache_readahead(mapping, filp, offset, req_size, 0); initial_readahead: ra->start = offset; ra->size = get_init_ra_size(req_size, max); ra->async_size = ra->size > req_size ? ra->size - req_size : ra->size; readit: /* * Will this read hit the readahead marker made by itself? * If so, trigger the readahead marker hit now, and merge * the resulted next readahead window into the current one. */ if (offset == ra->start && ra->size == ra->async_size) { ra->async_size = get_next_ra_size(ra, max); ra->size += ra->async_size; } return ra_submit(ra, mapping, filp); } /** * page_cache_sync_readahead - generic file readahead * @mapping: address_space which holds the pagecache and I/O vectors * @ra: file_ra_state which holds the readahead state * @filp: passed on to ->readpage() and ->readpages() * @offset: start offset into @mapping, in pagecache page-sized units * @req_size: hint: total size of the read which the caller is performing in * pagecache pages * * page_cache_sync_readahead() should be called when a cache miss happened: * it will submit the read. The readahead logic may decide to piggyback more * pages onto the read request if access patterns suggest it will improve * performance. */ void page_cache_sync_readahead(struct address_space *mapping, struct file_ra_state *ra, struct file *filp, pgoff_t offset, unsigned long req_size) { /* no read-ahead */ if (!ra->ra_pages) return; /* be dumb */ if (filp && (filp->f_mode & FMODE_RANDOM)) { force_page_cache_readahead(mapping, filp, offset, req_size); return; } /* do read-ahead */ ondemand_readahead(mapping, ra, filp, false, offset, req_size); } EXPORT_SYMBOL_GPL(page_cache_sync_readahead); /** * page_cache_async_readahead - file readahead for marked pages * @mapping: address_space which holds the pagecache and I/O vectors * @ra: file_ra_state which holds the readahead state * @filp: passed on to ->readpage() and ->readpages() * @page: the page at @offset which has the PG_readahead flag set * @offset: start offset into @mapping, in pagecache page-sized units * @req_size: hint: total size of the read which the caller is performing in * pagecache pages * * page_cache_async_readahead() should be called when a page is used which * has the PG_readahead flag; this is a marker to suggest that the application * has used up enough of the readahead window that we should start pulling in * more pages. */ void page_cache_async_readahead(struct address_space *mapping, struct file_ra_state *ra, struct file *filp, struct page *page, pgoff_t offset, unsigned long req_size) { /* no read-ahead */ if (!ra->ra_pages) return; /* * Same bit is used for PG_readahead and PG_reclaim. */ if (PageWriteback(page)) return; ClearPageReadahead(page); /* * Defer asynchronous read-ahead on IO congestion. */ if (bdi_read_congested(mapping->backing_dev_info)) return; /* do read-ahead */ ondemand_readahead(mapping, ra, filp, true, offset, req_size); } EXPORT_SYMBOL_GPL(page_cache_async_readahead); static ssize_t do_readahead(struct address_space *mapping, struct file *filp, pgoff_t index, unsigned long nr) { if (!mapping || !mapping->a_ops || !mapping->a_ops->readpage) return -EINVAL; force_page_cache_readahead(mapping, filp, index, nr); return 0; } SYSCALL_DEFINE(readahead)(int fd, loff_t offset, size_t count) { ssize_t ret; struct fd f; ret = -EBADF; f = fdget(fd); if (f.file) { if (f.file->f_mode & FMODE_READ) { struct address_space *mapping = f.file->f_mapping; pgoff_t start = offset >> PAGE_CACHE_SHIFT; pgoff_t end = (offset + count - 1) >> PAGE_CACHE_SHIFT; unsigned long len = end - start + 1; ret = do_readahead(mapping, f.file, start, len); } fdput(f); } return ret; } #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS asmlinkage long SyS_readahead(long fd, loff_t offset, long count) { return SYSC_readahead((int) fd, offset, (size_t) count); } SYSCALL_ALIAS(sys_readahead, SyS_readahead); #endif
gpl-2.0
kernel-hut/android_kernel_xiaomi_cancro
fs/exfat/exfat_upcase.c
187
37392
/* * Copyright (C) 2012-2013 Samsung Electronics Co., 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /************************************************************************/ /* */ /* PROJECT : exFAT & FAT12/16/32 File System */ /* FILE : exfat_upcase.c */ /* PURPOSE : exFAT Up-case Table */ /* */ /*----------------------------------------------------------------------*/ /* NOTES */ /* */ /*----------------------------------------------------------------------*/ /* REVISION HISTORY (Ver 0.9) */ /* */ /* - 2010.11.15 [Joosun Hahn] : first writing */ /* */ /************************************************************************/ #include "exfat_config.h" #include "exfat_nls.h" u8 uni_upcase[NUM_UPCASE<<1] = { 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0C, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x10, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13, 0x00, 0x14, 0x00, 0x15, 0x00, 0x16, 0x00, 0x17, 0x00, 0x18, 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B, 0x00, 0x1C, 0x00, 0x1D, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x20, 0x00, 0x21, 0x00, 0x22, 0x00, 0x23, 0x00, 0x24, 0x00, 0x25, 0x00, 0x26, 0x00, 0x27, 0x00, 0x28, 0x00, 0x29, 0x00, 0x2A, 0x00, 0x2B, 0x00, 0x2C, 0x00, 0x2D, 0x00, 0x2E, 0x00, 0x2F, 0x00, 0x30, 0x00, 0x31, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00, 0x37, 0x00, 0x38, 0x00, 0x39, 0x00, 0x3A, 0x00, 0x3B, 0x00, 0x3C, 0x00, 0x3D, 0x00, 0x3E, 0x00, 0x3F, 0x00, 0x40, 0x00, 0x41, 0x00, 0x42, 0x00, 0x43, 0x00, 0x44, 0x00, 0x45, 0x00, 0x46, 0x00, 0x47, 0x00, 0x48, 0x00, 0x49, 0x00, 0x4A, 0x00, 0x4B, 0x00, 0x4C, 0x00, 0x4D, 0x00, 0x4E, 0x00, 0x4F, 0x00, 0x50, 0x00, 0x51, 0x00, 0x52, 0x00, 0x53, 0x00, 0x54, 0x00, 0x55, 0x00, 0x56, 0x00, 0x57, 0x00, 0x58, 0x00, 0x59, 0x00, 0x5A, 0x00, 0x5B, 0x00, 0x5C, 0x00, 0x5D, 0x00, 0x5E, 0x00, 0x5F, 0x00, 0x60, 0x00, 0x41, 0x00, 0x42, 0x00, 0x43, 0x00, 0x44, 0x00, 0x45, 0x00, 0x46, 0x00, 0x47, 0x00, 0x48, 0x00, 0x49, 0x00, 0x4A, 0x00, 0x4B, 0x00, 0x4C, 0x00, 0x4D, 0x00, 0x4E, 0x00, 0x4F, 0x00, 0x50, 0x00, 0x51, 0x00, 0x52, 0x00, 0x53, 0x00, 0x54, 0x00, 0x55, 0x00, 0x56, 0x00, 0x57, 0x00, 0x58, 0x00, 0x59, 0x00, 0x5A, 0x00, 0x7B, 0x00, 0x7C, 0x00, 0x7D, 0x00, 0x7E, 0x00, 0x7F, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0x88, 0x00, 0x89, 0x00, 0x8A, 0x00, 0x8B, 0x00, 0x8C, 0x00, 0x8D, 0x00, 0x8E, 0x00, 0x8F, 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, 0x00, 0x96, 0x00, 0x97, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9A, 0x00, 0x9B, 0x00, 0x9C, 0x00, 0x9D, 0x00, 0x9E, 0x00, 0x9F, 0x00, 0xA0, 0x00, 0xA1, 0x00, 0xA2, 0x00, 0xA3, 0x00, 0xA4, 0x00, 0xA5, 0x00, 0xA6, 0x00, 0xA7, 0x00, 0xA8, 0x00, 0xA9, 0x00, 0xAA, 0x00, 0xAB, 0x00, 0xAC, 0x00, 0xAD, 0x00, 0xAE, 0x00, 0xAF, 0x00, 0xB0, 0x00, 0xB1, 0x00, 0xB2, 0x00, 0xB3, 0x00, 0xB4, 0x00, 0xB5, 0x00, 0xB6, 0x00, 0xB7, 0x00, 0xB8, 0x00, 0xB9, 0x00, 0xBA, 0x00, 0xBB, 0x00, 0xBC, 0x00, 0xBD, 0x00, 0xBE, 0x00, 0xBF, 0x00, 0xC0, 0x00, 0xC1, 0x00, 0xC2, 0x00, 0xC3, 0x00, 0xC4, 0x00, 0xC5, 0x00, 0xC6, 0x00, 0xC7, 0x00, 0xC8, 0x00, 0xC9, 0x00, 0xCA, 0x00, 0xCB, 0x00, 0xCC, 0x00, 0xCD, 0x00, 0xCE, 0x00, 0xCF, 0x00, 0xD0, 0x00, 0xD1, 0x00, 0xD2, 0x00, 0xD3, 0x00, 0xD4, 0x00, 0xD5, 0x00, 0xD6, 0x00, 0xD7, 0x00, 0xD8, 0x00, 0xD9, 0x00, 0xDA, 0x00, 0xDB, 0x00, 0xDC, 0x00, 0xDD, 0x00, 0xDE, 0x00, 0xDF, 0x00, 0xC0, 0x00, 0xC1, 0x00, 0xC2, 0x00, 0xC3, 0x00, 0xC4, 0x00, 0xC5, 0x00, 0xC6, 0x00, 0xC7, 0x00, 0xC8, 0x00, 0xC9, 0x00, 0xCA, 0x00, 0xCB, 0x00, 0xCC, 0x00, 0xCD, 0x00, 0xCE, 0x00, 0xCF, 0x00, 0xD0, 0x00, 0xD1, 0x00, 0xD2, 0x00, 0xD3, 0x00, 0xD4, 0x00, 0xD5, 0x00, 0xD6, 0x00, 0xF7, 0x00, 0xD8, 0x00, 0xD9, 0x00, 0xDA, 0x00, 0xDB, 0x00, 0xDC, 0x00, 0xDD, 0x00, 0xDE, 0x00, 0x78, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x04, 0x01, 0x04, 0x01, 0x06, 0x01, 0x06, 0x01, 0x08, 0x01, 0x08, 0x01, 0x0A, 0x01, 0x0A, 0x01, 0x0C, 0x01, 0x0C, 0x01, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x01, 0x10, 0x01, 0x12, 0x01, 0x12, 0x01, 0x14, 0x01, 0x14, 0x01, 0x16, 0x01, 0x16, 0x01, 0x18, 0x01, 0x18, 0x01, 0x1A, 0x01, 0x1A, 0x01, 0x1C, 0x01, 0x1C, 0x01, 0x1E, 0x01, 0x1E, 0x01, 0x20, 0x01, 0x20, 0x01, 0x22, 0x01, 0x22, 0x01, 0x24, 0x01, 0x24, 0x01, 0x26, 0x01, 0x26, 0x01, 0x28, 0x01, 0x28, 0x01, 0x2A, 0x01, 0x2A, 0x01, 0x2C, 0x01, 0x2C, 0x01, 0x2E, 0x01, 0x2E, 0x01, 0x30, 0x01, 0x31, 0x01, 0x32, 0x01, 0x32, 0x01, 0x34, 0x01, 0x34, 0x01, 0x36, 0x01, 0x36, 0x01, 0x38, 0x01, 0x39, 0x01, 0x39, 0x01, 0x3B, 0x01, 0x3B, 0x01, 0x3D, 0x01, 0x3D, 0x01, 0x3F, 0x01, 0x3F, 0x01, 0x41, 0x01, 0x41, 0x01, 0x43, 0x01, 0x43, 0x01, 0x45, 0x01, 0x45, 0x01, 0x47, 0x01, 0x47, 0x01, 0x49, 0x01, 0x4A, 0x01, 0x4A, 0x01, 0x4C, 0x01, 0x4C, 0x01, 0x4E, 0x01, 0x4E, 0x01, 0x50, 0x01, 0x50, 0x01, 0x52, 0x01, 0x52, 0x01, 0x54, 0x01, 0x54, 0x01, 0x56, 0x01, 0x56, 0x01, 0x58, 0x01, 0x58, 0x01, 0x5A, 0x01, 0x5A, 0x01, 0x5C, 0x01, 0x5C, 0x01, 0x5E, 0x01, 0x5E, 0x01, 0x60, 0x01, 0x60, 0x01, 0x62, 0x01, 0x62, 0x01, 0x64, 0x01, 0x64, 0x01, 0x66, 0x01, 0x66, 0x01, 0x68, 0x01, 0x68, 0x01, 0x6A, 0x01, 0x6A, 0x01, 0x6C, 0x01, 0x6C, 0x01, 0x6E, 0x01, 0x6E, 0x01, 0x70, 0x01, 0x70, 0x01, 0x72, 0x01, 0x72, 0x01, 0x74, 0x01, 0x74, 0x01, 0x76, 0x01, 0x76, 0x01, 0x78, 0x01, 0x79, 0x01, 0x79, 0x01, 0x7B, 0x01, 0x7B, 0x01, 0x7D, 0x01, 0x7D, 0x01, 0x7F, 0x01, 0x43, 0x02, 0x81, 0x01, 0x82, 0x01, 0x82, 0x01, 0x84, 0x01, 0x84, 0x01, 0x86, 0x01, 0x87, 0x01, 0x87, 0x01, 0x89, 0x01, 0x8A, 0x01, 0x8B, 0x01, 0x8B, 0x01, 0x8D, 0x01, 0x8E, 0x01, 0x8F, 0x01, 0x90, 0x01, 0x91, 0x01, 0x91, 0x01, 0x93, 0x01, 0x94, 0x01, 0xF6, 0x01, 0x96, 0x01, 0x97, 0x01, 0x98, 0x01, 0x98, 0x01, 0x3D, 0x02, 0x9B, 0x01, 0x9C, 0x01, 0x9D, 0x01, 0x20, 0x02, 0x9F, 0x01, 0xA0, 0x01, 0xA0, 0x01, 0xA2, 0x01, 0xA2, 0x01, 0xA4, 0x01, 0xA4, 0x01, 0xA6, 0x01, 0xA7, 0x01, 0xA7, 0x01, 0xA9, 0x01, 0xAA, 0x01, 0xAB, 0x01, 0xAC, 0x01, 0xAC, 0x01, 0xAE, 0x01, 0xAF, 0x01, 0xAF, 0x01, 0xB1, 0x01, 0xB2, 0x01, 0xB3, 0x01, 0xB3, 0x01, 0xB5, 0x01, 0xB5, 0x01, 0xB7, 0x01, 0xB8, 0x01, 0xB8, 0x01, 0xBA, 0x01, 0xBB, 0x01, 0xBC, 0x01, 0xBC, 0x01, 0xBE, 0x01, 0xF7, 0x01, 0xC0, 0x01, 0xC1, 0x01, 0xC2, 0x01, 0xC3, 0x01, 0xC4, 0x01, 0xC5, 0x01, 0xC4, 0x01, 0xC7, 0x01, 0xC8, 0x01, 0xC7, 0x01, 0xCA, 0x01, 0xCB, 0x01, 0xCA, 0x01, 0xCD, 0x01, 0xCD, 0x01, 0xCF, 0x01, 0xCF, 0x01, 0xD1, 0x01, 0xD1, 0x01, 0xD3, 0x01, 0xD3, 0x01, 0xD5, 0x01, 0xD5, 0x01, 0xD7, 0x01, 0xD7, 0x01, 0xD9, 0x01, 0xD9, 0x01, 0xDB, 0x01, 0xDB, 0x01, 0x8E, 0x01, 0xDE, 0x01, 0xDE, 0x01, 0xE0, 0x01, 0xE0, 0x01, 0xE2, 0x01, 0xE2, 0x01, 0xE4, 0x01, 0xE4, 0x01, 0xE6, 0x01, 0xE6, 0x01, 0xE8, 0x01, 0xE8, 0x01, 0xEA, 0x01, 0xEA, 0x01, 0xEC, 0x01, 0xEC, 0x01, 0xEE, 0x01, 0xEE, 0x01, 0xF0, 0x01, 0xF1, 0x01, 0xF2, 0x01, 0xF1, 0x01, 0xF4, 0x01, 0xF4, 0x01, 0xF6, 0x01, 0xF7, 0x01, 0xF8, 0x01, 0xF8, 0x01, 0xFA, 0x01, 0xFA, 0x01, 0xFC, 0x01, 0xFC, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0x02, 0x04, 0x02, 0x06, 0x02, 0x06, 0x02, 0x08, 0x02, 0x08, 0x02, 0x0A, 0x02, 0x0A, 0x02, 0x0C, 0x02, 0x0C, 0x02, 0x0E, 0x02, 0x0E, 0x02, 0x10, 0x02, 0x10, 0x02, 0x12, 0x02, 0x12, 0x02, 0x14, 0x02, 0x14, 0x02, 0x16, 0x02, 0x16, 0x02, 0x18, 0x02, 0x18, 0x02, 0x1A, 0x02, 0x1A, 0x02, 0x1C, 0x02, 0x1C, 0x02, 0x1E, 0x02, 0x1E, 0x02, 0x20, 0x02, 0x21, 0x02, 0x22, 0x02, 0x22, 0x02, 0x24, 0x02, 0x24, 0x02, 0x26, 0x02, 0x26, 0x02, 0x28, 0x02, 0x28, 0x02, 0x2A, 0x02, 0x2A, 0x02, 0x2C, 0x02, 0x2C, 0x02, 0x2E, 0x02, 0x2E, 0x02, 0x30, 0x02, 0x30, 0x02, 0x32, 0x02, 0x32, 0x02, 0x34, 0x02, 0x35, 0x02, 0x36, 0x02, 0x37, 0x02, 0x38, 0x02, 0x39, 0x02, 0x65, 0x2C, 0x3B, 0x02, 0x3B, 0x02, 0x3D, 0x02, 0x66, 0x2C, 0x3F, 0x02, 0x40, 0x02, 0x41, 0x02, 0x41, 0x02, 0x43, 0x02, 0x44, 0x02, 0x45, 0x02, 0x46, 0x02, 0x46, 0x02, 0x48, 0x02, 0x48, 0x02, 0x4A, 0x02, 0x4A, 0x02, 0x4C, 0x02, 0x4C, 0x02, 0x4E, 0x02, 0x4E, 0x02, 0x50, 0x02, 0x51, 0x02, 0x52, 0x02, 0x81, 0x01, 0x86, 0x01, 0x55, 0x02, 0x89, 0x01, 0x8A, 0x01, 0x58, 0x02, 0x8F, 0x01, 0x5A, 0x02, 0x90, 0x01, 0x5C, 0x02, 0x5D, 0x02, 0x5E, 0x02, 0x5F, 0x02, 0x93, 0x01, 0x61, 0x02, 0x62, 0x02, 0x94, 0x01, 0x64, 0x02, 0x65, 0x02, 0x66, 0x02, 0x67, 0x02, 0x97, 0x01, 0x96, 0x01, 0x6A, 0x02, 0x62, 0x2C, 0x6C, 0x02, 0x6D, 0x02, 0x6E, 0x02, 0x9C, 0x01, 0x70, 0x02, 0x71, 0x02, 0x9D, 0x01, 0x73, 0x02, 0x74, 0x02, 0x9F, 0x01, 0x76, 0x02, 0x77, 0x02, 0x78, 0x02, 0x79, 0x02, 0x7A, 0x02, 0x7B, 0x02, 0x7C, 0x02, 0x64, 0x2C, 0x7E, 0x02, 0x7F, 0x02, 0xA6, 0x01, 0x81, 0x02, 0x82, 0x02, 0xA9, 0x01, 0x84, 0x02, 0x85, 0x02, 0x86, 0x02, 0x87, 0x02, 0xAE, 0x01, 0x44, 0x02, 0xB1, 0x01, 0xB2, 0x01, 0x45, 0x02, 0x8D, 0x02, 0x8E, 0x02, 0x8F, 0x02, 0x90, 0x02, 0x91, 0x02, 0xB7, 0x01, 0x93, 0x02, 0x94, 0x02, 0x95, 0x02, 0x96, 0x02, 0x97, 0x02, 0x98, 0x02, 0x99, 0x02, 0x9A, 0x02, 0x9B, 0x02, 0x9C, 0x02, 0x9D, 0x02, 0x9E, 0x02, 0x9F, 0x02, 0xA0, 0x02, 0xA1, 0x02, 0xA2, 0x02, 0xA3, 0x02, 0xA4, 0x02, 0xA5, 0x02, 0xA6, 0x02, 0xA7, 0x02, 0xA8, 0x02, 0xA9, 0x02, 0xAA, 0x02, 0xAB, 0x02, 0xAC, 0x02, 0xAD, 0x02, 0xAE, 0x02, 0xAF, 0x02, 0xB0, 0x02, 0xB1, 0x02, 0xB2, 0x02, 0xB3, 0x02, 0xB4, 0x02, 0xB5, 0x02, 0xB6, 0x02, 0xB7, 0x02, 0xB8, 0x02, 0xB9, 0x02, 0xBA, 0x02, 0xBB, 0x02, 0xBC, 0x02, 0xBD, 0x02, 0xBE, 0x02, 0xBF, 0x02, 0xC0, 0x02, 0xC1, 0x02, 0xC2, 0x02, 0xC3, 0x02, 0xC4, 0x02, 0xC5, 0x02, 0xC6, 0x02, 0xC7, 0x02, 0xC8, 0x02, 0xC9, 0x02, 0xCA, 0x02, 0xCB, 0x02, 0xCC, 0x02, 0xCD, 0x02, 0xCE, 0x02, 0xCF, 0x02, 0xD0, 0x02, 0xD1, 0x02, 0xD2, 0x02, 0xD3, 0x02, 0xD4, 0x02, 0xD5, 0x02, 0xD6, 0x02, 0xD7, 0x02, 0xD8, 0x02, 0xD9, 0x02, 0xDA, 0x02, 0xDB, 0x02, 0xDC, 0x02, 0xDD, 0x02, 0xDE, 0x02, 0xDF, 0x02, 0xE0, 0x02, 0xE1, 0x02, 0xE2, 0x02, 0xE3, 0x02, 0xE4, 0x02, 0xE5, 0x02, 0xE6, 0x02, 0xE7, 0x02, 0xE8, 0x02, 0xE9, 0x02, 0xEA, 0x02, 0xEB, 0x02, 0xEC, 0x02, 0xED, 0x02, 0xEE, 0x02, 0xEF, 0x02, 0xF0, 0x02, 0xF1, 0x02, 0xF2, 0x02, 0xF3, 0x02, 0xF4, 0x02, 0xF5, 0x02, 0xF6, 0x02, 0xF7, 0x02, 0xF8, 0x02, 0xF9, 0x02, 0xFA, 0x02, 0xFB, 0x02, 0xFC, 0x02, 0xFD, 0x02, 0xFE, 0x02, 0xFF, 0x02, 0x00, 0x03, 0x01, 0x03, 0x02, 0x03, 0x03, 0x03, 0x04, 0x03, 0x05, 0x03, 0x06, 0x03, 0x07, 0x03, 0x08, 0x03, 0x09, 0x03, 0x0A, 0x03, 0x0B, 0x03, 0x0C, 0x03, 0x0D, 0x03, 0x0E, 0x03, 0x0F, 0x03, 0x10, 0x03, 0x11, 0x03, 0x12, 0x03, 0x13, 0x03, 0x14, 0x03, 0x15, 0x03, 0x16, 0x03, 0x17, 0x03, 0x18, 0x03, 0x19, 0x03, 0x1A, 0x03, 0x1B, 0x03, 0x1C, 0x03, 0x1D, 0x03, 0x1E, 0x03, 0x1F, 0x03, 0x20, 0x03, 0x21, 0x03, 0x22, 0x03, 0x23, 0x03, 0x24, 0x03, 0x25, 0x03, 0x26, 0x03, 0x27, 0x03, 0x28, 0x03, 0x29, 0x03, 0x2A, 0x03, 0x2B, 0x03, 0x2C, 0x03, 0x2D, 0x03, 0x2E, 0x03, 0x2F, 0x03, 0x30, 0x03, 0x31, 0x03, 0x32, 0x03, 0x33, 0x03, 0x34, 0x03, 0x35, 0x03, 0x36, 0x03, 0x37, 0x03, 0x38, 0x03, 0x39, 0x03, 0x3A, 0x03, 0x3B, 0x03, 0x3C, 0x03, 0x3D, 0x03, 0x3E, 0x03, 0x3F, 0x03, 0x40, 0x03, 0x41, 0x03, 0x42, 0x03, 0x43, 0x03, 0x44, 0x03, 0x45, 0x03, 0x46, 0x03, 0x47, 0x03, 0x48, 0x03, 0x49, 0x03, 0x4A, 0x03, 0x4B, 0x03, 0x4C, 0x03, 0x4D, 0x03, 0x4E, 0x03, 0x4F, 0x03, 0x50, 0x03, 0x51, 0x03, 0x52, 0x03, 0x53, 0x03, 0x54, 0x03, 0x55, 0x03, 0x56, 0x03, 0x57, 0x03, 0x58, 0x03, 0x59, 0x03, 0x5A, 0x03, 0x5B, 0x03, 0x5C, 0x03, 0x5D, 0x03, 0x5E, 0x03, 0x5F, 0x03, 0x60, 0x03, 0x61, 0x03, 0x62, 0x03, 0x63, 0x03, 0x64, 0x03, 0x65, 0x03, 0x66, 0x03, 0x67, 0x03, 0x68, 0x03, 0x69, 0x03, 0x6A, 0x03, 0x6B, 0x03, 0x6C, 0x03, 0x6D, 0x03, 0x6E, 0x03, 0x6F, 0x03, 0x70, 0x03, 0x71, 0x03, 0x72, 0x03, 0x73, 0x03, 0x74, 0x03, 0x75, 0x03, 0x76, 0x03, 0x77, 0x03, 0x78, 0x03, 0x79, 0x03, 0x7A, 0x03, 0xFD, 0x03, 0xFE, 0x03, 0xFF, 0x03, 0x7E, 0x03, 0x7F, 0x03, 0x80, 0x03, 0x81, 0x03, 0x82, 0x03, 0x83, 0x03, 0x84, 0x03, 0x85, 0x03, 0x86, 0x03, 0x87, 0x03, 0x88, 0x03, 0x89, 0x03, 0x8A, 0x03, 0x8B, 0x03, 0x8C, 0x03, 0x8D, 0x03, 0x8E, 0x03, 0x8F, 0x03, 0x90, 0x03, 0x91, 0x03, 0x92, 0x03, 0x93, 0x03, 0x94, 0x03, 0x95, 0x03, 0x96, 0x03, 0x97, 0x03, 0x98, 0x03, 0x99, 0x03, 0x9A, 0x03, 0x9B, 0x03, 0x9C, 0x03, 0x9D, 0x03, 0x9E, 0x03, 0x9F, 0x03, 0xA0, 0x03, 0xA1, 0x03, 0xA2, 0x03, 0xA3, 0x03, 0xA4, 0x03, 0xA5, 0x03, 0xA6, 0x03, 0xA7, 0x03, 0xA8, 0x03, 0xA9, 0x03, 0xAA, 0x03, 0xAB, 0x03, 0x86, 0x03, 0x88, 0x03, 0x89, 0x03, 0x8A, 0x03, 0xB0, 0x03, 0x91, 0x03, 0x92, 0x03, 0x93, 0x03, 0x94, 0x03, 0x95, 0x03, 0x96, 0x03, 0x97, 0x03, 0x98, 0x03, 0x99, 0x03, 0x9A, 0x03, 0x9B, 0x03, 0x9C, 0x03, 0x9D, 0x03, 0x9E, 0x03, 0x9F, 0x03, 0xA0, 0x03, 0xA1, 0x03, 0xA3, 0x03, 0xA3, 0x03, 0xA4, 0x03, 0xA5, 0x03, 0xA6, 0x03, 0xA7, 0x03, 0xA8, 0x03, 0xA9, 0x03, 0xAA, 0x03, 0xAB, 0x03, 0x8C, 0x03, 0x8E, 0x03, 0x8F, 0x03, 0xCF, 0x03, 0xD0, 0x03, 0xD1, 0x03, 0xD2, 0x03, 0xD3, 0x03, 0xD4, 0x03, 0xD5, 0x03, 0xD6, 0x03, 0xD7, 0x03, 0xD8, 0x03, 0xD8, 0x03, 0xDA, 0x03, 0xDA, 0x03, 0xDC, 0x03, 0xDC, 0x03, 0xDE, 0x03, 0xDE, 0x03, 0xE0, 0x03, 0xE0, 0x03, 0xE2, 0x03, 0xE2, 0x03, 0xE4, 0x03, 0xE4, 0x03, 0xE6, 0x03, 0xE6, 0x03, 0xE8, 0x03, 0xE8, 0x03, 0xEA, 0x03, 0xEA, 0x03, 0xEC, 0x03, 0xEC, 0x03, 0xEE, 0x03, 0xEE, 0x03, 0xF0, 0x03, 0xF1, 0x03, 0xF9, 0x03, 0xF3, 0x03, 0xF4, 0x03, 0xF5, 0x03, 0xF6, 0x03, 0xF7, 0x03, 0xF7, 0x03, 0xF9, 0x03, 0xFA, 0x03, 0xFA, 0x03, 0xFC, 0x03, 0xFD, 0x03, 0xFE, 0x03, 0xFF, 0x03, 0x00, 0x04, 0x01, 0x04, 0x02, 0x04, 0x03, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, 0x04, 0x07, 0x04, 0x08, 0x04, 0x09, 0x04, 0x0A, 0x04, 0x0B, 0x04, 0x0C, 0x04, 0x0D, 0x04, 0x0E, 0x04, 0x0F, 0x04, 0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13, 0x04, 0x14, 0x04, 0x15, 0x04, 0x16, 0x04, 0x17, 0x04, 0x18, 0x04, 0x19, 0x04, 0x1A, 0x04, 0x1B, 0x04, 0x1C, 0x04, 0x1D, 0x04, 0x1E, 0x04, 0x1F, 0x04, 0x20, 0x04, 0x21, 0x04, 0x22, 0x04, 0x23, 0x04, 0x24, 0x04, 0x25, 0x04, 0x26, 0x04, 0x27, 0x04, 0x28, 0x04, 0x29, 0x04, 0x2A, 0x04, 0x2B, 0x04, 0x2C, 0x04, 0x2D, 0x04, 0x2E, 0x04, 0x2F, 0x04, 0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13, 0x04, 0x14, 0x04, 0x15, 0x04, 0x16, 0x04, 0x17, 0x04, 0x18, 0x04, 0x19, 0x04, 0x1A, 0x04, 0x1B, 0x04, 0x1C, 0x04, 0x1D, 0x04, 0x1E, 0x04, 0x1F, 0x04, 0x20, 0x04, 0x21, 0x04, 0x22, 0x04, 0x23, 0x04, 0x24, 0x04, 0x25, 0x04, 0x26, 0x04, 0x27, 0x04, 0x28, 0x04, 0x29, 0x04, 0x2A, 0x04, 0x2B, 0x04, 0x2C, 0x04, 0x2D, 0x04, 0x2E, 0x04, 0x2F, 0x04, 0x00, 0x04, 0x01, 0x04, 0x02, 0x04, 0x03, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, 0x04, 0x07, 0x04, 0x08, 0x04, 0x09, 0x04, 0x0A, 0x04, 0x0B, 0x04, 0x0C, 0x04, 0x0D, 0x04, 0x0E, 0x04, 0x0F, 0x04, 0x60, 0x04, 0x60, 0x04, 0x62, 0x04, 0x62, 0x04, 0x64, 0x04, 0x64, 0x04, 0x66, 0x04, 0x66, 0x04, 0x68, 0x04, 0x68, 0x04, 0x6A, 0x04, 0x6A, 0x04, 0x6C, 0x04, 0x6C, 0x04, 0x6E, 0x04, 0x6E, 0x04, 0x70, 0x04, 0x70, 0x04, 0x72, 0x04, 0x72, 0x04, 0x74, 0x04, 0x74, 0x04, 0x76, 0x04, 0x76, 0x04, 0x78, 0x04, 0x78, 0x04, 0x7A, 0x04, 0x7A, 0x04, 0x7C, 0x04, 0x7C, 0x04, 0x7E, 0x04, 0x7E, 0x04, 0x80, 0x04, 0x80, 0x04, 0x82, 0x04, 0x83, 0x04, 0x84, 0x04, 0x85, 0x04, 0x86, 0x04, 0x87, 0x04, 0x88, 0x04, 0x89, 0x04, 0x8A, 0x04, 0x8A, 0x04, 0x8C, 0x04, 0x8C, 0x04, 0x8E, 0x04, 0x8E, 0x04, 0x90, 0x04, 0x90, 0x04, 0x92, 0x04, 0x92, 0x04, 0x94, 0x04, 0x94, 0x04, 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 0x04, 0xF4, 0x04, 0xF4, 0x04, 0xF6, 0x04, 0xF6, 0x04, 0xF8, 0x04, 0xF8, 0x04, 0xFA, 0x04, 0xFA, 0x04, 0xFC, 0x04, 0xFC, 0x04, 0xFE, 0x04, 0xFE, 0x04, 0x00, 0x05, 0x00, 0x05, 0x02, 0x05, 0x02, 0x05, 0x04, 0x05, 0x04, 0x05, 0x06, 0x05, 0x06, 0x05, 0x08, 0x05, 0x08, 0x05, 0x0A, 0x05, 0x0A, 0x05, 0x0C, 0x05, 0x0C, 0x05, 0x0E, 0x05, 0x0E, 0x05, 0x10, 0x05, 0x10, 0x05, 0x12, 0x05, 0x12, 0x05, 0x14, 0x05, 0x15, 0x05, 0x16, 0x05, 0x17, 0x05, 0x18, 0x05, 0x19, 0x05, 0x1A, 0x05, 0x1B, 0x05, 0x1C, 0x05, 0x1D, 0x05, 0x1E, 0x05, 0x1F, 0x05, 0x20, 0x05, 0x21, 0x05, 0x22, 0x05, 0x23, 0x05, 0x24, 0x05, 0x25, 0x05, 0x26, 0x05, 0x27, 0x05, 0x28, 0x05, 0x29, 0x05, 0x2A, 0x05, 0x2B, 0x05, 0x2C, 0x05, 0x2D, 0x05, 0x2E, 0x05, 0x2F, 0x05, 0x30, 0x05, 0x31, 0x05, 0x32, 0x05, 0x33, 0x05, 0x34, 0x05, 0x35, 0x05, 0x36, 0x05, 0x37, 0x05, 0x38, 0x05, 0x39, 0x05, 0x3A, 0x05, 0x3B, 0x05, 0x3C, 0x05, 0x3D, 0x05, 0x3E, 0x05, 0x3F, 0x05, 0x40, 0x05, 0x41, 0x05, 0x42, 0x05, 0x43, 0x05, 0x44, 0x05, 0x45, 0x05, 0x46, 0x05, 0x47, 0x05, 0x48, 0x05, 0x49, 0x05, 0x4A, 0x05, 0x4B, 0x05, 0x4C, 0x05, 0x4D, 0x05, 0x4E, 0x05, 0x4F, 0x05, 0x50, 0x05, 0x51, 0x05, 0x52, 0x05, 0x53, 0x05, 0x54, 0x05, 0x55, 0x05, 0x56, 0x05, 0x57, 0x05, 0x58, 0x05, 0x59, 0x05, 0x5A, 0x05, 0x5B, 0x05, 0x5C, 0x05, 0x5D, 0x05, 0x5E, 0x05, 0x5F, 0x05, 0x60, 0x05, 0x31, 0x05, 0x32, 0x05, 0x33, 0x05, 0x34, 0x05, 0x35, 0x05, 0x36, 0x05, 0x37, 0x05, 0x38, 0x05, 0x39, 0x05, 0x3A, 0x05, 0x3B, 0x05, 0x3C, 0x05, 0x3D, 0x05, 0x3E, 0x05, 0x3F, 0x05, 0x40, 0x05, 0x41, 0x05, 0x42, 0x05, 0x43, 0x05, 0x44, 0x05, 0x45, 0x05, 0x46, 0x05, 0x47, 0x05, 0x48, 0x05, 0x49, 0x05, 0x4A, 0x05, 0x4B, 0x05, 0x4C, 0x05, 0x4D, 0x05, 0x4E, 0x05, 0x4F, 0x05, 0x50, 0x05, 0x51, 0x05, 0x52, 0x05, 0x53, 0x05, 0x54, 0x05, 0x55, 0x05, 0x56, 0x05, 0xFF, 0xFF, 0xF6, 0x17, 0x63, 0x2C, 0x7E, 0x1D, 0x7F, 0x1D, 0x80, 0x1D, 0x81, 0x1D, 0x82, 0x1D, 0x83, 0x1D, 0x84, 0x1D, 0x85, 0x1D, 0x86, 0x1D, 0x87, 0x1D, 0x88, 0x1D, 0x89, 0x1D, 0x8A, 0x1D, 0x8B, 0x1D, 0x8C, 0x1D, 0x8D, 0x1D, 0x8E, 0x1D, 0x8F, 0x1D, 0x90, 0x1D, 0x91, 0x1D, 0x92, 0x1D, 0x93, 0x1D, 0x94, 0x1D, 0x95, 0x1D, 0x96, 0x1D, 0x97, 0x1D, 0x98, 0x1D, 0x99, 0x1D, 0x9A, 0x1D, 0x9B, 0x1D, 0x9C, 0x1D, 0x9D, 0x1D, 0x9E, 0x1D, 0x9F, 0x1D, 0xA0, 0x1D, 0xA1, 0x1D, 0xA2, 0x1D, 0xA3, 0x1D, 0xA4, 0x1D, 0xA5, 0x1D, 0xA6, 0x1D, 0xA7, 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x20, 0x0B, 0x20, 0x0C, 0x20, 0x0D, 0x20, 0x0E, 0x20, 0x0F, 0x20, 0x10, 0x20, 0x11, 0x20, 0x12, 0x20, 0x13, 0x20, 0x14, 0x20, 0x15, 0x20, 0x16, 0x20, 0x17, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1A, 0x20, 0x1B, 0x20, 0x1C, 0x20, 0x1D, 0x20, 0x1E, 0x20, 0x1F, 0x20, 0x20, 0x20, 0x21, 0x20, 0x22, 0x20, 0x23, 0x20, 0x24, 0x20, 0x25, 0x20, 0x26, 0x20, 0x27, 0x20, 0x28, 0x20, 0x29, 0x20, 0x2A, 0x20, 0x2B, 0x20, 0x2C, 0x20, 0x2D, 0x20, 0x2E, 0x20, 0x2F, 0x20, 0x30, 0x20, 0x31, 0x20, 0x32, 0x20, 0x33, 0x20, 0x34, 0x20, 0x35, 0x20, 0x36, 0x20, 0x37, 0x20, 0x38, 0x20, 0x39, 0x20, 0x3A, 0x20, 0x3B, 0x20, 0x3C, 0x20, 0x3D, 0x20, 0x3E, 0x20, 0x3F, 0x20, 0x40, 0x20, 0x41, 0x20, 0x42, 0x20, 0x43, 0x20, 0x44, 0x20, 0x45, 0x20, 0x46, 0x20, 0x47, 0x20, 0x48, 0x20, 0x49, 0x20, 0x4A, 0x20, 0x4B, 0x20, 0x4C, 0x20, 0x4D, 0x20, 0x4E, 0x20, 0x4F, 0x20, 0x50, 0x20, 0x51, 0x20, 0x52, 0x20, 0x53, 0x20, 0x54, 0x20, 0x55, 0x20, 0x56, 0x20, 0x57, 0x20, 0x58, 0x20, 0x59, 0x20, 0x5A, 0x20, 0x5B, 0x20, 0x5C, 0x20, 0x5D, 0x20, 0x5E, 0x20, 0x5F, 0x20, 0x60, 0x20, 0x61, 0x20, 0x62, 0x20, 0x63, 0x20, 0x64, 0x20, 0x65, 0x20, 0x66, 0x20, 0x67, 0x20, 0x68, 0x20, 0x69, 0x20, 0x6A, 0x20, 0x6B, 0x20, 0x6C, 0x20, 0x6D, 0x20, 0x6E, 0x20, 0x6F, 0x20, 0x70, 0x20, 0x71, 0x20, 0x72, 0x20, 0x73, 0x20, 0x74, 0x20, 0x75, 0x20, 0x76, 0x20, 0x77, 0x20, 0x78, 0x20, 0x79, 0x20, 0x7A, 0x20, 0x7B, 0x20, 0x7C, 0x20, 0x7D, 0x20, 0x7E, 0x20, 0x7F, 0x20, 0x80, 0x20, 0x81, 0x20, 0x82, 0x20, 0x83, 0x20, 0x84, 0x20, 0x85, 0x20, 0x86, 0x20, 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x8A, 0x20, 0x8B, 0x20, 0x8C, 0x20, 0x8D, 0x20, 0x8E, 0x20, 0x8F, 0x20, 0x90, 0x20, 0x91, 0x20, 0x92, 0x20, 0x93, 0x20, 0x94, 0x20, 0x95, 0x20, 0x96, 0x20, 0x97, 0x20, 0x98, 0x20, 0x99, 0x20, 0x9A, 0x20, 0x9B, 0x20, 0x9C, 0x20, 0x9D, 0x20, 0x9E, 0x20, 0x9F, 0x20, 0xA0, 0x20, 0xA1, 0x20, 0xA2, 0x20, 0xA3, 0x20, 0xA4, 0x20, 0xA5, 0x20, 0xA6, 0x20, 0xA7, 0x20, 0xA8, 0x20, 0xA9, 0x20, 0xAA, 0x20, 0xAB, 0x20, 0xAC, 0x20, 0xAD, 0x20, 0xAE, 0x20, 0xAF, 0x20, 0xB0, 0x20, 0xB1, 0x20, 0xB2, 0x20, 0xB3, 0x20, 0xB4, 0x20, 0xB5, 0x20, 0xB6, 0x20, 0xB7, 0x20, 0xB8, 0x20, 0xB9, 0x20, 0xBA, 0x20, 0xBB, 0x20, 0xBC, 0x20, 0xBD, 0x20, 0xBE, 0x20, 0xBF, 0x20, 0xC0, 0x20, 0xC1, 0x20, 0xC2, 0x20, 0xC3, 0x20, 0xC4, 0x20, 0xC5, 0x20, 0xC6, 0x20, 0xC7, 0x20, 0xC8, 0x20, 0xC9, 0x20, 0xCA, 0x20, 0xCB, 0x20, 0xCC, 0x20, 0xCD, 0x20, 0xCE, 0x20, 0xCF, 0x20, 0xD0, 0x20, 0xD1, 0x20, 0xD2, 0x20, 0xD3, 0x20, 0xD4, 0x20, 0xD5, 0x20, 0xD6, 0x20, 0xD7, 0x20, 0xD8, 0x20, 0xD9, 0x20, 0xDA, 0x20, 0xDB, 0x20, 0xDC, 0x20, 0xDD, 0x20, 0xDE, 0x20, 0xDF, 0x20, 0xE0, 0x20, 0xE1, 0x20, 0xE2, 0x20, 0xE3, 0x20, 0xE4, 0x20, 0xE5, 0x20, 0xE6, 0x20, 0xE7, 0x20, 0xE8, 0x20, 0xE9, 0x20, 0xEA, 0x20, 0xEB, 0x20, 0xEC, 0x20, 0xED, 0x20, 0xEE, 0x20, 0xEF, 0x20, 0xF0, 0x20, 0xF1, 0x20, 0xF2, 0x20, 0xF3, 0x20, 0xF4, 0x20, 0xF5, 0x20, 0xF6, 0x20, 0xF7, 0x20, 0xF8, 0x20, 0xF9, 0x20, 0xFA, 0x20, 0xFB, 0x20, 0xFC, 0x20, 0xFD, 0x20, 0xFE, 0x20, 0xFF, 0x20, 0x00, 0x21, 0x01, 0x21, 0x02, 0x21, 0x03, 0x21, 0x04, 0x21, 0x05, 0x21, 0x06, 0x21, 0x07, 0x21, 0x08, 0x21, 0x09, 0x21, 0x0A, 0x21, 0x0B, 0x21, 0x0C, 0x21, 0x0D, 0x21, 0x0E, 0x21, 0x0F, 0x21, 0x10, 0x21, 0x11, 0x21, 0x12, 0x21, 0x13, 0x21, 0x14, 0x21, 0x15, 0x21, 0x16, 0x21, 0x17, 0x21, 0x18, 0x21, 0x19, 0x21, 0x1A, 0x21, 0x1B, 0x21, 0x1C, 0x21, 0x1D, 0x21, 0x1E, 0x21, 0x1F, 0x21, 0x20, 0x21, 0x21, 0x21, 0x22, 0x21, 0x23, 0x21, 0x24, 0x21, 0x25, 0x21, 0x26, 0x21, 0x27, 0x21, 0x28, 0x21, 0x29, 0x21, 0x2A, 0x21, 0x2B, 0x21, 0x2C, 0x21, 0x2D, 0x21, 0x2E, 0x21, 0x2F, 0x21, 0x30, 0x21, 0x31, 0x21, 0x32, 0x21, 0x33, 0x21, 0x34, 0x21, 0x35, 0x21, 0x36, 0x21, 0x37, 0x21, 0x38, 0x21, 0x39, 0x21, 0x3A, 0x21, 0x3B, 0x21, 0x3C, 0x21, 0x3D, 0x21, 0x3E, 0x21, 0x3F, 0x21, 0x40, 0x21, 0x41, 0x21, 0x42, 0x21, 0x43, 0x21, 0x44, 0x21, 0x45, 0x21, 0x46, 0x21, 0x47, 0x21, 0x48, 0x21, 0x49, 0x21, 0x4A, 0x21, 0x4B, 0x21, 0x4C, 0x21, 0x4D, 0x21, 0x32, 0x21, 0x4F, 0x21, 0x50, 0x21, 0x51, 0x21, 0x52, 0x21, 0x53, 0x21, 0x54, 0x21, 0x55, 0x21, 0x56, 0x21, 0x57, 0x21, 0x58, 0x21, 0x59, 0x21, 0x5A, 0x21, 0x5B, 0x21, 0x5C, 0x21, 0x5D, 0x21, 0x5E, 0x21, 0x5F, 0x21, 0x60, 0x21, 0x61, 0x21, 0x62, 0x21, 0x63, 0x21, 0x64, 0x21, 0x65, 0x21, 0x66, 0x21, 0x67, 0x21, 0x68, 0x21, 0x69, 0x21, 0x6A, 0x21, 0x6B, 0x21, 0x6C, 0x21, 0x6D, 0x21, 0x6E, 0x21, 0x6F, 0x21, 0x60, 0x21, 0x61, 0x21, 0x62, 0x21, 0x63, 0x21, 0x64, 0x21, 0x65, 0x21, 0x66, 0x21, 0x67, 0x21, 0x68, 0x21, 0x69, 0x21, 0x6A, 0x21, 0x6B, 0x21, 0x6C, 0x21, 0x6D, 0x21, 0x6E, 0x21, 0x6F, 0x21, 0x80, 0x21, 0x81, 0x21, 0x82, 0x21, 0x83, 0x21, 0x83, 0x21, 0xFF, 0xFF, 0x4B, 0x03, 0xB6, 0x24, 0xB7, 0x24, 0xB8, 0x24, 0xB9, 0x24, 0xBA, 0x24, 0xBB, 0x24, 0xBC, 0x24, 0xBD, 0x24, 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0xFF, 0xF0, 0xFF, 0xF1, 0xFF, 0xF2, 0xFF, 0xF3, 0xFF, 0xF4, 0xFF, 0xF5, 0xFF, 0xF6, 0xFF, 0xF7, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF };
gpl-2.0
jakew02/sp3-linux
drivers/cpufreq/speedstep-lib.c
443
11852
/* * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> * * Licensed under the terms of the GNU GPL License version 2. * * Library for common functions for Intel SpeedStep v.1 and v.2 support * * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/init.h> #include <linux/cpufreq.h> #include <asm/msr.h> #include <asm/tsc.h> #include "speedstep-lib.h" #define PFX "speedstep-lib: " #ifdef CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK static int relaxed_check; #else #define relaxed_check 0 #endif /********************************************************************* * GET PROCESSOR CORE SPEED IN KHZ * *********************************************************************/ static unsigned int pentium3_get_frequency(enum speedstep_processor processor) { /* See table 14 of p3_ds.pdf and table 22 of 29834003.pdf */ struct { unsigned int ratio; /* Frequency Multiplier (x10) */ u8 bitmap; /* power on configuration bits [27, 25:22] (in MSR 0x2a) */ } msr_decode_mult[] = { { 30, 0x01 }, { 35, 0x05 }, { 40, 0x02 }, { 45, 0x06 }, { 50, 0x00 }, { 55, 0x04 }, { 60, 0x0b }, { 65, 0x0f }, { 70, 0x09 }, { 75, 0x0d }, { 80, 0x0a }, { 85, 0x26 }, { 90, 0x20 }, { 100, 0x2b }, { 0, 0xff } /* error or unknown value */ }; /* PIII(-M) FSB settings: see table b1-b of 24547206.pdf */ struct { unsigned int value; /* Front Side Bus speed in MHz */ u8 bitmap; /* power on configuration bits [18: 19] (in MSR 0x2a) */ } msr_decode_fsb[] = { { 66, 0x0 }, { 100, 0x2 }, { 133, 0x1 }, { 0, 0xff} }; u32 msr_lo, msr_tmp; int i = 0, j = 0; /* read MSR 0x2a - we only need the low 32 bits */ rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp); pr_debug("P3 - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp); msr_tmp = msr_lo; /* decode the FSB */ msr_tmp &= 0x00c0000; msr_tmp >>= 18; while (msr_tmp != msr_decode_fsb[i].bitmap) { if (msr_decode_fsb[i].bitmap == 0xff) return 0; i++; } /* decode the multiplier */ if (processor == SPEEDSTEP_CPU_PIII_C_EARLY) { pr_debug("workaround for early PIIIs\n"); msr_lo &= 0x03c00000; } else msr_lo &= 0x0bc00000; msr_lo >>= 22; while (msr_lo != msr_decode_mult[j].bitmap) { if (msr_decode_mult[j].bitmap == 0xff) return 0; j++; } pr_debug("speed is %u\n", (msr_decode_mult[j].ratio * msr_decode_fsb[i].value * 100)); return msr_decode_mult[j].ratio * msr_decode_fsb[i].value * 100; } static unsigned int pentiumM_get_frequency(void) { u32 msr_lo, msr_tmp; rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp); pr_debug("PM - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp); /* see table B-2 of 24547212.pdf */ if (msr_lo & 0x00040000) { printk(KERN_DEBUG PFX "PM - invalid FSB: 0x%x 0x%x\n", msr_lo, msr_tmp); return 0; } msr_tmp = (msr_lo >> 22) & 0x1f; pr_debug("bits 22-26 are 0x%x, speed is %u\n", msr_tmp, (msr_tmp * 100 * 1000)); return msr_tmp * 100 * 1000; } static unsigned int pentium_core_get_frequency(void) { u32 fsb = 0; u32 msr_lo, msr_tmp; int ret; rdmsr(MSR_FSB_FREQ, msr_lo, msr_tmp); /* see table B-2 of 25366920.pdf */ switch (msr_lo & 0x07) { case 5: fsb = 100000; break; case 1: fsb = 133333; break; case 3: fsb = 166667; break; case 2: fsb = 200000; break; case 0: fsb = 266667; break; case 4: fsb = 333333; break; default: printk(KERN_ERR "PCORE - MSR_FSB_FREQ undefined value"); } rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp); pr_debug("PCORE - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp); msr_tmp = (msr_lo >> 22) & 0x1f; pr_debug("bits 22-26 are 0x%x, speed is %u\n", msr_tmp, (msr_tmp * fsb)); ret = (msr_tmp * fsb); return ret; } static unsigned int pentium4_get_frequency(void) { struct cpuinfo_x86 *c = &boot_cpu_data; u32 msr_lo, msr_hi, mult; unsigned int fsb = 0; unsigned int ret; u8 fsb_code; /* Pentium 4 Model 0 and 1 do not have the Core Clock Frequency * to System Bus Frequency Ratio Field in the Processor Frequency * Configuration Register of the MSR. Therefore the current * frequency cannot be calculated and has to be measured. */ if (c->x86_model < 2) return cpu_khz; rdmsr(0x2c, msr_lo, msr_hi); pr_debug("P4 - MSR_EBC_FREQUENCY_ID: 0x%x 0x%x\n", msr_lo, msr_hi); /* decode the FSB: see IA-32 Intel (C) Architecture Software * Developer's Manual, Volume 3: System Prgramming Guide, * revision #12 in Table B-1: MSRs in the Pentium 4 and * Intel Xeon Processors, on page B-4 and B-5. */ fsb_code = (msr_lo >> 16) & 0x7; switch (fsb_code) { case 0: fsb = 100 * 1000; break; case 1: fsb = 13333 * 10; break; case 2: fsb = 200 * 1000; break; } if (!fsb) printk(KERN_DEBUG PFX "couldn't detect FSB speed. " "Please send an e-mail to <linux@brodo.de>\n"); /* Multiplier. */ mult = msr_lo >> 24; pr_debug("P4 - FSB %u kHz; Multiplier %u; Speed %u kHz\n", fsb, mult, (fsb * mult)); ret = (fsb * mult); return ret; } /* Warning: may get called from smp_call_function_single. */ unsigned int speedstep_get_frequency(enum speedstep_processor processor) { switch (processor) { case SPEEDSTEP_CPU_PCORE: return pentium_core_get_frequency(); case SPEEDSTEP_CPU_PM: return pentiumM_get_frequency(); case SPEEDSTEP_CPU_P4D: case SPEEDSTEP_CPU_P4M: return pentium4_get_frequency(); case SPEEDSTEP_CPU_PIII_T: case SPEEDSTEP_CPU_PIII_C: case SPEEDSTEP_CPU_PIII_C_EARLY: return pentium3_get_frequency(processor); default: return 0; }; return 0; } EXPORT_SYMBOL_GPL(speedstep_get_frequency); /********************************************************************* * DETECT SPEEDSTEP-CAPABLE PROCESSOR * *********************************************************************/ /* Keep in sync with the x86_cpu_id tables in the different modules */ unsigned int speedstep_detect_processor(void) { struct cpuinfo_x86 *c = &cpu_data(0); u32 ebx, msr_lo, msr_hi; pr_debug("x86: %x, model: %x\n", c->x86, c->x86_model); if ((c->x86_vendor != X86_VENDOR_INTEL) || ((c->x86 != 6) && (c->x86 != 0xF))) return 0; if (c->x86 == 0xF) { /* Intel Mobile Pentium 4-M * or Intel Mobile Pentium 4 with 533 MHz FSB */ if (c->x86_model != 2) return 0; ebx = cpuid_ebx(0x00000001); ebx &= 0x000000FF; pr_debug("ebx value is %x, x86_mask is %x\n", ebx, c->x86_mask); switch (c->x86_mask) { case 4: /* * B-stepping [M-P4-M] * sample has ebx = 0x0f, production has 0x0e. */ if ((ebx == 0x0e) || (ebx == 0x0f)) return SPEEDSTEP_CPU_P4M; break; case 7: /* * C-stepping [M-P4-M] * needs to have ebx=0x0e, else it's a celeron: * cf. 25130917.pdf / page 7, footnote 5 even * though 25072120.pdf / page 7 doesn't say * samples are only of B-stepping... */ if (ebx == 0x0e) return SPEEDSTEP_CPU_P4M; break; case 9: /* * D-stepping [M-P4-M or M-P4/533] * * this is totally strange: CPUID 0x0F29 is * used by M-P4-M, M-P4/533 and(!) Celeron CPUs. * The latter need to be sorted out as they don't * support speedstep. * Celerons with CPUID 0x0F29 may have either * ebx=0x8 or 0xf -- 25130917.pdf doesn't say anything * specific. * M-P4-Ms may have either ebx=0xe or 0xf [see above] * M-P4/533 have either ebx=0xe or 0xf. [25317607.pdf] * also, M-P4M HTs have ebx=0x8, too * For now, they are distinguished by the model_id * string */ if ((ebx == 0x0e) || (strstr(c->x86_model_id, "Mobile Intel(R) Pentium(R) 4") != NULL)) return SPEEDSTEP_CPU_P4M; break; default: break; } return 0; } switch (c->x86_model) { case 0x0B: /* Intel PIII [Tualatin] */ /* cpuid_ebx(1) is 0x04 for desktop PIII, * 0x06 for mobile PIII-M */ ebx = cpuid_ebx(0x00000001); pr_debug("ebx is %x\n", ebx); ebx &= 0x000000FF; if (ebx != 0x06) return 0; /* So far all PIII-M processors support SpeedStep. See * Intel's 24540640.pdf of June 2003 */ return SPEEDSTEP_CPU_PIII_T; case 0x08: /* Intel PIII [Coppermine] */ /* all mobile PIII Coppermines have FSB 100 MHz * ==> sort out a few desktop PIIIs. */ rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_hi); pr_debug("Coppermine: MSR_IA32_EBL_CR_POWERON is 0x%x, 0x%x\n", msr_lo, msr_hi); msr_lo &= 0x00c0000; if (msr_lo != 0x0080000) return 0; /* * If the processor is a mobile version, * platform ID has bit 50 set * it has SpeedStep technology if either * bit 56 or 57 is set */ rdmsr(MSR_IA32_PLATFORM_ID, msr_lo, msr_hi); pr_debug("Coppermine: MSR_IA32_PLATFORM ID is 0x%x, 0x%x\n", msr_lo, msr_hi); if ((msr_hi & (1<<18)) && (relaxed_check ? 1 : (msr_hi & (3<<24)))) { if (c->x86_mask == 0x01) { pr_debug("early PIII version\n"); return SPEEDSTEP_CPU_PIII_C_EARLY; } else return SPEEDSTEP_CPU_PIII_C; } default: return 0; } } EXPORT_SYMBOL_GPL(speedstep_detect_processor); /********************************************************************* * DETECT SPEEDSTEP SPEEDS * *********************************************************************/ unsigned int speedstep_get_freqs(enum speedstep_processor processor, unsigned int *low_speed, unsigned int *high_speed, unsigned int *transition_latency, void (*set_state) (unsigned int state)) { unsigned int prev_speed; unsigned int ret = 0; unsigned long flags; ktime_t tv1, tv2; if ((!processor) || (!low_speed) || (!high_speed) || (!set_state)) return -EINVAL; pr_debug("trying to determine both speeds\n"); /* get current speed */ prev_speed = speedstep_get_frequency(processor); if (!prev_speed) return -EIO; pr_debug("previous speed is %u\n", prev_speed); preempt_disable(); local_irq_save(flags); /* switch to low state */ set_state(SPEEDSTEP_LOW); *low_speed = speedstep_get_frequency(processor); if (!*low_speed) { ret = -EIO; goto out; } pr_debug("low speed is %u\n", *low_speed); /* start latency measurement */ if (transition_latency) tv1 = ktime_get(); /* switch to high state */ set_state(SPEEDSTEP_HIGH); /* end latency measurement */ if (transition_latency) tv2 = ktime_get(); *high_speed = speedstep_get_frequency(processor); if (!*high_speed) { ret = -EIO; goto out; } pr_debug("high speed is %u\n", *high_speed); if (*low_speed == *high_speed) { ret = -ENODEV; goto out; } /* switch to previous state, if necessary */ if (*high_speed != prev_speed) set_state(SPEEDSTEP_LOW); if (transition_latency) { *transition_latency = ktime_to_us(ktime_sub(tv2, tv1)); pr_debug("transition latency is %u uSec\n", *transition_latency); /* convert uSec to nSec and add 20% for safety reasons */ *transition_latency *= 1200; /* check if the latency measurement is too high or too low * and set it to a safe value (500uSec) in that case */ if (*transition_latency > 10000000 || *transition_latency < 50000) { printk(KERN_WARNING PFX "frequency transition " "measured seems out of range (%u " "nSec), falling back to a safe one of" "%u nSec.\n", *transition_latency, 500000); *transition_latency = 500000; } } out: local_irq_restore(flags); preempt_enable(); return ret; } EXPORT_SYMBOL_GPL(speedstep_get_freqs); #ifdef CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK module_param(relaxed_check, int, 0444); MODULE_PARM_DESC(relaxed_check, "Don't do all checks for speedstep capability."); #endif MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); MODULE_DESCRIPTION("Library for Intel SpeedStep 1 or 2 cpufreq drivers."); MODULE_LICENSE("GPL");
gpl-2.0
k2wl/3.0.y
fs/binfmt_script.c
699
2790
/* * linux/fs/binfmt_script.c * * Copyright (C) 1996 Martin von Löwis * original #!-checking implemented by tytso. */ #include <linux/module.h> #include <linux/string.h> #include <linux/stat.h> #include <linux/binfmts.h> #include <linux/init.h> #include <linux/file.h> #include <linux/err.h> #include <linux/fs.h> static int load_script(struct linux_binprm *bprm,struct pt_regs *regs) { const char *i_arg, *i_name; char *cp; struct file *file; char interp[BINPRM_BUF_SIZE]; int retval; if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!')) return -ENOEXEC; /* * This section does the #! interpretation. * Sorta complicated, but hopefully it will work. -TYT */ allow_write_access(bprm->file); fput(bprm->file); bprm->file = NULL; bprm->buf[BINPRM_BUF_SIZE - 1] = '\0'; if ((cp = strchr(bprm->buf, '\n')) == NULL) cp = bprm->buf+BINPRM_BUF_SIZE-1; *cp = '\0'; while (cp > bprm->buf) { cp--; if ((*cp == ' ') || (*cp == '\t')) *cp = '\0'; else break; } for (cp = bprm->buf+2; (*cp == ' ') || (*cp == '\t'); cp++); if (*cp == '\0') return -ENOEXEC; /* No interpreter name found */ i_name = cp; i_arg = NULL; for ( ; *cp && (*cp != ' ') && (*cp != '\t'); cp++) /* nothing */ ; while ((*cp == ' ') || (*cp == '\t')) *cp++ = '\0'; if (*cp) i_arg = cp; strcpy (interp, i_name); /* * OK, we've parsed out the interpreter name and * (optional) argument. * Splice in (1) the interpreter's name for argv[0] * (2) (optional) argument to interpreter * (3) filename of shell script (replace argv[0]) * * This is done in reverse order, because of how the * user environment and arguments are stored. */ retval = remove_arg_zero(bprm); if (retval) return retval; retval = copy_strings_kernel(1, &bprm->interp, bprm); if (retval < 0) return retval; bprm->argc++; if (i_arg) { retval = copy_strings_kernel(1, &i_arg, bprm); if (retval < 0) return retval; bprm->argc++; } retval = copy_strings_kernel(1, &i_name, bprm); if (retval) return retval; bprm->argc++; retval = bprm_change_interp(interp, bprm); if (retval < 0) return retval; /* * OK, now restart the process with the interpreter's dentry. */ file = open_exec(interp); if (IS_ERR(file)) return PTR_ERR(file); bprm->file = file; retval = prepare_binprm(bprm); if (retval < 0) return retval; return search_binary_handler(bprm,regs); } static struct linux_binfmt script_format = { .module = THIS_MODULE, .load_binary = load_script, }; static int __init init_script_binfmt(void) { return register_binfmt(&script_format); } static void __exit exit_script_binfmt(void) { unregister_binfmt(&script_format); } core_initcall(init_script_binfmt); module_exit(exit_script_binfmt); MODULE_LICENSE("GPL");
gpl-2.0
W4TCH0UT/zz_quark
arch/arm/plat-iop/time.c
955
3988
/* * arch/arm/plat-iop/time.c * * Timer code for IOP32x and IOP33x based systems * * Author: Deepak Saxena <dsaxena@mvista.com> * * Copyright 2002-2003 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/interrupt.h> #include <linux/time.h> #include <linux/init.h> #include <linux/timex.h> #include <linux/io.h> #include <linux/clocksource.h> #include <linux/clockchips.h> #include <linux/export.h> #include <mach/hardware.h> #include <asm/irq.h> #include <asm/sched_clock.h> #include <asm/uaccess.h> #include <asm/mach/irq.h> #include <asm/mach/time.h> #include <mach/time.h> /* * Minimum clocksource/clockevent timer range in seconds */ #define IOP_MIN_RANGE 4 /* * IOP clocksource (free-running timer 1). */ static cycle_t notrace iop_clocksource_read(struct clocksource *unused) { return 0xffffffffu - read_tcr1(); } static struct clocksource iop_clocksource = { .name = "iop_timer1", .rating = 300, .read = iop_clocksource_read, .mask = CLOCKSOURCE_MASK(32), .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; /* * IOP sched_clock() implementation via its clocksource. */ static u32 notrace iop_read_sched_clock(void) { return 0xffffffffu - read_tcr1(); } /* * IOP clockevents (interrupting timer 0). */ static int iop_set_next_event(unsigned long delta, struct clock_event_device *unused) { u32 tmr = IOP_TMR_PRIVILEGED | IOP_TMR_RATIO_1_1; BUG_ON(delta == 0); write_tmr0(tmr & ~(IOP_TMR_EN | IOP_TMR_RELOAD)); write_tcr0(delta); write_tmr0((tmr & ~IOP_TMR_RELOAD) | IOP_TMR_EN); return 0; } static unsigned long ticks_per_jiffy; static void iop_set_mode(enum clock_event_mode mode, struct clock_event_device *unused) { u32 tmr = read_tmr0(); switch (mode) { case CLOCK_EVT_MODE_PERIODIC: write_tmr0(tmr & ~IOP_TMR_EN); write_tcr0(ticks_per_jiffy - 1); write_trr0(ticks_per_jiffy - 1); tmr |= (IOP_TMR_RELOAD | IOP_TMR_EN); break; case CLOCK_EVT_MODE_ONESHOT: /* ->set_next_event sets period and enables timer */ tmr &= ~(IOP_TMR_RELOAD | IOP_TMR_EN); break; case CLOCK_EVT_MODE_RESUME: tmr |= IOP_TMR_EN; break; case CLOCK_EVT_MODE_SHUTDOWN: case CLOCK_EVT_MODE_UNUSED: default: tmr &= ~IOP_TMR_EN; break; } write_tmr0(tmr); } static struct clock_event_device iop_clockevent = { .name = "iop_timer0", .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, .rating = 300, .set_next_event = iop_set_next_event, .set_mode = iop_set_mode, }; static irqreturn_t iop_timer_interrupt(int irq, void *dev_id) { struct clock_event_device *evt = dev_id; write_tisr(1); evt->event_handler(evt); return IRQ_HANDLED; } static struct irqaction iop_timer_irq = { .name = "IOP Timer Tick", .handler = iop_timer_interrupt, .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, .dev_id = &iop_clockevent, }; static unsigned long iop_tick_rate; unsigned long get_iop_tick_rate(void) { return iop_tick_rate; } EXPORT_SYMBOL(get_iop_tick_rate); void __init iop_init_time(unsigned long tick_rate) { u32 timer_ctl; setup_sched_clock(iop_read_sched_clock, 32, tick_rate); ticks_per_jiffy = DIV_ROUND_CLOSEST(tick_rate, HZ); iop_tick_rate = tick_rate; timer_ctl = IOP_TMR_EN | IOP_TMR_PRIVILEGED | IOP_TMR_RELOAD | IOP_TMR_RATIO_1_1; /* * Set up interrupting clockevent timer 0. */ write_tmr0(timer_ctl & ~IOP_TMR_EN); write_tisr(1); setup_irq(IRQ_IOP_TIMER0, &iop_timer_irq); iop_clockevent.cpumask = cpumask_of(0); clockevents_config_and_register(&iop_clockevent, tick_rate, 0xf, 0xfffffffe); /* * Set up free-running clocksource timer 1. */ write_trr1(0xffffffff); write_tcr1(0xffffffff); write_tmr1(timer_ctl); clocksource_register_hz(&iop_clocksource, tick_rate); }
gpl-2.0
ch33kybutt/D3v1l-kernel
fs/dlm/lockspace.c
1211
19022
/****************************************************************************** ******************************************************************************* ** ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. ** Copyright (C) 2004-2008 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 "lockspace.h" #include "member.h" #include "recoverd.h" #include "ast.h" #include "dir.h" #include "lowcomms.h" #include "config.h" #include "memory.h" #include "lock.h" #include "recover.h" #include "requestqueue.h" #include "user.h" static int ls_count; static struct mutex ls_lock; static struct list_head lslist; static spinlock_t lslist_lock; static struct task_struct * scand_task; static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len) { ssize_t ret = len; int n = simple_strtol(buf, NULL, 0); ls = dlm_find_lockspace_local(ls->ls_local_handle); if (!ls) return -EINVAL; switch (n) { case 0: dlm_ls_stop(ls); break; case 1: dlm_ls_start(ls); break; default: ret = -EINVAL; } dlm_put_lockspace(ls); return ret; } static ssize_t dlm_event_store(struct dlm_ls *ls, const char *buf, size_t len) { ls->ls_uevent_result = simple_strtol(buf, NULL, 0); set_bit(LSFL_UEVENT_WAIT, &ls->ls_flags); wake_up(&ls->ls_uevent_wait); return len; } static ssize_t dlm_id_show(struct dlm_ls *ls, char *buf) { return snprintf(buf, PAGE_SIZE, "%u\n", ls->ls_global_id); } static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len) { ls->ls_global_id = simple_strtoul(buf, NULL, 0); return len; } static ssize_t dlm_recover_status_show(struct dlm_ls *ls, char *buf) { uint32_t status = dlm_recover_status(ls); return snprintf(buf, PAGE_SIZE, "%x\n", status); } static ssize_t dlm_recover_nodeid_show(struct dlm_ls *ls, char *buf) { return snprintf(buf, PAGE_SIZE, "%d\n", ls->ls_recover_nodeid); } struct dlm_attr { struct attribute attr; ssize_t (*show)(struct dlm_ls *, char *); ssize_t (*store)(struct dlm_ls *, const char *, size_t); }; static struct dlm_attr dlm_attr_control = { .attr = {.name = "control", .mode = S_IWUSR}, .store = dlm_control_store }; static struct dlm_attr dlm_attr_event = { .attr = {.name = "event_done", .mode = S_IWUSR}, .store = dlm_event_store }; static struct dlm_attr dlm_attr_id = { .attr = {.name = "id", .mode = S_IRUGO | S_IWUSR}, .show = dlm_id_show, .store = dlm_id_store }; static struct dlm_attr dlm_attr_recover_status = { .attr = {.name = "recover_status", .mode = S_IRUGO}, .show = dlm_recover_status_show }; static struct dlm_attr dlm_attr_recover_nodeid = { .attr = {.name = "recover_nodeid", .mode = S_IRUGO}, .show = dlm_recover_nodeid_show }; static struct attribute *dlm_attrs[] = { &dlm_attr_control.attr, &dlm_attr_event.attr, &dlm_attr_id.attr, &dlm_attr_recover_status.attr, &dlm_attr_recover_nodeid.attr, NULL, }; static ssize_t dlm_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct dlm_ls *ls = container_of(kobj, struct dlm_ls, ls_kobj); struct dlm_attr *a = container_of(attr, struct dlm_attr, attr); return a->show ? a->show(ls, buf) : 0; } static ssize_t dlm_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t len) { struct dlm_ls *ls = container_of(kobj, struct dlm_ls, ls_kobj); struct dlm_attr *a = container_of(attr, struct dlm_attr, attr); return a->store ? a->store(ls, buf, len) : len; } static void lockspace_kobj_release(struct kobject *k) { struct dlm_ls *ls = container_of(k, struct dlm_ls, ls_kobj); kfree(ls); } static const struct sysfs_ops dlm_attr_ops = { .show = dlm_attr_show, .store = dlm_attr_store, }; static struct kobj_type dlm_ktype = { .default_attrs = dlm_attrs, .sysfs_ops = &dlm_attr_ops, .release = lockspace_kobj_release, }; static struct kset *dlm_kset; static int do_uevent(struct dlm_ls *ls, int in) { int error; if (in) kobject_uevent(&ls->ls_kobj, KOBJ_ONLINE); else kobject_uevent(&ls->ls_kobj, KOBJ_OFFLINE); log_debug(ls, "%s the lockspace group...", in ? "joining" : "leaving"); /* dlm_controld will see the uevent, do the necessary group management and then write to sysfs to wake us */ error = wait_event_interruptible(ls->ls_uevent_wait, test_and_clear_bit(LSFL_UEVENT_WAIT, &ls->ls_flags)); log_debug(ls, "group event done %d %d", error, ls->ls_uevent_result); if (error) goto out; error = ls->ls_uevent_result; out: if (error) log_error(ls, "group %s failed %d %d", in ? "join" : "leave", error, ls->ls_uevent_result); return error; } static int dlm_uevent(struct kset *kset, struct kobject *kobj, struct kobj_uevent_env *env) { struct dlm_ls *ls = container_of(kobj, struct dlm_ls, ls_kobj); add_uevent_var(env, "LOCKSPACE=%s", ls->ls_name); return 0; } static struct kset_uevent_ops dlm_uevent_ops = { .uevent = dlm_uevent, }; int __init dlm_lockspace_init(void) { ls_count = 0; mutex_init(&ls_lock); INIT_LIST_HEAD(&lslist); spin_lock_init(&lslist_lock); dlm_kset = kset_create_and_add("dlm", &dlm_uevent_ops, kernel_kobj); if (!dlm_kset) { printk(KERN_WARNING "%s: can not create kset\n", __func__); return -ENOMEM; } return 0; } void dlm_lockspace_exit(void) { kset_unregister(dlm_kset); } static struct dlm_ls *find_ls_to_scan(void) { struct dlm_ls *ls; spin_lock(&lslist_lock); list_for_each_entry(ls, &lslist, ls_list) { if (time_after_eq(jiffies, ls->ls_scan_time + dlm_config.ci_scan_secs * HZ)) { spin_unlock(&lslist_lock); return ls; } } spin_unlock(&lslist_lock); return NULL; } static int dlm_scand(void *data) { struct dlm_ls *ls; int timeout_jiffies = dlm_config.ci_scan_secs * HZ; while (!kthread_should_stop()) { ls = find_ls_to_scan(); if (ls) { if (dlm_lock_recovery_try(ls)) { ls->ls_scan_time = jiffies; dlm_scan_rsbs(ls); dlm_scan_timeout(ls); dlm_unlock_recovery(ls); } else { ls->ls_scan_time += HZ; } } else { schedule_timeout_interruptible(timeout_jiffies); } } return 0; } static int dlm_scand_start(void) { struct task_struct *p; int error = 0; p = kthread_run(dlm_scand, NULL, "dlm_scand"); if (IS_ERR(p)) error = PTR_ERR(p); else scand_task = p; return error; } static void dlm_scand_stop(void) { kthread_stop(scand_task); } struct dlm_ls *dlm_find_lockspace_global(uint32_t id) { struct dlm_ls *ls; spin_lock(&lslist_lock); list_for_each_entry(ls, &lslist, ls_list) { if (ls->ls_global_id == id) { ls->ls_count++; goto out; } } ls = NULL; out: spin_unlock(&lslist_lock); return ls; } struct dlm_ls *dlm_find_lockspace_local(dlm_lockspace_t *lockspace) { struct dlm_ls *ls; spin_lock(&lslist_lock); list_for_each_entry(ls, &lslist, ls_list) { if (ls->ls_local_handle == lockspace) { ls->ls_count++; goto out; } } ls = NULL; out: spin_unlock(&lslist_lock); return ls; } struct dlm_ls *dlm_find_lockspace_device(int minor) { struct dlm_ls *ls; spin_lock(&lslist_lock); list_for_each_entry(ls, &lslist, ls_list) { if (ls->ls_device.minor == minor) { ls->ls_count++; goto out; } } ls = NULL; out: spin_unlock(&lslist_lock); return ls; } void dlm_put_lockspace(struct dlm_ls *ls) { spin_lock(&lslist_lock); ls->ls_count--; spin_unlock(&lslist_lock); } static void remove_lockspace(struct dlm_ls *ls) { for (;;) { spin_lock(&lslist_lock); if (ls->ls_count == 0) { WARN_ON(ls->ls_create_count != 0); list_del(&ls->ls_list); spin_unlock(&lslist_lock); return; } spin_unlock(&lslist_lock); ssleep(1); } } static int threads_start(void) { int error; /* Thread which process lock requests for all lockspace's */ error = dlm_astd_start(); if (error) { log_print("cannot start dlm_astd thread %d", error); goto fail; } error = dlm_scand_start(); if (error) { log_print("cannot start dlm_scand thread %d", error); goto astd_fail; } /* Thread for sending/receiving messages for all lockspace's */ error = dlm_lowcomms_start(); if (error) { log_print("cannot start dlm lowcomms %d", error); goto scand_fail; } return 0; scand_fail: dlm_scand_stop(); astd_fail: dlm_astd_stop(); fail: return error; } static void threads_stop(void) { dlm_scand_stop(); dlm_lowcomms_stop(); dlm_astd_stop(); } static int new_lockspace(const char *name, int namelen, void **lockspace, uint32_t flags, int lvblen) { struct dlm_ls *ls; int i, size, error; int do_unreg = 0; if (namelen > DLM_LOCKSPACE_LEN) return -EINVAL; if (!lvblen || (lvblen % 8)) return -EINVAL; if (!try_module_get(THIS_MODULE)) return -EINVAL; if (!dlm_user_daemon_available()) { module_put(THIS_MODULE); return -EUNATCH; } error = 0; spin_lock(&lslist_lock); list_for_each_entry(ls, &lslist, ls_list) { WARN_ON(ls->ls_create_count <= 0); if (ls->ls_namelen != namelen) continue; if (memcmp(ls->ls_name, name, namelen)) continue; if (flags & DLM_LSFL_NEWEXCL) { error = -EEXIST; break; } ls->ls_create_count++; *lockspace = ls; error = 1; break; } spin_unlock(&lslist_lock); if (error) goto out; error = -ENOMEM; ls = kzalloc(sizeof(struct dlm_ls) + namelen, GFP_NOFS); if (!ls) goto out; memcpy(ls->ls_name, name, namelen); ls->ls_namelen = namelen; ls->ls_lvblen = lvblen; ls->ls_count = 0; ls->ls_flags = 0; ls->ls_scan_time = jiffies; if (flags & DLM_LSFL_TIMEWARN) set_bit(LSFL_TIMEWARN, &ls->ls_flags); /* ls_exflags are forced to match among nodes, and we don't need to require all nodes to have some flags set */ ls->ls_exflags = (flags & ~(DLM_LSFL_TIMEWARN | DLM_LSFL_FS | DLM_LSFL_NEWEXCL)); size = dlm_config.ci_rsbtbl_size; ls->ls_rsbtbl_size = size; ls->ls_rsbtbl = kmalloc(sizeof(struct dlm_rsbtable) * size, GFP_NOFS); if (!ls->ls_rsbtbl) goto out_lsfree; for (i = 0; i < size; i++) { INIT_LIST_HEAD(&ls->ls_rsbtbl[i].list); INIT_LIST_HEAD(&ls->ls_rsbtbl[i].toss); spin_lock_init(&ls->ls_rsbtbl[i].lock); } size = dlm_config.ci_lkbtbl_size; ls->ls_lkbtbl_size = size; ls->ls_lkbtbl = kmalloc(sizeof(struct dlm_lkbtable) * size, GFP_NOFS); if (!ls->ls_lkbtbl) goto out_rsbfree; for (i = 0; i < size; i++) { INIT_LIST_HEAD(&ls->ls_lkbtbl[i].list); rwlock_init(&ls->ls_lkbtbl[i].lock); ls->ls_lkbtbl[i].counter = 1; } size = dlm_config.ci_dirtbl_size; ls->ls_dirtbl_size = size; ls->ls_dirtbl = kmalloc(sizeof(struct dlm_dirtable) * size, GFP_NOFS); if (!ls->ls_dirtbl) goto out_lkbfree; for (i = 0; i < size; i++) { INIT_LIST_HEAD(&ls->ls_dirtbl[i].list); spin_lock_init(&ls->ls_dirtbl[i].lock); } INIT_LIST_HEAD(&ls->ls_waiters); mutex_init(&ls->ls_waiters_mutex); INIT_LIST_HEAD(&ls->ls_orphans); mutex_init(&ls->ls_orphans_mutex); INIT_LIST_HEAD(&ls->ls_timeout); mutex_init(&ls->ls_timeout_mutex); INIT_LIST_HEAD(&ls->ls_nodes); INIT_LIST_HEAD(&ls->ls_nodes_gone); ls->ls_num_nodes = 0; ls->ls_low_nodeid = 0; ls->ls_total_weight = 0; ls->ls_node_array = NULL; memset(&ls->ls_stub_rsb, 0, sizeof(struct dlm_rsb)); ls->ls_stub_rsb.res_ls = ls; ls->ls_debug_rsb_dentry = NULL; ls->ls_debug_waiters_dentry = NULL; init_waitqueue_head(&ls->ls_uevent_wait); ls->ls_uevent_result = 0; init_completion(&ls->ls_members_done); ls->ls_members_result = -1; ls->ls_recoverd_task = NULL; mutex_init(&ls->ls_recoverd_active); spin_lock_init(&ls->ls_recover_lock); spin_lock_init(&ls->ls_rcom_spin); get_random_bytes(&ls->ls_rcom_seq, sizeof(uint64_t)); ls->ls_recover_status = 0; ls->ls_recover_seq = 0; ls->ls_recover_args = NULL; init_rwsem(&ls->ls_in_recovery); init_rwsem(&ls->ls_recv_active); INIT_LIST_HEAD(&ls->ls_requestqueue); mutex_init(&ls->ls_requestqueue_mutex); mutex_init(&ls->ls_clear_proc_locks); ls->ls_recover_buf = kmalloc(dlm_config.ci_buffer_size, GFP_NOFS); if (!ls->ls_recover_buf) goto out_dirfree; INIT_LIST_HEAD(&ls->ls_recover_list); spin_lock_init(&ls->ls_recover_list_lock); ls->ls_recover_list_count = 0; ls->ls_local_handle = ls; init_waitqueue_head(&ls->ls_wait_general); INIT_LIST_HEAD(&ls->ls_root_list); init_rwsem(&ls->ls_root_sem); down_write(&ls->ls_in_recovery); spin_lock(&lslist_lock); ls->ls_create_count = 1; list_add(&ls->ls_list, &lslist); spin_unlock(&lslist_lock); /* needs to find ls in lslist */ error = dlm_recoverd_start(ls); if (error) { log_error(ls, "can't start dlm_recoverd %d", error); goto out_delist; } ls->ls_kobj.kset = dlm_kset; error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL, "%s", ls->ls_name); if (error) goto out_stop; kobject_uevent(&ls->ls_kobj, KOBJ_ADD); /* let kobject handle freeing of ls if there's an error */ do_unreg = 1; /* This uevent triggers dlm_controld in userspace to add us to the group of nodes that are members of this lockspace (managed by the cluster infrastructure.) Once it's done that, it tells us who the current lockspace members are (via configfs) and then tells the lockspace to start running (via sysfs) in dlm_ls_start(). */ error = do_uevent(ls, 1); if (error) goto out_stop; wait_for_completion(&ls->ls_members_done); error = ls->ls_members_result; if (error) goto out_members; dlm_create_debug_file(ls); log_debug(ls, "join complete"); *lockspace = ls; return 0; out_members: do_uevent(ls, 0); dlm_clear_members(ls); kfree(ls->ls_node_array); out_stop: dlm_recoverd_stop(ls); out_delist: spin_lock(&lslist_lock); list_del(&ls->ls_list); spin_unlock(&lslist_lock); kfree(ls->ls_recover_buf); out_dirfree: kfree(ls->ls_dirtbl); out_lkbfree: kfree(ls->ls_lkbtbl); out_rsbfree: kfree(ls->ls_rsbtbl); out_lsfree: if (do_unreg) kobject_put(&ls->ls_kobj); else kfree(ls); out: module_put(THIS_MODULE); return error; } int dlm_new_lockspace(const char *name, int namelen, void **lockspace, uint32_t flags, int lvblen) { int error = 0; mutex_lock(&ls_lock); if (!ls_count) error = threads_start(); if (error) goto out; error = new_lockspace(name, namelen, lockspace, flags, lvblen); if (!error) ls_count++; if (error > 0) error = 0; if (!ls_count) threads_stop(); out: mutex_unlock(&ls_lock); return error; } /* Return 1 if the lockspace still has active remote locks, * 2 if the lockspace still has active local locks. */ static int lockspace_busy(struct dlm_ls *ls) { int i, lkb_found = 0; struct dlm_lkb *lkb; /* NOTE: We check the lockidtbl here rather than the resource table. This is because there may be LKBs queued as ASTs that have been unlinked from their RSBs and are pending deletion once the AST has been delivered */ for (i = 0; i < ls->ls_lkbtbl_size; i++) { read_lock(&ls->ls_lkbtbl[i].lock); if (!list_empty(&ls->ls_lkbtbl[i].list)) { lkb_found = 1; list_for_each_entry(lkb, &ls->ls_lkbtbl[i].list, lkb_idtbl_list) { if (!lkb->lkb_nodeid) { read_unlock(&ls->ls_lkbtbl[i].lock); return 2; } } } read_unlock(&ls->ls_lkbtbl[i].lock); } return lkb_found; } static int release_lockspace(struct dlm_ls *ls, int force) { struct dlm_lkb *lkb; struct dlm_rsb *rsb; struct list_head *head; int i, busy, rv; busy = lockspace_busy(ls); spin_lock(&lslist_lock); if (ls->ls_create_count == 1) { if (busy > force) rv = -EBUSY; else { /* remove_lockspace takes ls off lslist */ ls->ls_create_count = 0; rv = 0; } } else if (ls->ls_create_count > 1) { rv = --ls->ls_create_count; } else { rv = -EINVAL; } spin_unlock(&lslist_lock); if (rv) { log_debug(ls, "release_lockspace no remove %d", rv); return rv; } dlm_device_deregister(ls); if (force < 3 && dlm_user_daemon_available()) do_uevent(ls, 0); dlm_recoverd_stop(ls); remove_lockspace(ls); dlm_delete_debug_file(ls); dlm_astd_suspend(); kfree(ls->ls_recover_buf); /* * Free direntry structs. */ dlm_dir_clear(ls); kfree(ls->ls_dirtbl); /* * Free all lkb's on lkbtbl[] lists. */ for (i = 0; i < ls->ls_lkbtbl_size; i++) { head = &ls->ls_lkbtbl[i].list; while (!list_empty(head)) { lkb = list_entry(head->next, struct dlm_lkb, lkb_idtbl_list); list_del(&lkb->lkb_idtbl_list); dlm_del_ast(lkb); if (lkb->lkb_lvbptr && lkb->lkb_flags & DLM_IFL_MSTCPY) dlm_free_lvb(lkb->lkb_lvbptr); dlm_free_lkb(lkb); } } dlm_astd_resume(); kfree(ls->ls_lkbtbl); /* * Free all rsb's on rsbtbl[] lists */ for (i = 0; i < ls->ls_rsbtbl_size; i++) { head = &ls->ls_rsbtbl[i].list; while (!list_empty(head)) { rsb = list_entry(head->next, struct dlm_rsb, res_hashchain); list_del(&rsb->res_hashchain); dlm_free_rsb(rsb); } head = &ls->ls_rsbtbl[i].toss; while (!list_empty(head)) { rsb = list_entry(head->next, struct dlm_rsb, res_hashchain); list_del(&rsb->res_hashchain); dlm_free_rsb(rsb); } } kfree(ls->ls_rsbtbl); /* * Free structures on any other lists */ dlm_purge_requestqueue(ls); kfree(ls->ls_recover_args); dlm_clear_free_entries(ls); dlm_clear_members(ls); dlm_clear_members_gone(ls); kfree(ls->ls_node_array); log_debug(ls, "release_lockspace final free"); kobject_put(&ls->ls_kobj); /* The ls structure will be freed when the kobject is done with */ module_put(THIS_MODULE); return 0; } /* * Called when a system has released all its locks and is not going to use the * lockspace any longer. We free everything we're managing for this lockspace. * Remaining nodes will go through the recovery process as if we'd died. The * lockspace must continue to function as usual, participating in recoveries, * until this returns. * * Force has 4 possible values: * 0 - don't destroy locksapce if it has any LKBs * 1 - destroy lockspace if it has remote LKBs but not if it has local LKBs * 2 - destroy lockspace regardless of LKBs * 3 - destroy lockspace as part of a forced shutdown */ int dlm_release_lockspace(void *lockspace, int force) { struct dlm_ls *ls; int error; ls = dlm_find_lockspace_local(lockspace); if (!ls) return -EINVAL; dlm_put_lockspace(ls); mutex_lock(&ls_lock); error = release_lockspace(ls, force); if (!error) ls_count--; if (!ls_count) threads_stop(); mutex_unlock(&ls_lock); return error; } void dlm_stop_lockspaces(void) { struct dlm_ls *ls; restart: spin_lock(&lslist_lock); list_for_each_entry(ls, &lslist, ls_list) { if (!test_bit(LSFL_RUNNING, &ls->ls_flags)) continue; spin_unlock(&lslist_lock); log_error(ls, "no userland control daemon, stopping lockspace"); dlm_ls_stop(ls); goto restart; } spin_unlock(&lslist_lock); }
gpl-2.0
DroidThug/kernel_delta_msm8916
fs/proc/nommu.c
1211
3270
/* nommu.c: mmu-less memory info files * * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.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/init.h> #include <linux/module.h> #include <linux/errno.h> #include <linux/time.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/mman.h> #include <linux/proc_fs.h> #include <linux/mm.h> #include <linux/mmzone.h> #include <linux/pagemap.h> #include <linux/swap.h> #include <linux/smp.h> #include <linux/seq_file.h> #include <linux/hugetlb.h> #include <linux/vmalloc.h> #include <asm/uaccess.h> #include <asm/pgtable.h> #include <asm/tlb.h> #include <asm/div64.h> #include "internal.h" /* * display a single region to a sequenced file */ static int nommu_region_show(struct seq_file *m, struct vm_region *region) { unsigned long ino = 0; struct file *file; dev_t dev = 0; int flags; flags = region->vm_flags; file = region->vm_file; if (file) { struct inode *inode = file_inode(region->vm_file); dev = inode->i_sb->s_dev; ino = inode->i_ino; } seq_setwidth(m, 25 + sizeof(void *) * 6 - 1); seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ", region->vm_start, region->vm_end, flags & VM_READ ? 'r' : '-', flags & VM_WRITE ? 'w' : '-', flags & VM_EXEC ? 'x' : '-', flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p', ((loff_t)region->vm_pgoff) << PAGE_SHIFT, MAJOR(dev), MINOR(dev), ino); if (file) { seq_pad(m, ' '); seq_path(m, &file->f_path, ""); } seq_putc(m, '\n'); return 0; } /* * display a list of all the REGIONs the kernel knows about * - nommu kernels have a single flat list */ static int nommu_region_list_show(struct seq_file *m, void *_p) { struct rb_node *p = _p; return nommu_region_show(m, rb_entry(p, struct vm_region, vm_rb)); } static void *nommu_region_list_start(struct seq_file *m, loff_t *_pos) { struct rb_node *p; loff_t pos = *_pos; down_read(&nommu_region_sem); for (p = rb_first(&nommu_region_tree); p; p = rb_next(p)) if (pos-- == 0) return p; return NULL; } static void nommu_region_list_stop(struct seq_file *m, void *v) { up_read(&nommu_region_sem); } static void *nommu_region_list_next(struct seq_file *m, void *v, loff_t *pos) { (*pos)++; return rb_next((struct rb_node *) v); } static const struct seq_operations proc_nommu_region_list_seqop = { .start = nommu_region_list_start, .next = nommu_region_list_next, .stop = nommu_region_list_stop, .show = nommu_region_list_show }; static int proc_nommu_region_list_open(struct inode *inode, struct file *file) { return seq_open(file, &proc_nommu_region_list_seqop); } static const struct file_operations proc_nommu_region_list_operations = { .open = proc_nommu_region_list_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; static int __init proc_nommu_init(void) { proc_create("maps", S_IRUGO, NULL, &proc_nommu_region_list_operations); return 0; } module_init(proc_nommu_init);
gpl-2.0
timduru/kernel-asus-tf101
drivers/video/uvesafb.c
1467
51804
/* * A framebuffer driver for VBE 2.0+ compliant video cards * * (c) 2007 Michal Januszewski <spock@gentoo.org> * Loosely based upon the vesafb driver. * */ #include <linux/init.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/skbuff.h> #include <linux/timer.h> #include <linux/completion.h> #include <linux/connector.h> #include <linux/random.h> #include <linux/platform_device.h> #include <linux/limits.h> #include <linux/fb.h> #include <linux/io.h> #include <linux/mutex.h> #include <linux/slab.h> #include <video/edid.h> #include <video/uvesafb.h> #ifdef CONFIG_X86 #include <video/vga.h> #endif #ifdef CONFIG_MTRR #include <asm/mtrr.h> #endif #include "edid.h" static struct cb_id uvesafb_cn_id = { .idx = CN_IDX_V86D, .val = CN_VAL_V86D_UVESAFB }; static char v86d_path[PATH_MAX] = "/sbin/v86d"; static char v86d_started; /* has v86d been started by uvesafb? */ static struct fb_fix_screeninfo uvesafb_fix __devinitdata = { .id = "VESA VGA", .type = FB_TYPE_PACKED_PIXELS, .accel = FB_ACCEL_NONE, .visual = FB_VISUAL_TRUECOLOR, }; static int mtrr __devinitdata = 3; /* enable mtrr by default */ static int blank = 1; /* enable blanking by default */ static int ypan = 1; /* 0: scroll, 1: ypan, 2: ywrap */ static bool pmi_setpal __devinitdata = true; /* use PMI for palette changes */ static int nocrtc __devinitdata; /* ignore CRTC settings */ static int noedid __devinitdata; /* don't try DDC transfers */ static int vram_remap __devinitdata; /* set amt. of memory to be used */ static int vram_total __devinitdata; /* set total amount of memory */ static u16 maxclk __devinitdata; /* maximum pixel clock */ static u16 maxvf __devinitdata; /* maximum vertical frequency */ static u16 maxhf __devinitdata; /* maximum horizontal frequency */ static u16 vbemode __devinitdata; /* force use of a specific VBE mode */ static char *mode_option __devinitdata; static u8 dac_width = 6; static struct uvesafb_ktask *uvfb_tasks[UVESAFB_TASKS_MAX]; static DEFINE_MUTEX(uvfb_lock); /* * A handler for replies from userspace. * * Make sure each message passes consistency checks and if it does, * find the kernel part of the task struct, copy the registers and * the buffer contents and then complete the task. */ static void uvesafb_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) { struct uvesafb_task *utask; struct uvesafb_ktask *task; if (!cap_raised(current_cap(), CAP_SYS_ADMIN)) return; if (msg->seq >= UVESAFB_TASKS_MAX) return; mutex_lock(&uvfb_lock); task = uvfb_tasks[msg->seq]; if (!task || msg->ack != task->ack) { mutex_unlock(&uvfb_lock); return; } utask = (struct uvesafb_task *)msg->data; /* Sanity checks for the buffer length. */ if (task->t.buf_len < utask->buf_len || utask->buf_len > msg->len - sizeof(*utask)) { mutex_unlock(&uvfb_lock); return; } uvfb_tasks[msg->seq] = NULL; mutex_unlock(&uvfb_lock); memcpy(&task->t, utask, sizeof(*utask)); if (task->t.buf_len && task->buf) memcpy(task->buf, utask + 1, task->t.buf_len); complete(task->done); return; } static int uvesafb_helper_start(void) { char *envp[] = { "HOME=/", "PATH=/sbin:/bin", NULL, }; char *argv[] = { v86d_path, NULL, }; return call_usermodehelper(v86d_path, argv, envp, 1); } /* * Execute a uvesafb task. * * Returns 0 if the task is executed successfully. * * A message sent to the userspace consists of the uvesafb_task * struct and (optionally) a buffer. The uvesafb_task struct is * a simplified version of uvesafb_ktask (its kernel counterpart) * containing only the register values, flags and the length of * the buffer. * * Each message is assigned a sequence number (increased linearly) * and a random ack number. The sequence number is used as a key * for the uvfb_tasks array which holds pointers to uvesafb_ktask * structs for all requests. */ static int uvesafb_exec(struct uvesafb_ktask *task) { static int seq; struct cn_msg *m; int err; int len = sizeof(task->t) + task->t.buf_len; /* * Check whether the message isn't longer than the maximum * allowed by connector. */ if (sizeof(*m) + len > CONNECTOR_MAX_MSG_SIZE) { printk(KERN_WARNING "uvesafb: message too long (%d), " "can't execute task\n", (int)(sizeof(*m) + len)); return -E2BIG; } m = kzalloc(sizeof(*m) + len, GFP_KERNEL); if (!m) return -ENOMEM; init_completion(task->done); memcpy(&m->id, &uvesafb_cn_id, sizeof(m->id)); m->seq = seq; m->len = len; m->ack = random32(); /* uvesafb_task structure */ memcpy(m + 1, &task->t, sizeof(task->t)); /* Buffer */ memcpy((u8 *)(m + 1) + sizeof(task->t), task->buf, task->t.buf_len); /* * Save the message ack number so that we can find the kernel * part of this task when a reply is received from userspace. */ task->ack = m->ack; mutex_lock(&uvfb_lock); /* If all slots are taken -- bail out. */ if (uvfb_tasks[seq]) { mutex_unlock(&uvfb_lock); err = -EBUSY; goto out; } /* Save a pointer to the kernel part of the task struct. */ uvfb_tasks[seq] = task; mutex_unlock(&uvfb_lock); err = cn_netlink_send(m, 0, GFP_KERNEL); if (err == -ESRCH) { /* * Try to start the userspace helper if sending * the request failed the first time. */ err = uvesafb_helper_start(); if (err) { printk(KERN_ERR "uvesafb: failed to execute %s\n", v86d_path); printk(KERN_ERR "uvesafb: make sure that the v86d " "helper is installed and executable\n"); } else { v86d_started = 1; err = cn_netlink_send(m, 0, gfp_any()); if (err == -ENOBUFS) err = 0; } } else if (err == -ENOBUFS) err = 0; if (!err && !(task->t.flags & TF_EXIT)) err = !wait_for_completion_timeout(task->done, msecs_to_jiffies(UVESAFB_TIMEOUT)); mutex_lock(&uvfb_lock); uvfb_tasks[seq] = NULL; mutex_unlock(&uvfb_lock); seq++; if (seq >= UVESAFB_TASKS_MAX) seq = 0; out: kfree(m); return err; } /* * Free a uvesafb_ktask struct. */ static void uvesafb_free(struct uvesafb_ktask *task) { if (task) { if (task->done) kfree(task->done); kfree(task); } } /* * Prepare a uvesafb_ktask struct to be used again. */ static void uvesafb_reset(struct uvesafb_ktask *task) { struct completion *cpl = task->done; memset(task, 0, sizeof(*task)); task->done = cpl; } /* * Allocate and prepare a uvesafb_ktask struct. */ static struct uvesafb_ktask *uvesafb_prep(void) { struct uvesafb_ktask *task; task = kzalloc(sizeof(*task), GFP_KERNEL); if (task) { task->done = kzalloc(sizeof(*task->done), GFP_KERNEL); if (!task->done) { kfree(task); task = NULL; } } return task; } static void uvesafb_setup_var(struct fb_var_screeninfo *var, struct fb_info *info, struct vbe_mode_ib *mode) { struct uvesafb_par *par = info->par; var->vmode = FB_VMODE_NONINTERLACED; var->sync = FB_SYNC_VERT_HIGH_ACT; var->xres = mode->x_res; var->yres = mode->y_res; var->xres_virtual = mode->x_res; var->yres_virtual = (par->ypan) ? info->fix.smem_len / mode->bytes_per_scan_line : mode->y_res; var->xoffset = 0; var->yoffset = 0; var->bits_per_pixel = mode->bits_per_pixel; if (var->bits_per_pixel == 15) var->bits_per_pixel = 16; if (var->bits_per_pixel > 8) { var->red.offset = mode->red_off; var->red.length = mode->red_len; var->green.offset = mode->green_off; var->green.length = mode->green_len; var->blue.offset = mode->blue_off; var->blue.length = mode->blue_len; var->transp.offset = mode->rsvd_off; var->transp.length = mode->rsvd_len; } else { var->red.offset = 0; var->green.offset = 0; var->blue.offset = 0; var->transp.offset = 0; var->red.length = 8; var->green.length = 8; var->blue.length = 8; var->transp.length = 0; } } static int uvesafb_vbe_find_mode(struct uvesafb_par *par, int xres, int yres, int depth, unsigned char flags) { int i, match = -1, h = 0, d = 0x7fffffff; for (i = 0; i < par->vbe_modes_cnt; i++) { h = abs(par->vbe_modes[i].x_res - xres) + abs(par->vbe_modes[i].y_res - yres) + abs(depth - par->vbe_modes[i].depth); /* * We have an exact match in terms of resolution * and depth. */ if (h == 0) return i; if (h < d || (h == d && par->vbe_modes[i].depth > depth)) { d = h; match = i; } } i = 1; if (flags & UVESAFB_EXACT_DEPTH && par->vbe_modes[match].depth != depth) i = 0; if (flags & UVESAFB_EXACT_RES && d > 24) i = 0; if (i != 0) return match; else return -1; } static u8 *uvesafb_vbe_state_save(struct uvesafb_par *par) { struct uvesafb_ktask *task; u8 *state; int err; if (!par->vbe_state_size) return NULL; state = kmalloc(par->vbe_state_size, GFP_KERNEL); if (!state) return NULL; task = uvesafb_prep(); if (!task) { kfree(state); return NULL; } task->t.regs.eax = 0x4f04; task->t.regs.ecx = 0x000f; task->t.regs.edx = 0x0001; task->t.flags = TF_BUF_RET | TF_BUF_ESBX; task->t.buf_len = par->vbe_state_size; task->buf = state; err = uvesafb_exec(task); if (err || (task->t.regs.eax & 0xffff) != 0x004f) { printk(KERN_WARNING "uvesafb: VBE get state call " "failed (eax=0x%x, err=%d)\n", task->t.regs.eax, err); kfree(state); state = NULL; } uvesafb_free(task); return state; } static void uvesafb_vbe_state_restore(struct uvesafb_par *par, u8 *state_buf) { struct uvesafb_ktask *task; int err; if (!state_buf) return; task = uvesafb_prep(); if (!task) return; task->t.regs.eax = 0x4f04; task->t.regs.ecx = 0x000f; task->t.regs.edx = 0x0002; task->t.buf_len = par->vbe_state_size; task->t.flags = TF_BUF_ESBX; task->buf = state_buf; err = uvesafb_exec(task); if (err || (task->t.regs.eax & 0xffff) != 0x004f) printk(KERN_WARNING "uvesafb: VBE state restore call " "failed (eax=0x%x, err=%d)\n", task->t.regs.eax, err); uvesafb_free(task); } static int __devinit uvesafb_vbe_getinfo(struct uvesafb_ktask *task, struct uvesafb_par *par) { int err; task->t.regs.eax = 0x4f00; task->t.flags = TF_VBEIB; task->t.buf_len = sizeof(struct vbe_ib); task->buf = &par->vbe_ib; strncpy(par->vbe_ib.vbe_signature, "VBE2", 4); err = uvesafb_exec(task); if (err || (task->t.regs.eax & 0xffff) != 0x004f) { printk(KERN_ERR "uvesafb: Getting VBE info block failed " "(eax=0x%x, err=%d)\n", (u32)task->t.regs.eax, err); return -EINVAL; } if (par->vbe_ib.vbe_version < 0x0200) { printk(KERN_ERR "uvesafb: Sorry, pre-VBE 2.0 cards are " "not supported.\n"); return -EINVAL; } if (!par->vbe_ib.mode_list_ptr) { printk(KERN_ERR "uvesafb: Missing mode list!\n"); return -EINVAL; } printk(KERN_INFO "uvesafb: "); /* * Convert string pointers and the mode list pointer into * usable addresses. Print informational messages about the * video adapter and its vendor. */ if (par->vbe_ib.oem_vendor_name_ptr) printk("%s, ", ((char *)task->buf) + par->vbe_ib.oem_vendor_name_ptr); if (par->vbe_ib.oem_product_name_ptr) printk("%s, ", ((char *)task->buf) + par->vbe_ib.oem_product_name_ptr); if (par->vbe_ib.oem_product_rev_ptr) printk("%s, ", ((char *)task->buf) + par->vbe_ib.oem_product_rev_ptr); if (par->vbe_ib.oem_string_ptr) printk("OEM: %s, ", ((char *)task->buf) + par->vbe_ib.oem_string_ptr); printk("VBE v%d.%d\n", ((par->vbe_ib.vbe_version & 0xff00) >> 8), par->vbe_ib.vbe_version & 0xff); return 0; } static int __devinit uvesafb_vbe_getmodes(struct uvesafb_ktask *task, struct uvesafb_par *par) { int off = 0, err; u16 *mode; par->vbe_modes_cnt = 0; /* Count available modes. */ mode = (u16 *) (((u8 *)&par->vbe_ib) + par->vbe_ib.mode_list_ptr); while (*mode != 0xffff) { par->vbe_modes_cnt++; mode++; } par->vbe_modes = kzalloc(sizeof(struct vbe_mode_ib) * par->vbe_modes_cnt, GFP_KERNEL); if (!par->vbe_modes) return -ENOMEM; /* Get info about all available modes. */ mode = (u16 *) (((u8 *)&par->vbe_ib) + par->vbe_ib.mode_list_ptr); while (*mode != 0xffff) { struct vbe_mode_ib *mib; uvesafb_reset(task); task->t.regs.eax = 0x4f01; task->t.regs.ecx = (u32) *mode; task->t.flags = TF_BUF_RET | TF_BUF_ESDI; task->t.buf_len = sizeof(struct vbe_mode_ib); task->buf = par->vbe_modes + off; err = uvesafb_exec(task); if (err || (task->t.regs.eax & 0xffff) != 0x004f) { printk(KERN_WARNING "uvesafb: Getting mode info block " "for mode 0x%x failed (eax=0x%x, err=%d)\n", *mode, (u32)task->t.regs.eax, err); mode++; par->vbe_modes_cnt--; continue; } mib = task->buf; mib->mode_id = *mode; /* * We only want modes that are supported with the current * hardware configuration, color, graphics and that have * support for the LFB. */ if ((mib->mode_attr & VBE_MODE_MASK) == VBE_MODE_MASK && mib->bits_per_pixel >= 8) off++; else par->vbe_modes_cnt--; mode++; mib->depth = mib->red_len + mib->green_len + mib->blue_len; /* * Handle 8bpp modes and modes with broken color component * lengths. */ if (mib->depth == 0 || (mib->depth == 24 && mib->bits_per_pixel == 32)) mib->depth = mib->bits_per_pixel; } if (par->vbe_modes_cnt > 0) return 0; else return -EINVAL; } /* * The Protected Mode Interface is 32-bit x86 code, so we only run it on * x86 and not x86_64. */ #ifdef CONFIG_X86_32 static int __devinit uvesafb_vbe_getpmi(struct uvesafb_ktask *task, struct uvesafb_par *par) { int i, err; uvesafb_reset(task); task->t.regs.eax = 0x4f0a; task->t.regs.ebx = 0x0; err = uvesafb_exec(task); if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) { par->pmi_setpal = par->ypan = 0; } else { par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4) + task->t.regs.edi); par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1]; par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2]; printk(KERN_INFO "uvesafb: protected mode interface info at " "%04x:%04x\n", (u16)task->t.regs.es, (u16)task->t.regs.edi); printk(KERN_INFO "uvesafb: pmi: set display start = %p, " "set palette = %p\n", par->pmi_start, par->pmi_pal); if (par->pmi_base[3]) { printk(KERN_INFO "uvesafb: pmi: ports = "); for (i = par->pmi_base[3]/2; par->pmi_base[i] != 0xffff; i++) printk("%x ", par->pmi_base[i]); printk("\n"); if (par->pmi_base[i] != 0xffff) { printk(KERN_INFO "uvesafb: can't handle memory" " requests, pmi disabled\n"); par->ypan = par->pmi_setpal = 0; } } } return 0; } #endif /* CONFIG_X86_32 */ /* * Check whether a video mode is supported by the Video BIOS and is * compatible with the monitor limits. */ static int __devinit uvesafb_is_valid_mode(struct fb_videomode *mode, struct fb_info *info) { if (info->monspecs.gtf) { fb_videomode_to_var(&info->var, mode); if (fb_validate_mode(&info->var, info)) return 0; } if (uvesafb_vbe_find_mode(info->par, mode->xres, mode->yres, 8, UVESAFB_EXACT_RES) == -1) return 0; return 1; } static int __devinit uvesafb_vbe_getedid(struct uvesafb_ktask *task, struct fb_info *info) { struct uvesafb_par *par = info->par; int err = 0; if (noedid || par->vbe_ib.vbe_version < 0x0300) return -EINVAL; task->t.regs.eax = 0x4f15; task->t.regs.ebx = 0; task->t.regs.ecx = 0; task->t.buf_len = 0; task->t.flags = 0; err = uvesafb_exec(task); if ((task->t.regs.eax & 0xffff) != 0x004f || err) return -EINVAL; if ((task->t.regs.ebx & 0x3) == 3) { printk(KERN_INFO "uvesafb: VBIOS/hardware supports both " "DDC1 and DDC2 transfers\n"); } else if ((task->t.regs.ebx & 0x3) == 2) { printk(KERN_INFO "uvesafb: VBIOS/hardware supports DDC2 " "transfers\n"); } else if ((task->t.regs.ebx & 0x3) == 1) { printk(KERN_INFO "uvesafb: VBIOS/hardware supports DDC1 " "transfers\n"); } else { printk(KERN_INFO "uvesafb: VBIOS/hardware doesn't support " "DDC transfers\n"); return -EINVAL; } task->t.regs.eax = 0x4f15; task->t.regs.ebx = 1; task->t.regs.ecx = task->t.regs.edx = 0; task->t.flags = TF_BUF_RET | TF_BUF_ESDI; task->t.buf_len = EDID_LENGTH; task->buf = kzalloc(EDID_LENGTH, GFP_KERNEL); err = uvesafb_exec(task); if ((task->t.regs.eax & 0xffff) == 0x004f && !err) { fb_edid_to_monspecs(task->buf, &info->monspecs); if (info->monspecs.vfmax && info->monspecs.hfmax) { /* * If the maximum pixel clock wasn't specified in * the EDID block, set it to 300 MHz. */ if (info->monspecs.dclkmax == 0) info->monspecs.dclkmax = 300 * 1000000; info->monspecs.gtf = 1; } } else { err = -EINVAL; } kfree(task->buf); return err; } static void __devinit uvesafb_vbe_getmonspecs(struct uvesafb_ktask *task, struct fb_info *info) { struct uvesafb_par *par = info->par; int i; memset(&info->monspecs, 0, sizeof(info->monspecs)); /* * If we don't get all necessary data from the EDID block, * mark it as incompatible with the GTF and set nocrtc so * that we always use the default BIOS refresh rate. */ if (uvesafb_vbe_getedid(task, info)) { info->monspecs.gtf = 0; par->nocrtc = 1; } /* Kernel command line overrides. */ if (maxclk) info->monspecs.dclkmax = maxclk * 1000000; if (maxvf) info->monspecs.vfmax = maxvf; if (maxhf) info->monspecs.hfmax = maxhf * 1000; /* * In case DDC transfers are not supported, the user can provide * monitor limits manually. Lower limits are set to "safe" values. */ if (info->monspecs.gtf == 0 && maxclk && maxvf && maxhf) { info->monspecs.dclkmin = 0; info->monspecs.vfmin = 60; info->monspecs.hfmin = 29000; info->monspecs.gtf = 1; par->nocrtc = 0; } if (info->monspecs.gtf) printk(KERN_INFO "uvesafb: monitor limits: vf = %d Hz, hf = %d kHz, " "clk = %d MHz\n", info->monspecs.vfmax, (int)(info->monspecs.hfmax / 1000), (int)(info->monspecs.dclkmax / 1000000)); else printk(KERN_INFO "uvesafb: no monitor limits have been set, " "default refresh rate will be used\n"); /* Add VBE modes to the modelist. */ for (i = 0; i < par->vbe_modes_cnt; i++) { struct fb_var_screeninfo var; struct vbe_mode_ib *mode; struct fb_videomode vmode; mode = &par->vbe_modes[i]; memset(&var, 0, sizeof(var)); var.xres = mode->x_res; var.yres = mode->y_res; fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, &var, info); fb_var_to_videomode(&vmode, &var); fb_add_videomode(&vmode, &info->modelist); } /* Add valid VESA modes to our modelist. */ for (i = 0; i < VESA_MODEDB_SIZE; i++) { if (uvesafb_is_valid_mode((struct fb_videomode *) &vesa_modes[i], info)) fb_add_videomode(&vesa_modes[i], &info->modelist); } for (i = 0; i < info->monspecs.modedb_len; i++) { if (uvesafb_is_valid_mode(&info->monspecs.modedb[i], info)) fb_add_videomode(&info->monspecs.modedb[i], &info->modelist); } return; } static void __devinit uvesafb_vbe_getstatesize(struct uvesafb_ktask *task, struct uvesafb_par *par) { int err; uvesafb_reset(task); /* * Get the VBE state buffer size. We want all available * hardware state data (CL = 0x0f). */ task->t.regs.eax = 0x4f04; task->t.regs.ecx = 0x000f; task->t.regs.edx = 0x0000; task->t.flags = 0; err = uvesafb_exec(task); if (err || (task->t.regs.eax & 0xffff) != 0x004f) { printk(KERN_WARNING "uvesafb: VBE state buffer size " "cannot be determined (eax=0x%x, err=%d)\n", task->t.regs.eax, err); par->vbe_state_size = 0; return; } par->vbe_state_size = 64 * (task->t.regs.ebx & 0xffff); } static int __devinit uvesafb_vbe_init(struct fb_info *info) { struct uvesafb_ktask *task = NULL; struct uvesafb_par *par = info->par; int err; task = uvesafb_prep(); if (!task) return -ENOMEM; err = uvesafb_vbe_getinfo(task, par); if (err) goto out; err = uvesafb_vbe_getmodes(task, par); if (err) goto out; par->nocrtc = nocrtc; #ifdef CONFIG_X86_32 par->pmi_setpal = pmi_setpal; par->ypan = ypan; if (par->pmi_setpal || par->ypan) uvesafb_vbe_getpmi(task, par); #else /* The protected mode interface is not available on non-x86. */ par->pmi_setpal = par->ypan = 0; #endif INIT_LIST_HEAD(&info->modelist); uvesafb_vbe_getmonspecs(task, info); uvesafb_vbe_getstatesize(task, par); out: uvesafb_free(task); return err; } static int __devinit uvesafb_vbe_init_mode(struct fb_info *info) { struct list_head *pos; struct fb_modelist *modelist; struct fb_videomode *mode; struct uvesafb_par *par = info->par; int i, modeid; /* Has the user requested a specific VESA mode? */ if (vbemode) { for (i = 0; i < par->vbe_modes_cnt; i++) { if (par->vbe_modes[i].mode_id == vbemode) { modeid = i; uvesafb_setup_var(&info->var, info, &par->vbe_modes[modeid]); fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, &info->var, info); /* * With pixclock set to 0, the default BIOS * timings will be used in set_par(). */ info->var.pixclock = 0; goto gotmode; } } printk(KERN_INFO "uvesafb: requested VBE mode 0x%x is " "unavailable\n", vbemode); vbemode = 0; } /* Count the modes in the modelist */ i = 0; list_for_each(pos, &info->modelist) i++; /* * Convert the modelist into a modedb so that we can use it with * fb_find_mode(). */ mode = kzalloc(i * sizeof(*mode), GFP_KERNEL); if (mode) { i = 0; list_for_each(pos, &info->modelist) { modelist = list_entry(pos, struct fb_modelist, list); mode[i] = modelist->mode; i++; } if (!mode_option) mode_option = UVESAFB_DEFAULT_MODE; i = fb_find_mode(&info->var, info, mode_option, mode, i, NULL, 8); kfree(mode); } /* fb_find_mode() failed */ if (i == 0) { info->var.xres = 640; info->var.yres = 480; mode = (struct fb_videomode *) fb_find_best_mode(&info->var, &info->modelist); if (mode) { fb_videomode_to_var(&info->var, mode); } else { modeid = par->vbe_modes[0].mode_id; uvesafb_setup_var(&info->var, info, &par->vbe_modes[modeid]); fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, &info->var, info); goto gotmode; } } /* Look for a matching VBE mode. */ modeid = uvesafb_vbe_find_mode(par, info->var.xres, info->var.yres, info->var.bits_per_pixel, UVESAFB_EXACT_RES); if (modeid == -1) return -EINVAL; uvesafb_setup_var(&info->var, info, &par->vbe_modes[modeid]); gotmode: /* * If we are not VBE3.0+ compliant, we're done -- the BIOS will * ignore our timings anyway. */ if (par->vbe_ib.vbe_version < 0x0300 || par->nocrtc) fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, &info->var, info); return modeid; } static int uvesafb_setpalette(struct uvesafb_pal_entry *entries, int count, int start, struct fb_info *info) { struct uvesafb_ktask *task; #ifdef CONFIG_X86 struct uvesafb_par *par = info->par; int i = par->mode_idx; #endif int err = 0; /* * We support palette modifications for 8 bpp modes only, so * there can never be more than 256 entries. */ if (start + count > 256) return -EINVAL; #ifdef CONFIG_X86 /* Use VGA registers if mode is VGA-compatible. */ if (i >= 0 && i < par->vbe_modes_cnt && par->vbe_modes[i].mode_attr & VBE_MODE_VGACOMPAT) { for (i = 0; i < count; i++) { outb_p(start + i, dac_reg); outb_p(entries[i].red, dac_val); outb_p(entries[i].green, dac_val); outb_p(entries[i].blue, dac_val); } } #ifdef CONFIG_X86_32 else if (par->pmi_setpal) { __asm__ __volatile__( "call *(%%esi)" : /* no return value */ : "a" (0x4f09), /* EAX */ "b" (0), /* EBX */ "c" (count), /* ECX */ "d" (start), /* EDX */ "D" (entries), /* EDI */ "S" (&par->pmi_pal)); /* ESI */ } #endif /* CONFIG_X86_32 */ else #endif /* CONFIG_X86 */ { task = uvesafb_prep(); if (!task) return -ENOMEM; task->t.regs.eax = 0x4f09; task->t.regs.ebx = 0x0; task->t.regs.ecx = count; task->t.regs.edx = start; task->t.flags = TF_BUF_ESDI; task->t.buf_len = sizeof(struct uvesafb_pal_entry) * count; task->buf = entries; err = uvesafb_exec(task); if ((task->t.regs.eax & 0xffff) != 0x004f) err = 1; uvesafb_free(task); } return err; } static int uvesafb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *info) { struct uvesafb_pal_entry entry; int shift = 16 - dac_width; int err = 0; if (regno >= info->cmap.len) return -EINVAL; if (info->var.bits_per_pixel == 8) { entry.red = red >> shift; entry.green = green >> shift; entry.blue = blue >> shift; entry.pad = 0; err = uvesafb_setpalette(&entry, 1, regno, info); } else if (regno < 16) { switch (info->var.bits_per_pixel) { case 16: if (info->var.red.offset == 10) { /* 1:5:5:5 */ ((u32 *) (info->pseudo_palette))[regno] = ((red & 0xf800) >> 1) | ((green & 0xf800) >> 6) | ((blue & 0xf800) >> 11); } else { /* 0:5:6:5 */ ((u32 *) (info->pseudo_palette))[regno] = ((red & 0xf800) ) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11); } break; case 24: case 32: red >>= 8; green >>= 8; blue >>= 8; ((u32 *)(info->pseudo_palette))[regno] = (red << info->var.red.offset) | (green << info->var.green.offset) | (blue << info->var.blue.offset); break; } } return err; } static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info) { struct uvesafb_pal_entry *entries; int shift = 16 - dac_width; int i, err = 0; if (info->var.bits_per_pixel == 8) { if (cmap->start + cmap->len > info->cmap.start + info->cmap.len || cmap->start < info->cmap.start) return -EINVAL; entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL); if (!entries) return -ENOMEM; for (i = 0; i < cmap->len; i++) { entries[i].red = cmap->red[i] >> shift; entries[i].green = cmap->green[i] >> shift; entries[i].blue = cmap->blue[i] >> shift; entries[i].pad = 0; } err = uvesafb_setpalette(entries, cmap->len, cmap->start, info); kfree(entries); } else { /* * For modes with bpp > 8, we only set the pseudo palette in * the fb_info struct. We rely on uvesafb_setcolreg to do all * sanity checking. */ for (i = 0; i < cmap->len; i++) { err |= uvesafb_setcolreg(cmap->start + i, cmap->red[i], cmap->green[i], cmap->blue[i], 0, info); } } return err; } static int uvesafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { #ifdef CONFIG_X86_32 int offset; struct uvesafb_par *par = info->par; offset = (var->yoffset * info->fix.line_length + var->xoffset) / 4; /* * It turns out it's not the best idea to do panning via vm86, * so we only allow it if we have a PMI. */ if (par->pmi_start) { __asm__ __volatile__( "call *(%%edi)" : /* no return value */ : "a" (0x4f07), /* EAX */ "b" (0), /* EBX */ "c" (offset), /* ECX */ "d" (offset >> 16), /* EDX */ "D" (&par->pmi_start)); /* EDI */ } #endif return 0; } static int uvesafb_blank(int blank, struct fb_info *info) { struct uvesafb_ktask *task; int err = 1; #ifdef CONFIG_X86 struct uvesafb_par *par = info->par; if (par->vbe_ib.capabilities & VBE_CAP_VGACOMPAT) { int loop = 10000; u8 seq = 0, crtc17 = 0; if (blank == FB_BLANK_POWERDOWN) { seq = 0x20; crtc17 = 0x00; err = 0; } else { seq = 0x00; crtc17 = 0x80; err = (blank == FB_BLANK_UNBLANK) ? 0 : -EINVAL; } vga_wseq(NULL, 0x00, 0x01); seq |= vga_rseq(NULL, 0x01) & ~0x20; vga_wseq(NULL, 0x00, seq); crtc17 |= vga_rcrt(NULL, 0x17) & ~0x80; while (loop--); vga_wcrt(NULL, 0x17, crtc17); vga_wseq(NULL, 0x00, 0x03); } else #endif /* CONFIG_X86 */ { task = uvesafb_prep(); if (!task) return -ENOMEM; task->t.regs.eax = 0x4f10; switch (blank) { case FB_BLANK_UNBLANK: task->t.regs.ebx = 0x0001; break; case FB_BLANK_NORMAL: task->t.regs.ebx = 0x0101; /* standby */ break; case FB_BLANK_POWERDOWN: task->t.regs.ebx = 0x0401; /* powerdown */ break; default: goto out; } err = uvesafb_exec(task); if (err || (task->t.regs.eax & 0xffff) != 0x004f) err = 1; out: uvesafb_free(task); } return err; } static int uvesafb_open(struct fb_info *info, int user) { struct uvesafb_par *par = info->par; int cnt = atomic_read(&par->ref_count); if (!cnt && par->vbe_state_size) par->vbe_state_orig = uvesafb_vbe_state_save(par); atomic_inc(&par->ref_count); return 0; } static int uvesafb_release(struct fb_info *info, int user) { struct uvesafb_ktask *task = NULL; struct uvesafb_par *par = info->par; int cnt = atomic_read(&par->ref_count); if (!cnt) return -EINVAL; if (cnt != 1) goto out; task = uvesafb_prep(); if (!task) goto out; /* First, try to set the standard 80x25 text mode. */ task->t.regs.eax = 0x0003; uvesafb_exec(task); /* * Now try to restore whatever hardware state we might have * saved when the fb device was first opened. */ uvesafb_vbe_state_restore(par, par->vbe_state_orig); out: atomic_dec(&par->ref_count); if (task) uvesafb_free(task); return 0; } static int uvesafb_set_par(struct fb_info *info) { struct uvesafb_par *par = info->par; struct uvesafb_ktask *task = NULL; struct vbe_crtc_ib *crtc = NULL; struct vbe_mode_ib *mode = NULL; int i, err = 0, depth = info->var.bits_per_pixel; if (depth > 8 && depth != 32) depth = info->var.red.length + info->var.green.length + info->var.blue.length; i = uvesafb_vbe_find_mode(par, info->var.xres, info->var.yres, depth, UVESAFB_EXACT_RES | UVESAFB_EXACT_DEPTH); if (i >= 0) mode = &par->vbe_modes[i]; else return -EINVAL; task = uvesafb_prep(); if (!task) return -ENOMEM; setmode: task->t.regs.eax = 0x4f02; task->t.regs.ebx = mode->mode_id | 0x4000; /* use LFB */ if (par->vbe_ib.vbe_version >= 0x0300 && !par->nocrtc && info->var.pixclock != 0) { task->t.regs.ebx |= 0x0800; /* use CRTC data */ task->t.flags = TF_BUF_ESDI; crtc = kzalloc(sizeof(struct vbe_crtc_ib), GFP_KERNEL); if (!crtc) { err = -ENOMEM; goto out; } crtc->horiz_start = info->var.xres + info->var.right_margin; crtc->horiz_end = crtc->horiz_start + info->var.hsync_len; crtc->horiz_total = crtc->horiz_end + info->var.left_margin; crtc->vert_start = info->var.yres + info->var.lower_margin; crtc->vert_end = crtc->vert_start + info->var.vsync_len; crtc->vert_total = crtc->vert_end + info->var.upper_margin; crtc->pixel_clock = PICOS2KHZ(info->var.pixclock) * 1000; crtc->refresh_rate = (u16)(100 * (crtc->pixel_clock / (crtc->vert_total * crtc->horiz_total))); if (info->var.vmode & FB_VMODE_DOUBLE) crtc->flags |= 0x1; if (info->var.vmode & FB_VMODE_INTERLACED) crtc->flags |= 0x2; if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT)) crtc->flags |= 0x4; if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT)) crtc->flags |= 0x8; memcpy(&par->crtc, crtc, sizeof(*crtc)); } else { memset(&par->crtc, 0, sizeof(*crtc)); } task->t.buf_len = sizeof(struct vbe_crtc_ib); task->buf = &par->crtc; err = uvesafb_exec(task); if (err || (task->t.regs.eax & 0xffff) != 0x004f) { /* * The mode switch might have failed because we tried to * use our own timings. Try again with the default timings. */ if (crtc != NULL) { printk(KERN_WARNING "uvesafb: mode switch failed " "(eax=0x%x, err=%d). Trying again with " "default timings.\n", task->t.regs.eax, err); uvesafb_reset(task); kfree(crtc); crtc = NULL; info->var.pixclock = 0; goto setmode; } else { printk(KERN_ERR "uvesafb: mode switch failed (eax=" "0x%x, err=%d)\n", task->t.regs.eax, err); err = -EINVAL; goto out; } } par->mode_idx = i; /* For 8bpp modes, always try to set the DAC to 8 bits. */ if (par->vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC && mode->bits_per_pixel <= 8) { uvesafb_reset(task); task->t.regs.eax = 0x4f08; task->t.regs.ebx = 0x0800; err = uvesafb_exec(task); if (err || (task->t.regs.eax & 0xffff) != 0x004f || ((task->t.regs.ebx & 0xff00) >> 8) != 8) { dac_width = 6; } else { dac_width = 8; } } info->fix.visual = (info->var.bits_per_pixel == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; info->fix.line_length = mode->bytes_per_scan_line; out: if (crtc != NULL) kfree(crtc); uvesafb_free(task); return err; } static void uvesafb_check_limits(struct fb_var_screeninfo *var, struct fb_info *info) { const struct fb_videomode *mode; struct uvesafb_par *par = info->par; /* * If pixclock is set to 0, then we're using default BIOS timings * and thus don't have to perform any checks here. */ if (!var->pixclock) return; if (par->vbe_ib.vbe_version < 0x0300) { fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, var, info); return; } if (!fb_validate_mode(var, info)) return; mode = fb_find_best_mode(var, &info->modelist); if (mode) { if (mode->xres == var->xres && mode->yres == var->yres && !(mode->vmode & (FB_VMODE_INTERLACED | FB_VMODE_DOUBLE))) { fb_videomode_to_var(var, mode); return; } } if (info->monspecs.gtf && !fb_get_mode(FB_MAXTIMINGS, 0, var, info)) return; /* Use default refresh rate */ var->pixclock = 0; } static int uvesafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { struct uvesafb_par *par = info->par; struct vbe_mode_ib *mode = NULL; int match = -1; int depth = var->red.length + var->green.length + var->blue.length; /* * Various apps will use bits_per_pixel to set the color depth, * which is theoretically incorrect, but which we'll try to handle * here. */ if (depth == 0 || abs(depth - var->bits_per_pixel) >= 8) depth = var->bits_per_pixel; match = uvesafb_vbe_find_mode(par, var->xres, var->yres, depth, UVESAFB_EXACT_RES); if (match == -1) return -EINVAL; mode = &par->vbe_modes[match]; uvesafb_setup_var(var, info, mode); /* * Check whether we have remapped enough memory for this mode. * We might be called at an early stage, when we haven't remapped * any memory yet, in which case we simply skip the check. */ if (var->yres * mode->bytes_per_scan_line > info->fix.smem_len && info->fix.smem_len) return -EINVAL; if ((var->vmode & FB_VMODE_DOUBLE) && !(par->vbe_modes[match].mode_attr & 0x100)) var->vmode &= ~FB_VMODE_DOUBLE; if ((var->vmode & FB_VMODE_INTERLACED) && !(par->vbe_modes[match].mode_attr & 0x200)) var->vmode &= ~FB_VMODE_INTERLACED; uvesafb_check_limits(var, info); var->xres_virtual = var->xres; var->yres_virtual = (par->ypan) ? info->fix.smem_len / mode->bytes_per_scan_line : var->yres; return 0; } static struct fb_ops uvesafb_ops = { .owner = THIS_MODULE, .fb_open = uvesafb_open, .fb_release = uvesafb_release, .fb_setcolreg = uvesafb_setcolreg, .fb_setcmap = uvesafb_setcmap, .fb_pan_display = uvesafb_pan_display, .fb_blank = uvesafb_blank, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, .fb_check_var = uvesafb_check_var, .fb_set_par = uvesafb_set_par, }; static void __devinit uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode) { unsigned int size_vmode; unsigned int size_remap; unsigned int size_total; struct uvesafb_par *par = info->par; int i, h; info->pseudo_palette = ((u8 *)info->par + sizeof(struct uvesafb_par)); info->fix = uvesafb_fix; info->fix.ypanstep = par->ypan ? 1 : 0; info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0; /* Disable blanking if the user requested so. */ if (!blank) info->fbops->fb_blank = NULL; /* * Find out how much IO memory is required for the mode with * the highest resolution. */ size_remap = 0; for (i = 0; i < par->vbe_modes_cnt; i++) { h = par->vbe_modes[i].bytes_per_scan_line * par->vbe_modes[i].y_res; if (h > size_remap) size_remap = h; } size_remap *= 2; /* * size_vmode -- that is the amount of memory needed for the * used video mode, i.e. the minimum amount of * memory we need. */ if (mode != NULL) { size_vmode = info->var.yres * mode->bytes_per_scan_line; } else { size_vmode = info->var.yres * info->var.xres * ((info->var.bits_per_pixel + 7) >> 3); } /* * size_total -- all video memory we have. Used for mtrr * entries, resource allocation and bounds * checking. */ size_total = par->vbe_ib.total_memory * 65536; if (vram_total) size_total = vram_total * 1024 * 1024; if (size_total < size_vmode) size_total = size_vmode; /* * size_remap -- the amount of video memory we are going to * use for vesafb. With modern cards it is no * option to simply use size_total as th * wastes plenty of kernel address space. */ if (vram_remap) size_remap = vram_remap * 1024 * 1024; if (size_remap < size_vmode) size_remap = size_vmode; if (size_remap > size_total) size_remap = size_total; info->fix.smem_len = size_remap; info->fix.smem_start = mode->phys_base_ptr; /* * We have to set yres_virtual here because when setup_var() was * called, smem_len wasn't defined yet. */ info->var.yres_virtual = info->fix.smem_len / mode->bytes_per_scan_line; if (par->ypan && info->var.yres_virtual > info->var.yres) { printk(KERN_INFO "uvesafb: scrolling: %s " "using protected mode interface, " "yres_virtual=%d\n", (par->ypan > 1) ? "ywrap" : "ypan", info->var.yres_virtual); } else { printk(KERN_INFO "uvesafb: scrolling: redraw\n"); info->var.yres_virtual = info->var.yres; par->ypan = 0; } info->flags = FBINFO_FLAG_DEFAULT | (par->ypan ? FBINFO_HWACCEL_YPAN : 0); if (!par->ypan) info->fbops->fb_pan_display = NULL; } static void __devinit uvesafb_init_mtrr(struct fb_info *info) { #ifdef CONFIG_MTRR if (mtrr && !(info->fix.smem_start & (PAGE_SIZE - 1))) { int temp_size = info->fix.smem_len; unsigned int type = 0; switch (mtrr) { case 1: type = MTRR_TYPE_UNCACHABLE; break; case 2: type = MTRR_TYPE_WRBACK; break; case 3: type = MTRR_TYPE_WRCOMB; break; case 4: type = MTRR_TYPE_WRTHROUGH; break; default: type = 0; break; } if (type) { int rc; /* Find the largest power-of-two */ temp_size = roundup_pow_of_two(temp_size); /* Try and find a power of two to add */ do { rc = mtrr_add(info->fix.smem_start, temp_size, type, 1); temp_size >>= 1; } while (temp_size >= PAGE_SIZE && rc == -EINVAL); } } #endif /* CONFIG_MTRR */ } static void __devinit uvesafb_ioremap(struct fb_info *info) { #ifdef CONFIG_X86 switch (mtrr) { case 1: /* uncachable */ info->screen_base = ioremap_nocache(info->fix.smem_start, info->fix.smem_len); break; case 2: /* write-back */ info->screen_base = ioremap_cache(info->fix.smem_start, info->fix.smem_len); break; case 3: /* write-combining */ info->screen_base = ioremap_wc(info->fix.smem_start, info->fix.smem_len); break; case 4: /* write-through */ default: info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); break; } #else info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); #endif /* CONFIG_X86 */ } static ssize_t uvesafb_show_vbe_ver(struct device *dev, struct device_attribute *attr, char *buf) { struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); struct uvesafb_par *par = info->par; return snprintf(buf, PAGE_SIZE, "%.4x\n", par->vbe_ib.vbe_version); } static DEVICE_ATTR(vbe_version, S_IRUGO, uvesafb_show_vbe_ver, NULL); static ssize_t uvesafb_show_vbe_modes(struct device *dev, struct device_attribute *attr, char *buf) { struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); struct uvesafb_par *par = info->par; int ret = 0, i; for (i = 0; i < par->vbe_modes_cnt && ret < PAGE_SIZE; i++) { ret += snprintf(buf + ret, PAGE_SIZE - ret, "%dx%d-%d, 0x%.4x\n", par->vbe_modes[i].x_res, par->vbe_modes[i].y_res, par->vbe_modes[i].depth, par->vbe_modes[i].mode_id); } return ret; } static DEVICE_ATTR(vbe_modes, S_IRUGO, uvesafb_show_vbe_modes, NULL); static ssize_t uvesafb_show_vendor(struct device *dev, struct device_attribute *attr, char *buf) { struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); struct uvesafb_par *par = info->par; if (par->vbe_ib.oem_vendor_name_ptr) return snprintf(buf, PAGE_SIZE, "%s\n", (char *) (&par->vbe_ib) + par->vbe_ib.oem_vendor_name_ptr); else return 0; } static DEVICE_ATTR(oem_vendor, S_IRUGO, uvesafb_show_vendor, NULL); static ssize_t uvesafb_show_product_name(struct device *dev, struct device_attribute *attr, char *buf) { struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); struct uvesafb_par *par = info->par; if (par->vbe_ib.oem_product_name_ptr) return snprintf(buf, PAGE_SIZE, "%s\n", (char *) (&par->vbe_ib) + par->vbe_ib.oem_product_name_ptr); else return 0; } static DEVICE_ATTR(oem_product_name, S_IRUGO, uvesafb_show_product_name, NULL); static ssize_t uvesafb_show_product_rev(struct device *dev, struct device_attribute *attr, char *buf) { struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); struct uvesafb_par *par = info->par; if (par->vbe_ib.oem_product_rev_ptr) return snprintf(buf, PAGE_SIZE, "%s\n", (char *) (&par->vbe_ib) + par->vbe_ib.oem_product_rev_ptr); else return 0; } static DEVICE_ATTR(oem_product_rev, S_IRUGO, uvesafb_show_product_rev, NULL); static ssize_t uvesafb_show_oem_string(struct device *dev, struct device_attribute *attr, char *buf) { struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); struct uvesafb_par *par = info->par; if (par->vbe_ib.oem_string_ptr) return snprintf(buf, PAGE_SIZE, "%s\n", (char *)(&par->vbe_ib) + par->vbe_ib.oem_string_ptr); else return 0; } static DEVICE_ATTR(oem_string, S_IRUGO, uvesafb_show_oem_string, NULL); static ssize_t uvesafb_show_nocrtc(struct device *dev, struct device_attribute *attr, char *buf) { struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); struct uvesafb_par *par = info->par; return snprintf(buf, PAGE_SIZE, "%d\n", par->nocrtc); } static ssize_t uvesafb_store_nocrtc(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); struct uvesafb_par *par = info->par; if (count > 0) { if (buf[0] == '0') par->nocrtc = 0; else par->nocrtc = 1; } return count; } static DEVICE_ATTR(nocrtc, S_IRUGO | S_IWUSR, uvesafb_show_nocrtc, uvesafb_store_nocrtc); static struct attribute *uvesafb_dev_attrs[] = { &dev_attr_vbe_version.attr, &dev_attr_vbe_modes.attr, &dev_attr_oem_vendor.attr, &dev_attr_oem_product_name.attr, &dev_attr_oem_product_rev.attr, &dev_attr_oem_string.attr, &dev_attr_nocrtc.attr, NULL, }; static struct attribute_group uvesafb_dev_attgrp = { .name = NULL, .attrs = uvesafb_dev_attrs, }; static int __devinit uvesafb_probe(struct platform_device *dev) { struct fb_info *info; struct vbe_mode_ib *mode = NULL; struct uvesafb_par *par; int err = 0, i; info = framebuffer_alloc(sizeof(*par) + sizeof(u32) * 256, &dev->dev); if (!info) return -ENOMEM; par = info->par; err = uvesafb_vbe_init(info); if (err) { printk(KERN_ERR "uvesafb: vbe_init() failed with %d\n", err); goto out; } info->fbops = &uvesafb_ops; i = uvesafb_vbe_init_mode(info); if (i < 0) { err = -EINVAL; goto out; } else { mode = &par->vbe_modes[i]; } if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { err = -ENXIO; goto out; } uvesafb_init_info(info, mode); if (!request_region(0x3c0, 32, "uvesafb")) { printk(KERN_ERR "uvesafb: request region 0x3c0-0x3e0 failed\n"); err = -EIO; goto out_mode; } if (!request_mem_region(info->fix.smem_start, info->fix.smem_len, "uvesafb")) { printk(KERN_ERR "uvesafb: cannot reserve video memory at " "0x%lx\n", info->fix.smem_start); err = -EIO; goto out_reg; } uvesafb_init_mtrr(info); uvesafb_ioremap(info); if (!info->screen_base) { printk(KERN_ERR "uvesafb: abort, cannot ioremap 0x%x bytes of video " "memory at 0x%lx\n", info->fix.smem_len, info->fix.smem_start); err = -EIO; goto out_mem; } platform_set_drvdata(dev, info); if (register_framebuffer(info) < 0) { printk(KERN_ERR "uvesafb: failed to register framebuffer device\n"); err = -EINVAL; goto out_unmap; } printk(KERN_INFO "uvesafb: framebuffer at 0x%lx, mapped to 0x%p, " "using %dk, total %dk\n", info->fix.smem_start, info->screen_base, info->fix.smem_len/1024, par->vbe_ib.total_memory * 64); printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id); err = sysfs_create_group(&dev->dev.kobj, &uvesafb_dev_attgrp); if (err != 0) printk(KERN_WARNING "fb%d: failed to register attributes\n", info->node); return 0; out_unmap: iounmap(info->screen_base); out_mem: release_mem_region(info->fix.smem_start, info->fix.smem_len); out_reg: release_region(0x3c0, 32); out_mode: if (!list_empty(&info->modelist)) fb_destroy_modelist(&info->modelist); fb_destroy_modedb(info->monspecs.modedb); fb_dealloc_cmap(&info->cmap); out: if (par->vbe_modes) kfree(par->vbe_modes); framebuffer_release(info); return err; } static int uvesafb_remove(struct platform_device *dev) { struct fb_info *info = platform_get_drvdata(dev); if (info) { struct uvesafb_par *par = info->par; sysfs_remove_group(&dev->dev.kobj, &uvesafb_dev_attgrp); unregister_framebuffer(info); release_region(0x3c0, 32); iounmap(info->screen_base); release_mem_region(info->fix.smem_start, info->fix.smem_len); fb_destroy_modedb(info->monspecs.modedb); fb_dealloc_cmap(&info->cmap); if (par) { if (par->vbe_modes) kfree(par->vbe_modes); if (par->vbe_state_orig) kfree(par->vbe_state_orig); if (par->vbe_state_saved) kfree(par->vbe_state_saved); } framebuffer_release(info); } return 0; } static struct platform_driver uvesafb_driver = { .probe = uvesafb_probe, .remove = uvesafb_remove, .driver = { .name = "uvesafb", }, }; static struct platform_device *uvesafb_device; #ifndef MODULE static int __devinit uvesafb_setup(char *options) { char *this_opt; if (!options || !*options) return 0; while ((this_opt = strsep(&options, ",")) != NULL) { if (!*this_opt) continue; if (!strcmp(this_opt, "redraw")) ypan = 0; else if (!strcmp(this_opt, "ypan")) ypan = 1; else if (!strcmp(this_opt, "ywrap")) ypan = 2; else if (!strcmp(this_opt, "vgapal")) pmi_setpal = 0; else if (!strcmp(this_opt, "pmipal")) pmi_setpal = 1; else if (!strncmp(this_opt, "mtrr:", 5)) mtrr = simple_strtoul(this_opt+5, NULL, 0); else if (!strcmp(this_opt, "nomtrr")) mtrr = 0; else if (!strcmp(this_opt, "nocrtc")) nocrtc = 1; else if (!strcmp(this_opt, "noedid")) noedid = 1; else if (!strcmp(this_opt, "noblank")) blank = 0; else if (!strncmp(this_opt, "vtotal:", 7)) vram_total = simple_strtoul(this_opt + 7, NULL, 0); else if (!strncmp(this_opt, "vremap:", 7)) vram_remap = simple_strtoul(this_opt + 7, NULL, 0); else if (!strncmp(this_opt, "maxhf:", 6)) maxhf = simple_strtoul(this_opt + 6, NULL, 0); else if (!strncmp(this_opt, "maxvf:", 6)) maxvf = simple_strtoul(this_opt + 6, NULL, 0); else if (!strncmp(this_opt, "maxclk:", 7)) maxclk = simple_strtoul(this_opt + 7, NULL, 0); else if (!strncmp(this_opt, "vbemode:", 8)) vbemode = simple_strtoul(this_opt + 8, NULL, 0); else if (this_opt[0] >= '0' && this_opt[0] <= '9') { mode_option = this_opt; } else { printk(KERN_WARNING "uvesafb: unrecognized option %s\n", this_opt); } } return 0; } #endif /* !MODULE */ static ssize_t show_v86d(struct device_driver *dev, char *buf) { return snprintf(buf, PAGE_SIZE, "%s\n", v86d_path); } static ssize_t store_v86d(struct device_driver *dev, const char *buf, size_t count) { strncpy(v86d_path, buf, PATH_MAX); return count; } static DRIVER_ATTR(v86d, S_IRUGO | S_IWUSR, show_v86d, store_v86d); static int __devinit uvesafb_init(void) { int err; #ifndef MODULE char *option = NULL; if (fb_get_options("uvesafb", &option)) return -ENODEV; uvesafb_setup(option); #endif err = cn_add_callback(&uvesafb_cn_id, "uvesafb", uvesafb_cn_callback); if (err) return err; err = platform_driver_register(&uvesafb_driver); if (!err) { uvesafb_device = platform_device_alloc("uvesafb", 0); if (uvesafb_device) err = platform_device_add(uvesafb_device); else err = -ENOMEM; if (err) { platform_device_put(uvesafb_device); platform_driver_unregister(&uvesafb_driver); cn_del_callback(&uvesafb_cn_id); return err; } err = driver_create_file(&uvesafb_driver.driver, &driver_attr_v86d); if (err) { printk(KERN_WARNING "uvesafb: failed to register " "attributes\n"); err = 0; } } return err; } module_init(uvesafb_init); static void __devexit uvesafb_exit(void) { struct uvesafb_ktask *task; if (v86d_started) { task = uvesafb_prep(); if (task) { task->t.flags = TF_EXIT; uvesafb_exec(task); uvesafb_free(task); } } cn_del_callback(&uvesafb_cn_id); driver_remove_file(&uvesafb_driver.driver, &driver_attr_v86d); platform_device_unregister(uvesafb_device); platform_driver_unregister(&uvesafb_driver); } module_exit(uvesafb_exit); static int param_set_scroll(const char *val, const struct kernel_param *kp) { ypan = 0; if (!strcmp(val, "redraw")) ypan = 0; else if (!strcmp(val, "ypan")) ypan = 1; else if (!strcmp(val, "ywrap")) ypan = 2; else return -EINVAL; return 0; } static struct kernel_param_ops param_ops_scroll = { .set = param_set_scroll, }; #define param_check_scroll(name, p) __param_check(name, p, void) module_param_named(scroll, ypan, scroll, 0); MODULE_PARM_DESC(scroll, "Scrolling mode, set to 'redraw', 'ypan', or 'ywrap'"); module_param_named(vgapal, pmi_setpal, invbool, 0); MODULE_PARM_DESC(vgapal, "Set palette using VGA registers"); module_param_named(pmipal, pmi_setpal, bool, 0); MODULE_PARM_DESC(pmipal, "Set palette using PMI calls"); module_param(mtrr, uint, 0); MODULE_PARM_DESC(mtrr, "Memory Type Range Registers setting. Use 0 to disable."); module_param(blank, bool, 0); MODULE_PARM_DESC(blank, "Enable hardware blanking"); module_param(nocrtc, bool, 0); MODULE_PARM_DESC(nocrtc, "Ignore CRTC timings when setting modes"); module_param(noedid, bool, 0); MODULE_PARM_DESC(noedid, "Ignore EDID-provided monitor limits when setting modes"); module_param(vram_remap, uint, 0); MODULE_PARM_DESC(vram_remap, "Set amount of video memory to be used [MiB]"); module_param(vram_total, uint, 0); MODULE_PARM_DESC(vram_total, "Set total amount of video memoery [MiB]"); module_param(maxclk, ushort, 0); MODULE_PARM_DESC(maxclk, "Maximum pixelclock [MHz], overrides EDID data"); module_param(maxhf, ushort, 0); MODULE_PARM_DESC(maxhf, "Maximum horizontal frequency [kHz], overrides EDID data"); module_param(maxvf, ushort, 0); MODULE_PARM_DESC(maxvf, "Maximum vertical frequency [Hz], overrides EDID data"); module_param(mode_option, charp, 0); MODULE_PARM_DESC(mode_option, "Specify initial video mode as \"<xres>x<yres>[-<bpp>][@<refresh>]\""); module_param(vbemode, ushort, 0); MODULE_PARM_DESC(vbemode, "VBE mode number to set, overrides the 'mode' option"); module_param_string(v86d, v86d_path, PATH_MAX, 0660); MODULE_PARM_DESC(v86d, "Path to the v86d userspace helper."); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Michal Januszewski <spock@gentoo.org>"); MODULE_DESCRIPTION("Framebuffer driver for VBE2.0+ compliant graphics boards");
gpl-2.0
allwinner-zh/linux-3.4-sunxi
net/ipv6/netfilter/nf_conntrack_reasm.c
1467
16211
/* * IPv6 fragment reassembly for connection tracking * * Copyright (C)2004 USAGI/WIDE Project * * Author: * Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> * * Based on: net/ipv6/reassembly.c * * 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) "IPv6-nf: " fmt #include <linux/errno.h> #include <linux/types.h> #include <linux/string.h> #include <linux/socket.h> #include <linux/sockios.h> #include <linux/jiffies.h> #include <linux/net.h> #include <linux/list.h> #include <linux/netdevice.h> #include <linux/in6.h> #include <linux/ipv6.h> #include <linux/icmpv6.h> #include <linux/random.h> #include <linux/slab.h> #include <net/sock.h> #include <net/snmp.h> #include <net/inet_frag.h> #include <net/ipv6.h> #include <net/protocol.h> #include <net/transp_v6.h> #include <net/rawv6.h> #include <net/ndisc.h> #include <net/addrconf.h> #include <net/netfilter/ipv6/nf_conntrack_ipv6.h> #include <linux/sysctl.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv6.h> #include <linux/kernel.h> #include <linux/module.h> #include <net/netfilter/ipv6/nf_defrag_ipv6.h> struct nf_ct_frag6_skb_cb { struct inet6_skb_parm h; int offset; struct sk_buff *orig; }; #define NFCT_FRAG6_CB(skb) ((struct nf_ct_frag6_skb_cb*)((skb)->cb)) struct nf_ct_frag6_queue { struct inet_frag_queue q; __be32 id; /* fragment id */ u32 user; struct in6_addr saddr; struct in6_addr daddr; unsigned int csum; __u16 nhoffset; }; static struct inet_frags nf_frags; static struct netns_frags nf_init_frags; #ifdef CONFIG_SYSCTL static struct ctl_table nf_ct_frag6_sysctl_table[] = { { .procname = "nf_conntrack_frag6_timeout", .data = &nf_init_frags.timeout, .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "nf_conntrack_frag6_low_thresh", .data = &nf_init_frags.low_thresh, .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "nf_conntrack_frag6_high_thresh", .data = &nf_init_frags.high_thresh, .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec, }, { } }; static struct ctl_table_header *nf_ct_frag6_sysctl_header; #endif static unsigned int nf_hashfn(struct inet_frag_queue *q) { const struct nf_ct_frag6_queue *nq; nq = container_of(q, struct nf_ct_frag6_queue, q); return inet6_hash_frag(nq->id, &nq->saddr, &nq->daddr, nf_frags.rnd); } static void nf_skb_free(struct sk_buff *skb) { if (NFCT_FRAG6_CB(skb)->orig) kfree_skb(NFCT_FRAG6_CB(skb)->orig); } /* Destruction primitives. */ static __inline__ void fq_put(struct nf_ct_frag6_queue *fq) { inet_frag_put(&fq->q, &nf_frags); } /* Kill fq entry. It is not destroyed immediately, * because caller (and someone more) holds reference count. */ static __inline__ void fq_kill(struct nf_ct_frag6_queue *fq) { inet_frag_kill(&fq->q, &nf_frags); } static void nf_ct_frag6_evictor(void) { local_bh_disable(); inet_frag_evictor(&nf_init_frags, &nf_frags); local_bh_enable(); } static void nf_ct_frag6_expire(unsigned long data) { struct nf_ct_frag6_queue *fq; fq = container_of((struct inet_frag_queue *)data, struct nf_ct_frag6_queue, q); spin_lock(&fq->q.lock); if (fq->q.last_in & INET_FRAG_COMPLETE) goto out; fq_kill(fq); out: spin_unlock(&fq->q.lock); fq_put(fq); } /* Creation primitives. */ static __inline__ struct nf_ct_frag6_queue * fq_find(__be32 id, u32 user, struct in6_addr *src, struct in6_addr *dst) { struct inet_frag_queue *q; struct ip6_create_arg arg; unsigned int hash; arg.id = id; arg.user = user; arg.src = src; arg.dst = dst; read_lock_bh(&nf_frags.lock); hash = inet6_hash_frag(id, src, dst, nf_frags.rnd); q = inet_frag_find(&nf_init_frags, &nf_frags, &arg, hash); local_bh_enable(); if (IS_ERR_OR_NULL(q)) { inet_frag_maybe_warn_overflow(q, pr_fmt()); return NULL; } return container_of(q, struct nf_ct_frag6_queue, q); } static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb, const struct frag_hdr *fhdr, int nhoff) { struct sk_buff *prev, *next; int offset, end; if (fq->q.last_in & INET_FRAG_COMPLETE) { pr_debug("Already completed\n"); goto err; } offset = ntohs(fhdr->frag_off) & ~0x7; end = offset + (ntohs(ipv6_hdr(skb)->payload_len) - ((u8 *)(fhdr + 1) - (u8 *)(ipv6_hdr(skb) + 1))); if ((unsigned int)end > IPV6_MAXPLEN) { pr_debug("offset is too large.\n"); return -1; } if (skb->ip_summed == CHECKSUM_COMPLETE) { const unsigned char *nh = skb_network_header(skb); skb->csum = csum_sub(skb->csum, csum_partial(nh, (u8 *)(fhdr + 1) - nh, 0)); } /* Is this the final fragment? */ if (!(fhdr->frag_off & htons(IP6_MF))) { /* If we already have some bits beyond end * or have different end, the segment is corrupted. */ if (end < fq->q.len || ((fq->q.last_in & INET_FRAG_LAST_IN) && end != fq->q.len)) { pr_debug("already received last fragment\n"); goto err; } fq->q.last_in |= INET_FRAG_LAST_IN; fq->q.len = end; } else { /* Check if the fragment is rounded to 8 bytes. * Required by the RFC. */ if (end & 0x7) { /* RFC2460 says always send parameter problem in * this case. -DaveM */ pr_debug("end of fragment not rounded to 8 bytes.\n"); return -1; } if (end > fq->q.len) { /* Some bits beyond end -> corruption. */ if (fq->q.last_in & INET_FRAG_LAST_IN) { pr_debug("last packet already reached.\n"); goto err; } fq->q.len = end; } } if (end == offset) goto err; /* Point into the IP datagram 'data' part. */ if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) { pr_debug("queue: message is too short.\n"); goto err; } if (pskb_trim_rcsum(skb, end - offset)) { pr_debug("Can't trim\n"); goto err; } /* Find out which fragments are in front and at the back of us * in the chain of fragments so far. We must know where to put * this fragment, right? */ prev = fq->q.fragments_tail; if (!prev || NFCT_FRAG6_CB(prev)->offset < offset) { next = NULL; goto found; } prev = NULL; for (next = fq->q.fragments; next != NULL; next = next->next) { if (NFCT_FRAG6_CB(next)->offset >= offset) break; /* bingo! */ prev = next; } found: /* RFC5722, Section 4: * When reassembling an IPv6 datagram, if * one or more its constituent fragments is determined to be an * overlapping fragment, the entire datagram (and any constituent * fragments, including those not yet received) MUST be silently * discarded. */ /* Check for overlap with preceding fragment. */ if (prev && (NFCT_FRAG6_CB(prev)->offset + prev->len) > offset) goto discard_fq; /* Look for overlap with succeeding segment. */ if (next && NFCT_FRAG6_CB(next)->offset < end) goto discard_fq; NFCT_FRAG6_CB(skb)->offset = offset; /* Insert this fragment in the chain of fragments. */ skb->next = next; if (!next) fq->q.fragments_tail = skb; if (prev) prev->next = skb; else fq->q.fragments = skb; skb->dev = NULL; fq->q.stamp = skb->tstamp; fq->q.meat += skb->len; atomic_add(skb->truesize, &nf_init_frags.mem); /* The first fragment. * nhoffset is obtained from the first fragment, of course. */ if (offset == 0) { fq->nhoffset = nhoff; fq->q.last_in |= INET_FRAG_FIRST_IN; } write_lock(&nf_frags.lock); list_move_tail(&fq->q.lru_list, &nf_init_frags.lru_list); write_unlock(&nf_frags.lock); return 0; discard_fq: fq_kill(fq); err: return -1; } /* * Check if this packet is complete. * Returns NULL on failure by any reason, and pointer * to current nexthdr field in reassembled frame. * * It is called with locked fq, and caller must check that * queue is eligible for reassembly i.e. it is not COMPLETE, * the last and the first frames arrived and all the bits are here. */ static struct sk_buff * nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) { struct sk_buff *fp, *op, *head = fq->q.fragments; int payload_len; fq_kill(fq); WARN_ON(head == NULL); WARN_ON(NFCT_FRAG6_CB(head)->offset != 0); /* Unfragmented part is taken from the first segment. */ payload_len = ((head->data - skb_network_header(head)) - sizeof(struct ipv6hdr) + fq->q.len - sizeof(struct frag_hdr)); if (payload_len > IPV6_MAXPLEN) { pr_debug("payload len is too large.\n"); goto out_oversize; } /* Head of list must not be cloned. */ if (skb_cloned(head) && pskb_expand_head(head, 0, 0, GFP_ATOMIC)) { pr_debug("skb is cloned but can't expand head"); goto out_oom; } /* If the first fragment is fragmented itself, we split * it to two chunks: the first with data and paged part * and the second, holding only fragments. */ if (skb_has_frag_list(head)) { struct sk_buff *clone; int i, plen = 0; clone = alloc_skb(0, GFP_ATOMIC); if (clone == NULL) goto out_oom; clone->next = head->next; head->next = clone; skb_shinfo(clone)->frag_list = skb_shinfo(head)->frag_list; skb_frag_list_init(head); for (i = 0; i < skb_shinfo(head)->nr_frags; i++) plen += skb_frag_size(&skb_shinfo(head)->frags[i]); clone->len = clone->data_len = head->data_len - plen; head->data_len -= clone->len; head->len -= clone->len; clone->csum = 0; clone->ip_summed = head->ip_summed; NFCT_FRAG6_CB(clone)->orig = NULL; atomic_add(clone->truesize, &nf_init_frags.mem); } /* We have to remove fragment header from datagram and to relocate * header in order to calculate ICV correctly. */ skb_network_header(head)[fq->nhoffset] = skb_transport_header(head)[0]; memmove(head->head + sizeof(struct frag_hdr), head->head, (head->data - head->head) - sizeof(struct frag_hdr)); head->mac_header += sizeof(struct frag_hdr); head->network_header += sizeof(struct frag_hdr); skb_shinfo(head)->frag_list = head->next; skb_reset_transport_header(head); skb_push(head, head->data - skb_network_header(head)); for (fp=head->next; fp; fp = fp->next) { head->data_len += fp->len; head->len += fp->len; if (head->ip_summed != fp->ip_summed) head->ip_summed = CHECKSUM_NONE; else if (head->ip_summed == CHECKSUM_COMPLETE) head->csum = csum_add(head->csum, fp->csum); head->truesize += fp->truesize; } atomic_sub(head->truesize, &nf_init_frags.mem); head->next = NULL; head->dev = dev; head->tstamp = fq->q.stamp; ipv6_hdr(head)->payload_len = htons(payload_len); /* Yes, and fold redundant checksum back. 8) */ if (head->ip_summed == CHECKSUM_COMPLETE) head->csum = csum_partial(skb_network_header(head), skb_network_header_len(head), head->csum); fq->q.fragments = NULL; fq->q.fragments_tail = NULL; /* all original skbs are linked into the NFCT_FRAG6_CB(head).orig */ fp = skb_shinfo(head)->frag_list; if (fp && NFCT_FRAG6_CB(fp)->orig == NULL) /* at above code, head skb is divided into two skbs. */ fp = fp->next; op = NFCT_FRAG6_CB(head)->orig; for (; fp; fp = fp->next) { struct sk_buff *orig = NFCT_FRAG6_CB(fp)->orig; op->next = orig; op = orig; NFCT_FRAG6_CB(fp)->orig = NULL; } return head; out_oversize: if (net_ratelimit()) printk(KERN_DEBUG "nf_ct_frag6_reasm: payload len = %d\n", payload_len); goto out_fail; out_oom: if (net_ratelimit()) printk(KERN_DEBUG "nf_ct_frag6_reasm: no memory for reassembly\n"); out_fail: return NULL; } /* * find the header just before Fragment Header. * * if success return 0 and set ... * (*prevhdrp): the value of "Next Header Field" in the header * just before Fragment Header. * (*prevhoff): the offset of "Next Header Field" in the header * just before Fragment Header. * (*fhoff) : the offset of Fragment Header. * * Based on ipv6_skip_hdr() in net/ipv6/exthdr.c * */ static int find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff) { u8 nexthdr = ipv6_hdr(skb)->nexthdr; const int netoff = skb_network_offset(skb); u8 prev_nhoff = netoff + offsetof(struct ipv6hdr, nexthdr); int start = netoff + sizeof(struct ipv6hdr); int len = skb->len - start; u8 prevhdr = NEXTHDR_IPV6; while (nexthdr != NEXTHDR_FRAGMENT) { struct ipv6_opt_hdr hdr; int hdrlen; if (!ipv6_ext_hdr(nexthdr)) { return -1; } if (nexthdr == NEXTHDR_NONE) { pr_debug("next header is none\n"); return -1; } if (len < (int)sizeof(struct ipv6_opt_hdr)) { pr_debug("too short\n"); return -1; } if (skb_copy_bits(skb, start, &hdr, sizeof(hdr))) BUG(); if (nexthdr == NEXTHDR_AUTH) hdrlen = (hdr.hdrlen+2)<<2; else hdrlen = ipv6_optlen(&hdr); prevhdr = nexthdr; prev_nhoff = start; nexthdr = hdr.nexthdr; len -= hdrlen; start += hdrlen; } if (len < 0) return -1; *prevhdrp = prevhdr; *prevhoff = prev_nhoff; *fhoff = start; return 0; } struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user) { struct sk_buff *clone; struct net_device *dev = skb->dev; struct frag_hdr *fhdr; struct nf_ct_frag6_queue *fq; struct ipv6hdr *hdr; int fhoff, nhoff; u8 prevhdr; struct sk_buff *ret_skb = NULL; /* Jumbo payload inhibits frag. header */ if (ipv6_hdr(skb)->payload_len == 0) { pr_debug("payload len = 0\n"); return skb; } if (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0) return skb; clone = skb_clone(skb, GFP_ATOMIC); if (clone == NULL) { pr_debug("Can't clone skb\n"); return skb; } NFCT_FRAG6_CB(clone)->orig = skb; if (!pskb_may_pull(clone, fhoff + sizeof(*fhdr))) { pr_debug("message is too short.\n"); goto ret_orig; } skb_set_transport_header(clone, fhoff); hdr = ipv6_hdr(clone); fhdr = (struct frag_hdr *)skb_transport_header(clone); if (atomic_read(&nf_init_frags.mem) > nf_init_frags.high_thresh) nf_ct_frag6_evictor(); fq = fq_find(fhdr->identification, user, &hdr->saddr, &hdr->daddr); if (fq == NULL) { pr_debug("Can't find and can't create new queue\n"); goto ret_orig; } spin_lock_bh(&fq->q.lock); if (nf_ct_frag6_queue(fq, clone, fhdr, nhoff) < 0) { spin_unlock_bh(&fq->q.lock); pr_debug("Can't insert skb to queue\n"); fq_put(fq); goto ret_orig; } if (fq->q.last_in == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) && fq->q.meat == fq->q.len) { ret_skb = nf_ct_frag6_reasm(fq, dev); if (ret_skb == NULL) pr_debug("Can't reassemble fragmented packets\n"); } spin_unlock_bh(&fq->q.lock); fq_put(fq); return ret_skb; ret_orig: kfree_skb(clone); return skb; } void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb, struct net_device *in, struct net_device *out, int (*okfn)(struct sk_buff *)) { struct sk_buff *s, *s2; for (s = NFCT_FRAG6_CB(skb)->orig; s;) { nf_conntrack_put_reasm(s->nfct_reasm); nf_conntrack_get_reasm(skb); s->nfct_reasm = skb; s2 = s->next; s->next = NULL; NF_HOOK_THRESH(NFPROTO_IPV6, hooknum, s, in, out, okfn, NF_IP6_PRI_CONNTRACK_DEFRAG + 1); s = s2; } nf_conntrack_put_reasm(skb); } int nf_ct_frag6_init(void) { nf_frags.hashfn = nf_hashfn; nf_frags.constructor = ip6_frag_init; nf_frags.destructor = NULL; nf_frags.skb_free = nf_skb_free; nf_frags.qsize = sizeof(struct nf_ct_frag6_queue); nf_frags.match = ip6_frag_match; nf_frags.frag_expire = nf_ct_frag6_expire; nf_frags.secret_interval = 10 * 60 * HZ; nf_init_frags.timeout = IPV6_FRAG_TIMEOUT; nf_init_frags.high_thresh = IPV6_FRAG_HIGH_THRESH; nf_init_frags.low_thresh = IPV6_FRAG_LOW_THRESH; inet_frags_init_net(&nf_init_frags); inet_frags_init(&nf_frags); #ifdef CONFIG_SYSCTL nf_ct_frag6_sysctl_header = register_sysctl_paths(nf_net_netfilter_sysctl_path, nf_ct_frag6_sysctl_table); if (!nf_ct_frag6_sysctl_header) { inet_frags_fini(&nf_frags); return -ENOMEM; } #endif return 0; } void nf_ct_frag6_cleanup(void) { #ifdef CONFIG_SYSCTL unregister_sysctl_table(nf_ct_frag6_sysctl_header); nf_ct_frag6_sysctl_header = NULL; #endif inet_frags_fini(&nf_frags); nf_init_frags.low_thresh = 0; nf_ct_frag6_evictor(); }
gpl-2.0
NoSpamDan/android_kernel_samsung_msm8660-common
drivers/mtd/tests/mtd_stresstest.c
1979
7576
/* * Copyright (C) 2006-2008 Nokia Corporation * * 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; see the file COPYING. If not, write to the Free Software * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Test random reads, writes and erases on MTD device. * * Author: Adrian Hunter <ext-adrian.hunter@nokia.com> */ #include <linux/init.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/err.h> #include <linux/mtd/mtd.h> #include <linux/slab.h> #include <linux/sched.h> #include <linux/vmalloc.h> #define PRINT_PREF KERN_INFO "mtd_stresstest: " static int dev; module_param(dev, int, S_IRUGO); MODULE_PARM_DESC(dev, "MTD device number to use"); static int count = 10000; module_param(count, int, S_IRUGO); MODULE_PARM_DESC(count, "Number of operations to do (default is 10000)"); static struct mtd_info *mtd; static unsigned char *writebuf; static unsigned char *readbuf; static unsigned char *bbt; static int *offsets; static int pgsize; static int bufsize; static int ebcnt; static int pgcnt; static unsigned long next = 1; static inline unsigned int simple_rand(void) { next = next * 1103515245 + 12345; return (unsigned int)((next / 65536) % 32768); } static inline void simple_srand(unsigned long seed) { next = seed; } static int rand_eb(void) { int eb; again: if (ebcnt < 32768) eb = simple_rand(); else eb = (simple_rand() << 15) | simple_rand(); /* Read or write up 2 eraseblocks at a time - hence 'ebcnt - 1' */ eb %= (ebcnt - 1); if (bbt[eb]) goto again; return eb; } static int rand_offs(void) { int offs; if (bufsize < 32768) offs = simple_rand(); else offs = (simple_rand() << 15) | simple_rand(); offs %= bufsize; return offs; } static int rand_len(int offs) { int len; if (bufsize < 32768) len = simple_rand(); else len = (simple_rand() << 15) | simple_rand(); len %= (bufsize - offs); return len; } static int erase_eraseblock(int ebnum) { int err; struct erase_info ei; loff_t addr = ebnum * mtd->erasesize; memset(&ei, 0, sizeof(struct erase_info)); ei.mtd = mtd; ei.addr = addr; ei.len = mtd->erasesize; err = mtd->erase(mtd, &ei); if (unlikely(err)) { printk(PRINT_PREF "error %d while erasing EB %d\n", err, ebnum); return err; } if (unlikely(ei.state == MTD_ERASE_FAILED)) { printk(PRINT_PREF "some erase error occurred at EB %d\n", ebnum); return -EIO; } return 0; } static int is_block_bad(int ebnum) { loff_t addr = ebnum * mtd->erasesize; int ret; ret = mtd->block_isbad(mtd, addr); if (ret) printk(PRINT_PREF "block %d is bad\n", ebnum); return ret; } static int do_read(void) { size_t read = 0; int eb = rand_eb(); int offs = rand_offs(); int len = rand_len(offs), err; loff_t addr; if (bbt[eb + 1]) { if (offs >= mtd->erasesize) offs -= mtd->erasesize; if (offs + len > mtd->erasesize) len = mtd->erasesize - offs; } addr = eb * mtd->erasesize + offs; err = mtd->read(mtd, addr, len, &read, readbuf); if (err == -EUCLEAN) err = 0; if (unlikely(err || read != len)) { printk(PRINT_PREF "error: read failed at 0x%llx\n", (long long)addr); if (!err) err = -EINVAL; return err; } return 0; } static int do_write(void) { int eb = rand_eb(), offs, err, len; size_t written = 0; loff_t addr; offs = offsets[eb]; if (offs >= mtd->erasesize) { err = erase_eraseblock(eb); if (err) return err; offs = offsets[eb] = 0; } len = rand_len(offs); len = ((len + pgsize - 1) / pgsize) * pgsize; if (offs + len > mtd->erasesize) { if (bbt[eb + 1]) len = mtd->erasesize - offs; else { err = erase_eraseblock(eb + 1); if (err) return err; offsets[eb + 1] = 0; } } addr = eb * mtd->erasesize + offs; err = mtd->write(mtd, addr, len, &written, writebuf); if (unlikely(err || written != len)) { printk(PRINT_PREF "error: write failed at 0x%llx\n", (long long)addr); if (!err) err = -EINVAL; return err; } offs += len; while (offs > mtd->erasesize) { offsets[eb++] = mtd->erasesize; offs -= mtd->erasesize; } offsets[eb] = offs; return 0; } static int do_operation(void) { if (simple_rand() & 1) return do_read(); else return do_write(); } static int scan_for_bad_eraseblocks(void) { int i, bad = 0; bbt = kzalloc(ebcnt, GFP_KERNEL); if (!bbt) { printk(PRINT_PREF "error: cannot allocate memory\n"); return -ENOMEM; } /* NOR flash does not implement block_isbad */ if (mtd->block_isbad == NULL) return 0; printk(PRINT_PREF "scanning for bad eraseblocks\n"); for (i = 0; i < ebcnt; ++i) { bbt[i] = is_block_bad(i) ? 1 : 0; if (bbt[i]) bad += 1; cond_resched(); } printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad); return 0; } static int __init mtd_stresstest_init(void) { int err; int i, op; uint64_t tmp; printk(KERN_INFO "\n"); printk(KERN_INFO "=================================================\n"); printk(PRINT_PREF "MTD device: %d\n", dev); mtd = get_mtd_device(NULL, dev); if (IS_ERR(mtd)) { err = PTR_ERR(mtd); printk(PRINT_PREF "error: cannot get MTD device\n"); return err; } if (mtd->writesize == 1) { printk(PRINT_PREF "not NAND flash, assume page size is 512 " "bytes.\n"); pgsize = 512; } else pgsize = mtd->writesize; tmp = mtd->size; do_div(tmp, mtd->erasesize); ebcnt = tmp; pgcnt = mtd->erasesize / pgsize; printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, " "page size %u, count of eraseblocks %u, pages per " "eraseblock %u, OOB size %u\n", (unsigned long long)mtd->size, mtd->erasesize, pgsize, ebcnt, pgcnt, mtd->oobsize); if (ebcnt < 2) { printk(PRINT_PREF "error: need at least 2 eraseblocks\n"); err = -ENOSPC; goto out_put_mtd; } /* Read or write up 2 eraseblocks at a time */ bufsize = mtd->erasesize * 2; err = -ENOMEM; readbuf = vmalloc(bufsize); writebuf = vmalloc(bufsize); offsets = kmalloc(ebcnt * sizeof(int), GFP_KERNEL); if (!readbuf || !writebuf || !offsets) { printk(PRINT_PREF "error: cannot allocate memory\n"); goto out; } for (i = 0; i < ebcnt; i++) offsets[i] = mtd->erasesize; simple_srand(current->pid); for (i = 0; i < bufsize; i++) writebuf[i] = simple_rand(); err = scan_for_bad_eraseblocks(); if (err) goto out; /* Do operations */ printk(PRINT_PREF "doing operations\n"); for (op = 0; op < count; op++) { if ((op & 1023) == 0) printk(PRINT_PREF "%d operations done\n", op); err = do_operation(); if (err) goto out; cond_resched(); } printk(PRINT_PREF "finished, %d operations done\n", op); out: kfree(offsets); kfree(bbt); vfree(writebuf); vfree(readbuf); out_put_mtd: put_mtd_device(mtd); if (err) printk(PRINT_PREF "error %d occurred\n", err); printk(KERN_INFO "=================================================\n"); return err; } module_init(mtd_stresstest_init); static void __exit mtd_stresstest_exit(void) { return; } module_exit(mtd_stresstest_exit); MODULE_DESCRIPTION("Stress test module"); MODULE_AUTHOR("Adrian Hunter"); MODULE_LICENSE("GPL");
gpl-2.0
ballock/kernel-xenial-bbr
drivers/mtd/chips/gen_probe.c
1979
6805
/* * Routines common to all CFI-type probes. * (C) 2001-2003 Red Hat, Inc. * GPL'd */ #include <linux/kernel.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/mtd/mtd.h> #include <linux/mtd/map.h> #include <linux/mtd/cfi.h> #include <linux/mtd/gen_probe.h> static struct mtd_info *check_cmd_set(struct map_info *, int); static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chip_probe *cp); static int genprobe_new_chip(struct map_info *map, struct chip_probe *cp, struct cfi_private *cfi); struct mtd_info *mtd_do_chip_probe(struct map_info *map, struct chip_probe *cp) { struct mtd_info *mtd = NULL; struct cfi_private *cfi; /* First probe the map to see if we have CFI stuff there. */ cfi = genprobe_ident_chips(map, cp); if (!cfi) return NULL; map->fldrv_priv = cfi; /* OK we liked it. Now find a driver for the command set it talks */ mtd = check_cmd_set(map, 1); /* First the primary cmdset */ if (!mtd) mtd = check_cmd_set(map, 0); /* Then the secondary */ if (mtd) { if (mtd->size > map->size) { printk(KERN_WARNING "Reducing visibility of %ldKiB chip to %ldKiB\n", (unsigned long)mtd->size >> 10, (unsigned long)map->size >> 10); mtd->size = map->size; } return mtd; } printk(KERN_WARNING"gen_probe: No supported Vendor Command Set found\n"); kfree(cfi->cfiq); kfree(cfi); map->fldrv_priv = NULL; return NULL; } EXPORT_SYMBOL(mtd_do_chip_probe); static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chip_probe *cp) { struct cfi_private cfi; struct cfi_private *retcfi; unsigned long *chip_map; int i, j, mapsize; int max_chips; memset(&cfi, 0, sizeof(cfi)); /* Call the probetype-specific code with all permutations of interleave and device type, etc. */ if (!genprobe_new_chip(map, cp, &cfi)) { /* The probe didn't like it */ pr_debug("%s: Found no %s device at location zero\n", cp->name, map->name); return NULL; } #if 0 /* Let the CFI probe routine do this sanity check. The Intel and AMD probe routines won't ever return a broken CFI structure anyway, because they make them up themselves. */ if (cfi.cfiq->NumEraseRegions == 0) { printk(KERN_WARNING "Number of erase regions is zero\n"); kfree(cfi.cfiq); return NULL; } #endif cfi.chipshift = cfi.cfiq->DevSize; if (cfi_interleave_is_1(&cfi)) { ; } else if (cfi_interleave_is_2(&cfi)) { cfi.chipshift++; } else if (cfi_interleave_is_4((&cfi))) { cfi.chipshift += 2; } else if (cfi_interleave_is_8(&cfi)) { cfi.chipshift += 3; } else { BUG(); } cfi.numchips = 1; /* * Allocate memory for bitmap of valid chips. * Align bitmap storage size to full byte. */ max_chips = map->size >> cfi.chipshift; if (!max_chips) { printk(KERN_WARNING "NOR chip too large to fit in mapping. Attempting to cope...\n"); max_chips = 1; } mapsize = sizeof(long) * DIV_ROUND_UP(max_chips, BITS_PER_LONG); chip_map = kzalloc(mapsize, GFP_KERNEL); if (!chip_map) { kfree(cfi.cfiq); return NULL; } set_bit(0, chip_map); /* Mark first chip valid */ /* * Now probe for other chips, checking sensibly for aliases while * we're at it. The new_chip probe above should have let the first * chip in read mode. */ for (i = 1; i < max_chips; i++) { cp->probe_chip(map, i << cfi.chipshift, chip_map, &cfi); } /* * Now allocate the space for the structures we need to return to * our caller, and copy the appropriate data into them. */ retcfi = kmalloc(sizeof(struct cfi_private) + cfi.numchips * sizeof(struct flchip), GFP_KERNEL); if (!retcfi) { kfree(cfi.cfiq); kfree(chip_map); return NULL; } memcpy(retcfi, &cfi, sizeof(cfi)); memset(&retcfi->chips[0], 0, sizeof(struct flchip) * cfi.numchips); for (i = 0, j = 0; (j < cfi.numchips) && (i < max_chips); i++) { if(test_bit(i, chip_map)) { struct flchip *pchip = &retcfi->chips[j++]; pchip->start = (i << cfi.chipshift); pchip->state = FL_READY; init_waitqueue_head(&pchip->wq); mutex_init(&pchip->mutex); } } kfree(chip_map); return retcfi; } static int genprobe_new_chip(struct map_info *map, struct chip_probe *cp, struct cfi_private *cfi) { int min_chips = (map_bankwidth(map)/4?:1); /* At most 4-bytes wide. */ int max_chips = map_bankwidth(map); /* And minimum 1 */ int nr_chips, type; for (nr_chips = max_chips; nr_chips >= min_chips; nr_chips >>= 1) { if (!cfi_interleave_supported(nr_chips)) continue; cfi->interleave = nr_chips; /* Minimum device size. Don't look for one 8-bit device in a 16-bit bus, etc. */ type = map_bankwidth(map) / nr_chips; for (; type <= CFI_DEVICETYPE_X32; type<<=1) { cfi->device_type = type; if (cp->probe_chip(map, 0, NULL, cfi)) return 1; } } return 0; } typedef struct mtd_info *cfi_cmdset_fn_t(struct map_info *, int); extern cfi_cmdset_fn_t cfi_cmdset_0001; extern cfi_cmdset_fn_t cfi_cmdset_0002; extern cfi_cmdset_fn_t cfi_cmdset_0020; static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map, int primary) { struct cfi_private *cfi = map->fldrv_priv; __u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID; #ifdef CONFIG_MODULES char probename[sizeof(VMLINUX_SYMBOL_STR(cfi_cmdset_%4.4X))]; cfi_cmdset_fn_t *probe_function; sprintf(probename, VMLINUX_SYMBOL_STR(cfi_cmdset_%4.4X), type); probe_function = __symbol_get(probename); if (!probe_function) { request_module("cfi_cmdset_%4.4X", type); probe_function = __symbol_get(probename); } if (probe_function) { struct mtd_info *mtd; mtd = (*probe_function)(map, primary); /* If it was happy, it'll have increased its own use count */ symbol_put_addr(probe_function); return mtd; } #endif printk(KERN_NOTICE "Support for command set %04X not present\n", type); return NULL; } static struct mtd_info *check_cmd_set(struct map_info *map, int primary) { struct cfi_private *cfi = map->fldrv_priv; __u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID; if (type == P_ID_NONE || type == P_ID_RESERVED) return NULL; switch(type){ /* We need these for the !CONFIG_MODULES case, because symbol_get() doesn't work there */ #ifdef CONFIG_MTD_CFI_INTELEXT case P_ID_INTEL_EXT: case P_ID_INTEL_STD: case P_ID_INTEL_PERFORMANCE: return cfi_cmdset_0001(map, primary); #endif #ifdef CONFIG_MTD_CFI_AMDSTD case P_ID_AMD_STD: case P_ID_SST_OLD: case P_ID_WINBOND: return cfi_cmdset_0002(map, primary); #endif #ifdef CONFIG_MTD_CFI_STAA case P_ID_ST_ADV: return cfi_cmdset_0020(map, primary); #endif default: return cfi_cmdset_unknown(map, primary); } } MODULE_LICENSE("GPL"); MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); MODULE_DESCRIPTION("Helper routines for flash chip probe code");
gpl-2.0
spacecaker/Midnight_Acer_kernel
drivers/net/ethernet/intel/e1000e/82571.c
2747
55875
/******************************************************************************* Intel PRO/1000 Linux driver Copyright(c) 1999 - 2012 Intel Corporation. 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 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". Contact Information: Linux NICS <linux.nics@intel.com> e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *******************************************************************************/ /* * 82571EB Gigabit Ethernet Controller * 82571EB Gigabit Ethernet Controller (Copper) * 82571EB Gigabit Ethernet Controller (Fiber) * 82571EB Dual Port Gigabit Mezzanine Adapter * 82571EB Quad Port Gigabit Mezzanine Adapter * 82571PT Gigabit PT Quad Port Server ExpressModule * 82572EI Gigabit Ethernet Controller (Copper) * 82572EI Gigabit Ethernet Controller (Fiber) * 82572EI Gigabit Ethernet Controller * 82573V Gigabit Ethernet Controller (Copper) * 82573E Gigabit Ethernet Controller (Copper) * 82573L Gigabit Ethernet Controller * 82574L Gigabit Network Connection * 82583V Gigabit Network Connection */ #include "e1000.h" #define ID_LED_RESERVED_F746 0xF746 #define ID_LED_DEFAULT_82573 ((ID_LED_DEF1_DEF2 << 12) | \ (ID_LED_OFF1_ON2 << 8) | \ (ID_LED_DEF1_DEF2 << 4) | \ (ID_LED_DEF1_DEF2)) #define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000 #define AN_RETRY_COUNT 5 /* Autoneg Retry Count value */ #define E1000_BASE1000T_STATUS 10 #define E1000_IDLE_ERROR_COUNT_MASK 0xFF #define E1000_RECEIVE_ERROR_COUNTER 21 #define E1000_RECEIVE_ERROR_MAX 0xFFFF #define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */ static s32 e1000_get_phy_id_82571(struct e1000_hw *hw); static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw); static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw); static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw); static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw); static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw); static s32 e1000_setup_link_82571(struct e1000_hw *hw); static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw); static void e1000_clear_vfta_82571(struct e1000_hw *hw); static bool e1000_check_mng_mode_82574(struct e1000_hw *hw); static s32 e1000_led_on_82574(struct e1000_hw *hw); static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw); static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw); static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw); static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw); static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw); static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active); static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active); /** * e1000_init_phy_params_82571 - Init PHY func ptrs. * @hw: pointer to the HW structure **/ static s32 e1000_init_phy_params_82571(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; if (hw->phy.media_type != e1000_media_type_copper) { phy->type = e1000_phy_none; return 0; } phy->addr = 1; phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; phy->reset_delay_us = 100; phy->ops.power_up = e1000_power_up_phy_copper; phy->ops.power_down = e1000_power_down_phy_copper_82571; switch (hw->mac.type) { case e1000_82571: case e1000_82572: phy->type = e1000_phy_igp_2; break; case e1000_82573: phy->type = e1000_phy_m88; break; case e1000_82574: case e1000_82583: phy->type = e1000_phy_bm; phy->ops.acquire = e1000_get_hw_semaphore_82574; phy->ops.release = e1000_put_hw_semaphore_82574; phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82574; phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82574; break; default: return -E1000_ERR_PHY; break; } /* This can only be done after all function pointers are setup. */ ret_val = e1000_get_phy_id_82571(hw); if (ret_val) { e_dbg("Error getting PHY ID\n"); return ret_val; } /* Verify phy id */ switch (hw->mac.type) { case e1000_82571: case e1000_82572: if (phy->id != IGP01E1000_I_PHY_ID) ret_val = -E1000_ERR_PHY; break; case e1000_82573: if (phy->id != M88E1111_I_PHY_ID) ret_val = -E1000_ERR_PHY; break; case e1000_82574: case e1000_82583: if (phy->id != BME1000_E_PHY_ID_R2) ret_val = -E1000_ERR_PHY; break; default: ret_val = -E1000_ERR_PHY; break; } if (ret_val) e_dbg("PHY ID unknown: type = 0x%08x\n", phy->id); return ret_val; } /** * e1000_init_nvm_params_82571 - Init NVM func ptrs. * @hw: pointer to the HW structure **/ static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw) { struct e1000_nvm_info *nvm = &hw->nvm; u32 eecd = er32(EECD); u16 size; nvm->opcode_bits = 8; nvm->delay_usec = 1; switch (nvm->override) { case e1000_nvm_override_spi_large: nvm->page_size = 32; nvm->address_bits = 16; break; case e1000_nvm_override_spi_small: nvm->page_size = 8; nvm->address_bits = 8; break; default: nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8; break; } switch (hw->mac.type) { case e1000_82573: case e1000_82574: case e1000_82583: if (((eecd >> 15) & 0x3) == 0x3) { nvm->type = e1000_nvm_flash_hw; nvm->word_size = 2048; /* * Autonomous Flash update bit must be cleared due * to Flash update issue. */ eecd &= ~E1000_EECD_AUPDEN; ew32(EECD, eecd); break; } /* Fall Through */ default: nvm->type = e1000_nvm_eeprom_spi; size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >> E1000_EECD_SIZE_EX_SHIFT); /* * Added to a constant, "size" becomes the left-shift value * for setting word_size. */ size += NVM_WORD_SIZE_BASE_SHIFT; /* EEPROM access above 16k is unsupported */ if (size > 14) size = 14; nvm->word_size = 1 << size; break; } /* Function Pointers */ switch (hw->mac.type) { case e1000_82574: case e1000_82583: nvm->ops.acquire = e1000_get_hw_semaphore_82574; nvm->ops.release = e1000_put_hw_semaphore_82574; break; default: break; } return 0; } /** * e1000_init_mac_params_82571 - Init MAC func ptrs. * @hw: pointer to the HW structure **/ static s32 e1000_init_mac_params_82571(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; u32 swsm = 0; u32 swsm2 = 0; bool force_clear_smbi = false; /* Set media type and media-dependent function pointers */ switch (hw->adapter->pdev->device) { case E1000_DEV_ID_82571EB_FIBER: case E1000_DEV_ID_82572EI_FIBER: case E1000_DEV_ID_82571EB_QUAD_FIBER: hw->phy.media_type = e1000_media_type_fiber; mac->ops.setup_physical_interface = e1000_setup_fiber_serdes_link_82571; mac->ops.check_for_link = e1000e_check_for_fiber_link; mac->ops.get_link_up_info = e1000e_get_speed_and_duplex_fiber_serdes; break; case E1000_DEV_ID_82571EB_SERDES: case E1000_DEV_ID_82571EB_SERDES_DUAL: case E1000_DEV_ID_82571EB_SERDES_QUAD: case E1000_DEV_ID_82572EI_SERDES: hw->phy.media_type = e1000_media_type_internal_serdes; mac->ops.setup_physical_interface = e1000_setup_fiber_serdes_link_82571; mac->ops.check_for_link = e1000_check_for_serdes_link_82571; mac->ops.get_link_up_info = e1000e_get_speed_and_duplex_fiber_serdes; break; default: hw->phy.media_type = e1000_media_type_copper; mac->ops.setup_physical_interface = e1000_setup_copper_link_82571; mac->ops.check_for_link = e1000e_check_for_copper_link; mac->ops.get_link_up_info = e1000e_get_speed_and_duplex_copper; break; } /* Set mta register count */ mac->mta_reg_count = 128; /* Set rar entry count */ mac->rar_entry_count = E1000_RAR_ENTRIES; /* Adaptive IFS supported */ mac->adaptive_ifs = true; /* MAC-specific function pointers */ switch (hw->mac.type) { case e1000_82573: mac->ops.set_lan_id = e1000_set_lan_id_single_port; mac->ops.check_mng_mode = e1000e_check_mng_mode_generic; mac->ops.led_on = e1000e_led_on_generic; mac->ops.blink_led = e1000e_blink_led_generic; /* FWSM register */ mac->has_fwsm = true; /* * ARC supported; valid only if manageability features are * enabled. */ mac->arc_subsystem_valid = (er32(FWSM) & E1000_FWSM_MODE_MASK) ? true : false; break; case e1000_82574: case e1000_82583: mac->ops.set_lan_id = e1000_set_lan_id_single_port; mac->ops.check_mng_mode = e1000_check_mng_mode_82574; mac->ops.led_on = e1000_led_on_82574; break; default: mac->ops.check_mng_mode = e1000e_check_mng_mode_generic; mac->ops.led_on = e1000e_led_on_generic; mac->ops.blink_led = e1000e_blink_led_generic; /* FWSM register */ mac->has_fwsm = true; break; } /* * Ensure that the inter-port SWSM.SMBI lock bit is clear before * first NVM or PHY access. This should be done for single-port * devices, and for one port only on dual-port devices so that * for those devices we can still use the SMBI lock to synchronize * inter-port accesses to the PHY & NVM. */ switch (hw->mac.type) { case e1000_82571: case e1000_82572: swsm2 = er32(SWSM2); if (!(swsm2 & E1000_SWSM2_LOCK)) { /* Only do this for the first interface on this card */ ew32(SWSM2, swsm2 | E1000_SWSM2_LOCK); force_clear_smbi = true; } else { force_clear_smbi = false; } break; default: force_clear_smbi = true; break; } if (force_clear_smbi) { /* Make sure SWSM.SMBI is clear */ swsm = er32(SWSM); if (swsm & E1000_SWSM_SMBI) { /* This bit should not be set on a first interface, and * indicates that the bootagent or EFI code has * improperly left this bit enabled */ e_dbg("Please update your 82571 Bootagent\n"); } ew32(SWSM, swsm & ~E1000_SWSM_SMBI); } /* * Initialize device specific counter of SMBI acquisition * timeouts. */ hw->dev_spec.e82571.smb_counter = 0; return 0; } static s32 e1000_get_variants_82571(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; static int global_quad_port_a; /* global port a indication */ struct pci_dev *pdev = adapter->pdev; int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1; s32 rc; rc = e1000_init_mac_params_82571(hw); if (rc) return rc; rc = e1000_init_nvm_params_82571(hw); if (rc) return rc; rc = e1000_init_phy_params_82571(hw); if (rc) return rc; /* tag quad port adapters first, it's used below */ switch (pdev->device) { case E1000_DEV_ID_82571EB_QUAD_COPPER: case E1000_DEV_ID_82571EB_QUAD_FIBER: case E1000_DEV_ID_82571EB_QUAD_COPPER_LP: case E1000_DEV_ID_82571PT_QUAD_COPPER: adapter->flags |= FLAG_IS_QUAD_PORT; /* mark the first port */ if (global_quad_port_a == 0) adapter->flags |= FLAG_IS_QUAD_PORT_A; /* Reset for multiple quad port adapters */ global_quad_port_a++; if (global_quad_port_a == 4) global_quad_port_a = 0; break; default: break; } switch (adapter->hw.mac.type) { case e1000_82571: /* these dual ports don't have WoL on port B at all */ if (((pdev->device == E1000_DEV_ID_82571EB_FIBER) || (pdev->device == E1000_DEV_ID_82571EB_SERDES) || (pdev->device == E1000_DEV_ID_82571EB_COPPER)) && (is_port_b)) adapter->flags &= ~FLAG_HAS_WOL; /* quad ports only support WoL on port A */ if (adapter->flags & FLAG_IS_QUAD_PORT && (!(adapter->flags & FLAG_IS_QUAD_PORT_A))) adapter->flags &= ~FLAG_HAS_WOL; /* Does not support WoL on any port */ if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) adapter->flags &= ~FLAG_HAS_WOL; break; case e1000_82573: if (pdev->device == E1000_DEV_ID_82573L) { adapter->flags |= FLAG_HAS_JUMBO_FRAMES; adapter->max_hw_frame_size = DEFAULT_JUMBO; } break; default: break; } return 0; } /** * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision * @hw: pointer to the HW structure * * Reads the PHY registers and stores the PHY ID and possibly the PHY * revision in the hardware structure. **/ static s32 e1000_get_phy_id_82571(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; u16 phy_id = 0; switch (hw->mac.type) { case e1000_82571: case e1000_82572: /* * The 82571 firmware may still be configuring the PHY. * In this case, we cannot access the PHY until the * configuration is done. So we explicitly set the * PHY ID. */ phy->id = IGP01E1000_I_PHY_ID; break; case e1000_82573: return e1000e_get_phy_id(hw); break; case e1000_82574: case e1000_82583: ret_val = e1e_rphy(hw, PHY_ID1, &phy_id); if (ret_val) return ret_val; phy->id = (u32)(phy_id << 16); udelay(20); ret_val = e1e_rphy(hw, PHY_ID2, &phy_id); if (ret_val) return ret_val; phy->id |= (u32)(phy_id); phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); break; default: return -E1000_ERR_PHY; break; } return 0; } /** * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore * @hw: pointer to the HW structure * * Acquire the HW semaphore to access the PHY or NVM **/ static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw) { u32 swsm; s32 sw_timeout = hw->nvm.word_size + 1; s32 fw_timeout = hw->nvm.word_size + 1; s32 i = 0; /* * If we have timedout 3 times on trying to acquire * the inter-port SMBI semaphore, there is old code * operating on the other port, and it is not * releasing SMBI. Modify the number of times that * we try for the semaphore to interwork with this * older code. */ if (hw->dev_spec.e82571.smb_counter > 2) sw_timeout = 1; /* Get the SW semaphore */ while (i < sw_timeout) { swsm = er32(SWSM); if (!(swsm & E1000_SWSM_SMBI)) break; udelay(50); i++; } if (i == sw_timeout) { e_dbg("Driver can't access device - SMBI bit is set.\n"); hw->dev_spec.e82571.smb_counter++; } /* Get the FW semaphore. */ for (i = 0; i < fw_timeout; i++) { swsm = er32(SWSM); ew32(SWSM, swsm | E1000_SWSM_SWESMBI); /* Semaphore acquired if bit latched */ if (er32(SWSM) & E1000_SWSM_SWESMBI) break; udelay(50); } if (i == fw_timeout) { /* Release semaphores */ e1000_put_hw_semaphore_82571(hw); e_dbg("Driver can't access the NVM\n"); return -E1000_ERR_NVM; } return 0; } /** * e1000_put_hw_semaphore_82571 - Release hardware semaphore * @hw: pointer to the HW structure * * Release hardware semaphore used to access the PHY or NVM **/ static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw) { u32 swsm; swsm = er32(SWSM); swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI); ew32(SWSM, swsm); } /** * e1000_get_hw_semaphore_82573 - Acquire hardware semaphore * @hw: pointer to the HW structure * * Acquire the HW semaphore during reset. * **/ static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw) { u32 extcnf_ctrl; s32 i = 0; extcnf_ctrl = er32(EXTCNF_CTRL); extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; do { ew32(EXTCNF_CTRL, extcnf_ctrl); extcnf_ctrl = er32(EXTCNF_CTRL); if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP) break; extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; usleep_range(2000, 4000); i++; } while (i < MDIO_OWNERSHIP_TIMEOUT); if (i == MDIO_OWNERSHIP_TIMEOUT) { /* Release semaphores */ e1000_put_hw_semaphore_82573(hw); e_dbg("Driver can't access the PHY\n"); return -E1000_ERR_PHY; } return 0; } /** * e1000_put_hw_semaphore_82573 - Release hardware semaphore * @hw: pointer to the HW structure * * Release hardware semaphore used during reset. * **/ static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw) { u32 extcnf_ctrl; extcnf_ctrl = er32(EXTCNF_CTRL); extcnf_ctrl &= ~E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; ew32(EXTCNF_CTRL, extcnf_ctrl); } static DEFINE_MUTEX(swflag_mutex); /** * e1000_get_hw_semaphore_82574 - Acquire hardware semaphore * @hw: pointer to the HW structure * * Acquire the HW semaphore to access the PHY or NVM. * **/ static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw) { s32 ret_val; mutex_lock(&swflag_mutex); ret_val = e1000_get_hw_semaphore_82573(hw); if (ret_val) mutex_unlock(&swflag_mutex); return ret_val; } /** * e1000_put_hw_semaphore_82574 - Release hardware semaphore * @hw: pointer to the HW structure * * Release hardware semaphore used to access the PHY or NVM * **/ static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw) { e1000_put_hw_semaphore_82573(hw); mutex_unlock(&swflag_mutex); } /** * e1000_set_d0_lplu_state_82574 - Set Low Power Linkup D0 state * @hw: pointer to the HW structure * @active: true to enable LPLU, false to disable * * Sets the LPLU D0 state according to the active flag. * LPLU will not be activated unless the * device autonegotiation advertisement meets standards of * either 10 or 10/100 or 10/100/1000 at all duplexes. * This is a function pointer entry point only called by * PHY setup routines. **/ static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active) { u16 data = er32(POEMB); if (active) data |= E1000_PHY_CTRL_D0A_LPLU; else data &= ~E1000_PHY_CTRL_D0A_LPLU; ew32(POEMB, data); return 0; } /** * e1000_set_d3_lplu_state_82574 - Sets low power link up state for D3 * @hw: pointer to the HW structure * @active: boolean used to enable/disable lplu * * The low power link up (lplu) state is set to the power management level D3 * when active is true, else clear lplu for D3. LPLU * is used during Dx states where the power conservation is most important. * During driver activity, SmartSpeed should be enabled so performance is * maintained. **/ static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active) { u16 data = er32(POEMB); if (!active) { data &= ~E1000_PHY_CTRL_NOND0A_LPLU; } else if ((hw->phy.autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || (hw->phy.autoneg_advertised == E1000_ALL_NOT_GIG) || (hw->phy.autoneg_advertised == E1000_ALL_10_SPEED)) { data |= E1000_PHY_CTRL_NOND0A_LPLU; } ew32(POEMB, data); return 0; } /** * e1000_acquire_nvm_82571 - Request for access to the EEPROM * @hw: pointer to the HW structure * * To gain access to the EEPROM, first we must obtain a hardware semaphore. * Then for non-82573 hardware, set the EEPROM access request bit and wait * for EEPROM access grant bit. If the access grant bit is not set, release * hardware semaphore. **/ static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw) { s32 ret_val; ret_val = e1000_get_hw_semaphore_82571(hw); if (ret_val) return ret_val; switch (hw->mac.type) { case e1000_82573: break; default: ret_val = e1000e_acquire_nvm(hw); break; } if (ret_val) e1000_put_hw_semaphore_82571(hw); return ret_val; } /** * e1000_release_nvm_82571 - Release exclusive access to EEPROM * @hw: pointer to the HW structure * * Stop any current commands to the EEPROM and clear the EEPROM request bit. **/ static void e1000_release_nvm_82571(struct e1000_hw *hw) { e1000e_release_nvm(hw); e1000_put_hw_semaphore_82571(hw); } /** * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface * @hw: pointer to the HW structure * @offset: offset within the EEPROM to be written to * @words: number of words to write * @data: 16 bit word(s) to be written to the EEPROM * * For non-82573 silicon, write data to EEPROM at offset using SPI interface. * * If e1000e_update_nvm_checksum is not called after this function, the * EEPROM will most likely contain an invalid checksum. **/ static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) { s32 ret_val; switch (hw->mac.type) { case e1000_82573: case e1000_82574: case e1000_82583: ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data); break; case e1000_82571: case e1000_82572: ret_val = e1000e_write_nvm_spi(hw, offset, words, data); break; default: ret_val = -E1000_ERR_NVM; break; } return ret_val; } /** * e1000_update_nvm_checksum_82571 - Update EEPROM checksum * @hw: pointer to the HW structure * * Updates the EEPROM checksum by reading/adding each word of the EEPROM * up to the checksum. Then calculates the EEPROM checksum and writes the * value to the EEPROM. **/ static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw) { u32 eecd; s32 ret_val; u16 i; ret_val = e1000e_update_nvm_checksum_generic(hw); if (ret_val) return ret_val; /* * If our nvm is an EEPROM, then we're done * otherwise, commit the checksum to the flash NVM. */ if (hw->nvm.type != e1000_nvm_flash_hw) return 0; /* Check for pending operations. */ for (i = 0; i < E1000_FLASH_UPDATES; i++) { usleep_range(1000, 2000); if ((er32(EECD) & E1000_EECD_FLUPD) == 0) break; } if (i == E1000_FLASH_UPDATES) return -E1000_ERR_NVM; /* Reset the firmware if using STM opcode. */ if ((er32(FLOP) & 0xFF00) == E1000_STM_OPCODE) { /* * The enabling of and the actual reset must be done * in two write cycles. */ ew32(HICR, E1000_HICR_FW_RESET_ENABLE); e1e_flush(); ew32(HICR, E1000_HICR_FW_RESET); } /* Commit the write to flash */ eecd = er32(EECD) | E1000_EECD_FLUPD; ew32(EECD, eecd); for (i = 0; i < E1000_FLASH_UPDATES; i++) { usleep_range(1000, 2000); if ((er32(EECD) & E1000_EECD_FLUPD) == 0) break; } if (i == E1000_FLASH_UPDATES) return -E1000_ERR_NVM; return 0; } /** * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum * @hw: pointer to the HW structure * * Calculates the EEPROM checksum by reading/adding each word of the EEPROM * and then verifies that the sum of the EEPROM is equal to 0xBABA. **/ static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw) { if (hw->nvm.type == e1000_nvm_flash_hw) e1000_fix_nvm_checksum_82571(hw); return e1000e_validate_nvm_checksum_generic(hw); } /** * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon * @hw: pointer to the HW structure * @offset: offset within the EEPROM to be written to * @words: number of words to write * @data: 16 bit word(s) to be written to the EEPROM * * After checking for invalid values, poll the EEPROM to ensure the previous * command has completed before trying to write the next word. After write * poll for completion. * * If e1000e_update_nvm_checksum is not called after this function, the * EEPROM will most likely contain an invalid checksum. **/ static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) { struct e1000_nvm_info *nvm = &hw->nvm; u32 i, eewr = 0; s32 ret_val = 0; /* * A check for invalid values: offset too large, too many words, * and not enough words. */ if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || (words == 0)) { e_dbg("nvm parameter(s) out of bounds\n"); return -E1000_ERR_NVM; } for (i = 0; i < words; i++) { eewr = (data[i] << E1000_NVM_RW_REG_DATA) | ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) | E1000_NVM_RW_REG_START; ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); if (ret_val) break; ew32(EEWR, eewr); ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); if (ret_val) break; } return ret_val; } /** * e1000_get_cfg_done_82571 - Poll for configuration done * @hw: pointer to the HW structure * * Reads the management control register for the config done bit to be set. **/ static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw) { s32 timeout = PHY_CFG_TIMEOUT; while (timeout) { if (er32(EEMNGCTL) & E1000_NVM_CFG_DONE_PORT_0) break; usleep_range(1000, 2000); timeout--; } if (!timeout) { e_dbg("MNG configuration cycle has not completed.\n"); return -E1000_ERR_RESET; } return 0; } /** * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state * @hw: pointer to the HW structure * @active: true to enable LPLU, false to disable * * Sets the LPLU D0 state according to the active flag. When activating LPLU * this function also disables smart speed and vice versa. LPLU will not be * activated unless the device autonegotiation advertisement meets standards * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function * pointer entry point only called by PHY setup routines. **/ static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; u16 data; ret_val = e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &data); if (ret_val) return ret_val; if (active) { data |= IGP02E1000_PM_D0_LPLU; ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data); if (ret_val) return ret_val; /* When LPLU is enabled, we should disable SmartSpeed */ ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); data &= ~IGP01E1000_PSCFR_SMART_SPEED; ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); if (ret_val) return ret_val; } else { data &= ~IGP02E1000_PM_D0_LPLU; ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data); /* * LPLU and SmartSpeed are mutually exclusive. LPLU is used * during Dx states where the power conservation is most * important. During driver activity we should enable * SmartSpeed, so performance is maintained. */ if (phy->smart_speed == e1000_smart_speed_on) { ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); if (ret_val) return ret_val; data |= IGP01E1000_PSCFR_SMART_SPEED; ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); if (ret_val) return ret_val; } else if (phy->smart_speed == e1000_smart_speed_off) { ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); if (ret_val) return ret_val; data &= ~IGP01E1000_PSCFR_SMART_SPEED; ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); if (ret_val) return ret_val; } } return 0; } /** * e1000_reset_hw_82571 - Reset hardware * @hw: pointer to the HW structure * * This resets the hardware into a known state. **/ static s32 e1000_reset_hw_82571(struct e1000_hw *hw) { u32 ctrl, ctrl_ext; s32 ret_val; /* * Prevent the PCI-E bus from sticking if there is no TLP connection * on the last TLP read/write transaction when MAC is reset. */ ret_val = e1000e_disable_pcie_master(hw); if (ret_val) e_dbg("PCI-E Master disable polling has failed.\n"); e_dbg("Masking off all interrupts\n"); ew32(IMC, 0xffffffff); ew32(RCTL, 0); ew32(TCTL, E1000_TCTL_PSP); e1e_flush(); usleep_range(10000, 20000); /* * Must acquire the MDIO ownership before MAC reset. * Ownership defaults to firmware after a reset. */ switch (hw->mac.type) { case e1000_82573: ret_val = e1000_get_hw_semaphore_82573(hw); break; case e1000_82574: case e1000_82583: ret_val = e1000_get_hw_semaphore_82574(hw); break; default: break; } if (ret_val) e_dbg("Cannot acquire MDIO ownership\n"); ctrl = er32(CTRL); e_dbg("Issuing a global reset to MAC\n"); ew32(CTRL, ctrl | E1000_CTRL_RST); /* Must release MDIO ownership and mutex after MAC reset. */ switch (hw->mac.type) { case e1000_82574: case e1000_82583: e1000_put_hw_semaphore_82574(hw); break; default: break; } if (hw->nvm.type == e1000_nvm_flash_hw) { udelay(10); ctrl_ext = er32(CTRL_EXT); ctrl_ext |= E1000_CTRL_EXT_EE_RST; ew32(CTRL_EXT, ctrl_ext); e1e_flush(); } ret_val = e1000e_get_auto_rd_done(hw); if (ret_val) /* We don't want to continue accessing MAC registers. */ return ret_val; /* * Phy configuration from NVM just starts after EECD_AUTO_RD is set. * Need to wait for Phy configuration completion before accessing * NVM and Phy. */ switch (hw->mac.type) { case e1000_82573: case e1000_82574: case e1000_82583: msleep(25); break; default: break; } /* Clear any pending interrupt events. */ ew32(IMC, 0xffffffff); er32(ICR); if (hw->mac.type == e1000_82571) { /* Install any alternate MAC address into RAR0 */ ret_val = e1000_check_alt_mac_addr_generic(hw); if (ret_val) return ret_val; e1000e_set_laa_state_82571(hw, true); } /* Reinitialize the 82571 serdes link state machine */ if (hw->phy.media_type == e1000_media_type_internal_serdes) hw->mac.serdes_link_state = e1000_serdes_link_down; return 0; } /** * e1000_init_hw_82571 - Initialize hardware * @hw: pointer to the HW structure * * This inits the hardware readying it for operation. **/ static s32 e1000_init_hw_82571(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; u32 reg_data; s32 ret_val; u16 i, rar_count = mac->rar_entry_count; e1000_initialize_hw_bits_82571(hw); /* Initialize identification LED */ ret_val = mac->ops.id_led_init(hw); if (ret_val) e_dbg("Error initializing identification LED\n"); /* This is not fatal and we should not stop init due to this */ /* Disabling VLAN filtering */ e_dbg("Initializing the IEEE VLAN\n"); mac->ops.clear_vfta(hw); /* Setup the receive address. */ /* * If, however, a locally administered address was assigned to the * 82571, we must reserve a RAR for it to work around an issue where * resetting one port will reload the MAC on the other port. */ if (e1000e_get_laa_state_82571(hw)) rar_count--; e1000e_init_rx_addrs(hw, rar_count); /* Zero out the Multicast HASH table */ e_dbg("Zeroing the MTA\n"); for (i = 0; i < mac->mta_reg_count; i++) E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); /* Setup link and flow control */ ret_val = mac->ops.setup_link(hw); /* Set the transmit descriptor write-back policy */ reg_data = er32(TXDCTL(0)); reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC; ew32(TXDCTL(0), reg_data); /* ...for both queues. */ switch (mac->type) { case e1000_82573: e1000e_enable_tx_pkt_filtering(hw); /* fall through */ case e1000_82574: case e1000_82583: reg_data = er32(GCR); reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX; ew32(GCR, reg_data); break; default: reg_data = er32(TXDCTL(1)); reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC; ew32(TXDCTL(1), reg_data); break; } /* * Clear all of the statistics registers (clear on read). It is * important that we do this after we have tried to establish link * because the symbol error count will increment wildly if there * is no link. */ e1000_clear_hw_cntrs_82571(hw); return ret_val; } /** * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits * @hw: pointer to the HW structure * * Initializes required hardware-dependent bits needed for normal operation. **/ static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw) { u32 reg; /* Transmit Descriptor Control 0 */ reg = er32(TXDCTL(0)); reg |= (1 << 22); ew32(TXDCTL(0), reg); /* Transmit Descriptor Control 1 */ reg = er32(TXDCTL(1)); reg |= (1 << 22); ew32(TXDCTL(1), reg); /* Transmit Arbitration Control 0 */ reg = er32(TARC(0)); reg &= ~(0xF << 27); /* 30:27 */ switch (hw->mac.type) { case e1000_82571: case e1000_82572: reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26); break; case e1000_82574: case e1000_82583: reg |= (1 << 26); break; default: break; } ew32(TARC(0), reg); /* Transmit Arbitration Control 1 */ reg = er32(TARC(1)); switch (hw->mac.type) { case e1000_82571: case e1000_82572: reg &= ~((1 << 29) | (1 << 30)); reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26); if (er32(TCTL) & E1000_TCTL_MULR) reg &= ~(1 << 28); else reg |= (1 << 28); ew32(TARC(1), reg); break; default: break; } /* Device Control */ switch (hw->mac.type) { case e1000_82573: case e1000_82574: case e1000_82583: reg = er32(CTRL); reg &= ~(1 << 29); ew32(CTRL, reg); break; default: break; } /* Extended Device Control */ switch (hw->mac.type) { case e1000_82573: case e1000_82574: case e1000_82583: reg = er32(CTRL_EXT); reg &= ~(1 << 23); reg |= (1 << 22); ew32(CTRL_EXT, reg); break; default: break; } if (hw->mac.type == e1000_82571) { reg = er32(PBA_ECC); reg |= E1000_PBA_ECC_CORR_EN; ew32(PBA_ECC, reg); } /* * Workaround for hardware errata. * Ensure that DMA Dynamic Clock gating is disabled on 82571 and 82572 */ if ((hw->mac.type == e1000_82571) || (hw->mac.type == e1000_82572)) { reg = er32(CTRL_EXT); reg &= ~E1000_CTRL_EXT_DMA_DYN_CLK_EN; ew32(CTRL_EXT, reg); } /* PCI-Ex Control Registers */ switch (hw->mac.type) { case e1000_82574: case e1000_82583: reg = er32(GCR); reg |= (1 << 22); ew32(GCR, reg); /* * Workaround for hardware errata. * apply workaround for hardware errata documented in errata * docs Fixes issue where some error prone or unreliable PCIe * completions are occurring, particularly with ASPM enabled. * Without fix, issue can cause Tx timeouts. */ reg = er32(GCR2); reg |= 1; ew32(GCR2, reg); break; default: break; } } /** * e1000_clear_vfta_82571 - Clear VLAN filter table * @hw: pointer to the HW structure * * Clears the register array which contains the VLAN filter table by * setting all the values to 0. **/ static void e1000_clear_vfta_82571(struct e1000_hw *hw) { u32 offset; u32 vfta_value = 0; u32 vfta_offset = 0; u32 vfta_bit_in_reg = 0; switch (hw->mac.type) { case e1000_82573: case e1000_82574: case e1000_82583: if (hw->mng_cookie.vlan_id != 0) { /* * The VFTA is a 4096b bit-field, each identifying * a single VLAN ID. The following operations * determine which 32b entry (i.e. offset) into the * array we want to set the VLAN ID (i.e. bit) of * the manageability unit. */ vfta_offset = (hw->mng_cookie.vlan_id >> E1000_VFTA_ENTRY_SHIFT) & E1000_VFTA_ENTRY_MASK; vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id & E1000_VFTA_ENTRY_BIT_SHIFT_MASK); } break; default: break; } for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) { /* * If the offset we want to clear is the same offset of the * manageability VLAN ID, then clear all bits except that of * the manageability unit. */ vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0; E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value); e1e_flush(); } } /** * e1000_check_mng_mode_82574 - Check manageability is enabled * @hw: pointer to the HW structure * * Reads the NVM Initialization Control Word 2 and returns true * (>0) if any manageability is enabled, else false (0). **/ static bool e1000_check_mng_mode_82574(struct e1000_hw *hw) { u16 data; e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data); return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0; } /** * e1000_led_on_82574 - Turn LED on * @hw: pointer to the HW structure * * Turn LED on. **/ static s32 e1000_led_on_82574(struct e1000_hw *hw) { u32 ctrl; u32 i; ctrl = hw->mac.ledctl_mode2; if (!(E1000_STATUS_LU & er32(STATUS))) { /* * If no link, then turn LED on by setting the invert bit * for each LED that's "on" (0x0E) in ledctl_mode2. */ for (i = 0; i < 4; i++) if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) == E1000_LEDCTL_MODE_LED_ON) ctrl |= (E1000_LEDCTL_LED0_IVRT << (i * 8)); } ew32(LEDCTL, ctrl); return 0; } /** * e1000_check_phy_82574 - check 82574 phy hung state * @hw: pointer to the HW structure * * Returns whether phy is hung or not **/ bool e1000_check_phy_82574(struct e1000_hw *hw) { u16 status_1kbt = 0; u16 receive_errors = 0; s32 ret_val = 0; /* * Read PHY Receive Error counter first, if its is max - all F's then * read the Base1000T status register If both are max then PHY is hung. */ ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors); if (ret_val) return false; if (receive_errors == E1000_RECEIVE_ERROR_MAX) { ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt); if (ret_val) return false; if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) == E1000_IDLE_ERROR_COUNT_MASK) return true; } return false; } /** * e1000_setup_link_82571 - Setup flow control and link settings * @hw: pointer to the HW structure * * Determines which flow control settings to use, then configures flow * control. Calls the appropriate media-specific link configuration * function. Assuming the adapter has a valid link partner, a valid link * should be established. Assumes the hardware has previously been reset * and the transmitter and receiver are not enabled. **/ static s32 e1000_setup_link_82571(struct e1000_hw *hw) { /* * 82573 does not have a word in the NVM to determine * the default flow control setting, so we explicitly * set it to full. */ switch (hw->mac.type) { case e1000_82573: case e1000_82574: case e1000_82583: if (hw->fc.requested_mode == e1000_fc_default) hw->fc.requested_mode = e1000_fc_full; break; default: break; } return e1000e_setup_link_generic(hw); } /** * e1000_setup_copper_link_82571 - Configure copper link settings * @hw: pointer to the HW structure * * Configures the link for auto-neg or forced speed and duplex. Then we check * for link, once link is established calls to configure collision distance * and flow control are called. **/ static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw) { u32 ctrl; s32 ret_val; ctrl = er32(CTRL); ctrl |= E1000_CTRL_SLU; ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); ew32(CTRL, ctrl); switch (hw->phy.type) { case e1000_phy_m88: case e1000_phy_bm: ret_val = e1000e_copper_link_setup_m88(hw); break; case e1000_phy_igp_2: ret_val = e1000e_copper_link_setup_igp(hw); break; default: return -E1000_ERR_PHY; break; } if (ret_val) return ret_val; return e1000e_setup_copper_link(hw); } /** * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes * @hw: pointer to the HW structure * * Configures collision distance and flow control for fiber and serdes links. * Upon successful setup, poll for link. **/ static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw) { switch (hw->mac.type) { case e1000_82571: case e1000_82572: /* * If SerDes loopback mode is entered, there is no form * of reset to take the adapter out of that mode. So we * have to explicitly take the adapter out of loopback * mode. This prevents drivers from twiddling their thumbs * if another tool failed to take it out of loopback mode. */ ew32(SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK); break; default: break; } return e1000e_setup_fiber_serdes_link(hw); } /** * e1000_check_for_serdes_link_82571 - Check for link (Serdes) * @hw: pointer to the HW structure * * Reports the link state as up or down. * * If autonegotiation is supported by the link partner, the link state is * determined by the result of autonegotiation. This is the most likely case. * If autonegotiation is not supported by the link partner, and the link * has a valid signal, force the link up. * * The link state is represented internally here by 4 states: * * 1) down * 2) autoneg_progress * 3) autoneg_complete (the link successfully autonegotiated) * 4) forced_up (the link has been forced up, it did not autonegotiate) * **/ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; u32 rxcw; u32 ctrl; u32 status; u32 txcw; u32 i; s32 ret_val = 0; ctrl = er32(CTRL); status = er32(STATUS); rxcw = er32(RXCW); if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) { /* Receiver is synchronized with no invalid bits. */ switch (mac->serdes_link_state) { case e1000_serdes_link_autoneg_complete: if (!(status & E1000_STATUS_LU)) { /* * We have lost link, retry autoneg before * reporting link failure */ mac->serdes_link_state = e1000_serdes_link_autoneg_progress; mac->serdes_has_link = false; e_dbg("AN_UP -> AN_PROG\n"); } else { mac->serdes_has_link = true; } break; case e1000_serdes_link_forced_up: /* * If we are receiving /C/ ordered sets, re-enable * auto-negotiation in the TXCW register and disable * forced link in the Device Control register in an * attempt to auto-negotiate with our link partner. * If the partner code word is null, stop forcing * and restart auto negotiation. */ if ((rxcw & E1000_RXCW_C) || !(rxcw & E1000_RXCW_CW)) { /* Enable autoneg, and unforce link up */ ew32(TXCW, mac->txcw); ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); mac->serdes_link_state = e1000_serdes_link_autoneg_progress; mac->serdes_has_link = false; e_dbg("FORCED_UP -> AN_PROG\n"); } else { mac->serdes_has_link = true; } break; case e1000_serdes_link_autoneg_progress: if (rxcw & E1000_RXCW_C) { /* * We received /C/ ordered sets, meaning the * link partner has autonegotiated, and we can * trust the Link Up (LU) status bit. */ if (status & E1000_STATUS_LU) { mac->serdes_link_state = e1000_serdes_link_autoneg_complete; e_dbg("AN_PROG -> AN_UP\n"); mac->serdes_has_link = true; } else { /* Autoneg completed, but failed. */ mac->serdes_link_state = e1000_serdes_link_down; e_dbg("AN_PROG -> DOWN\n"); } } else { /* * The link partner did not autoneg. * Force link up and full duplex, and change * state to forced. */ ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE)); ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD); ew32(CTRL, ctrl); /* Configure Flow Control after link up. */ ret_val = e1000e_config_fc_after_link_up(hw); if (ret_val) { e_dbg("Error config flow control\n"); break; } mac->serdes_link_state = e1000_serdes_link_forced_up; mac->serdes_has_link = true; e_dbg("AN_PROG -> FORCED_UP\n"); } break; case e1000_serdes_link_down: default: /* * The link was down but the receiver has now gained * valid sync, so lets see if we can bring the link * up. */ ew32(TXCW, mac->txcw); ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); mac->serdes_link_state = e1000_serdes_link_autoneg_progress; mac->serdes_has_link = false; e_dbg("DOWN -> AN_PROG\n"); break; } } else { if (!(rxcw & E1000_RXCW_SYNCH)) { mac->serdes_has_link = false; mac->serdes_link_state = e1000_serdes_link_down; e_dbg("ANYSTATE -> DOWN\n"); } else { /* * Check several times, if Sync and Config * both are consistently 1 then simply ignore * the Invalid bit and restart Autoneg */ for (i = 0; i < AN_RETRY_COUNT; i++) { udelay(10); rxcw = er32(RXCW); if ((rxcw & E1000_RXCW_IV) && !((rxcw & E1000_RXCW_SYNCH) && (rxcw & E1000_RXCW_C))) { mac->serdes_has_link = false; mac->serdes_link_state = e1000_serdes_link_down; e_dbg("ANYSTATE -> DOWN\n"); break; } } if (i == AN_RETRY_COUNT) { txcw = er32(TXCW); txcw |= E1000_TXCW_ANE; ew32(TXCW, txcw); mac->serdes_link_state = e1000_serdes_link_autoneg_progress; mac->serdes_has_link = false; e_dbg("ANYSTATE -> AN_PROG\n"); } } } return ret_val; } /** * e1000_valid_led_default_82571 - Verify a valid default LED config * @hw: pointer to the HW structure * @data: pointer to the NVM (EEPROM) * * Read the EEPROM for the current default LED configuration. If the * LED configuration is not valid, set to a valid LED configuration. **/ static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data) { s32 ret_val; ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data); if (ret_val) { e_dbg("NVM Read Error\n"); return ret_val; } switch (hw->mac.type) { case e1000_82573: case e1000_82574: case e1000_82583: if (*data == ID_LED_RESERVED_F746) *data = ID_LED_DEFAULT_82573; break; default: if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF) *data = ID_LED_DEFAULT; break; } return 0; } /** * e1000e_get_laa_state_82571 - Get locally administered address state * @hw: pointer to the HW structure * * Retrieve and return the current locally administered address state. **/ bool e1000e_get_laa_state_82571(struct e1000_hw *hw) { if (hw->mac.type != e1000_82571) return false; return hw->dev_spec.e82571.laa_is_present; } /** * e1000e_set_laa_state_82571 - Set locally administered address state * @hw: pointer to the HW structure * @state: enable/disable locally administered address * * Enable/Disable the current locally administered address state. **/ void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state) { if (hw->mac.type != e1000_82571) return; hw->dev_spec.e82571.laa_is_present = state; /* If workaround is activated... */ if (state) /* * Hold a copy of the LAA in RAR[14] This is done so that * between the time RAR[0] gets clobbered and the time it * gets fixed, the actual LAA is in one of the RARs and no * incoming packets directed to this port are dropped. * Eventually the LAA will be in RAR[0] and RAR[14]. */ e1000e_rar_set(hw, hw->mac.addr, hw->mac.rar_entry_count - 1); } /** * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum * @hw: pointer to the HW structure * * Verifies that the EEPROM has completed the update. After updating the * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If * the checksum fix is not implemented, we need to set the bit and update * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect, * we need to return bad checksum. **/ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw) { struct e1000_nvm_info *nvm = &hw->nvm; s32 ret_val; u16 data; if (nvm->type != e1000_nvm_flash_hw) return 0; /* * Check bit 4 of word 10h. If it is 0, firmware is done updating * 10h-12h. Checksum may need to be fixed. */ ret_val = e1000_read_nvm(hw, 0x10, 1, &data); if (ret_val) return ret_val; if (!(data & 0x10)) { /* * Read 0x23 and check bit 15. This bit is a 1 * when the checksum has already been fixed. If * the checksum is still wrong and this bit is a * 1, we need to return bad checksum. Otherwise, * we need to set this bit to a 1 and update the * checksum. */ ret_val = e1000_read_nvm(hw, 0x23, 1, &data); if (ret_val) return ret_val; if (!(data & 0x8000)) { data |= 0x8000; ret_val = e1000_write_nvm(hw, 0x23, 1, &data); if (ret_val) return ret_val; ret_val = e1000e_update_nvm_checksum(hw); } } return 0; } /** * e1000_read_mac_addr_82571 - Read device MAC address * @hw: pointer to the HW structure **/ static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw) { if (hw->mac.type == e1000_82571) { s32 ret_val = 0; /* * If there's an alternate MAC address place it in RAR0 * so that it will override the Si installed default perm * address. */ ret_val = e1000_check_alt_mac_addr_generic(hw); if (ret_val) return ret_val; } return e1000_read_mac_addr_generic(hw); } /** * e1000_power_down_phy_copper_82571 - Remove link during PHY power down * @hw: pointer to the HW structure * * In the case of a PHY power down to save power, or to turn off link during a * driver unload, or wake on lan is not enabled, remove the link. **/ static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; struct e1000_mac_info *mac = &hw->mac; if (!phy->ops.check_reset_block) return; /* If the management interface is not enabled, then power down */ if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw))) e1000_power_down_phy_copper(hw); } /** * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters * @hw: pointer to the HW structure * * Clears the hardware counters by reading the counter registers. **/ static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw) { e1000e_clear_hw_cntrs_base(hw); er32(PRC64); er32(PRC127); er32(PRC255); er32(PRC511); er32(PRC1023); er32(PRC1522); er32(PTC64); er32(PTC127); er32(PTC255); er32(PTC511); er32(PTC1023); er32(PTC1522); er32(ALGNERRC); er32(RXERRC); er32(TNCRS); er32(CEXTERR); er32(TSCTC); er32(TSCTFC); er32(MGTPRC); er32(MGTPDC); er32(MGTPTC); er32(IAC); er32(ICRXOC); er32(ICRXPTC); er32(ICRXATC); er32(ICTXPTC); er32(ICTXATC); er32(ICTXQEC); er32(ICTXQMTC); er32(ICRXDMTC); } static const struct e1000_mac_operations e82571_mac_ops = { /* .check_mng_mode: mac type dependent */ /* .check_for_link: media type dependent */ .id_led_init = e1000e_id_led_init_generic, .cleanup_led = e1000e_cleanup_led_generic, .clear_hw_cntrs = e1000_clear_hw_cntrs_82571, .get_bus_info = e1000e_get_bus_info_pcie, .set_lan_id = e1000_set_lan_id_multi_port_pcie, /* .get_link_up_info: media type dependent */ /* .led_on: mac type dependent */ .led_off = e1000e_led_off_generic, .update_mc_addr_list = e1000e_update_mc_addr_list_generic, .write_vfta = e1000_write_vfta_generic, .clear_vfta = e1000_clear_vfta_82571, .reset_hw = e1000_reset_hw_82571, .init_hw = e1000_init_hw_82571, .setup_link = e1000_setup_link_82571, /* .setup_physical_interface: media type dependent */ .setup_led = e1000e_setup_led_generic, .config_collision_dist = e1000e_config_collision_dist_generic, .read_mac_addr = e1000_read_mac_addr_82571, }; static const struct e1000_phy_operations e82_phy_ops_igp = { .acquire = e1000_get_hw_semaphore_82571, .check_polarity = e1000_check_polarity_igp, .check_reset_block = e1000e_check_reset_block_generic, .commit = NULL, .force_speed_duplex = e1000e_phy_force_speed_duplex_igp, .get_cfg_done = e1000_get_cfg_done_82571, .get_cable_length = e1000e_get_cable_length_igp_2, .get_info = e1000e_get_phy_info_igp, .read_reg = e1000e_read_phy_reg_igp, .release = e1000_put_hw_semaphore_82571, .reset = e1000e_phy_hw_reset_generic, .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, .set_d3_lplu_state = e1000e_set_d3_lplu_state, .write_reg = e1000e_write_phy_reg_igp, .cfg_on_link_up = NULL, }; static const struct e1000_phy_operations e82_phy_ops_m88 = { .acquire = e1000_get_hw_semaphore_82571, .check_polarity = e1000_check_polarity_m88, .check_reset_block = e1000e_check_reset_block_generic, .commit = e1000e_phy_sw_reset, .force_speed_duplex = e1000e_phy_force_speed_duplex_m88, .get_cfg_done = e1000e_get_cfg_done, .get_cable_length = e1000e_get_cable_length_m88, .get_info = e1000e_get_phy_info_m88, .read_reg = e1000e_read_phy_reg_m88, .release = e1000_put_hw_semaphore_82571, .reset = e1000e_phy_hw_reset_generic, .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, .set_d3_lplu_state = e1000e_set_d3_lplu_state, .write_reg = e1000e_write_phy_reg_m88, .cfg_on_link_up = NULL, }; static const struct e1000_phy_operations e82_phy_ops_bm = { .acquire = e1000_get_hw_semaphore_82571, .check_polarity = e1000_check_polarity_m88, .check_reset_block = e1000e_check_reset_block_generic, .commit = e1000e_phy_sw_reset, .force_speed_duplex = e1000e_phy_force_speed_duplex_m88, .get_cfg_done = e1000e_get_cfg_done, .get_cable_length = e1000e_get_cable_length_m88, .get_info = e1000e_get_phy_info_m88, .read_reg = e1000e_read_phy_reg_bm2, .release = e1000_put_hw_semaphore_82571, .reset = e1000e_phy_hw_reset_generic, .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, .set_d3_lplu_state = e1000e_set_d3_lplu_state, .write_reg = e1000e_write_phy_reg_bm2, .cfg_on_link_up = NULL, }; static const struct e1000_nvm_operations e82571_nvm_ops = { .acquire = e1000_acquire_nvm_82571, .read = e1000e_read_nvm_eerd, .release = e1000_release_nvm_82571, .reload = e1000e_reload_nvm_generic, .update = e1000_update_nvm_checksum_82571, .valid_led_default = e1000_valid_led_default_82571, .validate = e1000_validate_nvm_checksum_82571, .write = e1000_write_nvm_82571, }; const struct e1000_info e1000_82571_info = { .mac = e1000_82571, .flags = FLAG_HAS_HW_VLAN_FILTER | FLAG_HAS_JUMBO_FRAMES | FLAG_HAS_WOL | FLAG_APME_IN_CTRL3 | FLAG_HAS_CTRLEXT_ON_LOAD | FLAG_HAS_SMART_POWER_DOWN | FLAG_RESET_OVERWRITES_LAA /* errata */ | FLAG_TARC_SPEED_MODE_BIT /* errata */ | FLAG_APME_CHECK_PORT_B, .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */ | FLAG2_DMA_BURST, .pba = 38, .max_hw_frame_size = DEFAULT_JUMBO, .get_variants = e1000_get_variants_82571, .mac_ops = &e82571_mac_ops, .phy_ops = &e82_phy_ops_igp, .nvm_ops = &e82571_nvm_ops, }; const struct e1000_info e1000_82572_info = { .mac = e1000_82572, .flags = FLAG_HAS_HW_VLAN_FILTER | FLAG_HAS_JUMBO_FRAMES | FLAG_HAS_WOL | FLAG_APME_IN_CTRL3 | FLAG_HAS_CTRLEXT_ON_LOAD | FLAG_TARC_SPEED_MODE_BIT, /* errata */ .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */ | FLAG2_DMA_BURST, .pba = 38, .max_hw_frame_size = DEFAULT_JUMBO, .get_variants = e1000_get_variants_82571, .mac_ops = &e82571_mac_ops, .phy_ops = &e82_phy_ops_igp, .nvm_ops = &e82571_nvm_ops, }; const struct e1000_info e1000_82573_info = { .mac = e1000_82573, .flags = FLAG_HAS_HW_VLAN_FILTER | FLAG_HAS_WOL | FLAG_APME_IN_CTRL3 | FLAG_HAS_SMART_POWER_DOWN | FLAG_HAS_AMT | FLAG_HAS_SWSM_ON_LOAD, .flags2 = FLAG2_DISABLE_ASPM_L1 | FLAG2_DISABLE_ASPM_L0S, .pba = 20, .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, .get_variants = e1000_get_variants_82571, .mac_ops = &e82571_mac_ops, .phy_ops = &e82_phy_ops_m88, .nvm_ops = &e82571_nvm_ops, }; const struct e1000_info e1000_82574_info = { .mac = e1000_82574, .flags = FLAG_HAS_HW_VLAN_FILTER | FLAG_HAS_MSIX | FLAG_HAS_JUMBO_FRAMES | FLAG_HAS_WOL | FLAG_APME_IN_CTRL3 | FLAG_HAS_SMART_POWER_DOWN | FLAG_HAS_AMT | FLAG_HAS_CTRLEXT_ON_LOAD, .flags2 = FLAG2_CHECK_PHY_HANG | FLAG2_DISABLE_ASPM_L0S | FLAG2_NO_DISABLE_RX, .pba = 32, .max_hw_frame_size = DEFAULT_JUMBO, .get_variants = e1000_get_variants_82571, .mac_ops = &e82571_mac_ops, .phy_ops = &e82_phy_ops_bm, .nvm_ops = &e82571_nvm_ops, }; const struct e1000_info e1000_82583_info = { .mac = e1000_82583, .flags = FLAG_HAS_HW_VLAN_FILTER | FLAG_HAS_WOL | FLAG_APME_IN_CTRL3 | FLAG_HAS_SMART_POWER_DOWN | FLAG_HAS_AMT | FLAG_HAS_JUMBO_FRAMES | FLAG_HAS_CTRLEXT_ON_LOAD, .flags2 = FLAG2_DISABLE_ASPM_L0S | FLAG2_NO_DISABLE_RX, .pba = 32, .max_hw_frame_size = DEFAULT_JUMBO, .get_variants = e1000_get_variants_82571, .mac_ops = &e82571_mac_ops, .phy_ops = &e82_phy_ops_bm, .nvm_ops = &e82571_nvm_ops, };
gpl-2.0
anryl/shooteru_HTC
arch/mips/sgi-ip27/ip27-timer.c
2747
5717
/* * Copytight (C) 1999, 2000, 05, 06 Ralf Baechle (ralf@linux-mips.org) * Copytight (C) 1999, 2000 Silicon Graphics, Inc. */ #include <linux/bcd.h> #include <linux/clockchips.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/interrupt.h> #include <linux/kernel_stat.h> #include <linux/param.h> #include <linux/smp.h> #include <linux/time.h> #include <linux/timex.h> #include <linux/mm.h> #include <linux/platform_device.h> #include <asm/time.h> #include <asm/pgtable.h> #include <asm/sgialib.h> #include <asm/sn/ioc3.h> #include <asm/sn/klconfig.h> #include <asm/sn/arch.h> #include <asm/sn/addrs.h> #include <asm/sn/sn_private.h> #include <asm/sn/sn0/ip27.h> #include <asm/sn/sn0/hub.h> #define TICK_SIZE (tick_nsec / 1000) /* Includes for ioc3_init(). */ #include <asm/sn/types.h> #include <asm/sn/sn0/addrs.h> #include <asm/sn/sn0/hubni.h> #include <asm/sn/sn0/hubio.h> #include <asm/pci/bridge.h> static void enable_rt_irq(struct irq_data *d) { } static void disable_rt_irq(struct irq_data *d) { } static struct irq_chip rt_irq_type = { .name = "SN HUB RT timer", .irq_mask = disable_rt_irq, .irq_unmask = enable_rt_irq, }; static int rt_next_event(unsigned long delta, struct clock_event_device *evt) { unsigned int cpu = smp_processor_id(); int slice = cputoslice(cpu); unsigned long cnt; cnt = LOCAL_HUB_L(PI_RT_COUNT); cnt += delta; LOCAL_HUB_S(PI_RT_COMPARE_A + PI_COUNT_OFFSET * slice, cnt); return LOCAL_HUB_L(PI_RT_COUNT) >= cnt ? -ETIME : 0; } static void rt_set_mode(enum clock_event_mode mode, struct clock_event_device *evt) { /* Nothing to do ... */ } int rt_timer_irq; static DEFINE_PER_CPU(struct clock_event_device, hub_rt_clockevent); static DEFINE_PER_CPU(char [11], hub_rt_name); static irqreturn_t hub_rt_counter_handler(int irq, void *dev_id) { unsigned int cpu = smp_processor_id(); struct clock_event_device *cd = &per_cpu(hub_rt_clockevent, cpu); int slice = cputoslice(cpu); /* * Ack */ LOCAL_HUB_S(PI_RT_PEND_A + PI_COUNT_OFFSET * slice, 0); cd->event_handler(cd); return IRQ_HANDLED; } struct irqaction hub_rt_irqaction = { .handler = hub_rt_counter_handler, .flags = IRQF_DISABLED | IRQF_PERCPU | IRQF_TIMER, .name = "hub-rt", }; /* * This is a hack; we really need to figure these values out dynamically * * Since 800 ns works very well with various HUB frequencies, such as * 360, 380, 390 and 400 MHZ, we use 800 ns rtc cycle time. * * Ralf: which clock rate is used to feed the counter? */ #define NSEC_PER_CYCLE 800 #define CYCLES_PER_SEC (NSEC_PER_SEC / NSEC_PER_CYCLE) void __cpuinit hub_rt_clock_event_init(void) { unsigned int cpu = smp_processor_id(); struct clock_event_device *cd = &per_cpu(hub_rt_clockevent, cpu); unsigned char *name = per_cpu(hub_rt_name, cpu); int irq = rt_timer_irq; sprintf(name, "hub-rt %d", cpu); cd->name = name; cd->features = CLOCK_EVT_FEAT_ONESHOT; clockevent_set_clock(cd, CYCLES_PER_SEC); cd->max_delta_ns = clockevent_delta2ns(0xfffffffffffff, cd); cd->min_delta_ns = clockevent_delta2ns(0x300, cd); cd->rating = 200; cd->irq = irq; cd->cpumask = cpumask_of(cpu); cd->set_next_event = rt_next_event; cd->set_mode = rt_set_mode; clockevents_register_device(cd); } static void __init hub_rt_clock_event_global_init(void) { int irq; do { smp_wmb(); irq = rt_timer_irq; if (irq) break; irq = allocate_irqno(); if (irq < 0) panic("Allocation of irq number for timer failed"); } while (xchg(&rt_timer_irq, irq)); irq_set_chip_and_handler(irq, &rt_irq_type, handle_percpu_irq); setup_irq(irq, &hub_rt_irqaction); } static cycle_t hub_rt_read(struct clocksource *cs) { return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT); } struct clocksource hub_rt_clocksource = { .name = "HUB-RT", .rating = 200, .read = hub_rt_read, .mask = CLOCKSOURCE_MASK(52), .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; static void __init hub_rt_clocksource_init(void) { struct clocksource *cs = &hub_rt_clocksource; clocksource_register_hz(cs, CYCLES_PER_SEC); } void __init plat_time_init(void) { hub_rt_clocksource_init(); hub_rt_clock_event_global_init(); hub_rt_clock_event_init(); } void __cpuinit cpu_time_init(void) { lboard_t *board; klcpu_t *cpu; int cpuid; /* Don't use ARCS. ARCS is fragile. Klconfig is simple and sane. */ board = find_lboard(KL_CONFIG_INFO(get_nasid()), KLTYPE_IP27); if (!board) panic("Can't find board info for myself."); cpuid = LOCAL_HUB_L(PI_CPU_NUM) ? IP27_CPU0_INDEX : IP27_CPU1_INDEX; cpu = (klcpu_t *) KLCF_COMP(board, cpuid); if (!cpu) panic("No information about myself?"); printk("CPU %d clock is %dMHz.\n", smp_processor_id(), cpu->cpu_speed); set_c0_status(SRB_TIMOCLK); } void __cpuinit hub_rtc_init(cnodeid_t cnode) { /* * We only need to initialize the current node. * If this is not the current node then it is a cpuless * node and timeouts will not happen there. */ if (get_compact_nodeid() == cnode) { LOCAL_HUB_S(PI_RT_EN_A, 1); LOCAL_HUB_S(PI_RT_EN_B, 1); LOCAL_HUB_S(PI_PROF_EN_A, 0); LOCAL_HUB_S(PI_PROF_EN_B, 0); LOCAL_HUB_S(PI_RT_COUNT, 0); LOCAL_HUB_S(PI_RT_PEND_A, 0); LOCAL_HUB_S(PI_RT_PEND_B, 0); } } static int __init sgi_ip27_rtc_devinit(void) { struct resource res; memset(&res, 0, sizeof(res)); res.start = XPHYSADDR(KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base + IOC3_BYTEBUS_DEV0); res.end = res.start + 32767; res.flags = IORESOURCE_MEM; return IS_ERR(platform_device_register_simple("rtc-m48t35", -1, &res, 1)); } /* * kludge make this a device_initcall after ioc3 resource conflicts * are resolved */ late_initcall(sgi_ip27_rtc_devinit);
gpl-2.0
whdgmawkd/android_kernel_lge_msm8974_kr
drivers/misc/bh1780gli.c
4795
6211
/* * bh1780gli.c * ROHM Ambient Light Sensor Driver * * Copyright (C) 2010 Texas Instruments * Author: Hemanth V <hemanthv@ti.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ #include <linux/i2c.h> #include <linux/slab.h> #include <linux/mutex.h> #include <linux/platform_device.h> #include <linux/delay.h> #include <linux/module.h> #define BH1780_REG_CONTROL 0x80 #define BH1780_REG_PARTID 0x8A #define BH1780_REG_MANFID 0x8B #define BH1780_REG_DLOW 0x8C #define BH1780_REG_DHIGH 0x8D #define BH1780_REVMASK (0xf) #define BH1780_POWMASK (0x3) #define BH1780_POFF (0x0) #define BH1780_PON (0x3) /* power on settling time in ms */ #define BH1780_PON_DELAY 2 struct bh1780_data { struct i2c_client *client; int power_state; /* lock for sysfs operations */ struct mutex lock; }; static int bh1780_write(struct bh1780_data *ddata, u8 reg, u8 val, char *msg) { int ret = i2c_smbus_write_byte_data(ddata->client, reg, val); if (ret < 0) dev_err(&ddata->client->dev, "i2c_smbus_write_byte_data failed error %d Register (%s)\n", ret, msg); return ret; } static int bh1780_read(struct bh1780_data *ddata, u8 reg, char *msg) { int ret = i2c_smbus_read_byte_data(ddata->client, reg); if (ret < 0) dev_err(&ddata->client->dev, "i2c_smbus_read_byte_data failed error %d Register (%s)\n", ret, msg); return ret; } static ssize_t bh1780_show_lux(struct device *dev, struct device_attribute *attr, char *buf) { struct platform_device *pdev = to_platform_device(dev); struct bh1780_data *ddata = platform_get_drvdata(pdev); int lsb, msb; lsb = bh1780_read(ddata, BH1780_REG_DLOW, "DLOW"); if (lsb < 0) return lsb; msb = bh1780_read(ddata, BH1780_REG_DHIGH, "DHIGH"); if (msb < 0) return msb; return sprintf(buf, "%d\n", (msb << 8) | lsb); } static ssize_t bh1780_show_power_state(struct device *dev, struct device_attribute *attr, char *buf) { struct platform_device *pdev = to_platform_device(dev); struct bh1780_data *ddata = platform_get_drvdata(pdev); int state; state = bh1780_read(ddata, BH1780_REG_CONTROL, "CONTROL"); if (state < 0) return state; return sprintf(buf, "%d\n", state & BH1780_POWMASK); } static ssize_t bh1780_store_power_state(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct platform_device *pdev = to_platform_device(dev); struct bh1780_data *ddata = platform_get_drvdata(pdev); unsigned long val; int error; error = strict_strtoul(buf, 0, &val); if (error) return error; if (val < BH1780_POFF || val > BH1780_PON) return -EINVAL; mutex_lock(&ddata->lock); error = bh1780_write(ddata, BH1780_REG_CONTROL, val, "CONTROL"); if (error < 0) { mutex_unlock(&ddata->lock); return error; } msleep(BH1780_PON_DELAY); ddata->power_state = val; mutex_unlock(&ddata->lock); return count; } static DEVICE_ATTR(lux, S_IRUGO, bh1780_show_lux, NULL); static DEVICE_ATTR(power_state, S_IWUSR | S_IRUGO, bh1780_show_power_state, bh1780_store_power_state); static struct attribute *bh1780_attributes[] = { &dev_attr_power_state.attr, &dev_attr_lux.attr, NULL }; static const struct attribute_group bh1780_attr_group = { .attrs = bh1780_attributes, }; static int __devinit bh1780_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; struct bh1780_data *ddata = NULL; struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) { ret = -EIO; goto err_op_failed; } ddata = kzalloc(sizeof(struct bh1780_data), GFP_KERNEL); if (ddata == NULL) { ret = -ENOMEM; goto err_op_failed; } ddata->client = client; i2c_set_clientdata(client, ddata); ret = bh1780_read(ddata, BH1780_REG_PARTID, "PART ID"); if (ret < 0) goto err_op_failed; dev_info(&client->dev, "Ambient Light Sensor, Rev : %d\n", (ret & BH1780_REVMASK)); mutex_init(&ddata->lock); ret = sysfs_create_group(&client->dev.kobj, &bh1780_attr_group); if (ret) goto err_op_failed; return 0; err_op_failed: kfree(ddata); return ret; } static int __devexit bh1780_remove(struct i2c_client *client) { struct bh1780_data *ddata; ddata = i2c_get_clientdata(client); sysfs_remove_group(&client->dev.kobj, &bh1780_attr_group); kfree(ddata); return 0; } #ifdef CONFIG_PM static int bh1780_suspend(struct device *dev) { struct bh1780_data *ddata; int state, ret; struct i2c_client *client = to_i2c_client(dev); ddata = i2c_get_clientdata(client); state = bh1780_read(ddata, BH1780_REG_CONTROL, "CONTROL"); if (state < 0) return state; ddata->power_state = state & BH1780_POWMASK; ret = bh1780_write(ddata, BH1780_REG_CONTROL, BH1780_POFF, "CONTROL"); if (ret < 0) return ret; return 0; } static int bh1780_resume(struct device *dev) { struct bh1780_data *ddata; int state, ret; struct i2c_client *client = to_i2c_client(dev); ddata = i2c_get_clientdata(client); state = ddata->power_state; ret = bh1780_write(ddata, BH1780_REG_CONTROL, state, "CONTROL"); if (ret < 0) return ret; return 0; } static SIMPLE_DEV_PM_OPS(bh1780_pm, bh1780_suspend, bh1780_resume); #define BH1780_PMOPS (&bh1780_pm) #else #define BH1780_PMOPS NULL #endif /* CONFIG_PM */ static const struct i2c_device_id bh1780_id[] = { { "bh1780", 0 }, { }, }; static struct i2c_driver bh1780_driver = { .probe = bh1780_probe, .remove = bh1780_remove, .id_table = bh1780_id, .driver = { .name = "bh1780", .pm = BH1780_PMOPS, }, }; module_i2c_driver(bh1780_driver); MODULE_DESCRIPTION("BH1780GLI Ambient Light Sensor Driver"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Hemanth V <hemanthv@ti.com>");
gpl-2.0
mcqaissi/galaxy-s3-kernel
sound/pci/au88x0/au88x0_xtalk.c
5051
23426
/*************************************************************************** * au88x0_cxtalk.c * * Wed Nov 19 16:29:47 2003 * Copyright 2003 mjander * mjander@users.sourceforge.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 Library 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 "au88x0_xtalk.h" /* Data (a whole lot of data.... ) */ static short const sXtalkWideKLeftEq = 0x269C; static short const sXtalkWideKRightEq = 0x269C; static short const sXtalkWideKLeftXt = 0xF25E; static short const sXtalkWideKRightXt = 0xF25E; static short const sXtalkWideShiftLeftEq = 1; static short const sXtalkWideShiftRightEq = 1; static short const sXtalkWideShiftLeftXt = 0; static short const sXtalkWideShiftRightXt = 0; static unsigned short const wXtalkWideLeftDelay = 0xd; static unsigned short const wXtalkWideRightDelay = 0xd; static short const sXtalkNarrowKLeftEq = 0x468D; static short const sXtalkNarrowKRightEq = 0x468D; static short const sXtalkNarrowKLeftXt = 0xF82E; static short const sXtalkNarrowKRightXt = 0xF82E; static short const sXtalkNarrowShiftLeftEq = 0x3; static short const sXtalkNarrowShiftRightEq = 0x3; static short const sXtalkNarrowShiftLeftXt = 0; static short const sXtalkNarrowShiftRightXt = 0; static unsigned short const wXtalkNarrowLeftDelay = 0x7; static unsigned short const wXtalkNarrowRightDelay = 0x7; static xtalk_gains_t const asXtalkGainsDefault = { 0x4000, 0x4000, 4000, 0x4000, 4000, 0x4000, 4000, 0x4000, 4000, 0x4000 }; static xtalk_gains_t const asXtalkGainsTest = { 0x8000, 0x7FFF, 0, 0xFFFF, 0x0001, 0xC000, 0x4000, 0xFFFE, 0x0002, 0 }; static xtalk_gains_t const asXtalkGains1Chan = { 0x7FFF, 0, 0, 0, 0x7FFF, 0, 0, 0, 0, 0 }; // Input gain for 4 A3D slices. One possible input pair is left zero. static xtalk_gains_t const asXtalkGainsAllChan = { 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0 //0x7FFF,0x7FFF,0x7FFF,0x7FFF,0x7fff,0x7FFF,0x7FFF,0x7FFF,0x7FFF,0x7fff }; static xtalk_gains_t const asXtalkGainsZeros; static xtalk_dline_t const alXtalkDlineZeros; static xtalk_dline_t const alXtalkDlineTest = { 0xFC18, 0x03E8FFFF, 0x186A0, 0x7960FFFE, 1, 0xFFFFFFFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static xtalk_instate_t const asXtalkInStateZeros; static xtalk_instate_t const asXtalkInStateTest = { 0xFF80, 0x0080, 0xFFFF, 0x0001 }; static xtalk_state_t const asXtalkOutStateZeros; static short const sDiamondKLeftEq = 0x401d; static short const sDiamondKRightEq = 0x401d; static short const sDiamondKLeftXt = 0xF90E; static short const sDiamondKRightXt = 0xF90E; static short const sDiamondShiftLeftEq = 1; /* 0xF90E Is this a bug ??? */ static short const sDiamondShiftRightEq = 1; static short const sDiamondShiftLeftXt = 0; static short const sDiamondShiftRightXt = 0; static unsigned short const wDiamondLeftDelay = 0xb; static unsigned short const wDiamondRightDelay = 0xb; static xtalk_coefs_t const asXtalkWideCoefsLeftEq = { {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0}, {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0}, {0x340B, 0xf504, 0x6CE8, 0x0D23, 0x00E4}, {0xD500, 0x8D76, 0xACC7, 0x5B05, 0x00FA}, {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0} }; static xtalk_coefs_t const asXtalkWideCoefsRightEq = { {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0}, {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0}, {0x340B, 0xF504, 0x6CE8, 0x0D23, 0x00E4}, {0xD500, 0x8D76, 0xACC7, 0x5B05, 0x00FA}, {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0} }; static xtalk_coefs_t const asXtalkWideCoefsLeftXt = { {0x86C3, 0x7B55, 0x89C3, 0x005B, 0x0047}, {0x6000, 0x206A, 0xC6CA, 0x40FF, 0}, {0x1100, 0x1164, 0xA1D7, 0x90FC, 0x0001}, {0xDC00, 0x9E77, 0xB8C7, 0x0AFF, 0}, {0, 0, 0, 0, 0} }; static xtalk_coefs_t const asXtalkWideCoefsRightXt = { {0x86C3, 0x7B55, 0x89C3, 0x005B, 0x0047}, {0x6000, 0x206A, 0xC6CA, 0x40FF, 0}, {0x1100, 0x1164, 0xA1D7, 0x90FC, 0x0001}, {0xDC00, 0x9E77, 0xB8C7, 0x0AFF, 0}, {0, 0, 0, 0, 0} }; static xtalk_coefs_t const asXtalkNarrowCoefsLeftEq = { {0x50B5, 0xD07C, 0x026D, 0xFD21, 0}, {0x460F, 0xE44F, 0xF75E, 0xEFA6, 0}, {0x556D, 0xDCAB, 0x2098, 0xF0F2, 0}, {0x7E03, 0xC1F0, 0x007D, 0xFF89, 0}, {0x383E, 0xFD9D, 0xB278, 0x4547, 0} }; static xtalk_coefs_t const asXtalkNarrowCoefsRightEq = { {0x50B5, 0xD07C, 0x026D, 0xFD21, 0}, {0x460F, 0xE44F, 0xF75E, 0xEFA6, 0}, {0x556D, 0xDCAB, 0x2098, 0xF0F2, 0}, {0x7E03, 0xC1F0, 0x007D, 0xFF89, 0}, {0x383E, 0xFD9D, 0xB278, 0x4547, 0} }; static xtalk_coefs_t const asXtalkNarrowCoefsLeftXt = { {0x3CB2, 0xDF49, 0xF6EA, 0x095B, 0}, {0x6777, 0xC915, 0xFEAF, 0x00B1, 0}, {0x7762, 0xC7D9, 0x025B, 0xFDA6, 0}, {0x6B7A, 0xD2AA, 0xF2FB, 0x0B64, 0}, {0, 0, 0, 0, 0} }; static xtalk_coefs_t const asXtalkNarrowCoefsRightXt = { {0x3CB2, 0xDF49, 0xF6EA, 0x095B, 0}, {0x6777, 0xC915, 0xFEAF, 0x00B1, 0}, {0x7762, 0xC7D9, 0x025B, 0xFDA6, 0}, {0x6B7A, 0xD2AA, 0xF2FB, 0x0B64, 0}, {0, 0, 0, 0, 0} }; static xtalk_coefs_t const asXtalkCoefsZeros; static xtalk_coefs_t const asXtalkCoefsPipe = { {0, 0, 0x0FA0, 0, 0}, {0, 0, 0x0FA0, 0, 0}, {0, 0, 0x0FA0, 0, 0}, {0, 0, 0x0FA0, 0, 0}, {0, 0, 0x1180, 0, 0}, }; static xtalk_coefs_t const asXtalkCoefsNegPipe = { {0, 0, 0xF380, 0, 0}, {0, 0, 0xF380, 0, 0}, {0, 0, 0xF380, 0, 0}, {0, 0, 0xF380, 0, 0}, {0, 0, 0xF200, 0, 0} }; static xtalk_coefs_t const asXtalkCoefsNumTest = { {0, 0, 0xF380, 0x8000, 0x6D60}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }; static xtalk_coefs_t const asXtalkCoefsDenTest = { {0xC000, 0x2000, 0x4000, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }; static xtalk_state_t const asXtalkOutStateTest = { {0x7FFF, 0x0004, 0xFFFC, 0}, {0xFE00, 0x0008, 0xFFF8, 0x4000}, {0x200, 0x0010, 0xFFF0, 0xC000}, {0x8000, 0x0020, 0xFFE0, 0}, {0, 0, 0, 0} }; static xtalk_coefs_t const asDiamondCoefsLeftEq = { {0x0F1E, 0x2D05, 0xF8E3, 0x07C8, 0}, {0x45E2, 0xCA51, 0x0448, 0xFCE7, 0}, {0xA93E, 0xDBD5, 0x022C, 0x028A, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }; static xtalk_coefs_t const asDiamondCoefsRightEq = { {0x0F1E, 0x2D05, 0xF8E3, 0x07C8, 0}, {0x45E2, 0xCA51, 0x0448, 0xFCE7, 0}, {0xA93E, 0xDBD5, 0x022C, 0x028A, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }; static xtalk_coefs_t const asDiamondCoefsLeftXt = { {0x3B50, 0xFE08, 0xF959, 0x0060, 0}, {0x9FCB, 0xD8F1, 0x00A2, 0x003A, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }; static xtalk_coefs_t const asDiamondCoefsRightXt = { {0x3B50, 0xFE08, 0xF959, 0x0060, 0}, {0x9FCB, 0xD8F1, 0x00A2, 0x003A, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }; /**/ /* XTalk EQ and XT */ static void vortex_XtalkHw_SetLeftEQ(vortex_t * vortex, short arg_0, short arg_4, xtalk_coefs_t const coefs) { int i; for (i = 0; i < 5; i++) { hwwrite(vortex->mmio, 0x24200 + i * 0x24, coefs[i][0]); hwwrite(vortex->mmio, 0x24204 + i * 0x24, coefs[i][1]); hwwrite(vortex->mmio, 0x24208 + i * 0x24, coefs[i][2]); hwwrite(vortex->mmio, 0x2420c + i * 0x24, coefs[i][3]); hwwrite(vortex->mmio, 0x24210 + i * 0x24, coefs[i][4]); } hwwrite(vortex->mmio, 0x24538, arg_0 & 0xffff); hwwrite(vortex->mmio, 0x2453C, arg_4 & 0xffff); } static void vortex_XtalkHw_SetRightEQ(vortex_t * vortex, short arg_0, short arg_4, xtalk_coefs_t const coefs) { int i; for (i = 0; i < 5; i++) { hwwrite(vortex->mmio, 0x242b4 + i * 0x24, coefs[i][0]); hwwrite(vortex->mmio, 0x242b8 + i * 0x24, coefs[i][1]); hwwrite(vortex->mmio, 0x242bc + i * 0x24, coefs[i][2]); hwwrite(vortex->mmio, 0x242c0 + i * 0x24, coefs[i][3]); hwwrite(vortex->mmio, 0x242c4 + i * 0x24, coefs[i][4]); } hwwrite(vortex->mmio, 0x24540, arg_0 & 0xffff); hwwrite(vortex->mmio, 0x24544, arg_4 & 0xffff); } static void vortex_XtalkHw_SetLeftXT(vortex_t * vortex, short arg_0, short arg_4, xtalk_coefs_t const coefs) { int i; for (i = 0; i < 5; i++) { hwwrite(vortex->mmio, 0x24368 + i * 0x24, coefs[i][0]); hwwrite(vortex->mmio, 0x2436c + i * 0x24, coefs[i][1]); hwwrite(vortex->mmio, 0x24370 + i * 0x24, coefs[i][2]); hwwrite(vortex->mmio, 0x24374 + i * 0x24, coefs[i][3]); hwwrite(vortex->mmio, 0x24378 + i * 0x24, coefs[i][4]); } hwwrite(vortex->mmio, 0x24548, arg_0 & 0xffff); hwwrite(vortex->mmio, 0x2454C, arg_4 & 0xffff); } static void vortex_XtalkHw_SetRightXT(vortex_t * vortex, short arg_0, short arg_4, xtalk_coefs_t const coefs) { int i; for (i = 0; i < 5; i++) { hwwrite(vortex->mmio, 0x2441C + i * 0x24, coefs[i][0]); hwwrite(vortex->mmio, 0x24420 + i * 0x24, coefs[i][1]); hwwrite(vortex->mmio, 0x24424 + i * 0x24, coefs[i][2]); hwwrite(vortex->mmio, 0x24428 + i * 0x24, coefs[i][3]); hwwrite(vortex->mmio, 0x2442C + i * 0x24, coefs[i][4]); } hwwrite(vortex->mmio, 0x24550, arg_0 & 0xffff); hwwrite(vortex->mmio, 0x24554, arg_4 & 0xffff); } static void vortex_XtalkHw_SetLeftEQStates(vortex_t * vortex, xtalk_instate_t const arg_0, xtalk_state_t const coefs) { int i; for (i = 0; i < 5; i++) { hwwrite(vortex->mmio, 0x24214 + i * 0x24, coefs[i][0]); hwwrite(vortex->mmio, 0x24218 + i * 0x24, coefs[i][1]); hwwrite(vortex->mmio, 0x2421C + i * 0x24, coefs[i][2]); hwwrite(vortex->mmio, 0x24220 + i * 0x24, coefs[i][3]); } hwwrite(vortex->mmio, 0x244F8 + i * 0x24, arg_0[0]); hwwrite(vortex->mmio, 0x244FC + i * 0x24, arg_0[1]); hwwrite(vortex->mmio, 0x24500 + i * 0x24, arg_0[2]); hwwrite(vortex->mmio, 0x24504 + i * 0x24, arg_0[3]); } static void vortex_XtalkHw_SetRightEQStates(vortex_t * vortex, xtalk_instate_t const arg_0, xtalk_state_t const coefs) { int i; for (i = 0; i < 5; i++) { hwwrite(vortex->mmio, 0x242C8 + i * 0x24, coefs[i][0]); hwwrite(vortex->mmio, 0x242CC + i * 0x24, coefs[i][1]); hwwrite(vortex->mmio, 0x242D0 + i * 0x24, coefs[i][2]); hwwrite(vortex->mmio, 0x244D4 + i * 0x24, coefs[i][3]); } hwwrite(vortex->mmio, 0x24508 + i * 0x24, arg_0[0]); hwwrite(vortex->mmio, 0x2450C + i * 0x24, arg_0[1]); hwwrite(vortex->mmio, 0x24510 + i * 0x24, arg_0[2]); hwwrite(vortex->mmio, 0x24514 + i * 0x24, arg_0[3]); } static void vortex_XtalkHw_SetLeftXTStates(vortex_t * vortex, xtalk_instate_t const arg_0, xtalk_state_t const coefs) { int i; for (i = 0; i < 5; i++) { hwwrite(vortex->mmio, 0x2437C + i * 0x24, coefs[i][0]); hwwrite(vortex->mmio, 0x24380 + i * 0x24, coefs[i][1]); hwwrite(vortex->mmio, 0x24384 + i * 0x24, coefs[i][2]); hwwrite(vortex->mmio, 0x24388 + i * 0x24, coefs[i][3]); } hwwrite(vortex->mmio, 0x24518 + i * 0x24, arg_0[0]); hwwrite(vortex->mmio, 0x2451C + i * 0x24, arg_0[1]); hwwrite(vortex->mmio, 0x24520 + i * 0x24, arg_0[2]); hwwrite(vortex->mmio, 0x24524 + i * 0x24, arg_0[3]); } static void vortex_XtalkHw_SetRightXTStates(vortex_t * vortex, xtalk_instate_t const arg_0, xtalk_state_t const coefs) { int i; for (i = 0; i < 5; i++) { hwwrite(vortex->mmio, 0x24430 + i * 0x24, coefs[i][0]); hwwrite(vortex->mmio, 0x24434 + i * 0x24, coefs[i][1]); hwwrite(vortex->mmio, 0x24438 + i * 0x24, coefs[i][2]); hwwrite(vortex->mmio, 0x2443C + i * 0x24, coefs[i][3]); } hwwrite(vortex->mmio, 0x24528 + i * 0x24, arg_0[0]); hwwrite(vortex->mmio, 0x2452C + i * 0x24, arg_0[1]); hwwrite(vortex->mmio, 0x24530 + i * 0x24, arg_0[2]); hwwrite(vortex->mmio, 0x24534 + i * 0x24, arg_0[3]); } #if 0 static void vortex_XtalkHw_GetLeftEQ(vortex_t * vortex, short *arg_0, short *arg_4, xtalk_coefs_t coefs) { int i; for (i = 0; i < 5; i++) { coefs[i][0] = hwread(vortex->mmio, 0x24200 + i * 0x24); coefs[i][1] = hwread(vortex->mmio, 0x24204 + i * 0x24); coefs[i][2] = hwread(vortex->mmio, 0x24208 + i * 0x24); coefs[i][3] = hwread(vortex->mmio, 0x2420c + i * 0x24); coefs[i][4] = hwread(vortex->mmio, 0x24210 + i * 0x24); } *arg_0 = hwread(vortex->mmio, 0x24538) & 0xffff; *arg_4 = hwread(vortex->mmio, 0x2453c) & 0xffff; } static void vortex_XtalkHw_GetRightEQ(vortex_t * vortex, short *arg_0, short *arg_4, xtalk_coefs_t coefs) { int i; for (i = 0; i < 5; i++) { coefs[i][0] = hwread(vortex->mmio, 0x242b4 + i * 0x24); coefs[i][1] = hwread(vortex->mmio, 0x242b8 + i * 0x24); coefs[i][2] = hwread(vortex->mmio, 0x242bc + i * 0x24); coefs[i][3] = hwread(vortex->mmio, 0x242c0 + i * 0x24); coefs[i][4] = hwread(vortex->mmio, 0x242c4 + i * 0x24); } *arg_0 = hwread(vortex->mmio, 0x24540) & 0xffff; *arg_4 = hwread(vortex->mmio, 0x24544) & 0xffff; } static void vortex_XtalkHw_GetLeftXT(vortex_t * vortex, short *arg_0, short *arg_4, xtalk_coefs_t coefs) { int i; for (i = 0; i < 5; i++) { coefs[i][0] = hwread(vortex->mmio, 0x24368 + i * 0x24); coefs[i][1] = hwread(vortex->mmio, 0x2436C + i * 0x24); coefs[i][2] = hwread(vortex->mmio, 0x24370 + i * 0x24); coefs[i][3] = hwread(vortex->mmio, 0x24374 + i * 0x24); coefs[i][4] = hwread(vortex->mmio, 0x24378 + i * 0x24); } *arg_0 = hwread(vortex->mmio, 0x24548) & 0xffff; *arg_4 = hwread(vortex->mmio, 0x2454C) & 0xffff; } static void vortex_XtalkHw_GetRightXT(vortex_t * vortex, short *arg_0, short *arg_4, xtalk_coefs_t coefs) { int i; for (i = 0; i < 5; i++) { coefs[i][0] = hwread(vortex->mmio, 0x2441C + i * 0x24); coefs[i][1] = hwread(vortex->mmio, 0x24420 + i * 0x24); coefs[i][2] = hwread(vortex->mmio, 0x24424 + i * 0x24); coefs[i][3] = hwread(vortex->mmio, 0x24428 + i * 0x24); coefs[i][4] = hwread(vortex->mmio, 0x2442C + i * 0x24); } *arg_0 = hwread(vortex->mmio, 0x24550) & 0xffff; *arg_4 = hwread(vortex->mmio, 0x24554) & 0xffff; } static void vortex_XtalkHw_GetLeftEQStates(vortex_t * vortex, xtalk_instate_t arg_0, xtalk_state_t coefs) { int i; for (i = 0; i < 5; i++) { coefs[i][0] = hwread(vortex->mmio, 0x24214 + i * 0x24); coefs[i][1] = hwread(vortex->mmio, 0x24218 + i * 0x24); coefs[i][2] = hwread(vortex->mmio, 0x2421C + i * 0x24); coefs[i][3] = hwread(vortex->mmio, 0x24220 + i * 0x24); } arg_0[0] = hwread(vortex->mmio, 0x244F8 + i * 0x24); arg_0[1] = hwread(vortex->mmio, 0x244FC + i * 0x24); arg_0[2] = hwread(vortex->mmio, 0x24500 + i * 0x24); arg_0[3] = hwread(vortex->mmio, 0x24504 + i * 0x24); } static void vortex_XtalkHw_GetRightEQStates(vortex_t * vortex, xtalk_instate_t arg_0, xtalk_state_t coefs) { int i; for (i = 0; i < 5; i++) { coefs[i][0] = hwread(vortex->mmio, 0x242C8 + i * 0x24); coefs[i][1] = hwread(vortex->mmio, 0x242CC + i * 0x24); coefs[i][2] = hwread(vortex->mmio, 0x242D0 + i * 0x24); coefs[i][3] = hwread(vortex->mmio, 0x242D4 + i * 0x24); } arg_0[0] = hwread(vortex->mmio, 0x24508 + i * 0x24); arg_0[1] = hwread(vortex->mmio, 0x2450C + i * 0x24); arg_0[2] = hwread(vortex->mmio, 0x24510 + i * 0x24); arg_0[3] = hwread(vortex->mmio, 0x24514 + i * 0x24); } static void vortex_XtalkHw_GetLeftXTStates(vortex_t * vortex, xtalk_instate_t arg_0, xtalk_state_t coefs) { int i; for (i = 0; i < 5; i++) { coefs[i][0] = hwread(vortex->mmio, 0x2437C + i * 0x24); coefs[i][1] = hwread(vortex->mmio, 0x24380 + i * 0x24); coefs[i][2] = hwread(vortex->mmio, 0x24384 + i * 0x24); coefs[i][3] = hwread(vortex->mmio, 0x24388 + i * 0x24); } arg_0[0] = hwread(vortex->mmio, 0x24518 + i * 0x24); arg_0[1] = hwread(vortex->mmio, 0x2451C + i * 0x24); arg_0[2] = hwread(vortex->mmio, 0x24520 + i * 0x24); arg_0[3] = hwread(vortex->mmio, 0x24524 + i * 0x24); } static void vortex_XtalkHw_GetRightXTStates(vortex_t * vortex, xtalk_instate_t arg_0, xtalk_state_t coefs) { int i; for (i = 0; i < 5; i++) { coefs[i][0] = hwread(vortex->mmio, 0x24430 + i * 0x24); coefs[i][1] = hwread(vortex->mmio, 0x24434 + i * 0x24); coefs[i][2] = hwread(vortex->mmio, 0x24438 + i * 0x24); coefs[i][3] = hwread(vortex->mmio, 0x2443C + i * 0x24); } arg_0[0] = hwread(vortex->mmio, 0x24528 + i * 0x24); arg_0[1] = hwread(vortex->mmio, 0x2452C + i * 0x24); arg_0[2] = hwread(vortex->mmio, 0x24530 + i * 0x24); arg_0[3] = hwread(vortex->mmio, 0x24534 + i * 0x24); } #endif /* Gains */ static void vortex_XtalkHw_SetGains(vortex_t * vortex, xtalk_gains_t const gains) { int i; for (i = 0; i < XTGAINS_SZ; i++) { hwwrite(vortex->mmio, 0x244D0 + (i * 4), gains[i]); } } static void vortex_XtalkHw_SetGainsAllChan(vortex_t * vortex) { vortex_XtalkHw_SetGains(vortex, asXtalkGainsAllChan); } #if 0 static void vortex_XtalkHw_GetGains(vortex_t * vortex, xtalk_gains_t gains) { int i; for (i = 0; i < XTGAINS_SZ; i++) gains[i] = hwread(vortex->mmio, 0x244D0 + i * 4); } #endif /* Delay parameters */ static void vortex_XtalkHw_SetDelay(vortex_t * vortex, unsigned short right, unsigned short left) { u32 esp0 = 0; esp0 &= 0x1FFFFFFF; esp0 |= 0xA0000000; esp0 = (esp0 & 0xffffE0ff) | ((right & 0x1F) << 8); esp0 = (esp0 & 0xfffc1fff) | ((left & 0x1F) << 0xd); hwwrite(vortex->mmio, 0x24660, esp0); } static void vortex_XtalkHw_SetLeftDline(vortex_t * vortex, xtalk_dline_t const dline) { int i; for (i = 0; i < 0x20; i++) { hwwrite(vortex->mmio, 0x24000 + (i << 2), dline[i] & 0xffff); hwwrite(vortex->mmio, 0x24080 + (i << 2), dline[i] >> 0x10); } } static void vortex_XtalkHw_SetRightDline(vortex_t * vortex, xtalk_dline_t const dline) { int i; for (i = 0; i < 0x20; i++) { hwwrite(vortex->mmio, 0x24100 + (i << 2), dline[i] & 0xffff); hwwrite(vortex->mmio, 0x24180 + (i << 2), dline[i] >> 0x10); } } #if 0 static void vortex_XtalkHw_GetDelay(vortex_t * vortex, unsigned short *right, unsigned short *left) { int esp0; esp0 = hwread(vortex->mmio, 0x24660); *right = (esp0 >> 8) & 0x1f; *left = (esp0 >> 0xd) & 0x1f; } static void vortex_XtalkHw_GetLeftDline(vortex_t * vortex, xtalk_dline_t dline) { int i; for (i = 0; i < 0x20; i++) { dline[i] = (hwread(vortex->mmio, 0x24000 + (i << 2)) & 0xffff) | (hwread(vortex->mmio, 0x24080 + (i << 2)) << 0x10); } } static void vortex_XtalkHw_GetRightDline(vortex_t * vortex, xtalk_dline_t dline) { int i; for (i = 0; i < 0x20; i++) { dline[i] = (hwread(vortex->mmio, 0x24100 + (i << 2)) & 0xffff) | (hwread(vortex->mmio, 0x24180 + (i << 2)) << 0x10); } } #endif /* Control/Global stuff */ #if 0 static void vortex_XtalkHw_SetControlReg(vortex_t * vortex, u32 ctrl) { hwwrite(vortex->mmio, 0x24660, ctrl); } static void vortex_XtalkHw_GetControlReg(vortex_t * vortex, u32 *ctrl) { *ctrl = hwread(vortex->mmio, 0x24660); } #endif static void vortex_XtalkHw_SetSampleRate(vortex_t * vortex, u32 sr) { u32 temp; temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000; temp = (temp & 0xffffff07) | ((sr & 0x1f) << 3); hwwrite(vortex->mmio, 0x24660, temp); } #if 0 static void vortex_XtalkHw_GetSampleRate(vortex_t * vortex, u32 *sr) { *sr = (hwread(vortex->mmio, 0x24660) >> 3) & 0x1f; } #endif static void vortex_XtalkHw_Enable(vortex_t * vortex) { u32 temp; temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000; temp |= 1; hwwrite(vortex->mmio, 0x24660, temp); } static void vortex_XtalkHw_Disable(vortex_t * vortex) { u32 temp; temp = (hwread(vortex->mmio, 0x24660) & 0x1FFFFFFF) | 0xC0000000; temp &= 0xfffffffe; hwwrite(vortex->mmio, 0x24660, temp); } static void vortex_XtalkHw_ZeroIO(vortex_t * vortex) { int i; for (i = 0; i < 20; i++) hwwrite(vortex->mmio, 0x24600 + (i << 2), 0); for (i = 0; i < 4; i++) hwwrite(vortex->mmio, 0x24650 + (i << 2), 0); } static void vortex_XtalkHw_ZeroState(vortex_t * vortex) { vortex_XtalkHw_ZeroIO(vortex); // inlined vortex_XtalkHw_SetLeftEQ(vortex, 0, 0, asXtalkCoefsZeros); vortex_XtalkHw_SetRightEQ(vortex, 0, 0, asXtalkCoefsZeros); vortex_XtalkHw_SetLeftXT(vortex, 0, 0, asXtalkCoefsZeros); vortex_XtalkHw_SetRightXT(vortex, 0, 0, asXtalkCoefsZeros); vortex_XtalkHw_SetGains(vortex, asXtalkGainsZeros); // inlined vortex_XtalkHw_SetDelay(vortex, 0, 0); // inlined vortex_XtalkHw_SetLeftDline(vortex, alXtalkDlineZeros); // inlined vortex_XtalkHw_SetRightDline(vortex, alXtalkDlineZeros); // inlined vortex_XtalkHw_SetLeftDline(vortex, alXtalkDlineZeros); // inlined vortex_XtalkHw_SetRightDline(vortex, alXtalkDlineZeros); // inlined vortex_XtalkHw_SetLeftEQStates(vortex, asXtalkInStateZeros, asXtalkOutStateZeros); vortex_XtalkHw_SetRightEQStates(vortex, asXtalkInStateZeros, asXtalkOutStateZeros); vortex_XtalkHw_SetLeftXTStates(vortex, asXtalkInStateZeros, asXtalkOutStateZeros); vortex_XtalkHw_SetRightXTStates(vortex, asXtalkInStateZeros, asXtalkOutStateZeros); } static void vortex_XtalkHw_ProgramPipe(vortex_t * vortex) { vortex_XtalkHw_SetLeftEQ(vortex, 0, 1, asXtalkCoefsPipe); vortex_XtalkHw_SetRightEQ(vortex, 0, 1, asXtalkCoefsPipe); vortex_XtalkHw_SetLeftXT(vortex, 0, 0, asXtalkCoefsZeros); vortex_XtalkHw_SetRightXT(vortex, 0, 0, asXtalkCoefsZeros); vortex_XtalkHw_SetDelay(vortex, 0, 0); // inlined } static void vortex_XtalkHw_ProgramXtalkWide(vortex_t * vortex) { vortex_XtalkHw_SetLeftEQ(vortex, sXtalkWideKLeftEq, sXtalkWideShiftLeftEq, asXtalkWideCoefsLeftEq); vortex_XtalkHw_SetRightEQ(vortex, sXtalkWideKRightEq, sXtalkWideShiftRightEq, asXtalkWideCoefsRightEq); vortex_XtalkHw_SetLeftXT(vortex, sXtalkWideKLeftXt, sXtalkWideShiftLeftXt, asXtalkWideCoefsLeftXt); vortex_XtalkHw_SetRightXT(vortex, sXtalkWideKLeftXt, sXtalkWideShiftLeftXt, asXtalkWideCoefsLeftXt); vortex_XtalkHw_SetDelay(vortex, wXtalkWideRightDelay, wXtalkWideLeftDelay); // inlined } static void vortex_XtalkHw_ProgramXtalkNarrow(vortex_t * vortex) { vortex_XtalkHw_SetLeftEQ(vortex, sXtalkNarrowKLeftEq, sXtalkNarrowShiftLeftEq, asXtalkNarrowCoefsLeftEq); vortex_XtalkHw_SetRightEQ(vortex, sXtalkNarrowKRightEq, sXtalkNarrowShiftRightEq, asXtalkNarrowCoefsRightEq); vortex_XtalkHw_SetLeftXT(vortex, sXtalkNarrowKLeftXt, sXtalkNarrowShiftLeftXt, asXtalkNarrowCoefsLeftXt); vortex_XtalkHw_SetRightXT(vortex, sXtalkNarrowKLeftXt, sXtalkNarrowShiftLeftXt, asXtalkNarrowCoefsLeftXt); vortex_XtalkHw_SetDelay(vortex, wXtalkNarrowRightDelay, wXtalkNarrowLeftDelay); // inlined } static void vortex_XtalkHw_ProgramDiamondXtalk(vortex_t * vortex) { //sDiamondKLeftEq,sDiamondKRightXt,asDiamondCoefsLeftEq vortex_XtalkHw_SetLeftEQ(vortex, sDiamondKLeftEq, sDiamondShiftLeftEq, asDiamondCoefsLeftEq); vortex_XtalkHw_SetRightEQ(vortex, sDiamondKRightEq, sDiamondShiftRightEq, asDiamondCoefsRightEq); vortex_XtalkHw_SetLeftXT(vortex, sDiamondKLeftXt, sDiamondShiftLeftXt, asDiamondCoefsLeftXt); vortex_XtalkHw_SetRightXT(vortex, sDiamondKLeftXt, sDiamondShiftLeftXt, asDiamondCoefsLeftXt); vortex_XtalkHw_SetDelay(vortex, wDiamondRightDelay, wDiamondLeftDelay); // inlined } static void vortex_XtalkHw_init(vortex_t * vortex) { vortex_XtalkHw_ZeroState(vortex); } /* End of file */
gpl-2.0
playfulgod/kernel_lge_dory
arch/powerpc/sysdev/fsl_rmu.c
6843
29584
/* * Freescale MPC85xx/MPC86xx RapidIO RMU support * * Copyright 2009 Sysgo AG * Thomas Moll <thomas.moll@sysgo.com> * - fixed maintenance access routines, check for aligned access * * Copyright 2009 Integrated Device Technology, Inc. * Alex Bounine <alexandre.bounine@idt.com> * - Added Port-Write message handling * - Added Machine Check exception handling * * Copyright (C) 2007, 2008, 2010, 2011 Freescale Semiconductor, Inc. * Zhang Wei <wei.zhang@freescale.com> * Lian Minghuan-B31939 <Minghuan.Lian@freescale.com> * Liu Gang <Gang.Liu@freescale.com> * * Copyright 2005 MontaVista Software, Inc. * Matt Porter <mporter@kernel.crashing.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. */ #include <linux/types.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/of_platform.h> #include <linux/slab.h> #include "fsl_rio.h" #define GET_RMM_HANDLE(mport) \ (((struct rio_priv *)(mport->priv))->rmm_handle) /* RapidIO definition irq, which read from OF-tree */ #define IRQ_RIO_PW(m) (((struct fsl_rio_pw *)(m))->pwirq) #define IRQ_RIO_BELL(m) (((struct fsl_rio_dbell *)(m))->bellirq) #define IRQ_RIO_TX(m) (((struct fsl_rmu *)(GET_RMM_HANDLE(m)))->txirq) #define IRQ_RIO_RX(m) (((struct fsl_rmu *)(GET_RMM_HANDLE(m)))->rxirq) #define RIO_MIN_TX_RING_SIZE 2 #define RIO_MAX_TX_RING_SIZE 2048 #define RIO_MIN_RX_RING_SIZE 2 #define RIO_MAX_RX_RING_SIZE 2048 #define RIO_IPWMR_SEN 0x00100000 #define RIO_IPWMR_QFIE 0x00000100 #define RIO_IPWMR_EIE 0x00000020 #define RIO_IPWMR_CQ 0x00000002 #define RIO_IPWMR_PWE 0x00000001 #define RIO_IPWSR_QF 0x00100000 #define RIO_IPWSR_TE 0x00000080 #define RIO_IPWSR_QFI 0x00000010 #define RIO_IPWSR_PWD 0x00000008 #define RIO_IPWSR_PWB 0x00000004 #define RIO_EPWISR 0x10010 /* EPWISR Error match value */ #define RIO_EPWISR_PINT1 0x80000000 #define RIO_EPWISR_PINT2 0x40000000 #define RIO_EPWISR_MU 0x00000002 #define RIO_EPWISR_PW 0x00000001 #define IPWSR_CLEAR 0x98 #define OMSR_CLEAR 0x1cb3 #define IMSR_CLEAR 0x491 #define IDSR_CLEAR 0x91 #define ODSR_CLEAR 0x1c00 #define LTLEECSR_ENABLE_ALL 0xFFC000FC #define RIO_LTLEECSR 0x060c #define RIO_IM0SR 0x64 #define RIO_IM1SR 0x164 #define RIO_OM0SR 0x4 #define RIO_OM1SR 0x104 #define RIO_DBELL_WIN_SIZE 0x1000 #define RIO_MSG_OMR_MUI 0x00000002 #define RIO_MSG_OSR_TE 0x00000080 #define RIO_MSG_OSR_QOI 0x00000020 #define RIO_MSG_OSR_QFI 0x00000010 #define RIO_MSG_OSR_MUB 0x00000004 #define RIO_MSG_OSR_EOMI 0x00000002 #define RIO_MSG_OSR_QEI 0x00000001 #define RIO_MSG_IMR_MI 0x00000002 #define RIO_MSG_ISR_TE 0x00000080 #define RIO_MSG_ISR_QFI 0x00000010 #define RIO_MSG_ISR_DIQI 0x00000001 #define RIO_MSG_DESC_SIZE 32 #define RIO_MSG_BUFFER_SIZE 4096 #define DOORBELL_DMR_DI 0x00000002 #define DOORBELL_DSR_TE 0x00000080 #define DOORBELL_DSR_QFI 0x00000010 #define DOORBELL_DSR_DIQI 0x00000001 #define DOORBELL_MESSAGE_SIZE 0x08 struct rio_msg_regs { u32 omr; u32 osr; u32 pad1; u32 odqdpar; u32 pad2; u32 osar; u32 odpr; u32 odatr; u32 odcr; u32 pad3; u32 odqepar; u32 pad4[13]; u32 imr; u32 isr; u32 pad5; u32 ifqdpar; u32 pad6; u32 ifqepar; }; struct rio_dbell_regs { u32 odmr; u32 odsr; u32 pad1[4]; u32 oddpr; u32 oddatr; u32 pad2[3]; u32 odretcr; u32 pad3[12]; u32 dmr; u32 dsr; u32 pad4; u32 dqdpar; u32 pad5; u32 dqepar; }; struct rio_pw_regs { u32 pwmr; u32 pwsr; u32 epwqbar; u32 pwqbar; }; struct rio_tx_desc { u32 pad1; u32 saddr; u32 dport; u32 dattr; u32 pad2; u32 pad3; u32 dwcnt; u32 pad4; }; struct rio_msg_tx_ring { void *virt; dma_addr_t phys; void *virt_buffer[RIO_MAX_TX_RING_SIZE]; dma_addr_t phys_buffer[RIO_MAX_TX_RING_SIZE]; int tx_slot; int size; void *dev_id; }; struct rio_msg_rx_ring { void *virt; dma_addr_t phys; void *virt_buffer[RIO_MAX_RX_RING_SIZE]; int rx_slot; int size; void *dev_id; }; struct fsl_rmu { struct rio_msg_regs __iomem *msg_regs; struct rio_msg_tx_ring msg_tx_ring; struct rio_msg_rx_ring msg_rx_ring; int txirq; int rxirq; }; struct rio_dbell_msg { u16 pad1; u16 tid; u16 sid; u16 info; }; /** * fsl_rio_tx_handler - MPC85xx outbound message interrupt handler * @irq: Linux interrupt number * @dev_instance: Pointer to interrupt-specific data * * Handles outbound message interrupts. Executes a register outbound * mailbox event handler and acks the interrupt occurrence. */ static irqreturn_t fsl_rio_tx_handler(int irq, void *dev_instance) { int osr; struct rio_mport *port = (struct rio_mport *)dev_instance; struct fsl_rmu *rmu = GET_RMM_HANDLE(port); osr = in_be32(&rmu->msg_regs->osr); if (osr & RIO_MSG_OSR_TE) { pr_info("RIO: outbound message transmission error\n"); out_be32(&rmu->msg_regs->osr, RIO_MSG_OSR_TE); goto out; } if (osr & RIO_MSG_OSR_QOI) { pr_info("RIO: outbound message queue overflow\n"); out_be32(&rmu->msg_regs->osr, RIO_MSG_OSR_QOI); goto out; } if (osr & RIO_MSG_OSR_EOMI) { u32 dqp = in_be32(&rmu->msg_regs->odqdpar); int slot = (dqp - rmu->msg_tx_ring.phys) >> 5; if (port->outb_msg[0].mcback != NULL) { port->outb_msg[0].mcback(port, rmu->msg_tx_ring.dev_id, -1, slot); } /* Ack the end-of-message interrupt */ out_be32(&rmu->msg_regs->osr, RIO_MSG_OSR_EOMI); } out: return IRQ_HANDLED; } /** * fsl_rio_rx_handler - MPC85xx inbound message interrupt handler * @irq: Linux interrupt number * @dev_instance: Pointer to interrupt-specific data * * Handles inbound message interrupts. Executes a registered inbound * mailbox event handler and acks the interrupt occurrence. */ static irqreturn_t fsl_rio_rx_handler(int irq, void *dev_instance) { int isr; struct rio_mport *port = (struct rio_mport *)dev_instance; struct fsl_rmu *rmu = GET_RMM_HANDLE(port); isr = in_be32(&rmu->msg_regs->isr); if (isr & RIO_MSG_ISR_TE) { pr_info("RIO: inbound message reception error\n"); out_be32((void *)&rmu->msg_regs->isr, RIO_MSG_ISR_TE); goto out; } /* XXX Need to check/dispatch until queue empty */ if (isr & RIO_MSG_ISR_DIQI) { /* * Can receive messages for any mailbox/letter to that * mailbox destination. So, make the callback with an * unknown/invalid mailbox number argument. */ if (port->inb_msg[0].mcback != NULL) port->inb_msg[0].mcback(port, rmu->msg_rx_ring.dev_id, -1, -1); /* Ack the queueing interrupt */ out_be32(&rmu->msg_regs->isr, RIO_MSG_ISR_DIQI); } out: return IRQ_HANDLED; } /** * fsl_rio_dbell_handler - MPC85xx doorbell interrupt handler * @irq: Linux interrupt number * @dev_instance: Pointer to interrupt-specific data * * Handles doorbell interrupts. Parses a list of registered * doorbell event handlers and executes a matching event handler. */ static irqreturn_t fsl_rio_dbell_handler(int irq, void *dev_instance) { int dsr; struct fsl_rio_dbell *fsl_dbell = (struct fsl_rio_dbell *)dev_instance; int i; dsr = in_be32(&fsl_dbell->dbell_regs->dsr); if (dsr & DOORBELL_DSR_TE) { pr_info("RIO: doorbell reception error\n"); out_be32(&fsl_dbell->dbell_regs->dsr, DOORBELL_DSR_TE); goto out; } if (dsr & DOORBELL_DSR_QFI) { pr_info("RIO: doorbell queue full\n"); out_be32(&fsl_dbell->dbell_regs->dsr, DOORBELL_DSR_QFI); } /* XXX Need to check/dispatch until queue empty */ if (dsr & DOORBELL_DSR_DIQI) { struct rio_dbell_msg *dmsg = fsl_dbell->dbell_ring.virt + (in_be32(&fsl_dbell->dbell_regs->dqdpar) & 0xfff); struct rio_dbell *dbell; int found = 0; pr_debug ("RIO: processing doorbell," " sid %2.2x tid %2.2x info %4.4x\n", dmsg->sid, dmsg->tid, dmsg->info); for (i = 0; i < MAX_PORT_NUM; i++) { if (fsl_dbell->mport[i]) { list_for_each_entry(dbell, &fsl_dbell->mport[i]->dbells, node) { if ((dbell->res->start <= dmsg->info) && (dbell->res->end >= dmsg->info)) { found = 1; break; } } if (found && dbell->dinb) { dbell->dinb(fsl_dbell->mport[i], dbell->dev_id, dmsg->sid, dmsg->tid, dmsg->info); break; } } } if (!found) { pr_debug ("RIO: spurious doorbell," " sid %2.2x tid %2.2x info %4.4x\n", dmsg->sid, dmsg->tid, dmsg->info); } setbits32(&fsl_dbell->dbell_regs->dmr, DOORBELL_DMR_DI); out_be32(&fsl_dbell->dbell_regs->dsr, DOORBELL_DSR_DIQI); } out: return IRQ_HANDLED; } void msg_unit_error_handler(void) { /*XXX: Error recovery is not implemented, we just clear errors */ out_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR), 0); out_be32((u32 *)(rmu_regs_win + RIO_IM0SR), IMSR_CLEAR); out_be32((u32 *)(rmu_regs_win + RIO_IM1SR), IMSR_CLEAR); out_be32((u32 *)(rmu_regs_win + RIO_OM0SR), OMSR_CLEAR); out_be32((u32 *)(rmu_regs_win + RIO_OM1SR), OMSR_CLEAR); out_be32(&dbell->dbell_regs->odsr, ODSR_CLEAR); out_be32(&dbell->dbell_regs->dsr, IDSR_CLEAR); out_be32(&pw->pw_regs->pwsr, IPWSR_CLEAR); } /** * fsl_rio_port_write_handler - MPC85xx port write interrupt handler * @irq: Linux interrupt number * @dev_instance: Pointer to interrupt-specific data * * Handles port write interrupts. Parses a list of registered * port write event handlers and executes a matching event handler. */ static irqreturn_t fsl_rio_port_write_handler(int irq, void *dev_instance) { u32 ipwmr, ipwsr; struct fsl_rio_pw *pw = (struct fsl_rio_pw *)dev_instance; u32 epwisr, tmp; epwisr = in_be32(rio_regs_win + RIO_EPWISR); if (!(epwisr & RIO_EPWISR_PW)) goto pw_done; ipwmr = in_be32(&pw->pw_regs->pwmr); ipwsr = in_be32(&pw->pw_regs->pwsr); #ifdef DEBUG_PW pr_debug("PW Int->IPWMR: 0x%08x IPWSR: 0x%08x (", ipwmr, ipwsr); if (ipwsr & RIO_IPWSR_QF) pr_debug(" QF"); if (ipwsr & RIO_IPWSR_TE) pr_debug(" TE"); if (ipwsr & RIO_IPWSR_QFI) pr_debug(" QFI"); if (ipwsr & RIO_IPWSR_PWD) pr_debug(" PWD"); if (ipwsr & RIO_IPWSR_PWB) pr_debug(" PWB"); pr_debug(" )\n"); #endif /* Schedule deferred processing if PW was received */ if (ipwsr & RIO_IPWSR_QFI) { /* Save PW message (if there is room in FIFO), * otherwise discard it. */ if (kfifo_avail(&pw->pw_fifo) >= RIO_PW_MSG_SIZE) { pw->port_write_msg.msg_count++; kfifo_in(&pw->pw_fifo, pw->port_write_msg.virt, RIO_PW_MSG_SIZE); } else { pw->port_write_msg.discard_count++; pr_debug("RIO: ISR Discarded Port-Write Msg(s) (%d)\n", pw->port_write_msg.discard_count); } /* Clear interrupt and issue Clear Queue command. This allows * another port-write to be received. */ out_be32(&pw->pw_regs->pwsr, RIO_IPWSR_QFI); out_be32(&pw->pw_regs->pwmr, ipwmr | RIO_IPWMR_CQ); schedule_work(&pw->pw_work); } if ((ipwmr & RIO_IPWMR_EIE) && (ipwsr & RIO_IPWSR_TE)) { pw->port_write_msg.err_count++; pr_debug("RIO: Port-Write Transaction Err (%d)\n", pw->port_write_msg.err_count); /* Clear Transaction Error: port-write controller should be * disabled when clearing this error */ out_be32(&pw->pw_regs->pwmr, ipwmr & ~RIO_IPWMR_PWE); out_be32(&pw->pw_regs->pwsr, RIO_IPWSR_TE); out_be32(&pw->pw_regs->pwmr, ipwmr); } if (ipwsr & RIO_IPWSR_PWD) { pw->port_write_msg.discard_count++; pr_debug("RIO: Port Discarded Port-Write Msg(s) (%d)\n", pw->port_write_msg.discard_count); out_be32(&pw->pw_regs->pwsr, RIO_IPWSR_PWD); } pw_done: if (epwisr & RIO_EPWISR_PINT1) { tmp = in_be32(rio_regs_win + RIO_LTLEDCSR); pr_debug("RIO_LTLEDCSR = 0x%x\n", tmp); fsl_rio_port_error_handler(0); } if (epwisr & RIO_EPWISR_PINT2) { tmp = in_be32(rio_regs_win + RIO_LTLEDCSR); pr_debug("RIO_LTLEDCSR = 0x%x\n", tmp); fsl_rio_port_error_handler(1); } if (epwisr & RIO_EPWISR_MU) { tmp = in_be32(rio_regs_win + RIO_LTLEDCSR); pr_debug("RIO_LTLEDCSR = 0x%x\n", tmp); msg_unit_error_handler(); } return IRQ_HANDLED; } static void fsl_pw_dpc(struct work_struct *work) { struct fsl_rio_pw *pw = container_of(work, struct fsl_rio_pw, pw_work); u32 msg_buffer[RIO_PW_MSG_SIZE/sizeof(u32)]; /* * Process port-write messages */ while (kfifo_out_spinlocked(&pw->pw_fifo, (unsigned char *)msg_buffer, RIO_PW_MSG_SIZE, &pw->pw_fifo_lock)) { /* Process one message */ #ifdef DEBUG_PW { u32 i; pr_debug("%s : Port-Write Message:", __func__); for (i = 0; i < RIO_PW_MSG_SIZE/sizeof(u32); i++) { if ((i%4) == 0) pr_debug("\n0x%02x: 0x%08x", i*4, msg_buffer[i]); else pr_debug(" 0x%08x", msg_buffer[i]); } pr_debug("\n"); } #endif /* Pass the port-write message to RIO core for processing */ rio_inb_pwrite_handler((union rio_pw_msg *)msg_buffer); } } /** * fsl_rio_pw_enable - enable/disable port-write interface init * @mport: Master port implementing the port write unit * @enable: 1=enable; 0=disable port-write message handling */ int fsl_rio_pw_enable(struct rio_mport *mport, int enable) { u32 rval; rval = in_be32(&pw->pw_regs->pwmr); if (enable) rval |= RIO_IPWMR_PWE; else rval &= ~RIO_IPWMR_PWE; out_be32(&pw->pw_regs->pwmr, rval); return 0; } /** * fsl_rio_port_write_init - MPC85xx port write interface init * @mport: Master port implementing the port write unit * * Initializes port write unit hardware and DMA buffer * ring. Called from fsl_rio_setup(). Returns %0 on success * or %-ENOMEM on failure. */ int fsl_rio_port_write_init(struct fsl_rio_pw *pw) { int rc = 0; /* Following configurations require a disabled port write controller */ out_be32(&pw->pw_regs->pwmr, in_be32(&pw->pw_regs->pwmr) & ~RIO_IPWMR_PWE); /* Initialize port write */ pw->port_write_msg.virt = dma_alloc_coherent(pw->dev, RIO_PW_MSG_SIZE, &pw->port_write_msg.phys, GFP_KERNEL); if (!pw->port_write_msg.virt) { pr_err("RIO: unable allocate port write queue\n"); return -ENOMEM; } pw->port_write_msg.err_count = 0; pw->port_write_msg.discard_count = 0; /* Point dequeue/enqueue pointers at first entry */ out_be32(&pw->pw_regs->epwqbar, 0); out_be32(&pw->pw_regs->pwqbar, (u32) pw->port_write_msg.phys); pr_debug("EIPWQBAR: 0x%08x IPWQBAR: 0x%08x\n", in_be32(&pw->pw_regs->epwqbar), in_be32(&pw->pw_regs->pwqbar)); /* Clear interrupt status IPWSR */ out_be32(&pw->pw_regs->pwsr, (RIO_IPWSR_TE | RIO_IPWSR_QFI | RIO_IPWSR_PWD)); /* Configure port write contoller for snooping enable all reporting, clear queue full */ out_be32(&pw->pw_regs->pwmr, RIO_IPWMR_SEN | RIO_IPWMR_QFIE | RIO_IPWMR_EIE | RIO_IPWMR_CQ); /* Hook up port-write handler */ rc = request_irq(IRQ_RIO_PW(pw), fsl_rio_port_write_handler, IRQF_SHARED, "port-write", (void *)pw); if (rc < 0) { pr_err("MPC85xx RIO: unable to request inbound doorbell irq"); goto err_out; } /* Enable Error Interrupt */ out_be32((u32 *)(rio_regs_win + RIO_LTLEECSR), LTLEECSR_ENABLE_ALL); INIT_WORK(&pw->pw_work, fsl_pw_dpc); spin_lock_init(&pw->pw_fifo_lock); if (kfifo_alloc(&pw->pw_fifo, RIO_PW_MSG_SIZE * 32, GFP_KERNEL)) { pr_err("FIFO allocation failed\n"); rc = -ENOMEM; goto err_out_irq; } pr_debug("IPWMR: 0x%08x IPWSR: 0x%08x\n", in_be32(&pw->pw_regs->pwmr), in_be32(&pw->pw_regs->pwsr)); return rc; err_out_irq: free_irq(IRQ_RIO_PW(pw), (void *)pw); err_out: dma_free_coherent(pw->dev, RIO_PW_MSG_SIZE, pw->port_write_msg.virt, pw->port_write_msg.phys); return rc; } /** * fsl_rio_doorbell_send - Send a MPC85xx doorbell message * @mport: RapidIO master port info * @index: ID of RapidIO interface * @destid: Destination ID of target device * @data: 16-bit info field of RapidIO doorbell message * * Sends a MPC85xx doorbell message. Returns %0 on success or * %-EINVAL on failure. */ int fsl_rio_doorbell_send(struct rio_mport *mport, int index, u16 destid, u16 data) { pr_debug("fsl_doorbell_send: index %d destid %4.4x data %4.4x\n", index, destid, data); /* In the serial version silicons, such as MPC8548, MPC8641, * below operations is must be. */ out_be32(&dbell->dbell_regs->odmr, 0x00000000); out_be32(&dbell->dbell_regs->odretcr, 0x00000004); out_be32(&dbell->dbell_regs->oddpr, destid << 16); out_be32(&dbell->dbell_regs->oddatr, (index << 20) | data); out_be32(&dbell->dbell_regs->odmr, 0x00000001); return 0; } /** * fsl_add_outb_message - Add message to the MPC85xx outbound message queue * @mport: Master port with outbound message queue * @rdev: Target of outbound message * @mbox: Outbound mailbox * @buffer: Message to add to outbound queue * @len: Length of message * * Adds the @buffer message to the MPC85xx outbound message queue. Returns * %0 on success or %-EINVAL on failure. */ int fsl_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox, void *buffer, size_t len) { struct fsl_rmu *rmu = GET_RMM_HANDLE(mport); u32 omr; struct rio_tx_desc *desc = (struct rio_tx_desc *)rmu->msg_tx_ring.virt + rmu->msg_tx_ring.tx_slot; int ret = 0; pr_debug("RIO: fsl_add_outb_message(): destid %4.4x mbox %d buffer " \ "%p len %8.8zx\n", rdev->destid, mbox, buffer, len); if ((len < 8) || (len > RIO_MAX_MSG_SIZE)) { ret = -EINVAL; goto out; } /* Copy and clear rest of buffer */ memcpy(rmu->msg_tx_ring.virt_buffer[rmu->msg_tx_ring.tx_slot], buffer, len); if (len < (RIO_MAX_MSG_SIZE - 4)) memset(rmu->msg_tx_ring.virt_buffer[rmu->msg_tx_ring.tx_slot] + len, 0, RIO_MAX_MSG_SIZE - len); /* Set mbox field for message, and set destid */ desc->dport = (rdev->destid << 16) | (mbox & 0x3); /* Enable EOMI interrupt and priority */ desc->dattr = 0x28000000 | ((mport->index) << 20); /* Set transfer size aligned to next power of 2 (in double words) */ desc->dwcnt = is_power_of_2(len) ? len : 1 << get_bitmask_order(len); /* Set snooping and source buffer address */ desc->saddr = 0x00000004 | rmu->msg_tx_ring.phys_buffer[rmu->msg_tx_ring.tx_slot]; /* Increment enqueue pointer */ omr = in_be32(&rmu->msg_regs->omr); out_be32(&rmu->msg_regs->omr, omr | RIO_MSG_OMR_MUI); /* Go to next descriptor */ if (++rmu->msg_tx_ring.tx_slot == rmu->msg_tx_ring.size) rmu->msg_tx_ring.tx_slot = 0; out: return ret; } /** * fsl_open_outb_mbox - Initialize MPC85xx outbound mailbox * @mport: Master port implementing the outbound message unit * @dev_id: Device specific pointer to pass on event * @mbox: Mailbox to open * @entries: Number of entries in the outbound mailbox ring * * Initializes buffer ring, request the outbound message interrupt, * and enables the outbound message unit. Returns %0 on success and * %-EINVAL or %-ENOMEM on failure. */ int fsl_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) { int i, j, rc = 0; struct rio_priv *priv = mport->priv; struct fsl_rmu *rmu = GET_RMM_HANDLE(mport); if ((entries < RIO_MIN_TX_RING_SIZE) || (entries > RIO_MAX_TX_RING_SIZE) || (!is_power_of_2(entries))) { rc = -EINVAL; goto out; } /* Initialize shadow copy ring */ rmu->msg_tx_ring.dev_id = dev_id; rmu->msg_tx_ring.size = entries; for (i = 0; i < rmu->msg_tx_ring.size; i++) { rmu->msg_tx_ring.virt_buffer[i] = dma_alloc_coherent(priv->dev, RIO_MSG_BUFFER_SIZE, &rmu->msg_tx_ring.phys_buffer[i], GFP_KERNEL); if (!rmu->msg_tx_ring.virt_buffer[i]) { rc = -ENOMEM; for (j = 0; j < rmu->msg_tx_ring.size; j++) if (rmu->msg_tx_ring.virt_buffer[j]) dma_free_coherent(priv->dev, RIO_MSG_BUFFER_SIZE, rmu->msg_tx_ring. virt_buffer[j], rmu->msg_tx_ring. phys_buffer[j]); goto out; } } /* Initialize outbound message descriptor ring */ rmu->msg_tx_ring.virt = dma_alloc_coherent(priv->dev, rmu->msg_tx_ring.size * RIO_MSG_DESC_SIZE, &rmu->msg_tx_ring.phys, GFP_KERNEL); if (!rmu->msg_tx_ring.virt) { rc = -ENOMEM; goto out_dma; } memset(rmu->msg_tx_ring.virt, 0, rmu->msg_tx_ring.size * RIO_MSG_DESC_SIZE); rmu->msg_tx_ring.tx_slot = 0; /* Point dequeue/enqueue pointers at first entry in ring */ out_be32(&rmu->msg_regs->odqdpar, rmu->msg_tx_ring.phys); out_be32(&rmu->msg_regs->odqepar, rmu->msg_tx_ring.phys); /* Configure for snooping */ out_be32(&rmu->msg_regs->osar, 0x00000004); /* Clear interrupt status */ out_be32(&rmu->msg_regs->osr, 0x000000b3); /* Hook up outbound message handler */ rc = request_irq(IRQ_RIO_TX(mport), fsl_rio_tx_handler, 0, "msg_tx", (void *)mport); if (rc < 0) goto out_irq; /* * Configure outbound message unit * Snooping * Interrupts (all enabled, except QEIE) * Chaining mode * Disable */ out_be32(&rmu->msg_regs->omr, 0x00100220); /* Set number of entries */ out_be32(&rmu->msg_regs->omr, in_be32(&rmu->msg_regs->omr) | ((get_bitmask_order(entries) - 2) << 12)); /* Now enable the unit */ out_be32(&rmu->msg_regs->omr, in_be32(&rmu->msg_regs->omr) | 0x1); out: return rc; out_irq: dma_free_coherent(priv->dev, rmu->msg_tx_ring.size * RIO_MSG_DESC_SIZE, rmu->msg_tx_ring.virt, rmu->msg_tx_ring.phys); out_dma: for (i = 0; i < rmu->msg_tx_ring.size; i++) dma_free_coherent(priv->dev, RIO_MSG_BUFFER_SIZE, rmu->msg_tx_ring.virt_buffer[i], rmu->msg_tx_ring.phys_buffer[i]); return rc; } /** * fsl_close_outb_mbox - Shut down MPC85xx outbound mailbox * @mport: Master port implementing the outbound message unit * @mbox: Mailbox to close * * Disables the outbound message unit, free all buffers, and * frees the outbound message interrupt. */ void fsl_close_outb_mbox(struct rio_mport *mport, int mbox) { struct rio_priv *priv = mport->priv; struct fsl_rmu *rmu = GET_RMM_HANDLE(mport); /* Disable inbound message unit */ out_be32(&rmu->msg_regs->omr, 0); /* Free ring */ dma_free_coherent(priv->dev, rmu->msg_tx_ring.size * RIO_MSG_DESC_SIZE, rmu->msg_tx_ring.virt, rmu->msg_tx_ring.phys); /* Free interrupt */ free_irq(IRQ_RIO_TX(mport), (void *)mport); } /** * fsl_open_inb_mbox - Initialize MPC85xx inbound mailbox * @mport: Master port implementing the inbound message unit * @dev_id: Device specific pointer to pass on event * @mbox: Mailbox to open * @entries: Number of entries in the inbound mailbox ring * * Initializes buffer ring, request the inbound message interrupt, * and enables the inbound message unit. Returns %0 on success * and %-EINVAL or %-ENOMEM on failure. */ int fsl_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) { int i, rc = 0; struct rio_priv *priv = mport->priv; struct fsl_rmu *rmu = GET_RMM_HANDLE(mport); if ((entries < RIO_MIN_RX_RING_SIZE) || (entries > RIO_MAX_RX_RING_SIZE) || (!is_power_of_2(entries))) { rc = -EINVAL; goto out; } /* Initialize client buffer ring */ rmu->msg_rx_ring.dev_id = dev_id; rmu->msg_rx_ring.size = entries; rmu->msg_rx_ring.rx_slot = 0; for (i = 0; i < rmu->msg_rx_ring.size; i++) rmu->msg_rx_ring.virt_buffer[i] = NULL; /* Initialize inbound message ring */ rmu->msg_rx_ring.virt = dma_alloc_coherent(priv->dev, rmu->msg_rx_ring.size * RIO_MAX_MSG_SIZE, &rmu->msg_rx_ring.phys, GFP_KERNEL); if (!rmu->msg_rx_ring.virt) { rc = -ENOMEM; goto out; } /* Point dequeue/enqueue pointers at first entry in ring */ out_be32(&rmu->msg_regs->ifqdpar, (u32) rmu->msg_rx_ring.phys); out_be32(&rmu->msg_regs->ifqepar, (u32) rmu->msg_rx_ring.phys); /* Clear interrupt status */ out_be32(&rmu->msg_regs->isr, 0x00000091); /* Hook up inbound message handler */ rc = request_irq(IRQ_RIO_RX(mport), fsl_rio_rx_handler, 0, "msg_rx", (void *)mport); if (rc < 0) { dma_free_coherent(priv->dev, RIO_MSG_BUFFER_SIZE, rmu->msg_tx_ring.virt_buffer[i], rmu->msg_tx_ring.phys_buffer[i]); goto out; } /* * Configure inbound message unit: * Snooping * 4KB max message size * Unmask all interrupt sources * Disable */ out_be32(&rmu->msg_regs->imr, 0x001b0060); /* Set number of queue entries */ setbits32(&rmu->msg_regs->imr, (get_bitmask_order(entries) - 2) << 12); /* Now enable the unit */ setbits32(&rmu->msg_regs->imr, 0x1); out: return rc; } /** * fsl_close_inb_mbox - Shut down MPC85xx inbound mailbox * @mport: Master port implementing the inbound message unit * @mbox: Mailbox to close * * Disables the inbound message unit, free all buffers, and * frees the inbound message interrupt. */ void fsl_close_inb_mbox(struct rio_mport *mport, int mbox) { struct rio_priv *priv = mport->priv; struct fsl_rmu *rmu = GET_RMM_HANDLE(mport); /* Disable inbound message unit */ out_be32(&rmu->msg_regs->imr, 0); /* Free ring */ dma_free_coherent(priv->dev, rmu->msg_rx_ring.size * RIO_MAX_MSG_SIZE, rmu->msg_rx_ring.virt, rmu->msg_rx_ring.phys); /* Free interrupt */ free_irq(IRQ_RIO_RX(mport), (void *)mport); } /** * fsl_add_inb_buffer - Add buffer to the MPC85xx inbound message queue * @mport: Master port implementing the inbound message unit * @mbox: Inbound mailbox number * @buf: Buffer to add to inbound queue * * Adds the @buf buffer to the MPC85xx inbound message queue. Returns * %0 on success or %-EINVAL on failure. */ int fsl_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf) { int rc = 0; struct fsl_rmu *rmu = GET_RMM_HANDLE(mport); pr_debug("RIO: fsl_add_inb_buffer(), msg_rx_ring.rx_slot %d\n", rmu->msg_rx_ring.rx_slot); if (rmu->msg_rx_ring.virt_buffer[rmu->msg_rx_ring.rx_slot]) { printk(KERN_ERR "RIO: error adding inbound buffer %d, buffer exists\n", rmu->msg_rx_ring.rx_slot); rc = -EINVAL; goto out; } rmu->msg_rx_ring.virt_buffer[rmu->msg_rx_ring.rx_slot] = buf; if (++rmu->msg_rx_ring.rx_slot == rmu->msg_rx_ring.size) rmu->msg_rx_ring.rx_slot = 0; out: return rc; } /** * fsl_get_inb_message - Fetch inbound message from the MPC85xx message unit * @mport: Master port implementing the inbound message unit * @mbox: Inbound mailbox number * * Gets the next available inbound message from the inbound message queue. * A pointer to the message is returned on success or NULL on failure. */ void *fsl_get_inb_message(struct rio_mport *mport, int mbox) { struct fsl_rmu *rmu = GET_RMM_HANDLE(mport); u32 phys_buf; void *virt_buf; void *buf = NULL; int buf_idx; phys_buf = in_be32(&rmu->msg_regs->ifqdpar); /* If no more messages, then bail out */ if (phys_buf == in_be32(&rmu->msg_regs->ifqepar)) goto out2; virt_buf = rmu->msg_rx_ring.virt + (phys_buf - rmu->msg_rx_ring.phys); buf_idx = (phys_buf - rmu->msg_rx_ring.phys) / RIO_MAX_MSG_SIZE; buf = rmu->msg_rx_ring.virt_buffer[buf_idx]; if (!buf) { printk(KERN_ERR "RIO: inbound message copy failed, no buffers\n"); goto out1; } /* Copy max message size, caller is expected to allocate that big */ memcpy(buf, virt_buf, RIO_MAX_MSG_SIZE); /* Clear the available buffer */ rmu->msg_rx_ring.virt_buffer[buf_idx] = NULL; out1: setbits32(&rmu->msg_regs->imr, RIO_MSG_IMR_MI); out2: return buf; } /** * fsl_rio_doorbell_init - MPC85xx doorbell interface init * @mport: Master port implementing the inbound doorbell unit * * Initializes doorbell unit hardware and inbound DMA buffer * ring. Called from fsl_rio_setup(). Returns %0 on success * or %-ENOMEM on failure. */ int fsl_rio_doorbell_init(struct fsl_rio_dbell *dbell) { int rc = 0; /* Initialize inbound doorbells */ dbell->dbell_ring.virt = dma_alloc_coherent(dbell->dev, 512 * DOORBELL_MESSAGE_SIZE, &dbell->dbell_ring.phys, GFP_KERNEL); if (!dbell->dbell_ring.virt) { printk(KERN_ERR "RIO: unable allocate inbound doorbell ring\n"); rc = -ENOMEM; goto out; } /* Point dequeue/enqueue pointers at first entry in ring */ out_be32(&dbell->dbell_regs->dqdpar, (u32) dbell->dbell_ring.phys); out_be32(&dbell->dbell_regs->dqepar, (u32) dbell->dbell_ring.phys); /* Clear interrupt status */ out_be32(&dbell->dbell_regs->dsr, 0x00000091); /* Hook up doorbell handler */ rc = request_irq(IRQ_RIO_BELL(dbell), fsl_rio_dbell_handler, 0, "dbell_rx", (void *)dbell); if (rc < 0) { dma_free_coherent(dbell->dev, 512 * DOORBELL_MESSAGE_SIZE, dbell->dbell_ring.virt, dbell->dbell_ring.phys); printk(KERN_ERR "MPC85xx RIO: unable to request inbound doorbell irq"); goto out; } /* Configure doorbells for snooping, 512 entries, and enable */ out_be32(&dbell->dbell_regs->dmr, 0x00108161); out: return rc; } int fsl_rio_setup_rmu(struct rio_mport *mport, struct device_node *node) { struct rio_priv *priv; struct fsl_rmu *rmu; u64 msg_start; const u32 *msg_addr; int mlen; int aw; if (!mport || !mport->priv) return -EINVAL; priv = mport->priv; if (!node) { dev_warn(priv->dev, "Can't get %s property 'fsl,rmu'\n", priv->dev->of_node->full_name); return -EINVAL; } rmu = kzalloc(sizeof(struct fsl_rmu), GFP_KERNEL); if (!rmu) return -ENOMEM; aw = of_n_addr_cells(node); msg_addr = of_get_property(node, "reg", &mlen); if (!msg_addr) { pr_err("%s: unable to find 'reg' property of message-unit\n", node->full_name); kfree(rmu); return -ENOMEM; } msg_start = of_read_number(msg_addr, aw); rmu->msg_regs = (struct rio_msg_regs *) (rmu_regs_win + (u32)msg_start); rmu->txirq = irq_of_parse_and_map(node, 0); rmu->rxirq = irq_of_parse_and_map(node, 1); printk(KERN_INFO "%s: txirq: %d, rxirq %d\n", node->full_name, rmu->txirq, rmu->rxirq); priv->rmm_handle = rmu; rio_init_dbell_res(&mport->riores[RIO_DOORBELL_RESOURCE], 0, 0xffff); rio_init_mbox_res(&mport->riores[RIO_INB_MBOX_RESOURCE], 0, 0); rio_init_mbox_res(&mport->riores[RIO_OUTB_MBOX_RESOURCE], 0, 0); return 0; }
gpl-2.0
Lazy79/shamu-5.0
arch/powerpc/platforms/powermac/setup.c
7355
16022
/* * Powermac setup and early boot code plus other random bits. * * PowerPC version * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) * * Adapted for Power Macintosh by Paul Mackerras * Copyright (C) 1996 Paul Mackerras (paulus@samba.org) * * Derived from "arch/alpha/kernel/setup.c" * Copyright (C) 1995 Linus Torvalds * * Maintained by Benjamin Herrenschmidt (benh@kernel.crashing.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. * */ /* * bootup setup stuff.. */ #include <linux/init.h> #include <linux/errno.h> #include <linux/sched.h> #include <linux/kernel.h> #include <linux/mm.h> #include <linux/stddef.h> #include <linux/unistd.h> #include <linux/ptrace.h> #include <linux/export.h> #include <linux/user.h> #include <linux/tty.h> #include <linux/string.h> #include <linux/delay.h> #include <linux/ioport.h> #include <linux/major.h> #include <linux/initrd.h> #include <linux/vt_kern.h> #include <linux/console.h> #include <linux/pci.h> #include <linux/adb.h> #include <linux/cuda.h> #include <linux/pmu.h> #include <linux/irq.h> #include <linux/seq_file.h> #include <linux/root_dev.h> #include <linux/bitops.h> #include <linux/suspend.h> #include <linux/of_device.h> #include <linux/of_platform.h> #include <linux/memblock.h> #include <asm/reg.h> #include <asm/sections.h> #include <asm/prom.h> #include <asm/pgtable.h> #include <asm/io.h> #include <asm/pci-bridge.h> #include <asm/ohare.h> #include <asm/mediabay.h> #include <asm/machdep.h> #include <asm/dma.h> #include <asm/cputable.h> #include <asm/btext.h> #include <asm/pmac_feature.h> #include <asm/time.h> #include <asm/mmu_context.h> #include <asm/iommu.h> #include <asm/smu.h> #include <asm/pmc.h> #include <asm/udbg.h> #include "pmac.h" #undef SHOW_GATWICK_IRQS int ppc_override_l2cr = 0; int ppc_override_l2cr_value; int has_l2cache = 0; int pmac_newworld; static int current_root_goodness = -1; extern struct machdep_calls pmac_md; #define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */ #ifdef CONFIG_PPC64 int sccdbg; #endif sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN; EXPORT_SYMBOL(sys_ctrler); #ifdef CONFIG_PMAC_SMU unsigned long smu_cmdbuf_abs; EXPORT_SYMBOL(smu_cmdbuf_abs); #endif static void pmac_show_cpuinfo(struct seq_file *m) { struct device_node *np; const char *pp; int plen; int mbmodel; unsigned int mbflags; char* mbname; mbmodel = pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_MODEL, 0); mbflags = pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_FLAGS, 0); if (pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_NAME, (long) &mbname) != 0) mbname = "Unknown"; /* find motherboard type */ seq_printf(m, "machine\t\t: "); np = of_find_node_by_path("/"); if (np != NULL) { pp = of_get_property(np, "model", NULL); if (pp != NULL) seq_printf(m, "%s\n", pp); else seq_printf(m, "PowerMac\n"); pp = of_get_property(np, "compatible", &plen); if (pp != NULL) { seq_printf(m, "motherboard\t:"); while (plen > 0) { int l = strlen(pp) + 1; seq_printf(m, " %s", pp); plen -= l; pp += l; } seq_printf(m, "\n"); } of_node_put(np); } else seq_printf(m, "PowerMac\n"); /* print parsed model */ seq_printf(m, "detected as\t: %d (%s)\n", mbmodel, mbname); seq_printf(m, "pmac flags\t: %08x\n", mbflags); /* find l2 cache info */ np = of_find_node_by_name(NULL, "l2-cache"); if (np == NULL) np = of_find_node_by_type(NULL, "cache"); if (np != NULL) { const unsigned int *ic = of_get_property(np, "i-cache-size", NULL); const unsigned int *dc = of_get_property(np, "d-cache-size", NULL); seq_printf(m, "L2 cache\t:"); has_l2cache = 1; if (of_get_property(np, "cache-unified", NULL) != 0 && dc) { seq_printf(m, " %dK unified", *dc / 1024); } else { if (ic) seq_printf(m, " %dK instruction", *ic / 1024); if (dc) seq_printf(m, "%s %dK data", (ic? " +": ""), *dc / 1024); } pp = of_get_property(np, "ram-type", NULL); if (pp) seq_printf(m, " %s", pp); seq_printf(m, "\n"); of_node_put(np); } /* Indicate newworld/oldworld */ seq_printf(m, "pmac-generation\t: %s\n", pmac_newworld ? "NewWorld" : "OldWorld"); } #ifndef CONFIG_ADB_CUDA int find_via_cuda(void) { struct device_node *dn = of_find_node_by_name(NULL, "via-cuda"); if (!dn) return 0; of_node_put(dn); printk("WARNING ! Your machine is CUDA-based but your kernel\n"); printk(" wasn't compiled with CONFIG_ADB_CUDA option !\n"); return 0; } #endif #ifndef CONFIG_ADB_PMU int find_via_pmu(void) { struct device_node *dn = of_find_node_by_name(NULL, "via-pmu"); if (!dn) return 0; of_node_put(dn); printk("WARNING ! Your machine is PMU-based but your kernel\n"); printk(" wasn't compiled with CONFIG_ADB_PMU option !\n"); return 0; } #endif #ifndef CONFIG_PMAC_SMU int smu_init(void) { /* should check and warn if SMU is present */ return 0; } #endif #ifdef CONFIG_PPC32 static volatile u32 *sysctrl_regs; static void __init ohare_init(void) { struct device_node *dn; /* this area has the CPU identification register and some registers used by smp boards */ sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000); /* * Turn on the L2 cache. * We assume that we have a PSX memory controller iff * we have an ohare I/O controller. */ dn = of_find_node_by_name(NULL, "ohare"); if (dn) { of_node_put(dn); if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) { if (sysctrl_regs[4] & 0x10) sysctrl_regs[4] |= 0x04000020; else sysctrl_regs[4] |= 0x04000000; if(has_l2cache) printk(KERN_INFO "Level 2 cache enabled\n"); } } } static void __init l2cr_init(void) { /* Checks "l2cr-value" property in the registry */ if (cpu_has_feature(CPU_FTR_L2CR)) { struct device_node *np = of_find_node_by_name(NULL, "cpus"); if (np == 0) np = of_find_node_by_type(NULL, "cpu"); if (np != 0) { const unsigned int *l2cr = of_get_property(np, "l2cr-value", NULL); if (l2cr != 0) { ppc_override_l2cr = 1; ppc_override_l2cr_value = *l2cr; _set_L2CR(0); _set_L2CR(ppc_override_l2cr_value); } of_node_put(np); } } if (ppc_override_l2cr) printk(KERN_INFO "L2CR overridden (0x%x), " "backside cache is %s\n", ppc_override_l2cr_value, (ppc_override_l2cr_value & 0x80000000) ? "enabled" : "disabled"); } #endif static void __init pmac_setup_arch(void) { struct device_node *cpu, *ic; const int *fp; unsigned long pvr; pvr = PVR_VER(mfspr(SPRN_PVR)); /* Set loops_per_jiffy to a half-way reasonable value, for use until calibrate_delay gets called. */ loops_per_jiffy = 50000000 / HZ; cpu = of_find_node_by_type(NULL, "cpu"); if (cpu != NULL) { fp = of_get_property(cpu, "clock-frequency", NULL); if (fp != NULL) { if (pvr >= 0x30 && pvr < 0x80) /* PPC970 etc. */ loops_per_jiffy = *fp / (3 * HZ); else if (pvr == 4 || pvr >= 8) /* 604, G3, G4 etc. */ loops_per_jiffy = *fp / HZ; else /* 601, 603, etc. */ loops_per_jiffy = *fp / (2 * HZ); } of_node_put(cpu); } /* See if newworld or oldworld */ ic = of_find_node_with_property(NULL, "interrupt-controller"); if (ic) { pmac_newworld = 1; of_node_put(ic); } /* Lookup PCI hosts */ pmac_pci_init(); #ifdef CONFIG_PPC32 ohare_init(); l2cr_init(); #endif /* CONFIG_PPC32 */ find_via_cuda(); find_via_pmu(); smu_init(); #if defined(CONFIG_NVRAM) || defined(CONFIG_NVRAM_MODULE) || \ defined(CONFIG_PPC64) pmac_nvram_init(); #endif #ifdef CONFIG_PPC32 #ifdef CONFIG_BLK_DEV_INITRD if (initrd_start) ROOT_DEV = Root_RAM0; else #endif ROOT_DEV = DEFAULT_ROOT_DEVICE; #endif #ifdef CONFIG_ADB if (strstr(cmd_line, "adb_sync")) { extern int __adb_probe_sync; __adb_probe_sync = 1; } #endif /* CONFIG_ADB */ } #ifdef CONFIG_SCSI void note_scsi_host(struct device_node *node, void *host) { } EXPORT_SYMBOL(note_scsi_host); #endif static int initializing = 1; static int pmac_late_init(void) { initializing = 0; return 0; } machine_late_initcall(powermac, pmac_late_init); /* * This is __init_refok because we check for "initializing" before * touching any of the __init sensitive things and "initializing" * will be false after __init time. This can't be __init because it * can be called whenever a disk is first accessed. */ void __init_refok note_bootable_part(dev_t dev, int part, int goodness) { char *p; if (!initializing) return; if ((goodness <= current_root_goodness) && ROOT_DEV != DEFAULT_ROOT_DEVICE) return; p = strstr(boot_command_line, "root="); if (p != NULL && (p == boot_command_line || p[-1] == ' ')) return; ROOT_DEV = dev + part; current_root_goodness = goodness; } #ifdef CONFIG_ADB_CUDA static void cuda_restart(void) { struct adb_request req; cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_RESET_SYSTEM); for (;;) cuda_poll(); } static void cuda_shutdown(void) { struct adb_request req; cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_POWERDOWN); for (;;) cuda_poll(); } #else #define cuda_restart() #define cuda_shutdown() #endif #ifndef CONFIG_ADB_PMU #define pmu_restart() #define pmu_shutdown() #endif #ifndef CONFIG_PMAC_SMU #define smu_restart() #define smu_shutdown() #endif static void pmac_restart(char *cmd) { switch (sys_ctrler) { case SYS_CTRLER_CUDA: cuda_restart(); break; case SYS_CTRLER_PMU: pmu_restart(); break; case SYS_CTRLER_SMU: smu_restart(); break; default: ; } } static void pmac_power_off(void) { switch (sys_ctrler) { case SYS_CTRLER_CUDA: cuda_shutdown(); break; case SYS_CTRLER_PMU: pmu_shutdown(); break; case SYS_CTRLER_SMU: smu_shutdown(); break; default: ; } } static void pmac_halt(void) { pmac_power_off(); } /* * Early initialization. */ static void __init pmac_init_early(void) { /* Enable early btext debug if requested */ if (strstr(cmd_line, "btextdbg")) { udbg_adb_init_early(); register_early_udbg_console(); } /* Probe motherboard chipset */ pmac_feature_init(); /* Initialize debug stuff */ udbg_scc_init(!!strstr(cmd_line, "sccdbg")); udbg_adb_init(!!strstr(cmd_line, "btextdbg")); #ifdef CONFIG_PPC64 iommu_init_early_dart(); #endif /* SMP Init has to be done early as we need to patch up * cpu_possible_mask before interrupt stacks are allocated * or kaboom... */ #ifdef CONFIG_SMP pmac_setup_smp(); #endif } static int __init pmac_declare_of_platform_devices(void) { struct device_node *np; if (machine_is(chrp)) return -1; np = of_find_node_by_name(NULL, "valkyrie"); if (np) { of_platform_device_create(np, "valkyrie", NULL); of_node_put(np); } np = of_find_node_by_name(NULL, "platinum"); if (np) { of_platform_device_create(np, "platinum", NULL); of_node_put(np); } np = of_find_node_by_type(NULL, "smu"); if (np) { of_platform_device_create(np, "smu", NULL); of_node_put(np); } np = of_find_node_by_type(NULL, "fcu"); if (np == NULL) { /* Some machines have strangely broken device-tree */ np = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/fan@15e"); } if (np) { of_platform_device_create(np, "temperature", NULL); of_node_put(np); } return 0; } machine_device_initcall(powermac, pmac_declare_of_platform_devices); #ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE /* * This is called very early, as part of console_init() (typically just after * time_init()). This function is respondible for trying to find a good * default console on serial ports. It tries to match the open firmware * default output with one of the available serial console drivers. */ static int __init check_pmac_serial_console(void) { struct device_node *prom_stdout = NULL; int offset = 0; const char *name; #ifdef CONFIG_SERIAL_PMACZILOG_TTYS char *devname = "ttyS"; #else char *devname = "ttyPZ"; #endif pr_debug(" -> check_pmac_serial_console()\n"); /* The user has requested a console so this is already set up. */ if (strstr(boot_command_line, "console=")) { pr_debug(" console was specified !\n"); return -EBUSY; } if (!of_chosen) { pr_debug(" of_chosen is NULL !\n"); return -ENODEV; } /* We are getting a weird phandle from OF ... */ /* ... So use the full path instead */ name = of_get_property(of_chosen, "linux,stdout-path", NULL); if (name == NULL) { pr_debug(" no linux,stdout-path !\n"); return -ENODEV; } prom_stdout = of_find_node_by_path(name); if (!prom_stdout) { pr_debug(" can't find stdout package %s !\n", name); return -ENODEV; } pr_debug("stdout is %s\n", prom_stdout->full_name); name = of_get_property(prom_stdout, "name", NULL); if (!name) { pr_debug(" stdout package has no name !\n"); goto not_found; } if (strcmp(name, "ch-a") == 0) offset = 0; else if (strcmp(name, "ch-b") == 0) offset = 1; else goto not_found; of_node_put(prom_stdout); pr_debug("Found serial console at %s%d\n", devname, offset); return add_preferred_console(devname, offset, NULL); not_found: pr_debug("No preferred console found !\n"); of_node_put(prom_stdout); return -ENODEV; } console_initcall(check_pmac_serial_console); #endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */ /* * Called very early, MMU is off, device-tree isn't unflattened */ static int __init pmac_probe(void) { unsigned long root = of_get_flat_dt_root(); if (!of_flat_dt_is_compatible(root, "Power Macintosh") && !of_flat_dt_is_compatible(root, "MacRISC")) return 0; #ifdef CONFIG_PPC64 /* * On U3, the DART (iommu) must be allocated now since it * has an impact on htab_initialize (due to the large page it * occupies having to be broken up so the DART itself is not * part of the cacheable linar mapping */ alloc_dart_table(); hpte_init_native(); #endif #ifdef CONFIG_PPC32 /* isa_io_base gets set in pmac_pci_init */ ISA_DMA_THRESHOLD = ~0L; DMA_MODE_READ = 1; DMA_MODE_WRITE = 2; #endif /* CONFIG_PPC32 */ #ifdef CONFIG_PMAC_SMU /* * SMU based G5s need some memory below 2Gb, at least the current * driver needs that. We have to allocate it now. We allocate 4k * (1 small page) for now. */ smu_cmdbuf_abs = memblock_alloc_base(4096, 4096, 0x80000000UL); #endif /* CONFIG_PMAC_SMU */ return 1; } #ifdef CONFIG_PPC64 /* Move that to pci.c */ static int pmac_pci_probe_mode(struct pci_bus *bus) { struct device_node *node = pci_bus_to_OF_node(bus); /* We need to use normal PCI probing for the AGP bus, * since the device for the AGP bridge isn't in the tree. * Same for the PCIe host on U4 and the HT host bridge. */ if (bus->self == NULL && (of_device_is_compatible(node, "u3-agp") || of_device_is_compatible(node, "u4-pcie") || of_device_is_compatible(node, "u3-ht"))) return PCI_PROBE_NORMAL; return PCI_PROBE_DEVTREE; } #endif /* CONFIG_PPC64 */ define_machine(powermac) { .name = "PowerMac", .probe = pmac_probe, .setup_arch = pmac_setup_arch, .init_early = pmac_init_early, .show_cpuinfo = pmac_show_cpuinfo, .init_IRQ = pmac_pic_init, .get_irq = NULL, /* changed later */ .pci_irq_fixup = pmac_pci_irq_fixup, .restart = pmac_restart, .power_off = pmac_power_off, .halt = pmac_halt, .time_init = pmac_time_init, .get_boot_time = pmac_get_boot_time, .set_rtc_time = pmac_set_rtc_time, .get_rtc_time = pmac_get_rtc_time, .calibrate_decr = pmac_calibrate_decr, .feature_call = pmac_do_feature_call, .progress = udbg_progress, #ifdef CONFIG_PPC64 .pci_probe_mode = pmac_pci_probe_mode, .power_save = power4_idle, .enable_pmcs = power4_enable_pmcs, #endif /* CONFIG_PPC64 */ #ifdef CONFIG_PPC32 .pcibios_enable_device_hook = pmac_pci_enable_device_hook, .pcibios_after_init = pmac_pcibios_after_init, .phys_mem_access_prot = pci_phys_mem_access_prot, #endif };
gpl-2.0
dagnarf/sgh-i717-dagkernel
fs/jffs2/xattr_user.c
12731
1418
/* * JFFS2 -- Journalling Flash File System, Version 2. * * Copyright © 2006 NEC Corporation * * Created by KaiGai Kohei <kaigai@ak.jp.nec.com> * * For licensing information, see the file 'LICENCE' in this directory. * */ #include <linux/kernel.h> #include <linux/fs.h> #include <linux/jffs2.h> #include <linux/xattr.h> #include <linux/mtd/mtd.h> #include "nodelist.h" static int jffs2_user_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size, int type) { if (!strcmp(name, "")) return -EINVAL; return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_USER, name, buffer, size); } static int jffs2_user_setxattr(struct dentry *dentry, const char *name, const void *buffer, size_t size, int flags, int type) { if (!strcmp(name, "")) return -EINVAL; return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_USER, name, buffer, size, flags); } static size_t jffs2_user_listxattr(struct dentry *dentry, char *list, size_t list_size, const char *name, size_t name_len, int type) { size_t retlen = XATTR_USER_PREFIX_LEN + name_len + 1; if (list && retlen <= list_size) { strcpy(list, XATTR_USER_PREFIX); strcpy(list + XATTR_USER_PREFIX_LEN, name); } return retlen; } const struct xattr_handler jffs2_user_xattr_handler = { .prefix = XATTR_USER_PREFIX, .list = jffs2_user_listxattr, .set = jffs2_user_setxattr, .get = jffs2_user_getxattr };
gpl-2.0
RomzesRover/liquid-chocolate-beta4
arch/cris/arch-v32/kernel/time.c
188
10605
/* * linux/arch/cris/arch-v32/kernel/time.c * * Copyright (C) 2003-2007 Axis Communications AB * */ #include <linux/timex.h> #include <linux/time.h> #include <linux/jiffies.h> #include <linux/interrupt.h> #include <linux/swap.h> #include <linux/sched.h> #include <linux/init.h> #include <linux/threads.h> #include <linux/cpufreq.h> #include <asm/types.h> #include <asm/signal.h> #include <asm/io.h> #include <asm/delay.h> #include <asm/rtc.h> #include <asm/irq.h> #include <asm/irq_regs.h> #include <hwregs/reg_map.h> #include <hwregs/reg_rdwr.h> #include <hwregs/timer_defs.h> #include <hwregs/intr_vect_defs.h> #ifdef CONFIG_CRIS_MACH_ARTPEC3 #include <hwregs/clkgen_defs.h> #endif /* Watchdog defines */ #define ETRAX_WD_KEY_MASK 0x7F /* key is 7 bit */ #define ETRAX_WD_HZ 763 /* watchdog counts at 763 Hz */ /* Number of 763 counts before watchdog bites */ #define ETRAX_WD_CNT ((2*ETRAX_WD_HZ)/HZ + 1) unsigned long timer_regs[NR_CPUS] = { regi_timer0, #ifdef CONFIG_SMP regi_timer2 #endif }; extern void update_xtime_from_cmos(void); extern int set_rtc_mmss(unsigned long nowtime); extern int setup_irq(int, struct irqaction *); extern int have_rtc; #ifdef CONFIG_CPU_FREQ static int cris_time_freq_notifier(struct notifier_block *nb, unsigned long val, void *data); static struct notifier_block cris_time_freq_notifier_block = { .notifier_call = cris_time_freq_notifier, }; #endif unsigned long get_ns_in_jiffie(void) { reg_timer_r_tmr0_data data; unsigned long ns; data = REG_RD(timer, regi_timer0, r_tmr0_data); ns = (TIMER0_DIV - data) * 10; return ns; } unsigned long do_slow_gettimeoffset(void) { unsigned long count; unsigned long usec_count = 0; /* For the first call after boot */ static unsigned long count_p = TIMER0_DIV; static unsigned long jiffies_p = 0; /* Cache volatile jiffies temporarily; we have IRQs turned off. */ unsigned long jiffies_t; /* The timer interrupt comes from Etrax timer 0. In order to get * better precision, we check the current value. It might have * underflowed already though. */ count = REG_RD(timer, regi_timer0, r_tmr0_data); jiffies_t = jiffies; /* Avoiding timer inconsistencies (they are rare, but they happen) * There is one problem that must be avoided here: * 1. the timer counter underflows */ if( jiffies_t == jiffies_p ) { if( count > count_p ) { /* Timer wrapped, use new count and prescale. * Increase the time corresponding to one jiffy. */ usec_count = 1000000/HZ; } } else jiffies_p = jiffies_t; count_p = count; /* Convert timer value to usec */ /* 100 MHz timer, divide by 100 to get usec */ usec_count += (TIMER0_DIV - count) / 100; return usec_count; } /* From timer MDS describing the hardware watchdog: * 4.3.1 Watchdog Operation * The watchdog timer is an 8-bit timer with a configurable start value. * Once started the watchdog counts downwards with a frequency of 763 Hz * (100/131072 MHz). When the watchdog counts down to 1, it generates an * NMI (Non Maskable Interrupt), and when it counts down to 0, it resets the * chip. */ /* This gives us 1.3 ms to do something useful when the NMI comes */ /* Right now, starting the watchdog is the same as resetting it */ #define start_watchdog reset_watchdog #if defined(CONFIG_ETRAX_WATCHDOG) static short int watchdog_key = 42; /* arbitrary 7 bit number */ #endif /* Number of pages to consider "out of memory". It is normal that the memory * is used though, so set this really low. */ #define WATCHDOG_MIN_FREE_PAGES 8 void reset_watchdog(void) { #if defined(CONFIG_ETRAX_WATCHDOG) reg_timer_rw_wd_ctrl wd_ctrl = { 0 }; /* Only keep watchdog happy as long as we have memory left! */ if(nr_free_pages() > WATCHDOG_MIN_FREE_PAGES) { /* Reset the watchdog with the inverse of the old key */ /* Invert key, which is 7 bits */ watchdog_key ^= ETRAX_WD_KEY_MASK; wd_ctrl.cnt = ETRAX_WD_CNT; wd_ctrl.cmd = regk_timer_start; wd_ctrl.key = watchdog_key; REG_WR(timer, regi_timer0, rw_wd_ctrl, wd_ctrl); } #endif } /* stop the watchdog - we still need the correct key */ void stop_watchdog(void) { #if defined(CONFIG_ETRAX_WATCHDOG) reg_timer_rw_wd_ctrl wd_ctrl = { 0 }; watchdog_key ^= ETRAX_WD_KEY_MASK; /* invert key, which is 7 bits */ wd_ctrl.cnt = ETRAX_WD_CNT; wd_ctrl.cmd = regk_timer_stop; wd_ctrl.key = watchdog_key; REG_WR(timer, regi_timer0, rw_wd_ctrl, wd_ctrl); #endif } extern void show_registers(struct pt_regs *regs); void handle_watchdog_bite(struct pt_regs* regs) { #if defined(CONFIG_ETRAX_WATCHDOG) extern int cause_of_death; oops_in_progress = 1; printk(KERN_WARNING "Watchdog bite\n"); /* Check if forced restart or unexpected watchdog */ if (cause_of_death == 0xbedead) { #ifdef CONFIG_CRIS_MACH_ARTPEC3 /* There is a bug in Artpec-3 (voodoo TR 78) that requires * us to go to lower frequency for the reset to be reliable */ reg_clkgen_rw_clk_ctrl ctrl = REG_RD(clkgen, regi_clkgen, rw_clk_ctrl); ctrl.pll = 0; REG_WR(clkgen, regi_clkgen, rw_clk_ctrl, ctrl); #endif while(1); } /* Unexpected watchdog, stop the watchdog and dump registers. */ stop_watchdog(); printk(KERN_WARNING "Oops: bitten by watchdog\n"); show_registers(regs); oops_in_progress = 0; #ifndef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY reset_watchdog(); #endif while(1) /* nothing */; #endif } /* Last time the cmos clock got updated. */ static long last_rtc_update = 0; /* * timer_interrupt() needs to keep up the real-time clock, * as well as call the "do_timer()" routine every clocktick. */ extern void cris_do_profile(struct pt_regs *regs); static inline irqreturn_t timer_interrupt(int irq, void *dev_id) { struct pt_regs *regs = get_irq_regs(); int cpu = smp_processor_id(); reg_timer_r_masked_intr masked_intr; reg_timer_rw_ack_intr ack_intr = { 0 }; /* Check if the timer interrupt is for us (a tmr0 int) */ masked_intr = REG_RD(timer, timer_regs[cpu], r_masked_intr); if (!masked_intr.tmr0) return IRQ_NONE; /* Acknowledge the timer irq. */ ack_intr.tmr0 = 1; REG_WR(timer, timer_regs[cpu], rw_ack_intr, ack_intr); /* Reset watchdog otherwise it resets us! */ reset_watchdog(); /* Update statistics. */ update_process_times(user_mode(regs)); cris_do_profile(regs); /* Save profiling information */ /* The master CPU is responsible for the time keeping. */ if (cpu != 0) return IRQ_HANDLED; /* Call the real timer interrupt handler */ do_timer(1); /* * If we have an externally synchronized Linux clock, then update * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be * called as close as possible to 500 ms before the new second starts. * * The division here is not time critical since it will run once in * 11 minutes */ if ((time_status & STA_UNSYNC) == 0 && xtime.tv_sec > last_rtc_update + 660 && (xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 && (xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) { if (set_rtc_mmss(xtime.tv_sec) == 0) last_rtc_update = xtime.tv_sec; else /* Do it again in 60 s */ last_rtc_update = xtime.tv_sec - 600; } return IRQ_HANDLED; } /* Timer is IRQF_SHARED so drivers can add stuff to the timer irq chain. * It needs to be IRQF_DISABLED to make the jiffies update work properly. */ static struct irqaction irq_timer = { .handler = timer_interrupt, .flags = IRQF_SHARED | IRQF_DISABLED, .mask = CPU_MASK_NONE, .name = "timer" }; void __init cris_timer_init(void) { int cpu = smp_processor_id(); reg_timer_rw_tmr0_ctrl tmr0_ctrl = { 0 }; reg_timer_rw_tmr0_div tmr0_div = TIMER0_DIV; reg_timer_rw_intr_mask timer_intr_mask; /* Setup the etrax timers. * Base frequency is 100MHz, divider 1000000 -> 100 HZ * We use timer0, so timer1 is free. * The trig timer is used by the fasttimer API if enabled. */ tmr0_ctrl.op = regk_timer_ld; tmr0_ctrl.freq = regk_timer_f100; REG_WR(timer, timer_regs[cpu], rw_tmr0_div, tmr0_div); REG_WR(timer, timer_regs[cpu], rw_tmr0_ctrl, tmr0_ctrl); /* Load */ tmr0_ctrl.op = regk_timer_run; REG_WR(timer, timer_regs[cpu], rw_tmr0_ctrl, tmr0_ctrl); /* Start */ /* Enable the timer irq. */ timer_intr_mask = REG_RD(timer, timer_regs[cpu], rw_intr_mask); timer_intr_mask.tmr0 = 1; REG_WR(timer, timer_regs[cpu], rw_intr_mask, timer_intr_mask); } void __init time_init(void) { reg_intr_vect_rw_mask intr_mask; /* Probe for the RTC and read it if it exists. * Before the RTC can be probed the loops_per_usec variable needs * to be initialized to make usleep work. A better value for * loops_per_usec is calculated by the kernel later once the * clock has started. */ loops_per_usec = 50; if(RTC_INIT() < 0) { /* No RTC, start at 1980 */ xtime.tv_sec = 0; xtime.tv_nsec = 0; have_rtc = 0; } else { /* Get the current time */ have_rtc = 1; update_xtime_from_cmos(); } /* * Initialize wall_to_monotonic such that adding it to * xtime will yield zero, the tv_nsec field must be normalized * (i.e., 0 <= nsec < NSEC_PER_SEC). */ set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec); /* Start CPU local timer. */ cris_timer_init(); /* Enable the timer irq in global config. */ intr_mask = REG_RD_VECT(intr_vect, regi_irq, rw_mask, 1); intr_mask.timer0 = 1; REG_WR_VECT(intr_vect, regi_irq, rw_mask, 1, intr_mask); /* Now actually register the timer irq handler that calls * timer_interrupt(). */ setup_irq(TIMER0_INTR_VECT, &irq_timer); /* Enable watchdog if we should use one. */ #if defined(CONFIG_ETRAX_WATCHDOG) printk(KERN_INFO "Enabling watchdog...\n"); start_watchdog(); /* If we use the hardware watchdog, we want to trap it as an NMI * and dump registers before it resets us. For this to happen, we * must set the "m" NMI enable flag (which once set, is unset only * when an NMI is taken). */ { unsigned long flags; local_save_flags(flags); flags |= (1<<30); /* NMI M flag is at bit 30 */ local_irq_restore(flags); } #endif #ifdef CONFIG_CPU_FREQ cpufreq_register_notifier(&cris_time_freq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); #endif } #ifdef CONFIG_CPU_FREQ static int cris_time_freq_notifier(struct notifier_block *nb, unsigned long val, void *data) { struct cpufreq_freqs *freqs = data; if (val == CPUFREQ_POSTCHANGE) { reg_timer_r_tmr0_data data; reg_timer_rw_tmr0_div div = (freqs->new * 500) / HZ; do { data = REG_RD(timer, timer_regs[freqs->cpu], r_tmr0_data); } while (data > 20); REG_WR(timer, timer_regs[freqs->cpu], rw_tmr0_div, div); } return 0; } #endif
gpl-2.0
JaeYoulLee/Linux-Kernel
drivers/input/joystick/xpad.c
188
32284
/* * X-Box gamepad driver * * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de> * 2004 Oliver Schwartz <Oliver.Schwartz@gmx.de>, * Steven Toth <steve@toth.demon.co.uk>, * Franz Lehner <franz@caos.at>, * Ivan Hawkes <blackhawk@ivanhawkes.com> * 2005 Dominic Cerquetti <binary1230@yahoo.com> * 2006 Adam Buchbinder <adam.buchbinder@gmail.com> * 2007 Jan Kratochvil <honza@jikos.cz> * 2010 Christoph Fritz <chf.fritz@googlemail.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 * * * This driver is based on: * - information from http://euc.jp/periphs/xbox-controller.ja.html * - the iForce driver drivers/char/joystick/iforce.c * - the skeleton-driver drivers/usb/usb-skeleton.c * - Xbox 360 information http://www.free60.org/wiki/Gamepad * * Thanks to: * - ITO Takayuki for providing essential xpad information on his website * - Vojtech Pavlik - iforce driver / input subsystem * - Greg Kroah-Hartman - usb-skeleton driver * - XBOX Linux project - extra USB id's * * TODO: * - fine tune axes (especially trigger axes) * - fix "analog" buttons (reported as digital now) * - get rumble working * - need USB IDs for other dance pads * * History: * * 2002-06-27 - 0.0.1 : first version, just said "XBOX HID controller" * * 2002-07-02 - 0.0.2 : basic working version * - all axes and 9 of the 10 buttons work (german InterAct device) * - the black button does not work * * 2002-07-14 - 0.0.3 : rework by Vojtech Pavlik * - indentation fixes * - usb + input init sequence fixes * * 2002-07-16 - 0.0.4 : minor changes, merge with Vojtech's v0.0.3 * - verified the lack of HID and report descriptors * - verified that ALL buttons WORK * - fixed d-pad to axes mapping * * 2002-07-17 - 0.0.5 : simplified d-pad handling * * 2004-10-02 - 0.0.6 : DDR pad support * - borrowed from the XBOX linux kernel * - USB id's for commonly used dance pads are present * - dance pads will map D-PAD to buttons, not axes * - pass the module paramater 'dpad_to_buttons' to force * the D-PAD to map to buttons if your pad is not detected * * Later changes can be tracked in SCM. */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/stat.h> #include <linux/module.h> #include <linux/usb/input.h> #define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>" #define DRIVER_DESC "X-Box pad driver" #define XPAD_PKT_LEN 32 /* xbox d-pads should map to buttons, as is required for DDR pads but we map them to axes when possible to simplify things */ #define MAP_DPAD_TO_BUTTONS (1 << 0) #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) #define MAP_STICKS_TO_NULL (1 << 2) #define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \ MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL) #define XTYPE_XBOX 0 #define XTYPE_XBOX360 1 #define XTYPE_XBOX360W 2 #define XTYPE_UNKNOWN 3 static bool dpad_to_buttons; module_param(dpad_to_buttons, bool, S_IRUGO); MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads"); static bool triggers_to_buttons; module_param(triggers_to_buttons, bool, S_IRUGO); MODULE_PARM_DESC(triggers_to_buttons, "Map triggers to buttons rather than axes for unknown pads"); static bool sticks_to_null; module_param(sticks_to_null, bool, S_IRUGO); MODULE_PARM_DESC(sticks_to_null, "Do not map sticks at all for unknown pads"); static const struct xpad_device { u16 idVendor; u16 idProduct; char *name; u8 mapping; u8 xtype; } xpad_device[] = { { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX }, { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX }, { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX }, { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX }, { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 }, { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 }, { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX }, { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX }, { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX }, { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX }, { 0x0738, 0x4516, "Mad Catz Control Pad", 0, XTYPE_XBOX }, { 0x0738, 0x4522, "Mad Catz LumiCON", 0, XTYPE_XBOX }, { 0x0738, 0x4526, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX }, { 0x0738, 0x4536, "Mad Catz MicroCON", 0, XTYPE_XBOX }, { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX }, { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 }, { 0x0738, 0x4728, "Mad Catz Street Fighter IV FightPad", XTYPE_XBOX360 }, { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, { 0x0738, 0xbeef, "Mad Catz JOYTECH NEO SE Advanced GamePad", XTYPE_XBOX360 }, { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX }, { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", DANCEPAD_MAP_CONFIG, XTYPE_XBOX }, { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX }, { 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX }, { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX }, { 0x0d2f, 0x0002, "Andamiro Pump It Up pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX }, { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX }, { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX }, { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX }, { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX }, { 0x0e6f, 0x0105, "HSM3 Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 }, { 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX }, { 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX }, { 0x12ab, 0x0004, "Honey Bee Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 }, { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 }, { 0x1689, 0xfd00, "Razer Onza Tournament Edition", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 }, { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 }, { 0x1bad, 0xf028, "Street Fighter IV FightPad", 0, XTYPE_XBOX360 }, { 0x1bad, 0xf901, "Gamestop Xbox 360 Controller", 0, XTYPE_XBOX360 }, { 0x1bad, 0xf903, "Tron Xbox 360 controller", 0, XTYPE_XBOX360 }, { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 }, { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } }; /* buttons shared with xbox and xbox360 */ static const signed short xpad_common_btn[] = { BTN_A, BTN_B, BTN_X, BTN_Y, /* "analog" buttons */ BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR, /* start/back/sticks */ -1 /* terminating entry */ }; /* original xbox controllers only */ static const signed short xpad_btn[] = { BTN_C, BTN_Z, /* "analog" buttons */ -1 /* terminating entry */ }; /* used when dpad is mapped to buttons */ static const signed short xpad_btn_pad[] = { BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, /* d-pad left, right */ BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4, /* d-pad up, down */ -1 /* terminating entry */ }; /* used when triggers are mapped to buttons */ static const signed short xpad_btn_triggers[] = { BTN_TL2, BTN_TR2, /* triggers left/right */ -1 }; static const signed short xpad360_btn[] = { /* buttons for x360 controller */ BTN_TL, BTN_TR, /* Button LB/RB */ BTN_MODE, /* The big X button */ -1 }; static const signed short xpad_abs[] = { ABS_X, ABS_Y, /* left stick */ ABS_RX, ABS_RY, /* right stick */ -1 /* terminating entry */ }; /* used when dpad is mapped to axes */ static const signed short xpad_abs_pad[] = { ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */ -1 /* terminating entry */ }; /* used when triggers are mapped to axes */ static const signed short xpad_abs_triggers[] = { ABS_Z, ABS_RZ, /* triggers left/right */ -1 }; /* Xbox 360 has a vendor-specific class, so we cannot match it with only * USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we * match against vendor id as well. Wired Xbox 360 devices have protocol 1, * wireless controllers have protocol 129. */ #define XPAD_XBOX360_VENDOR_PROTOCOL(vend,pr) \ .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO, \ .idVendor = (vend), \ .bInterfaceClass = USB_CLASS_VENDOR_SPEC, \ .bInterfaceSubClass = 93, \ .bInterfaceProtocol = (pr) #define XPAD_XBOX360_VENDOR(vend) \ { XPAD_XBOX360_VENDOR_PROTOCOL(vend,1) }, \ { XPAD_XBOX360_VENDOR_PROTOCOL(vend,129) } static struct usb_device_id xpad_table[] = { { USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */ XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */ XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */ XPAD_XBOX360_VENDOR(0x0738), /* Mad Catz X-Box 360 controllers */ { USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */ XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */ XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */ XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */ XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */ XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */ XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */ XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ XPAD_XBOX360_VENDOR(0x24c6), /* PowerA Controllers */ { } }; MODULE_DEVICE_TABLE(usb, xpad_table); struct usb_xpad { struct input_dev *dev; /* input device interface */ struct usb_device *udev; /* usb device */ struct usb_interface *intf; /* usb interface */ int pad_present; struct urb *irq_in; /* urb for interrupt in report */ unsigned char *idata; /* input data */ dma_addr_t idata_dma; struct urb *bulk_out; unsigned char *bdata; #if defined(CONFIG_JOYSTICK_XPAD_FF) || defined(CONFIG_JOYSTICK_XPAD_LEDS) struct urb *irq_out; /* urb for interrupt out report */ unsigned char *odata; /* output data */ dma_addr_t odata_dma; struct mutex odata_mutex; #endif #if defined(CONFIG_JOYSTICK_XPAD_LEDS) struct xpad_led *led; #endif char phys[64]; /* physical device path */ int mapping; /* map d-pad to buttons or to axes */ int xtype; /* type of xbox device */ }; /* * xpad_process_packet * * Completes a request by converting the data into events for the * input subsystem. * * The used report descriptor was taken from ITO Takayukis website: * http://euc.jp/periphs/xbox-controller.ja.html */ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) { struct input_dev *dev = xpad->dev; if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { /* left stick */ input_report_abs(dev, ABS_X, (__s16) le16_to_cpup((__le16 *)(data + 12))); input_report_abs(dev, ABS_Y, ~(__s16) le16_to_cpup((__le16 *)(data + 14))); /* right stick */ input_report_abs(dev, ABS_RX, (__s16) le16_to_cpup((__le16 *)(data + 16))); input_report_abs(dev, ABS_RY, ~(__s16) le16_to_cpup((__le16 *)(data + 18))); } /* triggers left/right */ if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { input_report_key(dev, BTN_TL2, data[10]); input_report_key(dev, BTN_TR2, data[11]); } else { input_report_abs(dev, ABS_Z, data[10]); input_report_abs(dev, ABS_RZ, data[11]); } /* digital pad */ if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { /* dpad as buttons (left, right, up, down) */ input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); } else { input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04)); input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01)); } /* start/back buttons and stick press left/right */ input_report_key(dev, BTN_START, data[2] & 0x10); input_report_key(dev, BTN_SELECT, data[2] & 0x20); input_report_key(dev, BTN_THUMBL, data[2] & 0x40); input_report_key(dev, BTN_THUMBR, data[2] & 0x80); /* "analog" buttons A, B, X, Y */ input_report_key(dev, BTN_A, data[4]); input_report_key(dev, BTN_B, data[5]); input_report_key(dev, BTN_X, data[6]); input_report_key(dev, BTN_Y, data[7]); /* "analog" buttons black, white */ input_report_key(dev, BTN_C, data[8]); input_report_key(dev, BTN_Z, data[9]); input_sync(dev); } /* * xpad360_process_packet * * Completes a request by converting the data into events for the * input subsystem. It is version for xbox 360 controller * * The used report descriptor was taken from: * http://www.free60.org/wiki/Gamepad */ static void xpad360_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) { struct input_dev *dev = xpad->dev; /* digital pad */ if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { /* dpad as buttons (left, right, up, down) */ input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); } else { input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04)); input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01)); } /* start/back buttons */ input_report_key(dev, BTN_START, data[2] & 0x10); input_report_key(dev, BTN_SELECT, data[2] & 0x20); /* stick press left/right */ input_report_key(dev, BTN_THUMBL, data[2] & 0x40); input_report_key(dev, BTN_THUMBR, data[2] & 0x80); /* buttons A,B,X,Y,TL,TR and MODE */ input_report_key(dev, BTN_A, data[3] & 0x10); input_report_key(dev, BTN_B, data[3] & 0x20); input_report_key(dev, BTN_X, data[3] & 0x40); input_report_key(dev, BTN_Y, data[3] & 0x80); input_report_key(dev, BTN_TL, data[3] & 0x01); input_report_key(dev, BTN_TR, data[3] & 0x02); input_report_key(dev, BTN_MODE, data[3] & 0x04); if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { /* left stick */ input_report_abs(dev, ABS_X, (__s16) le16_to_cpup((__le16 *)(data + 6))); input_report_abs(dev, ABS_Y, ~(__s16) le16_to_cpup((__le16 *)(data + 8))); /* right stick */ input_report_abs(dev, ABS_RX, (__s16) le16_to_cpup((__le16 *)(data + 10))); input_report_abs(dev, ABS_RY, ~(__s16) le16_to_cpup((__le16 *)(data + 12))); } /* triggers left/right */ if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { input_report_key(dev, BTN_TL2, data[4]); input_report_key(dev, BTN_TR2, data[5]); } else { input_report_abs(dev, ABS_Z, data[4]); input_report_abs(dev, ABS_RZ, data[5]); } input_sync(dev); } /* * xpad360w_process_packet * * Completes a request by converting the data into events for the * input subsystem. It is version for xbox 360 wireless controller. * * Byte.Bit * 00.1 - Status change: The controller or headset has connected/disconnected * Bits 01.7 and 01.6 are valid * 01.7 - Controller present * 01.6 - Headset present * 01.1 - Pad state (Bytes 4+) valid * */ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) { /* Presence change */ if (data[0] & 0x08) { if (data[1] & 0x80) { xpad->pad_present = 1; usb_submit_urb(xpad->bulk_out, GFP_ATOMIC); } else xpad->pad_present = 0; } /* Valid pad data */ if (!(data[1] & 0x1)) return; xpad360_process_packet(xpad, cmd, &data[4]); } static void xpad_irq_in(struct urb *urb) { struct usb_xpad *xpad = urb->context; struct device *dev = &xpad->intf->dev; int retval, status; status = urb->status; switch (status) { case 0: /* success */ break; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status); return; default: dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status); goto exit; } switch (xpad->xtype) { case XTYPE_XBOX360: xpad360_process_packet(xpad, 0, xpad->idata); break; case XTYPE_XBOX360W: xpad360w_process_packet(xpad, 0, xpad->idata); break; default: xpad_process_packet(xpad, 0, xpad->idata); } exit: retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); } static void xpad_bulk_out(struct urb *urb) { struct usb_xpad *xpad = urb->context; struct device *dev = &xpad->intf->dev; switch (urb->status) { case 0: /* success */ break; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, urb->status); break; default: dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, urb->status); } } #if defined(CONFIG_JOYSTICK_XPAD_FF) || defined(CONFIG_JOYSTICK_XPAD_LEDS) static void xpad_irq_out(struct urb *urb) { struct usb_xpad *xpad = urb->context; struct device *dev = &xpad->intf->dev; int retval, status; status = urb->status; switch (status) { case 0: /* success */ return; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status); return; default: dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status); goto exit; } exit: retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); } static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) { struct usb_endpoint_descriptor *ep_irq_out; int error; if (xpad->xtype == XTYPE_UNKNOWN) return 0; xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, GFP_KERNEL, &xpad->odata_dma); if (!xpad->odata) { error = -ENOMEM; goto fail1; } mutex_init(&xpad->odata_mutex); xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); if (!xpad->irq_out) { error = -ENOMEM; goto fail2; } ep_irq_out = &intf->cur_altsetting->endpoint[1].desc; usb_fill_int_urb(xpad->irq_out, xpad->udev, usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), xpad->odata, XPAD_PKT_LEN, xpad_irq_out, xpad, ep_irq_out->bInterval); xpad->irq_out->transfer_dma = xpad->odata_dma; xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; return 0; fail2: usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); fail1: return error; } static void xpad_stop_output(struct usb_xpad *xpad) { if (xpad->xtype != XTYPE_UNKNOWN) usb_kill_urb(xpad->irq_out); } static void xpad_deinit_output(struct usb_xpad *xpad) { if (xpad->xtype != XTYPE_UNKNOWN) { usb_free_urb(xpad->irq_out); usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); } } #else static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) { return 0; } static void xpad_deinit_output(struct usb_xpad *xpad) {} static void xpad_stop_output(struct usb_xpad *xpad) {} #endif #ifdef CONFIG_JOYSTICK_XPAD_FF static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) { struct usb_xpad *xpad = input_get_drvdata(dev); if (effect->type == FF_RUMBLE) { __u16 strong = effect->u.rumble.strong_magnitude; __u16 weak = effect->u.rumble.weak_magnitude; switch (xpad->xtype) { case XTYPE_XBOX: xpad->odata[0] = 0x00; xpad->odata[1] = 0x06; xpad->odata[2] = 0x00; xpad->odata[3] = strong / 256; /* left actuator */ xpad->odata[4] = 0x00; xpad->odata[5] = weak / 256; /* right actuator */ xpad->irq_out->transfer_buffer_length = 6; return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); case XTYPE_XBOX360: xpad->odata[0] = 0x00; xpad->odata[1] = 0x08; xpad->odata[2] = 0x00; xpad->odata[3] = strong / 256; /* left actuator? */ xpad->odata[4] = weak / 256; /* right actuator? */ xpad->odata[5] = 0x00; xpad->odata[6] = 0x00; xpad->odata[7] = 0x00; xpad->irq_out->transfer_buffer_length = 8; return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); case XTYPE_XBOX360W: xpad->odata[0] = 0x00; xpad->odata[1] = 0x01; xpad->odata[2] = 0x0F; xpad->odata[3] = 0xC0; xpad->odata[4] = 0x00; xpad->odata[5] = strong / 256; xpad->odata[6] = weak / 256; xpad->odata[7] = 0x00; xpad->odata[8] = 0x00; xpad->odata[9] = 0x00; xpad->odata[10] = 0x00; xpad->odata[11] = 0x00; xpad->irq_out->transfer_buffer_length = 12; return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); default: dev_dbg(&xpad->dev->dev, "%s - rumble command sent to unsupported xpad type: %d\n", __func__, xpad->xtype); return -1; } } return 0; } static int xpad_init_ff(struct usb_xpad *xpad) { if (xpad->xtype == XTYPE_UNKNOWN) return 0; input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect); } #else static int xpad_init_ff(struct usb_xpad *xpad) { return 0; } #endif #if defined(CONFIG_JOYSTICK_XPAD_LEDS) #include <linux/leds.h> struct xpad_led { char name[16]; struct led_classdev led_cdev; struct usb_xpad *xpad; }; static void xpad_send_led_command(struct usb_xpad *xpad, int command) { if (command >= 0 && command < 14) { mutex_lock(&xpad->odata_mutex); xpad->odata[0] = 0x01; xpad->odata[1] = 0x03; xpad->odata[2] = command; xpad->irq_out->transfer_buffer_length = 3; usb_submit_urb(xpad->irq_out, GFP_KERNEL); mutex_unlock(&xpad->odata_mutex); } } static void xpad_led_set(struct led_classdev *led_cdev, enum led_brightness value) { struct xpad_led *xpad_led = container_of(led_cdev, struct xpad_led, led_cdev); xpad_send_led_command(xpad_led->xpad, value); } static int xpad_led_probe(struct usb_xpad *xpad) { static atomic_t led_seq = ATOMIC_INIT(0); long led_no; struct xpad_led *led; struct led_classdev *led_cdev; int error; if (xpad->xtype != XTYPE_XBOX360) return 0; xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL); if (!led) return -ENOMEM; led_no = (long)atomic_inc_return(&led_seq) - 1; snprintf(led->name, sizeof(led->name), "xpad%ld", led_no); led->xpad = xpad; led_cdev = &led->led_cdev; led_cdev->name = led->name; led_cdev->brightness_set = xpad_led_set; error = led_classdev_register(&xpad->udev->dev, led_cdev); if (error) { kfree(led); xpad->led = NULL; return error; } /* * Light up the segment corresponding to controller number */ xpad_send_led_command(xpad, (led_no % 4) + 2); return 0; } static void xpad_led_disconnect(struct usb_xpad *xpad) { struct xpad_led *xpad_led = xpad->led; if (xpad_led) { led_classdev_unregister(&xpad_led->led_cdev); kfree(xpad_led); } } #else static int xpad_led_probe(struct usb_xpad *xpad) { return 0; } static void xpad_led_disconnect(struct usb_xpad *xpad) { } #endif static int xpad_open(struct input_dev *dev) { struct usb_xpad *xpad = input_get_drvdata(dev); /* URB was submitted in probe */ if (xpad->xtype == XTYPE_XBOX360W) return 0; xpad->irq_in->dev = xpad->udev; if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) return -EIO; return 0; } static void xpad_close(struct input_dev *dev) { struct usb_xpad *xpad = input_get_drvdata(dev); if (xpad->xtype != XTYPE_XBOX360W) usb_kill_urb(xpad->irq_in); xpad_stop_output(xpad); } static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs) { set_bit(abs, input_dev->absbit); switch (abs) { case ABS_X: case ABS_Y: case ABS_RX: case ABS_RY: /* the two sticks */ input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128); break; case ABS_Z: case ABS_RZ: /* the triggers (if mapped to axes) */ input_set_abs_params(input_dev, abs, 0, 255, 0, 0); break; case ABS_HAT0X: case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */ input_set_abs_params(input_dev, abs, -1, 1, 0, 0); break; } } static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *udev = interface_to_usbdev(intf); struct usb_xpad *xpad; struct input_dev *input_dev; struct usb_endpoint_descriptor *ep_irq_in; int i, error; for (i = 0; xpad_device[i].idVendor; i++) { if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) break; } xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); input_dev = input_allocate_device(); if (!xpad || !input_dev) { error = -ENOMEM; goto fail1; } xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, GFP_KERNEL, &xpad->idata_dma); if (!xpad->idata) { error = -ENOMEM; goto fail1; } xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); if (!xpad->irq_in) { error = -ENOMEM; goto fail2; } xpad->udev = udev; xpad->intf = intf; xpad->mapping = xpad_device[i].mapping; xpad->xtype = xpad_device[i].xtype; if (xpad->xtype == XTYPE_UNKNOWN) { if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) xpad->xtype = XTYPE_XBOX360W; else xpad->xtype = XTYPE_XBOX360; } else xpad->xtype = XTYPE_XBOX; if (dpad_to_buttons) xpad->mapping |= MAP_DPAD_TO_BUTTONS; if (triggers_to_buttons) xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; if (sticks_to_null) xpad->mapping |= MAP_STICKS_TO_NULL; } xpad->dev = input_dev; usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); input_dev->name = xpad_device[i].name; input_dev->phys = xpad->phys; usb_to_input_id(udev, &input_dev->id); input_dev->dev.parent = &intf->dev; input_set_drvdata(input_dev, xpad); input_dev->open = xpad_open; input_dev->close = xpad_close; input_dev->evbit[0] = BIT_MASK(EV_KEY); if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { input_dev->evbit[0] |= BIT_MASK(EV_ABS); /* set up axes */ for (i = 0; xpad_abs[i] >= 0; i++) xpad_set_up_abs(input_dev, xpad_abs[i]); } /* set up standard buttons */ for (i = 0; xpad_common_btn[i] >= 0; i++) __set_bit(xpad_common_btn[i], input_dev->keybit); /* set up model-specific ones */ if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) { for (i = 0; xpad360_btn[i] >= 0; i++) __set_bit(xpad360_btn[i], input_dev->keybit); } else { for (i = 0; xpad_btn[i] >= 0; i++) __set_bit(xpad_btn[i], input_dev->keybit); } if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { for (i = 0; xpad_btn_pad[i] >= 0; i++) __set_bit(xpad_btn_pad[i], input_dev->keybit); } else { for (i = 0; xpad_abs_pad[i] >= 0; i++) xpad_set_up_abs(input_dev, xpad_abs_pad[i]); } if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { for (i = 0; xpad_btn_triggers[i] >= 0; i++) __set_bit(xpad_btn_triggers[i], input_dev->keybit); } else { for (i = 0; xpad_abs_triggers[i] >= 0; i++) xpad_set_up_abs(input_dev, xpad_abs_triggers[i]); } error = xpad_init_output(intf, xpad); if (error) goto fail3; error = xpad_init_ff(xpad); if (error) goto fail4; error = xpad_led_probe(xpad); if (error) goto fail5; ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; usb_fill_int_urb(xpad->irq_in, udev, usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), xpad->idata, XPAD_PKT_LEN, xpad_irq_in, xpad, ep_irq_in->bInterval); xpad->irq_in->transfer_dma = xpad->idata_dma; xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; error = input_register_device(xpad->dev); if (error) goto fail6; usb_set_intfdata(intf, xpad); if (xpad->xtype == XTYPE_XBOX360W) { /* * Setup the message to set the LEDs on the * controller when it shows up */ xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL); if (!xpad->bulk_out) { error = -ENOMEM; goto fail7; } xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL); if (!xpad->bdata) { error = -ENOMEM; goto fail8; } xpad->bdata[2] = 0x08; switch (intf->cur_altsetting->desc.bInterfaceNumber) { case 0: xpad->bdata[3] = 0x42; break; case 2: xpad->bdata[3] = 0x43; break; case 4: xpad->bdata[3] = 0x44; break; case 6: xpad->bdata[3] = 0x45; } ep_irq_in = &intf->cur_altsetting->endpoint[1].desc; usb_fill_bulk_urb(xpad->bulk_out, udev, usb_sndbulkpipe(udev, ep_irq_in->bEndpointAddress), xpad->bdata, XPAD_PKT_LEN, xpad_bulk_out, xpad); /* * Submit the int URB immediately rather than waiting for open * because we get status messages from the device whether * or not any controllers are attached. In fact, it's * exactly the message that a controller has arrived that * we're waiting for. */ xpad->irq_in->dev = xpad->udev; error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); if (error) goto fail9; } return 0; fail9: kfree(xpad->bdata); fail8: usb_free_urb(xpad->bulk_out); fail7: input_unregister_device(input_dev); input_dev = NULL; fail6: xpad_led_disconnect(xpad); fail5: if (input_dev) input_ff_destroy(input_dev); fail4: xpad_deinit_output(xpad); fail3: usb_free_urb(xpad->irq_in); fail2: usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); fail1: input_free_device(input_dev); kfree(xpad); return error; } static void xpad_disconnect(struct usb_interface *intf) { struct usb_xpad *xpad = usb_get_intfdata (intf); xpad_led_disconnect(xpad); input_unregister_device(xpad->dev); xpad_deinit_output(xpad); if (xpad->xtype == XTYPE_XBOX360W) { usb_kill_urb(xpad->bulk_out); usb_free_urb(xpad->bulk_out); usb_kill_urb(xpad->irq_in); } usb_free_urb(xpad->irq_in); usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); kfree(xpad->bdata); kfree(xpad); usb_set_intfdata(intf, NULL); } static struct usb_driver xpad_driver = { .name = "xpad", .probe = xpad_probe, .disconnect = xpad_disconnect, .id_table = xpad_table, }; module_usb_driver(xpad_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL");
gpl-2.0
pokymobo/linux-yocto-lamobo-r1
arch/x86/kernel/msr.c
956
6655
/* ----------------------------------------------------------------------- * * * Copyright 2000-2008 H. Peter Anvin - All Rights Reserved * Copyright 2009 Intel Corporation; author: H. Peter Anvin * * 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, Inc., 675 Mass Ave, Cambridge MA 02139, * USA; either version 2 of the License, or (at your option) any later * version; incorporated herein by reference. * * ----------------------------------------------------------------------- */ /* * x86 MSR access device * * This device is accessed by lseek() to the appropriate register number * and then read/write in chunks of 8 bytes. A larger size means multiple * reads or writes of the same register. * * This driver uses /dev/cpu/%d/msr where %d is the minor number, and on * an SMP box will direct the access to CPU %d. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> #include <linux/types.h> #include <linux/errno.h> #include <linux/fcntl.h> #include <linux/init.h> #include <linux/poll.h> #include <linux/smp.h> #include <linux/major.h> #include <linux/fs.h> #include <linux/device.h> #include <linux/cpu.h> #include <linux/notifier.h> #include <linux/uaccess.h> #include <linux/gfp.h> #include <asm/processor.h> #include <asm/msr.h> static struct class *msr_class; static loff_t msr_seek(struct file *file, loff_t offset, int orig) { loff_t ret; struct inode *inode = file_inode(file); mutex_lock(&inode->i_mutex); switch (orig) { case SEEK_SET: file->f_pos = offset; ret = file->f_pos; break; case SEEK_CUR: file->f_pos += offset; ret = file->f_pos; break; default: ret = -EINVAL; } mutex_unlock(&inode->i_mutex); return ret; } static ssize_t msr_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { u32 __user *tmp = (u32 __user *) buf; u32 data[2]; u32 reg = *ppos; int cpu = iminor(file_inode(file)); int err = 0; ssize_t bytes = 0; if (count % 8) return -EINVAL; /* Invalid chunk size */ for (; count; count -= 8) { err = rdmsr_safe_on_cpu(cpu, reg, &data[0], &data[1]); if (err) break; if (copy_to_user(tmp, &data, 8)) { err = -EFAULT; break; } tmp += 2; bytes += 8; } return bytes ? bytes : err; } static ssize_t msr_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { const u32 __user *tmp = (const u32 __user *)buf; u32 data[2]; u32 reg = *ppos; int cpu = iminor(file_inode(file)); int err = 0; ssize_t bytes = 0; if (count % 8) return -EINVAL; /* Invalid chunk size */ for (; count; count -= 8) { if (copy_from_user(&data, tmp, 8)) { err = -EFAULT; break; } err = wrmsr_safe_on_cpu(cpu, reg, data[0], data[1]); if (err) break; tmp += 2; bytes += 8; } return bytes ? bytes : err; } static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) { u32 __user *uregs = (u32 __user *)arg; u32 regs[8]; int cpu = iminor(file_inode(file)); int err; switch (ioc) { case X86_IOC_RDMSR_REGS: if (!(file->f_mode & FMODE_READ)) { err = -EBADF; break; } if (copy_from_user(&regs, uregs, sizeof regs)) { err = -EFAULT; break; } err = rdmsr_safe_regs_on_cpu(cpu, regs); if (err) break; if (copy_to_user(uregs, &regs, sizeof regs)) err = -EFAULT; break; case X86_IOC_WRMSR_REGS: if (!(file->f_mode & FMODE_WRITE)) { err = -EBADF; break; } if (copy_from_user(&regs, uregs, sizeof regs)) { err = -EFAULT; break; } err = wrmsr_safe_regs_on_cpu(cpu, regs); if (err) break; if (copy_to_user(uregs, &regs, sizeof regs)) err = -EFAULT; break; default: err = -ENOTTY; break; } return err; } static int msr_open(struct inode *inode, struct file *file) { unsigned int cpu = iminor(file_inode(file)); struct cpuinfo_x86 *c; if (!capable(CAP_SYS_RAWIO)) return -EPERM; if (cpu >= nr_cpu_ids || !cpu_online(cpu)) return -ENXIO; /* No such CPU */ c = &cpu_data(cpu); if (!cpu_has(c, X86_FEATURE_MSR)) return -EIO; /* MSR not supported */ return 0; } /* * File operations we support */ static const struct file_operations msr_fops = { .owner = THIS_MODULE, .llseek = msr_seek, .read = msr_read, .write = msr_write, .open = msr_open, .unlocked_ioctl = msr_ioctl, .compat_ioctl = msr_ioctl, }; static int msr_device_create(int cpu) { struct device *dev; dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), NULL, "msr%d", cpu); return PTR_ERR_OR_ZERO(dev); } static void msr_device_destroy(int cpu) { device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu)); } static int msr_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; int err = 0; switch (action) { case CPU_UP_PREPARE: err = msr_device_create(cpu); break; case CPU_UP_CANCELED: case CPU_UP_CANCELED_FROZEN: case CPU_DEAD: msr_device_destroy(cpu); break; } return notifier_from_errno(err); } static struct notifier_block __refdata msr_class_cpu_notifier = { .notifier_call = msr_class_cpu_callback, }; static char *msr_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "cpu/%u/msr", MINOR(dev->devt)); } static int __init msr_init(void) { int i, err = 0; i = 0; if (__register_chrdev(MSR_MAJOR, 0, NR_CPUS, "cpu/msr", &msr_fops)) { pr_err("unable to get major %d for msr\n", MSR_MAJOR); err = -EBUSY; goto out; } msr_class = class_create(THIS_MODULE, "msr"); if (IS_ERR(msr_class)) { err = PTR_ERR(msr_class); goto out_chrdev; } msr_class->devnode = msr_devnode; cpu_notifier_register_begin(); for_each_online_cpu(i) { err = msr_device_create(i); if (err != 0) goto out_class; } __register_hotcpu_notifier(&msr_class_cpu_notifier); cpu_notifier_register_done(); err = 0; goto out; out_class: i = 0; for_each_online_cpu(i) msr_device_destroy(i); cpu_notifier_register_done(); class_destroy(msr_class); out_chrdev: __unregister_chrdev(MSR_MAJOR, 0, NR_CPUS, "cpu/msr"); out: return err; } static void __exit msr_exit(void) { int cpu = 0; cpu_notifier_register_begin(); for_each_online_cpu(cpu) msr_device_destroy(cpu); class_destroy(msr_class); __unregister_chrdev(MSR_MAJOR, 0, NR_CPUS, "cpu/msr"); __unregister_hotcpu_notifier(&msr_class_cpu_notifier); cpu_notifier_register_done(); } module_init(msr_init); module_exit(msr_exit) MODULE_AUTHOR("H. Peter Anvin <hpa@zytor.com>"); MODULE_DESCRIPTION("x86 generic MSR driver"); MODULE_LICENSE("GPL");
gpl-2.0
ziozzang/linux
fs/xfs/xfs_mru_cache.c
1212
18170
/* * Copyright (c) 2006-2007 Silicon 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. * * 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_mru_cache.h" /* * The MRU Cache data structure consists of a data store, an array of lists and * a lock to protect its internal state. At initialisation time, the client * supplies an element lifetime in milliseconds and a group count, as well as a * function pointer to call when deleting elements. A data structure for * queueing up work in the form of timed callbacks is also included. * * The group count controls how many lists are created, and thereby how finely * the elements are grouped in time. When reaping occurs, all the elements in * all the lists whose time has expired are deleted. * * To give an example of how this works in practice, consider a client that * initialises an MRU Cache with a lifetime of ten seconds and a group count of * five. Five internal lists will be created, each representing a two second * period in time. When the first element is added, time zero for the data * structure is initialised to the current time. * * All the elements added in the first two seconds are appended to the first * list. Elements added in the third second go into the second list, and so on. * If an element is accessed at any point, it is removed from its list and * inserted at the head of the current most-recently-used list. * * The reaper function will have nothing to do until at least twelve seconds * have elapsed since the first element was added. The reason for this is that * if it were called at t=11s, there could be elements in the first list that * have only been inactive for nine seconds, so it still does nothing. If it is * called anywhere between t=12 and t=14 seconds, it will delete all the * elements that remain in the first list. It's therefore possible for elements * to remain in the data store even after they've been inactive for up to * (t + t/g) seconds, where t is the inactive element lifetime and g is the * number of groups. * * The above example assumes that the reaper function gets called at least once * every (t/g) seconds. If it is called less frequently, unused elements will * accumulate in the reap list until the reaper function is eventually called. * The current implementation uses work queue callbacks to carefully time the * reaper function calls, so this should happen rarely, if at all. * * From a design perspective, the primary reason for the choice of a list array * representing discrete time intervals is that it's only practical to reap * expired elements in groups of some appreciable size. This automatically * introduces a granularity to element lifetimes, so there's no point storing an * individual timeout with each element that specifies a more precise reap time. * The bonus is a saving of sizeof(long) bytes of memory per element stored. * * The elements could have been stored in just one list, but an array of * counters or pointers would need to be maintained to allow them to be divided * up into discrete time groups. More critically, the process of touching or * removing an element would involve walking large portions of the entire list, * which would have a detrimental effect on performance. The additional memory * requirement for the array of list heads is minimal. * * When an element is touched or deleted, it needs to be removed from its * current list. Doubly linked lists are used to make the list maintenance * portion of these operations O(1). Since reaper timing can be imprecise, * inserts and lookups can occur when there are no free lists available. When * this happens, all the elements on the LRU list need to be migrated to the end * of the reap list. To keep the list maintenance portion of these operations * O(1) also, list tails need to be accessible without walking the entire list. * This is the reason why doubly linked list heads are used. */ /* * An MRU Cache is a dynamic data structure that stores its elements in a way * that allows efficient lookups, but also groups them into discrete time * intervals based on insertion time. This allows elements to be efficiently * and automatically reaped after a fixed period of inactivity. * * When a client data pointer is stored in the MRU Cache it needs to be added to * both the data store and to one of the lists. It must also be possible to * access each of these entries via the other, i.e. to: * * a) Walk a list, removing the corresponding data store entry for each item. * b) Look up a data store entry, then access its list entry directly. * * To achieve both of these goals, each entry must contain both a list entry and * a key, in addition to the user's data pointer. Note that it's not a good * idea to have the client embed one of these structures at the top of their own * data structure, because inserting the same item more than once would most * likely result in a loop in one of the lists. That's a sure-fire recipe for * an infinite loop in the code. */ struct xfs_mru_cache { struct radix_tree_root store; /* Core storage data structure. */ struct list_head *lists; /* Array of lists, one per grp. */ struct list_head reap_list; /* Elements overdue for reaping. */ spinlock_t lock; /* Lock to protect this struct. */ unsigned int grp_count; /* Number of discrete groups. */ unsigned int grp_time; /* Time period spanned by grps. */ unsigned int lru_grp; /* Group containing time zero. */ unsigned long time_zero; /* Time first element was added. */ xfs_mru_cache_free_func_t free_func; /* Function pointer for freeing. */ struct delayed_work work; /* Workqueue data for reaping. */ unsigned int queued; /* work has been queued */ }; static struct workqueue_struct *xfs_mru_reap_wq; /* * When inserting, destroying or reaping, it's first necessary to update the * lists relative to a particular time. In the case of destroying, that time * will be well in the future to ensure that all items are moved to the reap * list. In all other cases though, the time will be the current time. * * This function enters a loop, moving the contents of the LRU list to the reap * list again and again until either a) the lists are all empty, or b) time zero * has been advanced sufficiently to be within the immediate element lifetime. * * Case a) above is detected by counting how many groups are migrated and * stopping when they've all been moved. Case b) is detected by monitoring the * time_zero field, which is updated as each group is migrated. * * The return value is the earliest time that more migration could be needed, or * zero if there's no need to schedule more work because the lists are empty. */ STATIC unsigned long _xfs_mru_cache_migrate( struct xfs_mru_cache *mru, unsigned long now) { unsigned int grp; unsigned int migrated = 0; struct list_head *lru_list; /* Nothing to do if the data store is empty. */ if (!mru->time_zero) return 0; /* While time zero is older than the time spanned by all the lists. */ while (mru->time_zero <= now - mru->grp_count * mru->grp_time) { /* * If the LRU list isn't empty, migrate its elements to the tail * of the reap list. */ lru_list = mru->lists + mru->lru_grp; if (!list_empty(lru_list)) list_splice_init(lru_list, mru->reap_list.prev); /* * Advance the LRU group number, freeing the old LRU list to * become the new MRU list; advance time zero accordingly. */ mru->lru_grp = (mru->lru_grp + 1) % mru->grp_count; mru->time_zero += mru->grp_time; /* * If reaping is so far behind that all the elements on all the * lists have been migrated to the reap list, it's now empty. */ if (++migrated == mru->grp_count) { mru->lru_grp = 0; mru->time_zero = 0; return 0; } } /* Find the first non-empty list from the LRU end. */ for (grp = 0; grp < mru->grp_count; grp++) { /* Check the grp'th list from the LRU end. */ lru_list = mru->lists + ((mru->lru_grp + grp) % mru->grp_count); if (!list_empty(lru_list)) return mru->time_zero + (mru->grp_count + grp) * mru->grp_time; } /* All the lists must be empty. */ mru->lru_grp = 0; mru->time_zero = 0; return 0; } /* * When inserting or doing a lookup, an element needs to be inserted into the * MRU list. The lists must be migrated first to ensure that they're * up-to-date, otherwise the new element could be given a shorter lifetime in * the cache than it should. */ STATIC void _xfs_mru_cache_list_insert( struct xfs_mru_cache *mru, struct xfs_mru_cache_elem *elem) { unsigned int grp = 0; unsigned long now = jiffies; /* * If the data store is empty, initialise time zero, leave grp set to * zero and start the work queue timer if necessary. Otherwise, set grp * to the number of group times that have elapsed since time zero. */ if (!_xfs_mru_cache_migrate(mru, now)) { mru->time_zero = now; if (!mru->queued) { mru->queued = 1; queue_delayed_work(xfs_mru_reap_wq, &mru->work, mru->grp_count * mru->grp_time); } } else { grp = (now - mru->time_zero) / mru->grp_time; grp = (mru->lru_grp + grp) % mru->grp_count; } /* Insert the element at the tail of the corresponding list. */ list_add_tail(&elem->list_node, mru->lists + grp); } /* * When destroying or reaping, all the elements that were migrated to the reap * list need to be deleted. For each element this involves removing it from the * data store, removing it from the reap list, calling the client's free * function and deleting the element from the element zone. * * We get called holding the mru->lock, which we drop and then reacquire. * Sparse need special help with this to tell it we know what we are doing. */ STATIC void _xfs_mru_cache_clear_reap_list( struct xfs_mru_cache *mru) __releases(mru->lock) __acquires(mru->lock) { struct xfs_mru_cache_elem *elem, *next; struct list_head tmp; INIT_LIST_HEAD(&tmp); list_for_each_entry_safe(elem, next, &mru->reap_list, list_node) { /* Remove the element from the data store. */ radix_tree_delete(&mru->store, elem->key); /* * remove to temp list so it can be freed without * needing to hold the lock */ list_move(&elem->list_node, &tmp); } spin_unlock(&mru->lock); list_for_each_entry_safe(elem, next, &tmp, list_node) { list_del_init(&elem->list_node); mru->free_func(elem); } spin_lock(&mru->lock); } /* * We fire the reap timer every group expiry interval so * we always have a reaper ready to run. This makes shutdown * and flushing of the reaper easy to do. Hence we need to * keep when the next reap must occur so we can determine * at each interval whether there is anything we need to do. */ STATIC void _xfs_mru_cache_reap( struct work_struct *work) { struct xfs_mru_cache *mru = container_of(work, struct xfs_mru_cache, work.work); unsigned long now, next; ASSERT(mru && mru->lists); if (!mru || !mru->lists) return; spin_lock(&mru->lock); next = _xfs_mru_cache_migrate(mru, jiffies); _xfs_mru_cache_clear_reap_list(mru); mru->queued = next; if ((mru->queued > 0)) { now = jiffies; if (next <= now) next = 0; else next -= now; queue_delayed_work(xfs_mru_reap_wq, &mru->work, next); } spin_unlock(&mru->lock); } int xfs_mru_cache_init(void) { xfs_mru_reap_wq = alloc_workqueue("xfs_mru_cache", WQ_MEM_RECLAIM|WQ_FREEZABLE, 1); if (!xfs_mru_reap_wq) return -ENOMEM; return 0; } void xfs_mru_cache_uninit(void) { destroy_workqueue(xfs_mru_reap_wq); } /* * To initialise a struct xfs_mru_cache pointer, call xfs_mru_cache_create() * with the address of the pointer, a lifetime value in milliseconds, a group * count and a free function to use when deleting elements. This function * returns 0 if the initialisation was successful. */ int xfs_mru_cache_create( struct xfs_mru_cache **mrup, unsigned int lifetime_ms, unsigned int grp_count, xfs_mru_cache_free_func_t free_func) { struct xfs_mru_cache *mru = NULL; int err = 0, grp; unsigned int grp_time; if (mrup) *mrup = NULL; if (!mrup || !grp_count || !lifetime_ms || !free_func) return -EINVAL; if (!(grp_time = msecs_to_jiffies(lifetime_ms) / grp_count)) return -EINVAL; if (!(mru = kmem_zalloc(sizeof(*mru), KM_SLEEP))) return -ENOMEM; /* An extra list is needed to avoid reaping up to a grp_time early. */ mru->grp_count = grp_count + 1; mru->lists = kmem_zalloc(mru->grp_count * sizeof(*mru->lists), KM_SLEEP); if (!mru->lists) { err = -ENOMEM; goto exit; } for (grp = 0; grp < mru->grp_count; grp++) INIT_LIST_HEAD(mru->lists + grp); /* * We use GFP_KERNEL radix tree preload and do inserts under a * spinlock so GFP_ATOMIC is appropriate for the radix tree itself. */ INIT_RADIX_TREE(&mru->store, GFP_ATOMIC); INIT_LIST_HEAD(&mru->reap_list); spin_lock_init(&mru->lock); INIT_DELAYED_WORK(&mru->work, _xfs_mru_cache_reap); mru->grp_time = grp_time; mru->free_func = free_func; *mrup = mru; exit: if (err && mru && mru->lists) kmem_free(mru->lists); if (err && mru) kmem_free(mru); return err; } /* * Call xfs_mru_cache_flush() to flush out all cached entries, calling their * free functions as they're deleted. When this function returns, the caller is * guaranteed that all the free functions for all the elements have finished * executing and the reaper is not running. */ static void xfs_mru_cache_flush( struct xfs_mru_cache *mru) { if (!mru || !mru->lists) return; spin_lock(&mru->lock); if (mru->queued) { spin_unlock(&mru->lock); cancel_delayed_work_sync(&mru->work); spin_lock(&mru->lock); } _xfs_mru_cache_migrate(mru, jiffies + mru->grp_count * mru->grp_time); _xfs_mru_cache_clear_reap_list(mru); spin_unlock(&mru->lock); } void xfs_mru_cache_destroy( struct xfs_mru_cache *mru) { if (!mru || !mru->lists) return; xfs_mru_cache_flush(mru); kmem_free(mru->lists); kmem_free(mru); } /* * To insert an element, call xfs_mru_cache_insert() with the data store, the * element's key and the client data pointer. This function returns 0 on * success or ENOMEM if memory for the data element couldn't be allocated. */ int xfs_mru_cache_insert( struct xfs_mru_cache *mru, unsigned long key, struct xfs_mru_cache_elem *elem) { int error; ASSERT(mru && mru->lists); if (!mru || !mru->lists) return -EINVAL; if (radix_tree_preload(GFP_NOFS)) return -ENOMEM; INIT_LIST_HEAD(&elem->list_node); elem->key = key; spin_lock(&mru->lock); error = radix_tree_insert(&mru->store, key, elem); radix_tree_preload_end(); if (!error) _xfs_mru_cache_list_insert(mru, elem); spin_unlock(&mru->lock); return error; } /* * To remove an element without calling the free function, call * xfs_mru_cache_remove() with the data store and the element's key. On success * the client data pointer for the removed element is returned, otherwise this * function will return a NULL pointer. */ struct xfs_mru_cache_elem * xfs_mru_cache_remove( struct xfs_mru_cache *mru, unsigned long key) { struct xfs_mru_cache_elem *elem; ASSERT(mru && mru->lists); if (!mru || !mru->lists) return NULL; spin_lock(&mru->lock); elem = radix_tree_delete(&mru->store, key); if (elem) list_del(&elem->list_node); spin_unlock(&mru->lock); return elem; } /* * To remove and element and call the free function, call xfs_mru_cache_delete() * with the data store and the element's key. */ void xfs_mru_cache_delete( struct xfs_mru_cache *mru, unsigned long key) { struct xfs_mru_cache_elem *elem; elem = xfs_mru_cache_remove(mru, key); if (elem) mru->free_func(elem); } /* * To look up an element using its key, call xfs_mru_cache_lookup() with the * data store and the element's key. If found, the element will be moved to the * head of the MRU list to indicate that it's been touched. * * The internal data structures are protected by a spinlock that is STILL HELD * when this function returns. Call xfs_mru_cache_done() to release it. Note * that it is not safe to call any function that might sleep in the interim. * * The implementation could have used reference counting to avoid this * restriction, but since most clients simply want to get, set or test a member * of the returned data structure, the extra per-element memory isn't warranted. * * If the element isn't found, this function returns NULL and the spinlock is * released. xfs_mru_cache_done() should NOT be called when this occurs. * * Because sparse isn't smart enough to know about conditional lock return * status, we need to help it get it right by annotating the path that does * not release the lock. */ struct xfs_mru_cache_elem * xfs_mru_cache_lookup( struct xfs_mru_cache *mru, unsigned long key) { struct xfs_mru_cache_elem *elem; ASSERT(mru && mru->lists); if (!mru || !mru->lists) return NULL; spin_lock(&mru->lock); elem = radix_tree_lookup(&mru->store, key); if (elem) { list_del(&elem->list_node); _xfs_mru_cache_list_insert(mru, elem); __release(mru_lock); /* help sparse not be stupid */ } else spin_unlock(&mru->lock); return elem; } /* * To release the internal data structure spinlock after having performed an * xfs_mru_cache_lookup() or an xfs_mru_cache_peek(), call xfs_mru_cache_done() * with the data store pointer. */ void xfs_mru_cache_done( struct xfs_mru_cache *mru) __releases(mru->lock) { spin_unlock(&mru->lock); }
gpl-2.0
mathkid95/linux_samsung_jb
arch/arm/mach-ixp4xx/common-pci.c
1724
11966
/* * arch/arm/mach-ixp4xx/common-pci.c * * IXP4XX PCI routines for all platforms * * Maintainer: Deepak Saxena <dsaxena@plexity.net> * * Copyright (C) 2002 Intel Corporation. * Copyright (C) 2003 Greg Ungerer <gerg@snapgear.com> * 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 version 2 as * published by the Free Software Foundation. * */ #include <linux/sched.h> #include <linux/kernel.h> #include <linux/pci.h> #include <linux/interrupt.h> #include <linux/mm.h> #include <linux/init.h> #include <linux/ioport.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/io.h> #include <asm/dma-mapping.h> #include <asm/cputype.h> #include <asm/irq.h> #include <asm/sizes.h> #include <asm/system.h> #include <asm/mach/pci.h> #include <mach/hardware.h> /* * IXP4xx PCI read function is dependent on whether we are * running A0 or B0 (AppleGate) silicon. */ int (*ixp4xx_pci_read)(u32 addr, u32 cmd, u32* data); /* * Base address for PCI regsiter region */ unsigned long ixp4xx_pci_reg_base = 0; /* * PCI cfg an I/O routines are done by programming a * command/byte enable register, and then read/writing * the data from a data regsiter. We need to ensure * these transactions are atomic or we will end up * with corrupt data on the bus or in a driver. */ static DEFINE_SPINLOCK(ixp4xx_pci_lock); /* * Read from PCI config space */ static void crp_read(u32 ad_cbe, u32 *data) { unsigned long flags; spin_lock_irqsave(&ixp4xx_pci_lock, flags); *PCI_CRP_AD_CBE = ad_cbe; *data = *PCI_CRP_RDATA; spin_unlock_irqrestore(&ixp4xx_pci_lock, flags); } /* * Write to PCI config space */ static void crp_write(u32 ad_cbe, u32 data) { unsigned long flags; spin_lock_irqsave(&ixp4xx_pci_lock, flags); *PCI_CRP_AD_CBE = CRP_AD_CBE_WRITE | ad_cbe; *PCI_CRP_WDATA = data; spin_unlock_irqrestore(&ixp4xx_pci_lock, flags); } static inline int check_master_abort(void) { /* check Master Abort bit after access */ unsigned long isr = *PCI_ISR; if (isr & PCI_ISR_PFE) { /* make sure the Master Abort bit is reset */ *PCI_ISR = PCI_ISR_PFE; pr_debug("%s failed\n", __func__); return 1; } return 0; } int ixp4xx_pci_read_errata(u32 addr, u32 cmd, u32* data) { unsigned long flags; int retval = 0; int i; spin_lock_irqsave(&ixp4xx_pci_lock, flags); *PCI_NP_AD = addr; /* * PCI workaround - only works if NP PCI space reads have * no side effects!!! Read 8 times. last one will be good. */ for (i = 0; i < 8; i++) { *PCI_NP_CBE = cmd; *data = *PCI_NP_RDATA; *data = *PCI_NP_RDATA; } if(check_master_abort()) retval = 1; spin_unlock_irqrestore(&ixp4xx_pci_lock, flags); return retval; } int ixp4xx_pci_read_no_errata(u32 addr, u32 cmd, u32* data) { unsigned long flags; int retval = 0; spin_lock_irqsave(&ixp4xx_pci_lock, flags); *PCI_NP_AD = addr; /* set up and execute the read */ *PCI_NP_CBE = cmd; /* the result of the read is now in NP_RDATA */ *data = *PCI_NP_RDATA; if(check_master_abort()) retval = 1; spin_unlock_irqrestore(&ixp4xx_pci_lock, flags); return retval; } int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data) { unsigned long flags; int retval = 0; spin_lock_irqsave(&ixp4xx_pci_lock, flags); *PCI_NP_AD = addr; /* set up the write */ *PCI_NP_CBE = cmd; /* execute the write by writing to NP_WDATA */ *PCI_NP_WDATA = data; if(check_master_abort()) retval = 1; spin_unlock_irqrestore(&ixp4xx_pci_lock, flags); return retval; } static u32 ixp4xx_config_addr(u8 bus_num, u16 devfn, int where) { u32 addr; if (!bus_num) { /* type 0 */ addr = BIT(32-PCI_SLOT(devfn)) | ((PCI_FUNC(devfn)) << 8) | (where & ~3); } else { /* type 1 */ addr = (bus_num << 16) | ((PCI_SLOT(devfn)) << 11) | ((PCI_FUNC(devfn)) << 8) | (where & ~3) | 1; } return addr; } /* * Mask table, bits to mask for quantity of size 1, 2 or 4 bytes. * 0 and 3 are not valid indexes... */ static u32 bytemask[] = { /*0*/ 0, /*1*/ 0xff, /*2*/ 0xffff, /*3*/ 0, /*4*/ 0xffffffff, }; static u32 local_byte_lane_enable_bits(u32 n, int size) { if (size == 1) return (0xf & ~BIT(n)) << CRP_AD_CBE_BESL; if (size == 2) return (0xf & ~(BIT(n) | BIT(n+1))) << CRP_AD_CBE_BESL; if (size == 4) return 0; return 0xffffffff; } static int local_read_config(int where, int size, u32 *value) { u32 n, data; pr_debug("local_read_config from %d size %d\n", where, size); n = where % 4; crp_read(where & ~3, &data); *value = (data >> (8*n)) & bytemask[size]; pr_debug("local_read_config read %#x\n", *value); return PCIBIOS_SUCCESSFUL; } static int local_write_config(int where, int size, u32 value) { u32 n, byte_enables, data; pr_debug("local_write_config %#x to %d size %d\n", value, where, size); n = where % 4; byte_enables = local_byte_lane_enable_bits(n, size); if (byte_enables == 0xffffffff) return PCIBIOS_BAD_REGISTER_NUMBER; data = value << (8*n); crp_write((where & ~3) | byte_enables, data); return PCIBIOS_SUCCESSFUL; } static u32 byte_lane_enable_bits(u32 n, int size) { if (size == 1) return (0xf & ~BIT(n)) << 4; if (size == 2) return (0xf & ~(BIT(n) | BIT(n+1))) << 4; if (size == 4) return 0; return 0xffffffff; } static int ixp4xx_pci_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) { u32 n, byte_enables, addr, data; u8 bus_num = bus->number; pr_debug("read_config from %d size %d dev %d:%d:%d\n", where, size, bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn)); *value = 0xffffffff; n = where % 4; byte_enables = byte_lane_enable_bits(n, size); if (byte_enables == 0xffffffff) return PCIBIOS_BAD_REGISTER_NUMBER; addr = ixp4xx_config_addr(bus_num, devfn, where); if (ixp4xx_pci_read(addr, byte_enables | NP_CMD_CONFIGREAD, &data)) return PCIBIOS_DEVICE_NOT_FOUND; *value = (data >> (8*n)) & bytemask[size]; pr_debug("read_config_byte read %#x\n", *value); return PCIBIOS_SUCCESSFUL; } static int ixp4xx_pci_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) { u32 n, byte_enables, addr, data; u8 bus_num = bus->number; pr_debug("write_config_byte %#x to %d size %d dev %d:%d:%d\n", value, where, size, bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn)); n = where % 4; byte_enables = byte_lane_enable_bits(n, size); if (byte_enables == 0xffffffff) return PCIBIOS_BAD_REGISTER_NUMBER; addr = ixp4xx_config_addr(bus_num, devfn, where); data = value << (8*n); if (ixp4xx_pci_write(addr, byte_enables | NP_CMD_CONFIGWRITE, data)) return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_SUCCESSFUL; } struct pci_ops ixp4xx_ops = { .read = ixp4xx_pci_read_config, .write = ixp4xx_pci_write_config, }; /* * PCI abort handler */ static int abort_handler(unsigned long addr, unsigned int fsr, struct pt_regs *regs) { u32 isr, status; isr = *PCI_ISR; local_read_config(PCI_STATUS, 2, &status); pr_debug("PCI: abort_handler addr = %#lx, isr = %#x, " "status = %#x\n", addr, isr, status); /* make sure the Master Abort bit is reset */ *PCI_ISR = PCI_ISR_PFE; status |= PCI_STATUS_REC_MASTER_ABORT; local_write_config(PCI_STATUS, 2, status); /* * If it was an imprecise abort, then we need to correct the * return address to be _after_ the instruction. */ if (fsr & (1 << 10)) regs->ARM_pc += 4; return 0; } /* * Setup DMA mask to 64MB on PCI devices. Ignore all other devices. */ static int ixp4xx_pci_platform_notify(struct device *dev) { if(dev->bus == &pci_bus_type) { *dev->dma_mask = SZ_64M - 1; dev->coherent_dma_mask = SZ_64M - 1; dmabounce_register_dev(dev, 2048, 4096); } return 0; } static int ixp4xx_pci_platform_notify_remove(struct device *dev) { if(dev->bus == &pci_bus_type) { dmabounce_unregister_dev(dev); } return 0; } int dma_needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size) { return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >= SZ_64M); } void __init ixp4xx_pci_preinit(void) { unsigned long cpuid = read_cpuid_id(); /* * Determine which PCI read method to use. * Rev 0 IXP425 requires workaround. */ if (!(cpuid & 0xf) && cpu_is_ixp42x()) { printk("PCI: IXP42x A0 silicon detected - " "PCI Non-Prefetch Workaround Enabled\n"); ixp4xx_pci_read = ixp4xx_pci_read_errata; } else ixp4xx_pci_read = ixp4xx_pci_read_no_errata; /* hook in our fault handler for PCI errors */ hook_fault_code(16+6, abort_handler, SIGBUS, 0, "imprecise external abort"); pr_debug("setup PCI-AHB(inbound) and AHB-PCI(outbound) address mappings\n"); /* * We use identity AHB->PCI address translation * in the 0x48000000 to 0x4bffffff address space */ *PCI_PCIMEMBASE = 0x48494A4B; /* * We also use identity PCI->AHB address translation * in 4 16MB BARs that begin at the physical memory start */ *PCI_AHBMEMBASE = (PHYS_OFFSET & 0xFF000000) + ((PHYS_OFFSET & 0xFF000000) >> 8) + ((PHYS_OFFSET & 0xFF000000) >> 16) + ((PHYS_OFFSET & 0xFF000000) >> 24) + 0x00010203; if (*PCI_CSR & PCI_CSR_HOST) { printk("PCI: IXP4xx is host\n"); pr_debug("setup BARs in controller\n"); /* * We configure the PCI inbound memory windows to be * 1:1 mapped to SDRAM */ local_write_config(PCI_BASE_ADDRESS_0, 4, PHYS_OFFSET); local_write_config(PCI_BASE_ADDRESS_1, 4, PHYS_OFFSET + SZ_16M); local_write_config(PCI_BASE_ADDRESS_2, 4, PHYS_OFFSET + SZ_32M); local_write_config(PCI_BASE_ADDRESS_3, 4, PHYS_OFFSET + SZ_48M); /* * Enable CSR window at 64 MiB to allow PCI masters * to continue prefetching past 64 MiB boundary. */ local_write_config(PCI_BASE_ADDRESS_4, 4, PHYS_OFFSET + SZ_64M); /* * Enable the IO window to be way up high, at 0xfffffc00 */ local_write_config(PCI_BASE_ADDRESS_5, 4, 0xfffffc01); } else { printk("PCI: IXP4xx is target - No bus scan performed\n"); } printk("PCI: IXP4xx Using %s access for memory space\n", #ifndef CONFIG_IXP4XX_INDIRECT_PCI "direct" #else "indirect" #endif ); pr_debug("clear error bits in ISR\n"); *PCI_ISR = PCI_ISR_PSE | PCI_ISR_PFE | PCI_ISR_PPE | PCI_ISR_AHBE; /* * Set Initialize Complete in PCI Control Register: allow IXP4XX to * respond to PCI configuration cycles. Specify that the AHB bus is * operating in big endian mode. Set up byte lane swapping between * little-endian PCI and the big-endian AHB bus */ #ifdef __ARMEB__ *PCI_CSR = PCI_CSR_IC | PCI_CSR_ABE | PCI_CSR_PDS | PCI_CSR_ADS; #else *PCI_CSR = PCI_CSR_IC | PCI_CSR_ABE; #endif pr_debug("DONE\n"); } int ixp4xx_setup(int nr, struct pci_sys_data *sys) { struct resource *res; if (nr >= 1) return 0; res = kzalloc(sizeof(*res) * 2, GFP_KERNEL); if (res == NULL) { /* * If we're out of memory this early, something is wrong, * so we might as well catch it here. */ panic("PCI: unable to allocate resources?\n"); } local_write_config(PCI_COMMAND, 2, PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY); res[0].name = "PCI I/O Space"; res[0].start = 0x00000000; res[0].end = 0x0000ffff; res[0].flags = IORESOURCE_IO; res[1].name = "PCI Memory Space"; res[1].start = PCIBIOS_MIN_MEM; res[1].end = PCIBIOS_MAX_MEM; res[1].flags = IORESOURCE_MEM; request_resource(&ioport_resource, &res[0]); request_resource(&iomem_resource, &res[1]); sys->resource[0] = &res[0]; sys->resource[1] = &res[1]; sys->resource[2] = NULL; platform_notify = ixp4xx_pci_platform_notify; platform_notify_remove = ixp4xx_pci_platform_notify_remove; return 1; } struct pci_bus * __devinit ixp4xx_scan_bus(int nr, struct pci_sys_data *sys) { return pci_scan_bus(sys->busnr, &ixp4xx_ops, sys); } int dma_set_coherent_mask(struct device *dev, u64 mask) { if (mask >= SZ_64M - 1) return 0; return -EIO; } EXPORT_SYMBOL(ixp4xx_pci_read); EXPORT_SYMBOL(ixp4xx_pci_write); EXPORT_SYMBOL(dma_set_coherent_mask);
gpl-2.0
OpenDesireProject/android_kernel_htc_msm7x30
arch/arm/mach-omap1/gpio15xx.c
1980
2514
/* * OMAP15xx specific gpio init * * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ * * Author: * Charulatha V <charu@ti.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 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/gpio.h> #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE #define OMAP1510_GPIO_BASE 0xFFFCE000 /* gpio1 */ static struct __initdata resource omap15xx_mpu_gpio_resources[] = { { .start = OMAP1_MPUIO_VBASE, .end = OMAP1_MPUIO_VBASE + SZ_2K - 1, .flags = IORESOURCE_MEM, }, { .start = INT_MPUIO, .flags = IORESOURCE_IRQ, }, }; static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { .virtual_irq_start = IH_MPUIO_BASE, .bank_type = METHOD_MPUIO, .bank_width = 16, .bank_stride = 1, }; static struct platform_device omap15xx_mpu_gpio = { .name = "omap_gpio", .id = 0, .dev = { .platform_data = &omap15xx_mpu_gpio_config, }, .num_resources = ARRAY_SIZE(omap15xx_mpu_gpio_resources), .resource = omap15xx_mpu_gpio_resources, }; /* gpio2 */ static struct __initdata resource omap15xx_gpio_resources[] = { { .start = OMAP1510_GPIO_BASE, .end = OMAP1510_GPIO_BASE + SZ_2K - 1, .flags = IORESOURCE_MEM, }, { .start = INT_GPIO_BANK1, .flags = IORESOURCE_IRQ, }, }; static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { .virtual_irq_start = IH_GPIO_BASE, .bank_type = METHOD_GPIO_1510, .bank_width = 16, }; static struct platform_device omap15xx_gpio = { .name = "omap_gpio", .id = 1, .dev = { .platform_data = &omap15xx_gpio_config, }, .num_resources = ARRAY_SIZE(omap15xx_gpio_resources), .resource = omap15xx_gpio_resources, }; /* * omap15xx_gpio_init needs to be done before * machine_init functions access gpio APIs. * Hence omap15xx_gpio_init is a postcore_initcall. */ static int __init omap15xx_gpio_init(void) { if (!cpu_is_omap15xx()) return -EINVAL; platform_device_register(&omap15xx_mpu_gpio); platform_device_register(&omap15xx_gpio); gpio_bank_count = 2; return 0; } postcore_initcall(omap15xx_gpio_init);
gpl-2.0
androidbftab1/bf-kernel
arch/avr32/kernel/process.c
1980
8689
/* * Copyright (C) 2004-2006 Atmel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/sched.h> #include <linux/module.h> #include <linux/kallsyms.h> #include <linux/fs.h> #include <linux/pm.h> #include <linux/ptrace.h> #include <linux/slab.h> #include <linux/reboot.h> #include <linux/tick.h> #include <linux/uaccess.h> #include <linux/unistd.h> #include <asm/sysreg.h> #include <asm/ocd.h> #include <asm/syscalls.h> #include <mach/pm.h> void (*pm_power_off)(void); EXPORT_SYMBOL(pm_power_off); /* * This file handles the architecture-dependent parts of process handling.. */ void arch_cpu_idle(void) { cpu_enter_idle(); } void machine_halt(void) { /* * Enter Stop mode. The 32 kHz oscillator will keep running so * the RTC will keep the time properly and the system will * boot quickly. */ asm volatile("sleep 3\n\t" "sub pc, -2"); } void machine_power_off(void) { if (pm_power_off) pm_power_off(); } void machine_restart(char *cmd) { ocd_write(DC, (1 << OCD_DC_DBE_BIT)); ocd_write(DC, (1 << OCD_DC_RES_BIT)); while (1) ; } /* * Free current thread data structures etc */ void exit_thread(void) { ocd_disable(current); } void flush_thread(void) { /* nothing to do */ } void release_thread(struct task_struct *dead_task) { /* do nothing */ } static void dump_mem(const char *str, const char *log_lvl, unsigned long bottom, unsigned long top) { unsigned long p; int i; printk("%s%s(0x%08lx to 0x%08lx)\n", log_lvl, str, bottom, top); for (p = bottom & ~31; p < top; ) { printk("%s%04lx: ", log_lvl, p & 0xffff); for (i = 0; i < 8; i++, p += 4) { unsigned int val; if (p < bottom || p >= top) printk(" "); else { if (__get_user(val, (unsigned int __user *)p)) { printk("\n"); goto out; } printk("%08x ", val); } } printk("\n"); } out: return; } static inline int valid_stack_ptr(struct thread_info *tinfo, unsigned long p) { return (p > (unsigned long)tinfo) && (p < (unsigned long)tinfo + THREAD_SIZE - 3); } #ifdef CONFIG_FRAME_POINTER static void show_trace_log_lvl(struct task_struct *tsk, unsigned long *sp, struct pt_regs *regs, const char *log_lvl) { unsigned long lr, fp; struct thread_info *tinfo; if (regs) fp = regs->r7; else if (tsk == current) asm("mov %0, r7" : "=r"(fp)); else fp = tsk->thread.cpu_context.r7; /* * Walk the stack as long as the frame pointer (a) is within * the kernel stack of the task, and (b) it doesn't move * downwards. */ tinfo = task_thread_info(tsk); printk("%sCall trace:\n", log_lvl); while (valid_stack_ptr(tinfo, fp)) { unsigned long new_fp; lr = *(unsigned long *)fp; #ifdef CONFIG_KALLSYMS printk("%s [<%08lx>] ", log_lvl, lr); #else printk(" [<%08lx>] ", lr); #endif print_symbol("%s\n", lr); new_fp = *(unsigned long *)(fp + 4); if (new_fp <= fp) break; fp = new_fp; } printk("\n"); } #else static void show_trace_log_lvl(struct task_struct *tsk, unsigned long *sp, struct pt_regs *regs, const char *log_lvl) { unsigned long addr; printk("%sCall trace:\n", log_lvl); while (!kstack_end(sp)) { addr = *sp++; if (kernel_text_address(addr)) { #ifdef CONFIG_KALLSYMS printk("%s [<%08lx>] ", log_lvl, addr); #else printk(" [<%08lx>] ", addr); #endif print_symbol("%s\n", addr); } } printk("\n"); } #endif void show_stack_log_lvl(struct task_struct *tsk, unsigned long sp, struct pt_regs *regs, const char *log_lvl) { struct thread_info *tinfo; if (sp == 0) { if (tsk) sp = tsk->thread.cpu_context.ksp; else sp = (unsigned long)&tinfo; } if (!tsk) tsk = current; tinfo = task_thread_info(tsk); if (valid_stack_ptr(tinfo, sp)) { dump_mem("Stack: ", log_lvl, sp, THREAD_SIZE + (unsigned long)tinfo); show_trace_log_lvl(tsk, (unsigned long *)sp, regs, log_lvl); } } void show_stack(struct task_struct *tsk, unsigned long *stack) { show_stack_log_lvl(tsk, (unsigned long)stack, NULL, ""); } static const char *cpu_modes[] = { "Application", "Supervisor", "Interrupt level 0", "Interrupt level 1", "Interrupt level 2", "Interrupt level 3", "Exception", "NMI" }; void show_regs_log_lvl(struct pt_regs *regs, const char *log_lvl) { unsigned long sp = regs->sp; unsigned long lr = regs->lr; unsigned long mode = (regs->sr & MODE_MASK) >> MODE_SHIFT; show_regs_print_info(log_lvl); if (!user_mode(regs)) { sp = (unsigned long)regs + FRAME_SIZE_FULL; printk("%s", log_lvl); print_symbol("PC is at %s\n", instruction_pointer(regs)); printk("%s", log_lvl); print_symbol("LR is at %s\n", lr); } printk("%spc : [<%08lx>] lr : [<%08lx>] %s\n" "%ssp : %08lx r12: %08lx r11: %08lx\n", log_lvl, instruction_pointer(regs), lr, print_tainted(), log_lvl, sp, regs->r12, regs->r11); printk("%sr10: %08lx r9 : %08lx r8 : %08lx\n", log_lvl, regs->r10, regs->r9, regs->r8); printk("%sr7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n", log_lvl, regs->r7, regs->r6, regs->r5, regs->r4); printk("%sr3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n", log_lvl, regs->r3, regs->r2, regs->r1, regs->r0); printk("%sFlags: %c%c%c%c%c\n", log_lvl, regs->sr & SR_Q ? 'Q' : 'q', regs->sr & SR_V ? 'V' : 'v', regs->sr & SR_N ? 'N' : 'n', regs->sr & SR_Z ? 'Z' : 'z', regs->sr & SR_C ? 'C' : 'c'); printk("%sMode bits: %c%c%c%c%c%c%c%c%c%c\n", log_lvl, regs->sr & SR_H ? 'H' : 'h', regs->sr & SR_J ? 'J' : 'j', regs->sr & SR_DM ? 'M' : 'm', regs->sr & SR_D ? 'D' : 'd', regs->sr & SR_EM ? 'E' : 'e', regs->sr & SR_I3M ? '3' : '.', regs->sr & SR_I2M ? '2' : '.', regs->sr & SR_I1M ? '1' : '.', regs->sr & SR_I0M ? '0' : '.', regs->sr & SR_GM ? 'G' : 'g'); printk("%sCPU Mode: %s\n", log_lvl, cpu_modes[mode]); } void show_regs(struct pt_regs *regs) { unsigned long sp = regs->sp; if (!user_mode(regs)) sp = (unsigned long)regs + FRAME_SIZE_FULL; show_regs_log_lvl(regs, ""); show_trace_log_lvl(current, (unsigned long *)sp, regs, ""); } EXPORT_SYMBOL(show_regs); /* Fill in the fpu structure for a core dump. This is easy -- we don't have any */ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) { /* Not valid */ return 0; } asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); asmlinkage void syscall_return(void); int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); if (unlikely(p->flags & PF_KTHREAD)) { memset(childregs, 0, sizeof(struct pt_regs)); p->thread.cpu_context.r0 = arg; p->thread.cpu_context.r1 = usp; /* fn */ p->thread.cpu_context.r2 = (unsigned long)syscall_return; p->thread.cpu_context.pc = (unsigned long)ret_from_kernel_thread; childregs->sr = MODE_SUPERVISOR; } else { *childregs = *current_pt_regs(); if (usp) childregs->sp = usp; childregs->r12 = 0; /* Set return value for child */ p->thread.cpu_context.pc = (unsigned long)ret_from_fork; } p->thread.cpu_context.sr = MODE_SUPERVISOR | SR_GM; p->thread.cpu_context.ksp = (unsigned long)childregs; clear_tsk_thread_flag(p, TIF_DEBUG); if ((clone_flags & CLONE_PTRACE) && test_thread_flag(TIF_DEBUG)) ocd_enable(p); return 0; } /* * This function is supposed to answer the question "who called * schedule()?" */ unsigned long get_wchan(struct task_struct *p) { unsigned long pc; unsigned long stack_page; if (!p || p == current || p->state == TASK_RUNNING) return 0; stack_page = (unsigned long)task_stack_page(p); BUG_ON(!stack_page); /* * The stored value of PC is either the address right after * the call to __switch_to() or ret_from_fork. */ pc = thread_saved_pc(p); if (in_sched_functions(pc)) { #ifdef CONFIG_FRAME_POINTER unsigned long fp = p->thread.cpu_context.r7; BUG_ON(fp < stack_page || fp > (THREAD_SIZE + stack_page)); pc = *(unsigned long *)fp; #else /* * We depend on the frame size of schedule here, which * is actually quite ugly. It might be possible to * determine the frame size automatically at build * time by doing this: * - compile sched/core.c * - disassemble the resulting sched.o * - look for 'sub sp,??' shortly after '<schedule>:' */ unsigned long sp = p->thread.cpu_context.ksp + 16; BUG_ON(sp < stack_page || sp > (THREAD_SIZE + stack_page)); pc = *(unsigned long *)sp; #endif } return pc; }
gpl-2.0
krieger-od/linux
arch/avr32/kernel/process.c
1980
8689
/* * Copyright (C) 2004-2006 Atmel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/sched.h> #include <linux/module.h> #include <linux/kallsyms.h> #include <linux/fs.h> #include <linux/pm.h> #include <linux/ptrace.h> #include <linux/slab.h> #include <linux/reboot.h> #include <linux/tick.h> #include <linux/uaccess.h> #include <linux/unistd.h> #include <asm/sysreg.h> #include <asm/ocd.h> #include <asm/syscalls.h> #include <mach/pm.h> void (*pm_power_off)(void); EXPORT_SYMBOL(pm_power_off); /* * This file handles the architecture-dependent parts of process handling.. */ void arch_cpu_idle(void) { cpu_enter_idle(); } void machine_halt(void) { /* * Enter Stop mode. The 32 kHz oscillator will keep running so * the RTC will keep the time properly and the system will * boot quickly. */ asm volatile("sleep 3\n\t" "sub pc, -2"); } void machine_power_off(void) { if (pm_power_off) pm_power_off(); } void machine_restart(char *cmd) { ocd_write(DC, (1 << OCD_DC_DBE_BIT)); ocd_write(DC, (1 << OCD_DC_RES_BIT)); while (1) ; } /* * Free current thread data structures etc */ void exit_thread(void) { ocd_disable(current); } void flush_thread(void) { /* nothing to do */ } void release_thread(struct task_struct *dead_task) { /* do nothing */ } static void dump_mem(const char *str, const char *log_lvl, unsigned long bottom, unsigned long top) { unsigned long p; int i; printk("%s%s(0x%08lx to 0x%08lx)\n", log_lvl, str, bottom, top); for (p = bottom & ~31; p < top; ) { printk("%s%04lx: ", log_lvl, p & 0xffff); for (i = 0; i < 8; i++, p += 4) { unsigned int val; if (p < bottom || p >= top) printk(" "); else { if (__get_user(val, (unsigned int __user *)p)) { printk("\n"); goto out; } printk("%08x ", val); } } printk("\n"); } out: return; } static inline int valid_stack_ptr(struct thread_info *tinfo, unsigned long p) { return (p > (unsigned long)tinfo) && (p < (unsigned long)tinfo + THREAD_SIZE - 3); } #ifdef CONFIG_FRAME_POINTER static void show_trace_log_lvl(struct task_struct *tsk, unsigned long *sp, struct pt_regs *regs, const char *log_lvl) { unsigned long lr, fp; struct thread_info *tinfo; if (regs) fp = regs->r7; else if (tsk == current) asm("mov %0, r7" : "=r"(fp)); else fp = tsk->thread.cpu_context.r7; /* * Walk the stack as long as the frame pointer (a) is within * the kernel stack of the task, and (b) it doesn't move * downwards. */ tinfo = task_thread_info(tsk); printk("%sCall trace:\n", log_lvl); while (valid_stack_ptr(tinfo, fp)) { unsigned long new_fp; lr = *(unsigned long *)fp; #ifdef CONFIG_KALLSYMS printk("%s [<%08lx>] ", log_lvl, lr); #else printk(" [<%08lx>] ", lr); #endif print_symbol("%s\n", lr); new_fp = *(unsigned long *)(fp + 4); if (new_fp <= fp) break; fp = new_fp; } printk("\n"); } #else static void show_trace_log_lvl(struct task_struct *tsk, unsigned long *sp, struct pt_regs *regs, const char *log_lvl) { unsigned long addr; printk("%sCall trace:\n", log_lvl); while (!kstack_end(sp)) { addr = *sp++; if (kernel_text_address(addr)) { #ifdef CONFIG_KALLSYMS printk("%s [<%08lx>] ", log_lvl, addr); #else printk(" [<%08lx>] ", addr); #endif print_symbol("%s\n", addr); } } printk("\n"); } #endif void show_stack_log_lvl(struct task_struct *tsk, unsigned long sp, struct pt_regs *regs, const char *log_lvl) { struct thread_info *tinfo; if (sp == 0) { if (tsk) sp = tsk->thread.cpu_context.ksp; else sp = (unsigned long)&tinfo; } if (!tsk) tsk = current; tinfo = task_thread_info(tsk); if (valid_stack_ptr(tinfo, sp)) { dump_mem("Stack: ", log_lvl, sp, THREAD_SIZE + (unsigned long)tinfo); show_trace_log_lvl(tsk, (unsigned long *)sp, regs, log_lvl); } } void show_stack(struct task_struct *tsk, unsigned long *stack) { show_stack_log_lvl(tsk, (unsigned long)stack, NULL, ""); } static const char *cpu_modes[] = { "Application", "Supervisor", "Interrupt level 0", "Interrupt level 1", "Interrupt level 2", "Interrupt level 3", "Exception", "NMI" }; void show_regs_log_lvl(struct pt_regs *regs, const char *log_lvl) { unsigned long sp = regs->sp; unsigned long lr = regs->lr; unsigned long mode = (regs->sr & MODE_MASK) >> MODE_SHIFT; show_regs_print_info(log_lvl); if (!user_mode(regs)) { sp = (unsigned long)regs + FRAME_SIZE_FULL; printk("%s", log_lvl); print_symbol("PC is at %s\n", instruction_pointer(regs)); printk("%s", log_lvl); print_symbol("LR is at %s\n", lr); } printk("%spc : [<%08lx>] lr : [<%08lx>] %s\n" "%ssp : %08lx r12: %08lx r11: %08lx\n", log_lvl, instruction_pointer(regs), lr, print_tainted(), log_lvl, sp, regs->r12, regs->r11); printk("%sr10: %08lx r9 : %08lx r8 : %08lx\n", log_lvl, regs->r10, regs->r9, regs->r8); printk("%sr7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n", log_lvl, regs->r7, regs->r6, regs->r5, regs->r4); printk("%sr3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n", log_lvl, regs->r3, regs->r2, regs->r1, regs->r0); printk("%sFlags: %c%c%c%c%c\n", log_lvl, regs->sr & SR_Q ? 'Q' : 'q', regs->sr & SR_V ? 'V' : 'v', regs->sr & SR_N ? 'N' : 'n', regs->sr & SR_Z ? 'Z' : 'z', regs->sr & SR_C ? 'C' : 'c'); printk("%sMode bits: %c%c%c%c%c%c%c%c%c%c\n", log_lvl, regs->sr & SR_H ? 'H' : 'h', regs->sr & SR_J ? 'J' : 'j', regs->sr & SR_DM ? 'M' : 'm', regs->sr & SR_D ? 'D' : 'd', regs->sr & SR_EM ? 'E' : 'e', regs->sr & SR_I3M ? '3' : '.', regs->sr & SR_I2M ? '2' : '.', regs->sr & SR_I1M ? '1' : '.', regs->sr & SR_I0M ? '0' : '.', regs->sr & SR_GM ? 'G' : 'g'); printk("%sCPU Mode: %s\n", log_lvl, cpu_modes[mode]); } void show_regs(struct pt_regs *regs) { unsigned long sp = regs->sp; if (!user_mode(regs)) sp = (unsigned long)regs + FRAME_SIZE_FULL; show_regs_log_lvl(regs, ""); show_trace_log_lvl(current, (unsigned long *)sp, regs, ""); } EXPORT_SYMBOL(show_regs); /* Fill in the fpu structure for a core dump. This is easy -- we don't have any */ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) { /* Not valid */ return 0; } asmlinkage void ret_from_fork(void); asmlinkage void ret_from_kernel_thread(void); asmlinkage void syscall_return(void); int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg, struct task_struct *p) { struct pt_regs *childregs = task_pt_regs(p); if (unlikely(p->flags & PF_KTHREAD)) { memset(childregs, 0, sizeof(struct pt_regs)); p->thread.cpu_context.r0 = arg; p->thread.cpu_context.r1 = usp; /* fn */ p->thread.cpu_context.r2 = (unsigned long)syscall_return; p->thread.cpu_context.pc = (unsigned long)ret_from_kernel_thread; childregs->sr = MODE_SUPERVISOR; } else { *childregs = *current_pt_regs(); if (usp) childregs->sp = usp; childregs->r12 = 0; /* Set return value for child */ p->thread.cpu_context.pc = (unsigned long)ret_from_fork; } p->thread.cpu_context.sr = MODE_SUPERVISOR | SR_GM; p->thread.cpu_context.ksp = (unsigned long)childregs; clear_tsk_thread_flag(p, TIF_DEBUG); if ((clone_flags & CLONE_PTRACE) && test_thread_flag(TIF_DEBUG)) ocd_enable(p); return 0; } /* * This function is supposed to answer the question "who called * schedule()?" */ unsigned long get_wchan(struct task_struct *p) { unsigned long pc; unsigned long stack_page; if (!p || p == current || p->state == TASK_RUNNING) return 0; stack_page = (unsigned long)task_stack_page(p); BUG_ON(!stack_page); /* * The stored value of PC is either the address right after * the call to __switch_to() or ret_from_fork. */ pc = thread_saved_pc(p); if (in_sched_functions(pc)) { #ifdef CONFIG_FRAME_POINTER unsigned long fp = p->thread.cpu_context.r7; BUG_ON(fp < stack_page || fp > (THREAD_SIZE + stack_page)); pc = *(unsigned long *)fp; #else /* * We depend on the frame size of schedule here, which * is actually quite ugly. It might be possible to * determine the frame size automatically at build * time by doing this: * - compile sched/core.c * - disassemble the resulting sched.o * - look for 'sub sp,??' shortly after '<schedule>:' */ unsigned long sp = p->thread.cpu_context.ksp + 16; BUG_ON(sp < stack_page || sp > (THREAD_SIZE + stack_page)); pc = *(unsigned long *)sp; #endif } return pc; }
gpl-2.0
u9621071/kernel-uek-UEK3
sound/pci/es1968.c
2236
80456
/* * Driver for ESS Maestro 1/2/2E Sound Card (started 21.8.99) * Copyright (c) by Matze Braun <MatzeBraun@gmx.de>. * Takashi Iwai <tiwai@suse.de> * * Most of the driver code comes from Zach Brown(zab@redhat.com) * Alan Cox OSS Driver * Rewritted from card-es1938.c source. * * TODO: * Perhaps Synth * * 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 * * * Notes from Zach Brown about the driver code * * Hardware Description * * A working Maestro setup contains the Maestro chip wired to a * codec or 2. In the Maestro we have the APUs, the ASSP, and the * Wavecache. The APUs can be though of as virtual audio routing * channels. They can take data from a number of sources and perform * basic encodings of the data. The wavecache is a storehouse for * PCM data. Typically it deals with PCI and interracts with the * APUs. The ASSP is a wacky DSP like device that ESS is loth * to release docs on. Thankfully it isn't required on the Maestro * until you start doing insane things like FM emulation and surround * encoding. The codecs are almost always AC-97 compliant codecs, * but it appears that early Maestros may have had PT101 (an ESS * part?) wired to them. The only real difference in the Maestro * families is external goop like docking capability, memory for * the ASSP, and initialization differences. * * Driver Operation * * We only drive the APU/Wavecache as typical DACs and drive the * mixers in the codecs. There are 64 APUs. We assign 6 to each * /dev/dsp? device. 2 channels for output, and 4 channels for * input. * * Each APU can do a number of things, but we only really use * 3 basic functions. For playback we use them to convert PCM * data fetched over PCI by the wavecahche into analog data that * is handed to the codec. One APU for mono, and a pair for stereo. * When in stereo, the combination of smarts in the APU and Wavecache * decide which wavecache gets the left or right channel. * * For record we still use the old overly mono system. For each in * coming channel the data comes in from the codec, through a 'input' * APU, through another rate converter APU, and then into memory via * the wavecache and PCI. If its stereo, we mash it back into LRLR in * software. The pass between the 2 APUs is supposedly what requires us * to have a 512 byte buffer sitting around in wavecache/memory. * * The wavecache makes our life even more fun. First off, it can * only address the first 28 bits of PCI address space, making it * useless on quite a few architectures. Secondly, its insane. * It claims to fetch from 4 regions of PCI space, each 4 meg in length. * But that doesn't really work. You can only use 1 region. So all our * allocations have to be in 4meg of each other. Booo. Hiss. * So we have a module parameter, dsps_order, that is the order of * the number of dsps to provide. All their buffer space is allocated * on open time. The sonicvibes OSS routines we inherited really want * power of 2 buffers, so we have all those next to each other, then * 512 byte regions for the recording wavecaches. This ends up * wasting quite a bit of memory. The only fixes I can see would be * getting a kernel allocator that could work in zones, or figuring out * just how to coerce the WP into doing what we want. * * The indirection of the various registers means we have to spinlock * nearly all register accesses. We have the main register indirection * like the wave cache, maestro registers, etc. Then we have beasts * like the APU interface that is indirect registers gotten at through * the main maestro indirection. Ouch. We spinlock around the actual * ports on a per card basis. This means spinlock activity at each IO * operation, but the only IO operation clusters are in non critical * paths and it makes the code far easier to follow. Interrupts are * blocked while holding the locks because the int handler has to * get at some of them :(. The mixer interface doesn't, however. * We also have an OSS state lock that is thrown around in a few * places. */ #include <asm/io.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/dma-mapping.h> #include <linux/slab.h> #include <linux/gameport.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/input.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/mpu401.h> #include <sound/ac97_codec.h> #include <sound/initval.h> #ifdef CONFIG_SND_ES1968_RADIO #include <sound/tea575x-tuner.h> #endif #define CARD_NAME "ESS Maestro1/2" #define DRIVER_NAME "ES1968" MODULE_DESCRIPTION("ESS Maestro"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{ESS,Maestro 2e}," "{ESS,Maestro 2}," "{ESS,Maestro 1}," "{TerraTec,DMX}}"); #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) #define SUPPORT_JOYSTICK 1 #endif static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 1-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ static int total_bufsize[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1024 }; static int pcm_substreams_p[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4 }; static int pcm_substreams_c[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1 }; static int clock[SNDRV_CARDS]; static int use_pm[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; static int enable_mpu[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; #ifdef SUPPORT_JOYSTICK static bool joystick[SNDRV_CARDS]; #endif static int radio_nr[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); module_param_array(id, charp, NULL, 0444); MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard."); module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard."); module_param_array(total_bufsize, int, NULL, 0444); MODULE_PARM_DESC(total_bufsize, "Total buffer size in kB."); module_param_array(pcm_substreams_p, int, NULL, 0444); MODULE_PARM_DESC(pcm_substreams_p, "PCM Playback substreams for " CARD_NAME " soundcard."); module_param_array(pcm_substreams_c, int, NULL, 0444); MODULE_PARM_DESC(pcm_substreams_c, "PCM Capture substreams for " CARD_NAME " soundcard."); module_param_array(clock, int, NULL, 0444); MODULE_PARM_DESC(clock, "Clock on " CARD_NAME " soundcard. (0 = auto-detect)"); module_param_array(use_pm, int, NULL, 0444); MODULE_PARM_DESC(use_pm, "Toggle power-management. (0 = off, 1 = on, 2 = auto)"); module_param_array(enable_mpu, int, NULL, 0444); MODULE_PARM_DESC(enable_mpu, "Enable MPU401. (0 = off, 1 = on, 2 = auto)"); #ifdef SUPPORT_JOYSTICK module_param_array(joystick, bool, NULL, 0444); MODULE_PARM_DESC(joystick, "Enable joystick."); #endif module_param_array(radio_nr, int, NULL, 0444); MODULE_PARM_DESC(radio_nr, "Radio device numbers"); #define NR_APUS 64 #define NR_APU_REGS 16 /* NEC Versas ? */ #define NEC_VERSA_SUBID1 0x80581033 #define NEC_VERSA_SUBID2 0x803c1033 /* Mode Flags */ #define ESS_FMT_STEREO 0x01 #define ESS_FMT_16BIT 0x02 #define DAC_RUNNING 1 #define ADC_RUNNING 2 /* Values for the ESM_LEGACY_AUDIO_CONTROL */ #define ESS_DISABLE_AUDIO 0x8000 #define ESS_ENABLE_SERIAL_IRQ 0x4000 #define IO_ADRESS_ALIAS 0x0020 #define MPU401_IRQ_ENABLE 0x0010 #define MPU401_IO_ENABLE 0x0008 #define GAME_IO_ENABLE 0x0004 #define FM_IO_ENABLE 0x0002 #define SB_IO_ENABLE 0x0001 /* Values for the ESM_CONFIG_A */ #define PIC_SNOOP1 0x4000 #define PIC_SNOOP2 0x2000 #define SAFEGUARD 0x0800 #define DMA_CLEAR 0x0700 #define DMA_DDMA 0x0000 #define DMA_TDMA 0x0100 #define DMA_PCPCI 0x0200 #define POST_WRITE 0x0080 #define PCI_TIMING 0x0040 #define SWAP_LR 0x0020 #define SUBTR_DECODE 0x0002 /* Values for the ESM_CONFIG_B */ #define SPDIF_CONFB 0x0100 #define HWV_CONFB 0x0080 #define DEBOUNCE 0x0040 #define GPIO_CONFB 0x0020 #define CHI_CONFB 0x0010 #define IDMA_CONFB 0x0008 /*undoc */ #define MIDI_FIX 0x0004 /*undoc */ #define IRQ_TO_ISA 0x0001 /*undoc */ /* Values for Ring Bus Control B */ #define RINGB_2CODEC_ID_MASK 0x0003 #define RINGB_DIS_VALIDATION 0x0008 #define RINGB_EN_SPDIF 0x0010 #define RINGB_EN_2CODEC 0x0020 #define RINGB_SING_BIT_DUAL 0x0040 /* ****Port Addresses**** */ /* Write & Read */ #define ESM_INDEX 0x02 #define ESM_DATA 0x00 /* AC97 + RingBus */ #define ESM_AC97_INDEX 0x30 #define ESM_AC97_DATA 0x32 #define ESM_RING_BUS_DEST 0x34 #define ESM_RING_BUS_CONTR_A 0x36 #define ESM_RING_BUS_CONTR_B 0x38 #define ESM_RING_BUS_SDO 0x3A /* WaveCache*/ #define WC_INDEX 0x10 #define WC_DATA 0x12 #define WC_CONTROL 0x14 /* ASSP*/ #define ASSP_INDEX 0x80 #define ASSP_MEMORY 0x82 #define ASSP_DATA 0x84 #define ASSP_CONTROL_A 0xA2 #define ASSP_CONTROL_B 0xA4 #define ASSP_CONTROL_C 0xA6 #define ASSP_HOSTW_INDEX 0xA8 #define ASSP_HOSTW_DATA 0xAA #define ASSP_HOSTW_IRQ 0xAC /* Midi */ #define ESM_MPU401_PORT 0x98 /* Others */ #define ESM_PORT_HOST_IRQ 0x18 #define IDR0_DATA_PORT 0x00 #define IDR1_CRAM_POINTER 0x01 #define IDR2_CRAM_DATA 0x02 #define IDR3_WAVE_DATA 0x03 #define IDR4_WAVE_PTR_LOW 0x04 #define IDR5_WAVE_PTR_HI 0x05 #define IDR6_TIMER_CTRL 0x06 #define IDR7_WAVE_ROMRAM 0x07 #define WRITEABLE_MAP 0xEFFFFF #define READABLE_MAP 0x64003F /* PCI Register */ #define ESM_LEGACY_AUDIO_CONTROL 0x40 #define ESM_ACPI_COMMAND 0x54 #define ESM_CONFIG_A 0x50 #define ESM_CONFIG_B 0x52 #define ESM_DDMA 0x60 /* Bob Bits */ #define ESM_BOB_ENABLE 0x0001 #define ESM_BOB_START 0x0001 /* Host IRQ Control Bits */ #define ESM_RESET_MAESTRO 0x8000 #define ESM_RESET_DIRECTSOUND 0x4000 #define ESM_HIRQ_ClkRun 0x0100 #define ESM_HIRQ_HW_VOLUME 0x0040 #define ESM_HIRQ_HARPO 0x0030 /* What's that? */ #define ESM_HIRQ_ASSP 0x0010 #define ESM_HIRQ_DSIE 0x0004 #define ESM_HIRQ_MPU401 0x0002 #define ESM_HIRQ_SB 0x0001 /* Host IRQ Status Bits */ #define ESM_MPU401_IRQ 0x02 #define ESM_SB_IRQ 0x01 #define ESM_SOUND_IRQ 0x04 #define ESM_ASSP_IRQ 0x10 #define ESM_HWVOL_IRQ 0x40 #define ESS_SYSCLK 50000000 #define ESM_BOB_FREQ 200 #define ESM_BOB_FREQ_MAX 800 #define ESM_FREQ_ESM1 (49152000L / 1024L) /* default rate 48000 */ #define ESM_FREQ_ESM2 (50000000L / 1024L) /* APU Modes: reg 0x00, bit 4-7 */ #define ESM_APU_MODE_SHIFT 4 #define ESM_APU_MODE_MASK (0xf << 4) #define ESM_APU_OFF 0x00 #define ESM_APU_16BITLINEAR 0x01 /* 16-Bit Linear Sample Player */ #define ESM_APU_16BITSTEREO 0x02 /* 16-Bit Stereo Sample Player */ #define ESM_APU_8BITLINEAR 0x03 /* 8-Bit Linear Sample Player */ #define ESM_APU_8BITSTEREO 0x04 /* 8-Bit Stereo Sample Player */ #define ESM_APU_8BITDIFF 0x05 /* 8-Bit Differential Sample Playrer */ #define ESM_APU_DIGITALDELAY 0x06 /* Digital Delay Line */ #define ESM_APU_DUALTAP 0x07 /* Dual Tap Reader */ #define ESM_APU_CORRELATOR 0x08 /* Correlator */ #define ESM_APU_INPUTMIXER 0x09 /* Input Mixer */ #define ESM_APU_WAVETABLE 0x0A /* Wave Table Mode */ #define ESM_APU_SRCONVERTOR 0x0B /* Sample Rate Convertor */ #define ESM_APU_16BITPINGPONG 0x0C /* 16-Bit Ping-Pong Sample Player */ #define ESM_APU_RESERVED1 0x0D /* Reserved 1 */ #define ESM_APU_RESERVED2 0x0E /* Reserved 2 */ #define ESM_APU_RESERVED3 0x0F /* Reserved 3 */ /* reg 0x00 */ #define ESM_APU_FILTER_Q_SHIFT 0 #define ESM_APU_FILTER_Q_MASK (3 << 0) /* APU Filtey Q Control */ #define ESM_APU_FILTER_LESSQ 0x00 #define ESM_APU_FILTER_MOREQ 0x03 #define ESM_APU_FILTER_TYPE_SHIFT 2 #define ESM_APU_FILTER_TYPE_MASK (3 << 2) #define ESM_APU_ENV_TYPE_SHIFT 8 #define ESM_APU_ENV_TYPE_MASK (3 << 8) #define ESM_APU_ENV_STATE_SHIFT 10 #define ESM_APU_ENV_STATE_MASK (3 << 10) #define ESM_APU_END_CURVE (1 << 12) #define ESM_APU_INT_ON_LOOP (1 << 13) #define ESM_APU_DMA_ENABLE (1 << 14) /* reg 0x02 */ #define ESM_APU_SUBMIX_GROUP_SHIRT 0 #define ESM_APU_SUBMIX_GROUP_MASK (7 << 0) #define ESM_APU_SUBMIX_MODE (1 << 3) #define ESM_APU_6dB (1 << 4) #define ESM_APU_DUAL_EFFECT (1 << 5) #define ESM_APU_EFFECT_CHANNELS_SHIFT 6 #define ESM_APU_EFFECT_CHANNELS_MASK (3 << 6) /* reg 0x03 */ #define ESM_APU_STEP_SIZE_MASK 0x0fff /* reg 0x04 */ #define ESM_APU_PHASE_SHIFT 0 #define ESM_APU_PHASE_MASK (0xff << 0) #define ESM_APU_WAVE64K_PAGE_SHIFT 8 /* most 8bit of wave start offset */ #define ESM_APU_WAVE64K_PAGE_MASK (0xff << 8) /* reg 0x05 - wave start offset */ /* reg 0x06 - wave end offset */ /* reg 0x07 - wave loop length */ /* reg 0x08 */ #define ESM_APU_EFFECT_GAIN_SHIFT 0 #define ESM_APU_EFFECT_GAIN_MASK (0xff << 0) #define ESM_APU_TREMOLO_DEPTH_SHIFT 8 #define ESM_APU_TREMOLO_DEPTH_MASK (0xf << 8) #define ESM_APU_TREMOLO_RATE_SHIFT 12 #define ESM_APU_TREMOLO_RATE_MASK (0xf << 12) /* reg 0x09 */ /* bit 0-7 amplitude dest? */ #define ESM_APU_AMPLITUDE_NOW_SHIFT 8 #define ESM_APU_AMPLITUDE_NOW_MASK (0xff << 8) /* reg 0x0a */ #define ESM_APU_POLAR_PAN_SHIFT 0 #define ESM_APU_POLAR_PAN_MASK (0x3f << 0) /* Polar Pan Control */ #define ESM_APU_PAN_CENTER_CIRCLE 0x00 #define ESM_APU_PAN_MIDDLE_RADIUS 0x01 #define ESM_APU_PAN_OUTSIDE_RADIUS 0x02 #define ESM_APU_FILTER_TUNING_SHIFT 8 #define ESM_APU_FILTER_TUNING_MASK (0xff << 8) /* reg 0x0b */ #define ESM_APU_DATA_SRC_A_SHIFT 0 #define ESM_APU_DATA_SRC_A_MASK (0x7f << 0) #define ESM_APU_INV_POL_A (1 << 7) #define ESM_APU_DATA_SRC_B_SHIFT 8 #define ESM_APU_DATA_SRC_B_MASK (0x7f << 8) #define ESM_APU_INV_POL_B (1 << 15) #define ESM_APU_VIBRATO_RATE_SHIFT 0 #define ESM_APU_VIBRATO_RATE_MASK (0xf << 0) #define ESM_APU_VIBRATO_DEPTH_SHIFT 4 #define ESM_APU_VIBRATO_DEPTH_MASK (0xf << 4) #define ESM_APU_VIBRATO_PHASE_SHIFT 8 #define ESM_APU_VIBRATO_PHASE_MASK (0xff << 8) /* reg 0x0c */ #define ESM_APU_RADIUS_SELECT (1 << 6) /* APU Filter Control */ #define ESM_APU_FILTER_2POLE_LOPASS 0x00 #define ESM_APU_FILTER_2POLE_BANDPASS 0x01 #define ESM_APU_FILTER_2POLE_HIPASS 0x02 #define ESM_APU_FILTER_1POLE_LOPASS 0x03 #define ESM_APU_FILTER_1POLE_HIPASS 0x04 #define ESM_APU_FILTER_OFF 0x05 /* APU ATFP Type */ #define ESM_APU_ATFP_AMPLITUDE 0x00 #define ESM_APU_ATFP_TREMELO 0x01 #define ESM_APU_ATFP_FILTER 0x02 #define ESM_APU_ATFP_PAN 0x03 /* APU ATFP Flags */ #define ESM_APU_ATFP_FLG_OFF 0x00 #define ESM_APU_ATFP_FLG_WAIT 0x01 #define ESM_APU_ATFP_FLG_DONE 0x02 #define ESM_APU_ATFP_FLG_INPROCESS 0x03 /* capture mixing buffer size */ #define ESM_MEM_ALIGN 0x1000 #define ESM_MIXBUF_SIZE 0x400 #define ESM_MODE_PLAY 0 #define ESM_MODE_CAPTURE 1 /* APU use in the driver */ enum snd_enum_apu_type { ESM_APU_PCM_PLAY, ESM_APU_PCM_CAPTURE, ESM_APU_PCM_RATECONV, ESM_APU_FREE }; /* chip type */ enum { TYPE_MAESTRO, TYPE_MAESTRO2, TYPE_MAESTRO2E }; /* DMA Hack! */ struct esm_memory { struct snd_dma_buffer buf; int empty; /* status */ struct list_head list; }; /* Playback Channel */ struct esschan { int running; u8 apu[4]; u8 apu_mode[4]; /* playback/capture pcm buffer */ struct esm_memory *memory; /* capture mixer buffer */ struct esm_memory *mixbuf; unsigned int hwptr; /* current hw pointer in bytes */ unsigned int count; /* sample counter in bytes */ unsigned int dma_size; /* total buffer size in bytes */ unsigned int frag_size; /* period size in bytes */ unsigned int wav_shift; u16 base[4]; /* offset for ptr */ /* stereo/16bit flag */ unsigned char fmt; int mode; /* playback / capture */ int bob_freq; /* required timer frequency */ struct snd_pcm_substream *substream; /* linked list */ struct list_head list; #ifdef CONFIG_PM_SLEEP u16 wc_map[4]; #endif }; struct es1968 { /* Module Config */ int total_bufsize; /* in bytes */ int playback_streams, capture_streams; unsigned int clock; /* clock */ /* for clock measurement */ unsigned int in_measurement: 1; unsigned int measure_apu; unsigned int measure_lastpos; unsigned int measure_count; /* buffer */ struct snd_dma_buffer dma; /* Resources... */ int irq; unsigned long io_port; int type; struct pci_dev *pci; struct snd_card *card; struct snd_pcm *pcm; int do_pm; /* power-management enabled */ /* DMA memory block */ struct list_head buf_list; /* ALSA Stuff */ struct snd_ac97 *ac97; struct snd_rawmidi *rmidi; spinlock_t reg_lock; unsigned int in_suspend; /* Maestro Stuff */ u16 maestro_map[32]; int bobclient; /* active timer instancs */ int bob_freq; /* timer frequency */ struct mutex memory_mutex; /* memory lock */ /* APU states */ unsigned char apu[NR_APUS]; /* active substreams */ struct list_head substream_list; spinlock_t substream_lock; #ifdef CONFIG_PM_SLEEP u16 apu_map[NR_APUS][NR_APU_REGS]; #endif #ifdef SUPPORT_JOYSTICK struct gameport *gameport; #endif #ifdef CONFIG_SND_ES1968_INPUT struct input_dev *input_dev; char phys[64]; /* physical device path */ #else struct snd_kcontrol *master_switch; /* for h/w volume control */ struct snd_kcontrol *master_volume; #endif struct work_struct hwvol_work; #ifdef CONFIG_SND_ES1968_RADIO struct v4l2_device v4l2_dev; struct snd_tea575x tea; #endif }; static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id); static DEFINE_PCI_DEVICE_TABLE(snd_es1968_ids) = { /* Maestro 1 */ { 0x1285, 0x0100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, TYPE_MAESTRO }, /* Maestro 2 */ { 0x125d, 0x1968, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, TYPE_MAESTRO2 }, /* Maestro 2E */ { 0x125d, 0x1978, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, TYPE_MAESTRO2E }, { 0, } }; MODULE_DEVICE_TABLE(pci, snd_es1968_ids); /* ********************* * Low Level Funcs! * *********************/ /* no spinlock */ static void __maestro_write(struct es1968 *chip, u16 reg, u16 data) { outw(reg, chip->io_port + ESM_INDEX); outw(data, chip->io_port + ESM_DATA); chip->maestro_map[reg] = data; } static inline void maestro_write(struct es1968 *chip, u16 reg, u16 data) { unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); __maestro_write(chip, reg, data); spin_unlock_irqrestore(&chip->reg_lock, flags); } /* no spinlock */ static u16 __maestro_read(struct es1968 *chip, u16 reg) { if (READABLE_MAP & (1 << reg)) { outw(reg, chip->io_port + ESM_INDEX); chip->maestro_map[reg] = inw(chip->io_port + ESM_DATA); } return chip->maestro_map[reg]; } static inline u16 maestro_read(struct es1968 *chip, u16 reg) { unsigned long flags; u16 result; spin_lock_irqsave(&chip->reg_lock, flags); result = __maestro_read(chip, reg); spin_unlock_irqrestore(&chip->reg_lock, flags); return result; } /* Wait for the codec bus to be free */ static int snd_es1968_ac97_wait(struct es1968 *chip) { int timeout = 100000; while (timeout-- > 0) { if (!(inb(chip->io_port + ESM_AC97_INDEX) & 1)) return 0; cond_resched(); } snd_printd("es1968: ac97 timeout\n"); return 1; /* timeout */ } static int snd_es1968_ac97_wait_poll(struct es1968 *chip) { int timeout = 100000; while (timeout-- > 0) { if (!(inb(chip->io_port + ESM_AC97_INDEX) & 1)) return 0; } snd_printd("es1968: ac97 timeout\n"); return 1; /* timeout */ } static void snd_es1968_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { struct es1968 *chip = ac97->private_data; snd_es1968_ac97_wait(chip); /* Write the bus */ outw(val, chip->io_port + ESM_AC97_DATA); /*msleep(1);*/ outb(reg, chip->io_port + ESM_AC97_INDEX); /*msleep(1);*/ } static unsigned short snd_es1968_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { u16 data = 0; struct es1968 *chip = ac97->private_data; snd_es1968_ac97_wait(chip); outb(reg | 0x80, chip->io_port + ESM_AC97_INDEX); /*msleep(1);*/ if (!snd_es1968_ac97_wait_poll(chip)) { data = inw(chip->io_port + ESM_AC97_DATA); /*msleep(1);*/ } return data; } /* no spinlock */ static void apu_index_set(struct es1968 *chip, u16 index) { int i; __maestro_write(chip, IDR1_CRAM_POINTER, index); for (i = 0; i < 1000; i++) if (__maestro_read(chip, IDR1_CRAM_POINTER) == index) return; snd_printd("es1968: APU register select failed. (Timeout)\n"); } /* no spinlock */ static void apu_data_set(struct es1968 *chip, u16 data) { int i; for (i = 0; i < 1000; i++) { if (__maestro_read(chip, IDR0_DATA_PORT) == data) return; __maestro_write(chip, IDR0_DATA_PORT, data); } snd_printd("es1968: APU register set probably failed (Timeout)!\n"); } /* no spinlock */ static void __apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data) { if (snd_BUG_ON(channel >= NR_APUS)) return; #ifdef CONFIG_PM_SLEEP chip->apu_map[channel][reg] = data; #endif reg |= (channel << 4); apu_index_set(chip, reg); apu_data_set(chip, data); } static void apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data) { unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); __apu_set_register(chip, channel, reg, data); spin_unlock_irqrestore(&chip->reg_lock, flags); } static u16 __apu_get_register(struct es1968 *chip, u16 channel, u8 reg) { if (snd_BUG_ON(channel >= NR_APUS)) return 0; reg |= (channel << 4); apu_index_set(chip, reg); return __maestro_read(chip, IDR0_DATA_PORT); } static u16 apu_get_register(struct es1968 *chip, u16 channel, u8 reg) { unsigned long flags; u16 v; spin_lock_irqsave(&chip->reg_lock, flags); v = __apu_get_register(chip, channel, reg); spin_unlock_irqrestore(&chip->reg_lock, flags); return v; } #if 0 /* ASSP is not supported */ static void assp_set_register(struct es1968 *chip, u32 reg, u32 value) { unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); outl(reg, chip->io_port + ASSP_INDEX); outl(value, chip->io_port + ASSP_DATA); spin_unlock_irqrestore(&chip->reg_lock, flags); } static u32 assp_get_register(struct es1968 *chip, u32 reg) { unsigned long flags; u32 value; spin_lock_irqsave(&chip->reg_lock, flags); outl(reg, chip->io_port + ASSP_INDEX); value = inl(chip->io_port + ASSP_DATA); spin_unlock_irqrestore(&chip->reg_lock, flags); return value; } #endif static void wave_set_register(struct es1968 *chip, u16 reg, u16 value) { unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); outw(reg, chip->io_port + WC_INDEX); outw(value, chip->io_port + WC_DATA); spin_unlock_irqrestore(&chip->reg_lock, flags); } static u16 wave_get_register(struct es1968 *chip, u16 reg) { unsigned long flags; u16 value; spin_lock_irqsave(&chip->reg_lock, flags); outw(reg, chip->io_port + WC_INDEX); value = inw(chip->io_port + WC_DATA); spin_unlock_irqrestore(&chip->reg_lock, flags); return value; } /* ******************* * Bob the Timer! * *******************/ static void snd_es1968_bob_stop(struct es1968 *chip) { u16 reg; reg = __maestro_read(chip, 0x11); reg &= ~ESM_BOB_ENABLE; __maestro_write(chip, 0x11, reg); reg = __maestro_read(chip, 0x17); reg &= ~ESM_BOB_START; __maestro_write(chip, 0x17, reg); } static void snd_es1968_bob_start(struct es1968 *chip) { int prescale; int divide; /* compute ideal interrupt frequency for buffer size & play rate */ /* first, find best prescaler value to match freq */ for (prescale = 5; prescale < 12; prescale++) if (chip->bob_freq > (ESS_SYSCLK >> (prescale + 9))) break; /* next, back off prescaler whilst getting divider into optimum range */ divide = 1; while ((prescale > 5) && (divide < 32)) { prescale--; divide <<= 1; } divide >>= 1; /* now fine-tune the divider for best match */ for (; divide < 31; divide++) if (chip->bob_freq > ((ESS_SYSCLK >> (prescale + 9)) / (divide + 1))) break; /* divide = 0 is illegal, but don't let prescale = 4! */ if (divide == 0) { divide++; if (prescale > 5) prescale--; } else if (divide > 1) divide--; __maestro_write(chip, 6, 0x9000 | (prescale << 5) | divide); /* set reg */ /* Now set IDR 11/17 */ __maestro_write(chip, 0x11, __maestro_read(chip, 0x11) | 1); __maestro_write(chip, 0x17, __maestro_read(chip, 0x17) | 1); } /* call with substream spinlock */ static void snd_es1968_bob_inc(struct es1968 *chip, int freq) { chip->bobclient++; if (chip->bobclient == 1) { chip->bob_freq = freq; snd_es1968_bob_start(chip); } else if (chip->bob_freq < freq) { snd_es1968_bob_stop(chip); chip->bob_freq = freq; snd_es1968_bob_start(chip); } } /* call with substream spinlock */ static void snd_es1968_bob_dec(struct es1968 *chip) { chip->bobclient--; if (chip->bobclient <= 0) snd_es1968_bob_stop(chip); else if (chip->bob_freq > ESM_BOB_FREQ) { /* check reduction of timer frequency */ int max_freq = ESM_BOB_FREQ; struct esschan *es; list_for_each_entry(es, &chip->substream_list, list) { if (max_freq < es->bob_freq) max_freq = es->bob_freq; } if (max_freq != chip->bob_freq) { snd_es1968_bob_stop(chip); chip->bob_freq = max_freq; snd_es1968_bob_start(chip); } } } static int snd_es1968_calc_bob_rate(struct es1968 *chip, struct esschan *es, struct snd_pcm_runtime *runtime) { /* we acquire 4 interrupts per period for precise control.. */ int freq = runtime->rate * 4; if (es->fmt & ESS_FMT_STEREO) freq <<= 1; if (es->fmt & ESS_FMT_16BIT) freq <<= 1; freq /= es->frag_size; if (freq < ESM_BOB_FREQ) freq = ESM_BOB_FREQ; else if (freq > ESM_BOB_FREQ_MAX) freq = ESM_BOB_FREQ_MAX; return freq; } /************* * PCM Part * *************/ static u32 snd_es1968_compute_rate(struct es1968 *chip, u32 freq) { u32 rate = (freq << 16) / chip->clock; #if 0 /* XXX: do we need this? */ if (rate > 0x10000) rate = 0x10000; #endif return rate; } /* get current pointer */ static inline unsigned int snd_es1968_get_dma_ptr(struct es1968 *chip, struct esschan *es) { unsigned int offset; offset = apu_get_register(chip, es->apu[0], 5); offset -= es->base[0]; return (offset & 0xFFFE); /* hardware is in words */ } static void snd_es1968_apu_set_freq(struct es1968 *chip, int apu, int freq) { apu_set_register(chip, apu, 2, (apu_get_register(chip, apu, 2) & 0x00FF) | ((freq & 0xff) << 8) | 0x10); apu_set_register(chip, apu, 3, freq >> 8); } /* spin lock held */ static inline void snd_es1968_trigger_apu(struct es1968 *esm, int apu, int mode) { /* set the APU mode */ __apu_set_register(esm, apu, 0, (__apu_get_register(esm, apu, 0) & 0xff0f) | (mode << 4)); } static void snd_es1968_pcm_start(struct es1968 *chip, struct esschan *es) { spin_lock(&chip->reg_lock); __apu_set_register(chip, es->apu[0], 5, es->base[0]); snd_es1968_trigger_apu(chip, es->apu[0], es->apu_mode[0]); if (es->mode == ESM_MODE_CAPTURE) { __apu_set_register(chip, es->apu[2], 5, es->base[2]); snd_es1968_trigger_apu(chip, es->apu[2], es->apu_mode[2]); } if (es->fmt & ESS_FMT_STEREO) { __apu_set_register(chip, es->apu[1], 5, es->base[1]); snd_es1968_trigger_apu(chip, es->apu[1], es->apu_mode[1]); if (es->mode == ESM_MODE_CAPTURE) { __apu_set_register(chip, es->apu[3], 5, es->base[3]); snd_es1968_trigger_apu(chip, es->apu[3], es->apu_mode[3]); } } spin_unlock(&chip->reg_lock); } static void snd_es1968_pcm_stop(struct es1968 *chip, struct esschan *es) { spin_lock(&chip->reg_lock); snd_es1968_trigger_apu(chip, es->apu[0], 0); snd_es1968_trigger_apu(chip, es->apu[1], 0); if (es->mode == ESM_MODE_CAPTURE) { snd_es1968_trigger_apu(chip, es->apu[2], 0); snd_es1968_trigger_apu(chip, es->apu[3], 0); } spin_unlock(&chip->reg_lock); } /* set the wavecache control reg */ static void snd_es1968_program_wavecache(struct es1968 *chip, struct esschan *es, int channel, u32 addr, int capture) { u32 tmpval = (addr - 0x10) & 0xFFF8; if (! capture) { if (!(es->fmt & ESS_FMT_16BIT)) tmpval |= 4; /* 8bit */ if (es->fmt & ESS_FMT_STEREO) tmpval |= 2; /* stereo */ } /* set the wavecache control reg */ wave_set_register(chip, es->apu[channel] << 3, tmpval); #ifdef CONFIG_PM_SLEEP es->wc_map[channel] = tmpval; #endif } static void snd_es1968_playback_setup(struct es1968 *chip, struct esschan *es, struct snd_pcm_runtime *runtime) { u32 pa; int high_apu = 0; int channel, apu; int i, size; unsigned long flags; u32 freq; size = es->dma_size >> es->wav_shift; if (es->fmt & ESS_FMT_STEREO) high_apu++; for (channel = 0; channel <= high_apu; channel++) { apu = es->apu[channel]; snd_es1968_program_wavecache(chip, es, channel, es->memory->buf.addr, 0); /* Offset to PCMBAR */ pa = es->memory->buf.addr; pa -= chip->dma.addr; pa >>= 1; /* words */ pa |= 0x00400000; /* System RAM (Bit 22) */ if (es->fmt & ESS_FMT_STEREO) { /* Enable stereo */ if (channel) pa |= 0x00800000; /* (Bit 23) */ if (es->fmt & ESS_FMT_16BIT) pa >>= 1; } /* base offset of dma calcs when reading the pointer on this left one */ es->base[channel] = pa & 0xFFFF; for (i = 0; i < 16; i++) apu_set_register(chip, apu, i, 0x0000); /* Load the buffer into the wave engine */ apu_set_register(chip, apu, 4, ((pa >> 16) & 0xFF) << 8); apu_set_register(chip, apu, 5, pa & 0xFFFF); apu_set_register(chip, apu, 6, (pa + size) & 0xFFFF); /* setting loop == sample len */ apu_set_register(chip, apu, 7, size); /* clear effects/env.. */ apu_set_register(chip, apu, 8, 0x0000); /* set amp now to 0xd0 (?), low byte is 'amplitude dest'? */ apu_set_register(chip, apu, 9, 0xD000); /* clear routing stuff */ apu_set_register(chip, apu, 11, 0x0000); /* dma on, no envelopes, filter to all 1s) */ apu_set_register(chip, apu, 0, 0x400F); if (es->fmt & ESS_FMT_16BIT) es->apu_mode[channel] = ESM_APU_16BITLINEAR; else es->apu_mode[channel] = ESM_APU_8BITLINEAR; if (es->fmt & ESS_FMT_STEREO) { /* set panning: left or right */ /* Check: different panning. On my Canyon 3D Chipset the Channels are swapped. I don't know, about the output to the SPDif Link. Perhaps you have to change this and not the APU Regs 4-5. */ apu_set_register(chip, apu, 10, 0x8F00 | (channel ? 0 : 0x10)); es->apu_mode[channel] += 1; /* stereo */ } else apu_set_register(chip, apu, 10, 0x8F08); } spin_lock_irqsave(&chip->reg_lock, flags); /* clear WP interrupts */ outw(1, chip->io_port + 0x04); /* enable WP ints */ outw(inw(chip->io_port + ESM_PORT_HOST_IRQ) | ESM_HIRQ_DSIE, chip->io_port + ESM_PORT_HOST_IRQ); spin_unlock_irqrestore(&chip->reg_lock, flags); freq = runtime->rate; /* set frequency */ if (freq > 48000) freq = 48000; if (freq < 4000) freq = 4000; /* hmmm.. */ if (!(es->fmt & ESS_FMT_16BIT) && !(es->fmt & ESS_FMT_STEREO)) freq >>= 1; freq = snd_es1968_compute_rate(chip, freq); /* Load the frequency, turn on 6dB */ snd_es1968_apu_set_freq(chip, es->apu[0], freq); snd_es1968_apu_set_freq(chip, es->apu[1], freq); } static void init_capture_apu(struct es1968 *chip, struct esschan *es, int channel, unsigned int pa, unsigned int bsize, int mode, int route) { int i, apu = es->apu[channel]; es->apu_mode[channel] = mode; /* set the wavecache control reg */ snd_es1968_program_wavecache(chip, es, channel, pa, 1); /* Offset to PCMBAR */ pa -= chip->dma.addr; pa >>= 1; /* words */ /* base offset of dma calcs when reading the pointer on this left one */ es->base[channel] = pa & 0xFFFF; pa |= 0x00400000; /* bit 22 -> System RAM */ /* Begin loading the APU */ for (i = 0; i < 16; i++) apu_set_register(chip, apu, i, 0x0000); /* need to enable subgroups.. and we should probably have different groups for different /dev/dsps.. */ apu_set_register(chip, apu, 2, 0x8); /* Load the buffer into the wave engine */ apu_set_register(chip, apu, 4, ((pa >> 16) & 0xFF) << 8); apu_set_register(chip, apu, 5, pa & 0xFFFF); apu_set_register(chip, apu, 6, (pa + bsize) & 0xFFFF); apu_set_register(chip, apu, 7, bsize); /* clear effects/env.. */ apu_set_register(chip, apu, 8, 0x00F0); /* amplitude now? sure. why not. */ apu_set_register(chip, apu, 9, 0x0000); /* set filter tune, radius, polar pan */ apu_set_register(chip, apu, 10, 0x8F08); /* route input */ apu_set_register(chip, apu, 11, route); /* dma on, no envelopes, filter to all 1s) */ apu_set_register(chip, apu, 0, 0x400F); } static void snd_es1968_capture_setup(struct es1968 *chip, struct esschan *es, struct snd_pcm_runtime *runtime) { int size; u32 freq; unsigned long flags; size = es->dma_size >> es->wav_shift; /* APU assignments: 0 = mono/left SRC 1 = right SRC 2 = mono/left Input Mixer 3 = right Input Mixer */ /* data seems to flow from the codec, through an apu into the 'mixbuf' bit of page, then through the SRC apu and out to the real 'buffer'. ok. sure. */ /* input mixer (left/mono) */ /* parallel in crap, see maestro reg 0xC [8-11] */ init_capture_apu(chip, es, 2, es->mixbuf->buf.addr, ESM_MIXBUF_SIZE/4, /* in words */ ESM_APU_INPUTMIXER, 0x14); /* SRC (left/mono); get input from inputing apu */ init_capture_apu(chip, es, 0, es->memory->buf.addr, size, ESM_APU_SRCONVERTOR, es->apu[2]); if (es->fmt & ESS_FMT_STEREO) { /* input mixer (right) */ init_capture_apu(chip, es, 3, es->mixbuf->buf.addr + ESM_MIXBUF_SIZE/2, ESM_MIXBUF_SIZE/4, /* in words */ ESM_APU_INPUTMIXER, 0x15); /* SRC (right) */ init_capture_apu(chip, es, 1, es->memory->buf.addr + size*2, size, ESM_APU_SRCONVERTOR, es->apu[3]); } freq = runtime->rate; /* Sample Rate conversion APUs don't like 0x10000 for their rate */ if (freq > 47999) freq = 47999; if (freq < 4000) freq = 4000; freq = snd_es1968_compute_rate(chip, freq); /* Load the frequency, turn on 6dB */ snd_es1968_apu_set_freq(chip, es->apu[0], freq); snd_es1968_apu_set_freq(chip, es->apu[1], freq); /* fix mixer rate at 48khz. and its _must_ be 0x10000. */ freq = 0x10000; snd_es1968_apu_set_freq(chip, es->apu[2], freq); snd_es1968_apu_set_freq(chip, es->apu[3], freq); spin_lock_irqsave(&chip->reg_lock, flags); /* clear WP interrupts */ outw(1, chip->io_port + 0x04); /* enable WP ints */ outw(inw(chip->io_port + ESM_PORT_HOST_IRQ) | ESM_HIRQ_DSIE, chip->io_port + ESM_PORT_HOST_IRQ); spin_unlock_irqrestore(&chip->reg_lock, flags); } /******************* * ALSA Interface * *******************/ static int snd_es1968_pcm_prepare(struct snd_pcm_substream *substream) { struct es1968 *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct esschan *es = runtime->private_data; es->dma_size = snd_pcm_lib_buffer_bytes(substream); es->frag_size = snd_pcm_lib_period_bytes(substream); es->wav_shift = 1; /* maestro handles always 16bit */ es->fmt = 0; if (snd_pcm_format_width(runtime->format) == 16) es->fmt |= ESS_FMT_16BIT; if (runtime->channels > 1) { es->fmt |= ESS_FMT_STEREO; if (es->fmt & ESS_FMT_16BIT) /* 8bit is already word shifted */ es->wav_shift++; } es->bob_freq = snd_es1968_calc_bob_rate(chip, es, runtime); switch (es->mode) { case ESM_MODE_PLAY: snd_es1968_playback_setup(chip, es, runtime); break; case ESM_MODE_CAPTURE: snd_es1968_capture_setup(chip, es, runtime); break; } return 0; } static int snd_es1968_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct es1968 *chip = snd_pcm_substream_chip(substream); struct esschan *es = substream->runtime->private_data; spin_lock(&chip->substream_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: if (es->running) break; snd_es1968_bob_inc(chip, es->bob_freq); es->count = 0; es->hwptr = 0; snd_es1968_pcm_start(chip, es); es->running = 1; break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: if (! es->running) break; snd_es1968_pcm_stop(chip, es); es->running = 0; snd_es1968_bob_dec(chip); break; } spin_unlock(&chip->substream_lock); return 0; } static snd_pcm_uframes_t snd_es1968_pcm_pointer(struct snd_pcm_substream *substream) { struct es1968 *chip = snd_pcm_substream_chip(substream); struct esschan *es = substream->runtime->private_data; unsigned int ptr; ptr = snd_es1968_get_dma_ptr(chip, es) << es->wav_shift; return bytes_to_frames(substream->runtime, ptr % es->dma_size); } static struct snd_pcm_hardware snd_es1968_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | /*SNDRV_PCM_INFO_PAUSE |*/ SNDRV_PCM_INFO_RESUME), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, .rate_min = 4000, .rate_max = 48000, .channels_min = 1, .channels_max = 2, .buffer_bytes_max = 65536, .period_bytes_min = 256, .period_bytes_max = 65536, .periods_min = 1, .periods_max = 1024, .fifo_size = 0, }; static struct snd_pcm_hardware snd_es1968_capture = { .info = (SNDRV_PCM_INFO_NONINTERLEAVED | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER | /*SNDRV_PCM_INFO_PAUSE |*/ SNDRV_PCM_INFO_RESUME), .formats = /*SNDRV_PCM_FMTBIT_U8 |*/ SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, .rate_min = 4000, .rate_max = 48000, .channels_min = 1, .channels_max = 2, .buffer_bytes_max = 65536, .period_bytes_min = 256, .period_bytes_max = 65536, .periods_min = 1, .periods_max = 1024, .fifo_size = 0, }; /* ************************* * DMA memory management * *************************/ /* Because the Maestro can only take addresses relative to the PCM base address register :( */ static int calc_available_memory_size(struct es1968 *chip) { int max_size = 0; struct esm_memory *buf; mutex_lock(&chip->memory_mutex); list_for_each_entry(buf, &chip->buf_list, list) { if (buf->empty && buf->buf.bytes > max_size) max_size = buf->buf.bytes; } mutex_unlock(&chip->memory_mutex); if (max_size >= 128*1024) max_size = 127*1024; return max_size; } /* allocate a new memory chunk with the specified size */ static struct esm_memory *snd_es1968_new_memory(struct es1968 *chip, int size) { struct esm_memory *buf; size = ALIGN(size, ESM_MEM_ALIGN); mutex_lock(&chip->memory_mutex); list_for_each_entry(buf, &chip->buf_list, list) { if (buf->empty && buf->buf.bytes >= size) goto __found; } mutex_unlock(&chip->memory_mutex); return NULL; __found: if (buf->buf.bytes > size) { struct esm_memory *chunk = kmalloc(sizeof(*chunk), GFP_KERNEL); if (chunk == NULL) { mutex_unlock(&chip->memory_mutex); return NULL; } chunk->buf = buf->buf; chunk->buf.bytes -= size; chunk->buf.area += size; chunk->buf.addr += size; chunk->empty = 1; buf->buf.bytes = size; list_add(&chunk->list, &buf->list); } buf->empty = 0; mutex_unlock(&chip->memory_mutex); return buf; } /* free a memory chunk */ static void snd_es1968_free_memory(struct es1968 *chip, struct esm_memory *buf) { struct esm_memory *chunk; mutex_lock(&chip->memory_mutex); buf->empty = 1; if (buf->list.prev != &chip->buf_list) { chunk = list_entry(buf->list.prev, struct esm_memory, list); if (chunk->empty) { chunk->buf.bytes += buf->buf.bytes; list_del(&buf->list); kfree(buf); buf = chunk; } } if (buf->list.next != &chip->buf_list) { chunk = list_entry(buf->list.next, struct esm_memory, list); if (chunk->empty) { buf->buf.bytes += chunk->buf.bytes; list_del(&chunk->list); kfree(chunk); } } mutex_unlock(&chip->memory_mutex); } static void snd_es1968_free_dmabuf(struct es1968 *chip) { struct list_head *p; if (! chip->dma.area) return; snd_dma_reserve_buf(&chip->dma, snd_dma_pci_buf_id(chip->pci)); while ((p = chip->buf_list.next) != &chip->buf_list) { struct esm_memory *chunk = list_entry(p, struct esm_memory, list); list_del(p); kfree(chunk); } } static int snd_es1968_init_dmabuf(struct es1968 *chip) { int err; struct esm_memory *chunk; chip->dma.dev.type = SNDRV_DMA_TYPE_DEV; chip->dma.dev.dev = snd_dma_pci_data(chip->pci); if (! snd_dma_get_reserved_buf(&chip->dma, snd_dma_pci_buf_id(chip->pci))) { err = snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), chip->total_bufsize, &chip->dma); if (err < 0 || ! chip->dma.area) { snd_printk(KERN_ERR "es1968: can't allocate dma pages for size %d\n", chip->total_bufsize); return -ENOMEM; } if ((chip->dma.addr + chip->dma.bytes - 1) & ~((1 << 28) - 1)) { snd_dma_free_pages(&chip->dma); snd_printk(KERN_ERR "es1968: DMA buffer beyond 256MB.\n"); return -ENOMEM; } } INIT_LIST_HEAD(&chip->buf_list); /* allocate an empty chunk */ chunk = kmalloc(sizeof(*chunk), GFP_KERNEL); if (chunk == NULL) { snd_es1968_free_dmabuf(chip); return -ENOMEM; } memset(chip->dma.area, 0, ESM_MEM_ALIGN); chunk->buf = chip->dma; chunk->buf.area += ESM_MEM_ALIGN; chunk->buf.addr += ESM_MEM_ALIGN; chunk->buf.bytes -= ESM_MEM_ALIGN; chunk->empty = 1; list_add(&chunk->list, &chip->buf_list); return 0; } /* setup the dma_areas */ /* buffer is extracted from the pre-allocated memory chunk */ static int snd_es1968_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct es1968 *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct esschan *chan = runtime->private_data; int size = params_buffer_bytes(hw_params); if (chan->memory) { if (chan->memory->buf.bytes >= size) { runtime->dma_bytes = size; return 0; } snd_es1968_free_memory(chip, chan->memory); } chan->memory = snd_es1968_new_memory(chip, size); if (chan->memory == NULL) { // snd_printd("cannot allocate dma buffer: size = %d\n", size); return -ENOMEM; } snd_pcm_set_runtime_buffer(substream, &chan->memory->buf); return 1; /* area was changed */ } /* remove dma areas if allocated */ static int snd_es1968_hw_free(struct snd_pcm_substream *substream) { struct es1968 *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct esschan *chan; if (runtime->private_data == NULL) return 0; chan = runtime->private_data; if (chan->memory) { snd_es1968_free_memory(chip, chan->memory); chan->memory = NULL; } return 0; } /* * allocate APU pair */ static int snd_es1968_alloc_apu_pair(struct es1968 *chip, int type) { int apu; for (apu = 0; apu < NR_APUS; apu += 2) { if (chip->apu[apu] == ESM_APU_FREE && chip->apu[apu + 1] == ESM_APU_FREE) { chip->apu[apu] = chip->apu[apu + 1] = type; return apu; } } return -EBUSY; } /* * release APU pair */ static void snd_es1968_free_apu_pair(struct es1968 *chip, int apu) { chip->apu[apu] = chip->apu[apu + 1] = ESM_APU_FREE; } /****************** * PCM open/close * ******************/ static int snd_es1968_playback_open(struct snd_pcm_substream *substream) { struct es1968 *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct esschan *es; int apu1; /* search 2 APUs */ apu1 = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_PLAY); if (apu1 < 0) return apu1; es = kzalloc(sizeof(*es), GFP_KERNEL); if (!es) { snd_es1968_free_apu_pair(chip, apu1); return -ENOMEM; } es->apu[0] = apu1; es->apu[1] = apu1 + 1; es->apu_mode[0] = 0; es->apu_mode[1] = 0; es->running = 0; es->substream = substream; es->mode = ESM_MODE_PLAY; runtime->private_data = es; runtime->hw = snd_es1968_playback; runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max = calc_available_memory_size(chip); spin_lock_irq(&chip->substream_lock); list_add(&es->list, &chip->substream_list); spin_unlock_irq(&chip->substream_lock); return 0; } static int snd_es1968_capture_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct es1968 *chip = snd_pcm_substream_chip(substream); struct esschan *es; int apu1, apu2; apu1 = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_CAPTURE); if (apu1 < 0) return apu1; apu2 = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_RATECONV); if (apu2 < 0) { snd_es1968_free_apu_pair(chip, apu1); return apu2; } es = kzalloc(sizeof(*es), GFP_KERNEL); if (!es) { snd_es1968_free_apu_pair(chip, apu1); snd_es1968_free_apu_pair(chip, apu2); return -ENOMEM; } es->apu[0] = apu1; es->apu[1] = apu1 + 1; es->apu[2] = apu2; es->apu[3] = apu2 + 1; es->apu_mode[0] = 0; es->apu_mode[1] = 0; es->apu_mode[2] = 0; es->apu_mode[3] = 0; es->running = 0; es->substream = substream; es->mode = ESM_MODE_CAPTURE; /* get mixbuffer */ if ((es->mixbuf = snd_es1968_new_memory(chip, ESM_MIXBUF_SIZE)) == NULL) { snd_es1968_free_apu_pair(chip, apu1); snd_es1968_free_apu_pair(chip, apu2); kfree(es); return -ENOMEM; } memset(es->mixbuf->buf.area, 0, ESM_MIXBUF_SIZE); runtime->private_data = es; runtime->hw = snd_es1968_capture; runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max = calc_available_memory_size(chip) - 1024; /* keep MIXBUF size */ snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES); spin_lock_irq(&chip->substream_lock); list_add(&es->list, &chip->substream_list); spin_unlock_irq(&chip->substream_lock); return 0; } static int snd_es1968_playback_close(struct snd_pcm_substream *substream) { struct es1968 *chip = snd_pcm_substream_chip(substream); struct esschan *es; if (substream->runtime->private_data == NULL) return 0; es = substream->runtime->private_data; spin_lock_irq(&chip->substream_lock); list_del(&es->list); spin_unlock_irq(&chip->substream_lock); snd_es1968_free_apu_pair(chip, es->apu[0]); kfree(es); return 0; } static int snd_es1968_capture_close(struct snd_pcm_substream *substream) { struct es1968 *chip = snd_pcm_substream_chip(substream); struct esschan *es; if (substream->runtime->private_data == NULL) return 0; es = substream->runtime->private_data; spin_lock_irq(&chip->substream_lock); list_del(&es->list); spin_unlock_irq(&chip->substream_lock); snd_es1968_free_memory(chip, es->mixbuf); snd_es1968_free_apu_pair(chip, es->apu[0]); snd_es1968_free_apu_pair(chip, es->apu[2]); kfree(es); return 0; } static struct snd_pcm_ops snd_es1968_playback_ops = { .open = snd_es1968_playback_open, .close = snd_es1968_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_es1968_hw_params, .hw_free = snd_es1968_hw_free, .prepare = snd_es1968_pcm_prepare, .trigger = snd_es1968_pcm_trigger, .pointer = snd_es1968_pcm_pointer, }; static struct snd_pcm_ops snd_es1968_capture_ops = { .open = snd_es1968_capture_open, .close = snd_es1968_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_es1968_hw_params, .hw_free = snd_es1968_hw_free, .prepare = snd_es1968_pcm_prepare, .trigger = snd_es1968_pcm_trigger, .pointer = snd_es1968_pcm_pointer, }; /* * measure clock */ #define CLOCK_MEASURE_BUFSIZE 16768 /* enough large for a single shot */ static void es1968_measure_clock(struct es1968 *chip) { int i, apu; unsigned int pa, offset, t; struct esm_memory *memory; struct timeval start_time, stop_time; if (chip->clock == 0) chip->clock = 48000; /* default clock value */ /* search 2 APUs (although one apu is enough) */ if ((apu = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_PLAY)) < 0) { snd_printk(KERN_ERR "Hmm, cannot find empty APU pair!?\n"); return; } if ((memory = snd_es1968_new_memory(chip, CLOCK_MEASURE_BUFSIZE)) == NULL) { snd_printk(KERN_ERR "cannot allocate dma buffer - using default clock %d\n", chip->clock); snd_es1968_free_apu_pair(chip, apu); return; } memset(memory->buf.area, 0, CLOCK_MEASURE_BUFSIZE); wave_set_register(chip, apu << 3, (memory->buf.addr - 0x10) & 0xfff8); pa = (unsigned int)((memory->buf.addr - chip->dma.addr) >> 1); pa |= 0x00400000; /* System RAM (Bit 22) */ /* initialize apu */ for (i = 0; i < 16; i++) apu_set_register(chip, apu, i, 0x0000); apu_set_register(chip, apu, 0, 0x400f); apu_set_register(chip, apu, 4, ((pa >> 16) & 0xff) << 8); apu_set_register(chip, apu, 5, pa & 0xffff); apu_set_register(chip, apu, 6, (pa + CLOCK_MEASURE_BUFSIZE/2) & 0xffff); apu_set_register(chip, apu, 7, CLOCK_MEASURE_BUFSIZE/2); apu_set_register(chip, apu, 8, 0x0000); apu_set_register(chip, apu, 9, 0xD000); apu_set_register(chip, apu, 10, 0x8F08); apu_set_register(chip, apu, 11, 0x0000); spin_lock_irq(&chip->reg_lock); outw(1, chip->io_port + 0x04); /* clear WP interrupts */ outw(inw(chip->io_port + ESM_PORT_HOST_IRQ) | ESM_HIRQ_DSIE, chip->io_port + ESM_PORT_HOST_IRQ); /* enable WP ints */ spin_unlock_irq(&chip->reg_lock); snd_es1968_apu_set_freq(chip, apu, ((unsigned int)48000 << 16) / chip->clock); /* 48000 Hz */ chip->in_measurement = 1; chip->measure_apu = apu; spin_lock_irq(&chip->reg_lock); snd_es1968_bob_inc(chip, ESM_BOB_FREQ); __apu_set_register(chip, apu, 5, pa & 0xffff); snd_es1968_trigger_apu(chip, apu, ESM_APU_16BITLINEAR); do_gettimeofday(&start_time); spin_unlock_irq(&chip->reg_lock); msleep(50); spin_lock_irq(&chip->reg_lock); offset = __apu_get_register(chip, apu, 5); do_gettimeofday(&stop_time); snd_es1968_trigger_apu(chip, apu, 0); /* stop */ snd_es1968_bob_dec(chip); chip->in_measurement = 0; spin_unlock_irq(&chip->reg_lock); /* check the current position */ offset -= (pa & 0xffff); offset &= 0xfffe; offset += chip->measure_count * (CLOCK_MEASURE_BUFSIZE/2); t = stop_time.tv_sec - start_time.tv_sec; t *= 1000000; if (stop_time.tv_usec < start_time.tv_usec) t -= start_time.tv_usec - stop_time.tv_usec; else t += stop_time.tv_usec - start_time.tv_usec; if (t == 0) { snd_printk(KERN_ERR "?? calculation error..\n"); } else { offset *= 1000; offset = (offset / t) * 1000 + ((offset % t) * 1000) / t; if (offset < 47500 || offset > 48500) { if (offset >= 40000 && offset <= 50000) chip->clock = (chip->clock * offset) / 48000; } printk(KERN_INFO "es1968: clocking to %d\n", chip->clock); } snd_es1968_free_memory(chip, memory); snd_es1968_free_apu_pair(chip, apu); } /* */ static void snd_es1968_pcm_free(struct snd_pcm *pcm) { struct es1968 *esm = pcm->private_data; snd_es1968_free_dmabuf(esm); esm->pcm = NULL; } static int snd_es1968_pcm(struct es1968 *chip, int device) { struct snd_pcm *pcm; int err; /* get DMA buffer */ if ((err = snd_es1968_init_dmabuf(chip)) < 0) return err; /* set PCMBAR */ wave_set_register(chip, 0x01FC, chip->dma.addr >> 12); wave_set_register(chip, 0x01FD, chip->dma.addr >> 12); wave_set_register(chip, 0x01FE, chip->dma.addr >> 12); wave_set_register(chip, 0x01FF, chip->dma.addr >> 12); if ((err = snd_pcm_new(chip->card, "ESS Maestro", device, chip->playback_streams, chip->capture_streams, &pcm)) < 0) return err; pcm->private_data = chip; pcm->private_free = snd_es1968_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_es1968_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_es1968_capture_ops); pcm->info_flags = 0; strcpy(pcm->name, "ESS Maestro"); chip->pcm = pcm; return 0; } /* * suppress jitter on some maestros when playing stereo */ static void snd_es1968_suppress_jitter(struct es1968 *chip, struct esschan *es) { unsigned int cp1; unsigned int cp2; unsigned int diff; cp1 = __apu_get_register(chip, 0, 5); cp2 = __apu_get_register(chip, 1, 5); diff = (cp1 > cp2 ? cp1 - cp2 : cp2 - cp1); if (diff > 1) __maestro_write(chip, IDR0_DATA_PORT, cp1); } /* * update pointer */ static void snd_es1968_update_pcm(struct es1968 *chip, struct esschan *es) { unsigned int hwptr; unsigned int diff; struct snd_pcm_substream *subs = es->substream; if (subs == NULL || !es->running) return; hwptr = snd_es1968_get_dma_ptr(chip, es) << es->wav_shift; hwptr %= es->dma_size; diff = (es->dma_size + hwptr - es->hwptr) % es->dma_size; es->hwptr = hwptr; es->count += diff; if (es->count > es->frag_size) { spin_unlock(&chip->substream_lock); snd_pcm_period_elapsed(subs); spin_lock(&chip->substream_lock); es->count %= es->frag_size; } } /* The hardware volume works by incrementing / decrementing 2 counters (without wrap around) in response to volume button presses and then generating an interrupt. The pair of counters is stored in bits 1-3 and 5-7 of a byte wide register. The meaning of bits 0 and 4 is unknown. */ static void es1968_update_hw_volume(struct work_struct *work) { struct es1968 *chip = container_of(work, struct es1968, hwvol_work); int x, val; /* Figure out which volume control button was pushed, based on differences from the default register values. */ x = inb(chip->io_port + 0x1c) & 0xee; /* Reset the volume control registers. */ outb(0x88, chip->io_port + 0x1c); outb(0x88, chip->io_port + 0x1d); outb(0x88, chip->io_port + 0x1e); outb(0x88, chip->io_port + 0x1f); if (chip->in_suspend) return; #ifndef CONFIG_SND_ES1968_INPUT if (! chip->master_switch || ! chip->master_volume) return; val = snd_ac97_read(chip->ac97, AC97_MASTER); switch (x) { case 0x88: /* mute */ val ^= 0x8000; break; case 0xaa: /* volume up */ if ((val & 0x7f) > 0) val--; if ((val & 0x7f00) > 0) val -= 0x0100; break; case 0x66: /* volume down */ if ((val & 0x7f) < 0x1f) val++; if ((val & 0x7f00) < 0x1f00) val += 0x0100; break; } if (snd_ac97_update(chip->ac97, AC97_MASTER, val)) snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id); #else if (!chip->input_dev) return; val = 0; switch (x) { case 0x88: /* The counters have not changed, yet we've received a HV interrupt. According to tests run by various people this happens when pressing the mute button. */ val = KEY_MUTE; break; case 0xaa: /* counters increased by 1 -> volume up */ val = KEY_VOLUMEUP; break; case 0x66: /* counters decreased by 1 -> volume down */ val = KEY_VOLUMEDOWN; break; } if (val) { input_report_key(chip->input_dev, val, 1); input_sync(chip->input_dev); input_report_key(chip->input_dev, val, 0); input_sync(chip->input_dev); } #endif } /* * interrupt handler */ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id) { struct es1968 *chip = dev_id; u32 event; if (!(event = inb(chip->io_port + 0x1A))) return IRQ_NONE; outw(inw(chip->io_port + 4) & 1, chip->io_port + 4); if (event & ESM_HWVOL_IRQ) schedule_work(&chip->hwvol_work); /* else ack 'em all, i imagine */ outb(0xFF, chip->io_port + 0x1A); if ((event & ESM_MPU401_IRQ) && chip->rmidi) { snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); } if (event & ESM_SOUND_IRQ) { struct esschan *es; spin_lock(&chip->substream_lock); list_for_each_entry(es, &chip->substream_list, list) { if (es->running) { snd_es1968_update_pcm(chip, es); if (es->fmt & ESS_FMT_STEREO) snd_es1968_suppress_jitter(chip, es); } } spin_unlock(&chip->substream_lock); if (chip->in_measurement) { unsigned int curp = __apu_get_register(chip, chip->measure_apu, 5); if (curp < chip->measure_lastpos) chip->measure_count++; chip->measure_lastpos = curp; } } return IRQ_HANDLED; } /* * Mixer stuff */ static int snd_es1968_mixer(struct es1968 *chip) { struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; #ifndef CONFIG_SND_ES1968_INPUT struct snd_ctl_elem_id elem_id; #endif int err; static struct snd_ac97_bus_ops ops = { .write = snd_es1968_ac97_write, .read = snd_es1968_ac97_read, }; if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0) return err; pbus->no_vra = 1; /* ES1968 doesn't need VRA */ memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97)) < 0) return err; #ifndef CONFIG_SND_ES1968_INPUT /* attach master switch / volumes for h/w volume control */ memset(&elem_id, 0, sizeof(elem_id)); elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(elem_id.name, "Master Playback Switch"); chip->master_switch = snd_ctl_find_id(chip->card, &elem_id); memset(&elem_id, 0, sizeof(elem_id)); elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(elem_id.name, "Master Playback Volume"); chip->master_volume = snd_ctl_find_id(chip->card, &elem_id); #endif return 0; } /* * reset ac97 codec */ static void snd_es1968_ac97_reset(struct es1968 *chip) { unsigned long ioaddr = chip->io_port; unsigned short save_ringbus_a; unsigned short save_68; unsigned short w; unsigned int vend; /* save configuration */ save_ringbus_a = inw(ioaddr + 0x36); //outw(inw(ioaddr + 0x38) & 0xfffc, ioaddr + 0x38); /* clear second codec id? */ /* set command/status address i/o to 1st codec */ outw(inw(ioaddr + 0x3a) & 0xfffc, ioaddr + 0x3a); outw(inw(ioaddr + 0x3c) & 0xfffc, ioaddr + 0x3c); /* disable ac link */ outw(0x0000, ioaddr + 0x36); save_68 = inw(ioaddr + 0x68); pci_read_config_word(chip->pci, 0x58, &w); /* something magical with gpio and bus arb. */ pci_read_config_dword(chip->pci, PCI_SUBSYSTEM_VENDOR_ID, &vend); if (w & 1) save_68 |= 0x10; outw(0xfffe, ioaddr + 0x64); /* unmask gpio 0 */ outw(0x0001, ioaddr + 0x68); /* gpio write */ outw(0x0000, ioaddr + 0x60); /* write 0 to gpio 0 */ udelay(20); outw(0x0001, ioaddr + 0x60); /* write 1 to gpio 1 */ msleep(20); outw(save_68 | 0x1, ioaddr + 0x68); /* now restore .. */ outw((inw(ioaddr + 0x38) & 0xfffc) | 0x1, ioaddr + 0x38); outw((inw(ioaddr + 0x3a) & 0xfffc) | 0x1, ioaddr + 0x3a); outw((inw(ioaddr + 0x3c) & 0xfffc) | 0x1, ioaddr + 0x3c); /* now the second codec */ /* disable ac link */ outw(0x0000, ioaddr + 0x36); outw(0xfff7, ioaddr + 0x64); /* unmask gpio 3 */ save_68 = inw(ioaddr + 0x68); outw(0x0009, ioaddr + 0x68); /* gpio write 0 & 3 ?? */ outw(0x0001, ioaddr + 0x60); /* write 1 to gpio */ udelay(20); outw(0x0009, ioaddr + 0x60); /* write 9 to gpio */ msleep(500); //outw(inw(ioaddr + 0x38) & 0xfffc, ioaddr + 0x38); outw(inw(ioaddr + 0x3a) & 0xfffc, ioaddr + 0x3a); outw(inw(ioaddr + 0x3c) & 0xfffc, ioaddr + 0x3c); #if 0 /* the loop here needs to be much better if we want it.. */ snd_printk(KERN_INFO "trying software reset\n"); /* try and do a software reset */ outb(0x80 | 0x7c, ioaddr + 0x30); for (w = 0;; w++) { if ((inw(ioaddr + 0x30) & 1) == 0) { if (inb(ioaddr + 0x32) != 0) break; outb(0x80 | 0x7d, ioaddr + 0x30); if (((inw(ioaddr + 0x30) & 1) == 0) && (inb(ioaddr + 0x32) != 0)) break; outb(0x80 | 0x7f, ioaddr + 0x30); if (((inw(ioaddr + 0x30) & 1) == 0) && (inb(ioaddr + 0x32) != 0)) break; } if (w > 10000) { outb(inb(ioaddr + 0x37) | 0x08, ioaddr + 0x37); /* do a software reset */ msleep(500); /* oh my.. */ outb(inb(ioaddr + 0x37) & ~0x08, ioaddr + 0x37); udelay(1); outw(0x80, ioaddr + 0x30); for (w = 0; w < 10000; w++) { if ((inw(ioaddr + 0x30) & 1) == 0) break; } } } #endif if (vend == NEC_VERSA_SUBID1 || vend == NEC_VERSA_SUBID2) { /* turn on external amp? */ outw(0xf9ff, ioaddr + 0x64); outw(inw(ioaddr + 0x68) | 0x600, ioaddr + 0x68); outw(0x0209, ioaddr + 0x60); } /* restore.. */ outw(save_ringbus_a, ioaddr + 0x36); /* Turn on the 978 docking chip. First frob the "master output enable" bit, then set most of the playback volume control registers to max. */ outb(inb(ioaddr+0xc0)|(1<<5), ioaddr+0xc0); outb(0xff, ioaddr+0xc3); outb(0xff, ioaddr+0xc4); outb(0xff, ioaddr+0xc6); outb(0xff, ioaddr+0xc8); outb(0x3f, ioaddr+0xcf); outb(0x3f, ioaddr+0xd0); } static void snd_es1968_reset(struct es1968 *chip) { /* Reset */ outw(ESM_RESET_MAESTRO | ESM_RESET_DIRECTSOUND, chip->io_port + ESM_PORT_HOST_IRQ); udelay(10); outw(0x0000, chip->io_port + ESM_PORT_HOST_IRQ); udelay(10); } /* * initialize maestro chip */ static void snd_es1968_chip_init(struct es1968 *chip) { struct pci_dev *pci = chip->pci; int i; unsigned long iobase = chip->io_port; u16 w; u32 n; /* We used to muck around with pci config space that * we had no business messing with. We don't know enough * about the machine to know which DMA mode is appropriate, * etc. We were guessing wrong on some machines and making * them unhappy. We now trust in the BIOS to do things right, * which almost certainly means a new host of problems will * arise with broken BIOS implementations. screw 'em. * We're already intolerant of machines that don't assign * IRQs. */ /* Config Reg A */ pci_read_config_word(pci, ESM_CONFIG_A, &w); w &= ~DMA_CLEAR; /* Clear DMA bits */ w &= ~(PIC_SNOOP1 | PIC_SNOOP2); /* Clear Pic Snoop Mode Bits */ w &= ~SAFEGUARD; /* Safeguard off */ w |= POST_WRITE; /* Posted write */ w |= PCI_TIMING; /* PCI timing on */ /* XXX huh? claims to be reserved.. */ w &= ~SWAP_LR; /* swap left/right seems to only have effect on SB Emulation */ w &= ~SUBTR_DECODE; /* Subtractive decode off */ pci_write_config_word(pci, ESM_CONFIG_A, w); /* Config Reg B */ pci_read_config_word(pci, ESM_CONFIG_B, &w); w &= ~(1 << 15); /* Turn off internal clock multiplier */ /* XXX how do we know which to use? */ w &= ~(1 << 14); /* External clock */ w &= ~SPDIF_CONFB; /* disable S/PDIF output */ w |= HWV_CONFB; /* HWV on */ w |= DEBOUNCE; /* Debounce off: easier to push the HW buttons */ w &= ~GPIO_CONFB; /* GPIO 4:5 */ w |= CHI_CONFB; /* Disconnect from the CHI. Enabling this made a dell 7500 work. */ w &= ~IDMA_CONFB; /* IDMA off (undocumented) */ w &= ~MIDI_FIX; /* MIDI fix off (undoc) */ w &= ~(1 << 1); /* reserved, always write 0 */ w &= ~IRQ_TO_ISA; /* IRQ to ISA off (undoc) */ pci_write_config_word(pci, ESM_CONFIG_B, w); /* DDMA off */ pci_read_config_word(pci, ESM_DDMA, &w); w &= ~(1 << 0); pci_write_config_word(pci, ESM_DDMA, w); /* * Legacy mode */ pci_read_config_word(pci, ESM_LEGACY_AUDIO_CONTROL, &w); w |= ESS_DISABLE_AUDIO; /* Disable Legacy Audio */ w &= ~ESS_ENABLE_SERIAL_IRQ; /* Disable SIRQ */ w &= ~(0x1f); /* disable mpu irq/io, game port, fm, SB */ pci_write_config_word(pci, ESM_LEGACY_AUDIO_CONTROL, w); /* Set up 978 docking control chip. */ pci_read_config_word(pci, 0x58, &w); w|=1<<2; /* Enable 978. */ w|=1<<3; /* Turn on 978 hardware volume control. */ w&=~(1<<11); /* Turn on 978 mixer volume control. */ pci_write_config_word(pci, 0x58, w); /* Sound Reset */ snd_es1968_reset(chip); /* * Ring Bus Setup */ /* setup usual 0x34 stuff.. 0x36 may be chip specific */ outw(0xC090, iobase + ESM_RING_BUS_DEST); /* direct sound, stereo */ udelay(20); outw(0x3000, iobase + ESM_RING_BUS_CONTR_A); /* enable ringbus/serial */ udelay(20); /* * Reset the CODEC */ snd_es1968_ac97_reset(chip); /* Ring Bus Control B */ n = inl(iobase + ESM_RING_BUS_CONTR_B); n &= ~RINGB_EN_SPDIF; /* SPDIF off */ //w |= RINGB_EN_2CODEC; /* enable 2nd codec */ outl(n, iobase + ESM_RING_BUS_CONTR_B); /* Set hardware volume control registers to midpoints. We can tell which button was pushed based on how they change. */ outb(0x88, iobase+0x1c); outb(0x88, iobase+0x1d); outb(0x88, iobase+0x1e); outb(0x88, iobase+0x1f); /* it appears some maestros (dell 7500) only work if these are set, regardless of whether we use the assp or not. */ outb(0, iobase + ASSP_CONTROL_B); outb(3, iobase + ASSP_CONTROL_A); /* M: Reserved bits... */ outb(0, iobase + ASSP_CONTROL_C); /* M: Disable ASSP, ASSP IRQ's and FM Port */ /* * set up wavecache */ for (i = 0; i < 16; i++) { /* Write 0 into the buffer area 0x1E0->1EF */ outw(0x01E0 + i, iobase + WC_INDEX); outw(0x0000, iobase + WC_DATA); /* The 1.10 test program seem to write 0 into the buffer area * 0x1D0-0x1DF too.*/ outw(0x01D0 + i, iobase + WC_INDEX); outw(0x0000, iobase + WC_DATA); } wave_set_register(chip, IDR7_WAVE_ROMRAM, (wave_get_register(chip, IDR7_WAVE_ROMRAM) & 0xFF00)); wave_set_register(chip, IDR7_WAVE_ROMRAM, wave_get_register(chip, IDR7_WAVE_ROMRAM) | 0x100); wave_set_register(chip, IDR7_WAVE_ROMRAM, wave_get_register(chip, IDR7_WAVE_ROMRAM) & ~0x200); wave_set_register(chip, IDR7_WAVE_ROMRAM, wave_get_register(chip, IDR7_WAVE_ROMRAM) | ~0x400); maestro_write(chip, IDR2_CRAM_DATA, 0x0000); /* Now back to the DirectSound stuff */ /* audio serial configuration.. ? */ maestro_write(chip, 0x08, 0xB004); maestro_write(chip, 0x09, 0x001B); maestro_write(chip, 0x0A, 0x8000); maestro_write(chip, 0x0B, 0x3F37); maestro_write(chip, 0x0C, 0x0098); /* parallel in, has something to do with recording :) */ maestro_write(chip, 0x0C, (maestro_read(chip, 0x0C) & ~0xF000) | 0x8000); /* parallel out */ maestro_write(chip, 0x0C, (maestro_read(chip, 0x0C) & ~0x0F00) | 0x0500); maestro_write(chip, 0x0D, 0x7632); /* Wave cache control on - test off, sg off, enable, enable extra chans 1Mb */ w = inw(iobase + WC_CONTROL); w &= ~0xFA00; /* Seems to be reserved? I don't know */ w |= 0xA000; /* reserved... I don't know */ w &= ~0x0200; /* Channels 56,57,58,59 as Extra Play,Rec Channel enable Seems to crash the Computer if enabled... */ w |= 0x0100; /* Wave Cache Operation Enabled */ w |= 0x0080; /* Channels 60/61 as Placback/Record enabled */ w &= ~0x0060; /* Clear Wavtable Size */ w |= 0x0020; /* Wavetable Size : 1MB */ /* Bit 4 is reserved */ w &= ~0x000C; /* DMA Stuff? I don't understand what the datasheet means */ /* Bit 1 is reserved */ w &= ~0x0001; /* Test Mode off */ outw(w, iobase + WC_CONTROL); /* Now clear the APU control ram */ for (i = 0; i < NR_APUS; i++) { for (w = 0; w < NR_APU_REGS; w++) apu_set_register(chip, i, w, 0); } } /* Enable IRQ's */ static void snd_es1968_start_irq(struct es1968 *chip) { unsigned short w; w = ESM_HIRQ_DSIE | ESM_HIRQ_HW_VOLUME; if (chip->rmidi) w |= ESM_HIRQ_MPU401; outb(w, chip->io_port + 0x1A); outw(w, chip->io_port + ESM_PORT_HOST_IRQ); } #ifdef CONFIG_PM_SLEEP /* * PM support */ static int es1968_suspend(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct es1968 *chip = card->private_data; if (! chip->do_pm) return 0; chip->in_suspend = 1; cancel_work_sync(&chip->hwvol_work); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); snd_es1968_bob_stop(chip); pci_disable_device(pci); pci_save_state(pci); pci_set_power_state(pci, PCI_D3hot); return 0; } static int es1968_resume(struct device *dev) { struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct es1968 *chip = card->private_data; struct esschan *es; if (! chip->do_pm) return 0; /* restore all our config */ pci_set_power_state(pci, PCI_D0); pci_restore_state(pci); if (pci_enable_device(pci) < 0) { printk(KERN_ERR "es1968: pci_enable_device failed, " "disabling device\n"); snd_card_disconnect(card); return -EIO; } pci_set_master(pci); snd_es1968_chip_init(chip); /* need to restore the base pointers.. */ if (chip->dma.addr) { /* set PCMBAR */ wave_set_register(chip, 0x01FC, chip->dma.addr >> 12); } snd_es1968_start_irq(chip); /* restore ac97 state */ snd_ac97_resume(chip->ac97); list_for_each_entry(es, &chip->substream_list, list) { switch (es->mode) { case ESM_MODE_PLAY: snd_es1968_playback_setup(chip, es, es->substream->runtime); break; case ESM_MODE_CAPTURE: snd_es1968_capture_setup(chip, es, es->substream->runtime); break; } } /* start timer again */ if (chip->bobclient) snd_es1968_bob_start(chip); snd_power_change_state(card, SNDRV_CTL_POWER_D0); chip->in_suspend = 0; return 0; } static SIMPLE_DEV_PM_OPS(es1968_pm, es1968_suspend, es1968_resume); #define ES1968_PM_OPS &es1968_pm #else #define ES1968_PM_OPS NULL #endif /* CONFIG_PM_SLEEP */ #ifdef SUPPORT_JOYSTICK #define JOYSTICK_ADDR 0x200 static int snd_es1968_create_gameport(struct es1968 *chip, int dev) { struct gameport *gp; struct resource *r; u16 val; if (!joystick[dev]) return -ENODEV; r = request_region(JOYSTICK_ADDR, 8, "ES1968 gameport"); if (!r) return -EBUSY; chip->gameport = gp = gameport_allocate_port(); if (!gp) { printk(KERN_ERR "es1968: cannot allocate memory for gameport\n"); release_and_free_resource(r); return -ENOMEM; } pci_read_config_word(chip->pci, ESM_LEGACY_AUDIO_CONTROL, &val); pci_write_config_word(chip->pci, ESM_LEGACY_AUDIO_CONTROL, val | 0x04); gameport_set_name(gp, "ES1968 Gameport"); gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci)); gameport_set_dev_parent(gp, &chip->pci->dev); gp->io = JOYSTICK_ADDR; gameport_set_port_data(gp, r); gameport_register_port(gp); return 0; } static void snd_es1968_free_gameport(struct es1968 *chip) { if (chip->gameport) { struct resource *r = gameport_get_port_data(chip->gameport); gameport_unregister_port(chip->gameport); chip->gameport = NULL; release_and_free_resource(r); } } #else static inline int snd_es1968_create_gameport(struct es1968 *chip, int dev) { return -ENOSYS; } static inline void snd_es1968_free_gameport(struct es1968 *chip) { } #endif #ifdef CONFIG_SND_ES1968_INPUT static int snd_es1968_input_register(struct es1968 *chip) { struct input_dev *input_dev; int err; input_dev = input_allocate_device(); if (!input_dev) return -ENOMEM; snprintf(chip->phys, sizeof(chip->phys), "pci-%s/input0", pci_name(chip->pci)); input_dev->name = chip->card->driver; input_dev->phys = chip->phys; input_dev->id.bustype = BUS_PCI; input_dev->id.vendor = chip->pci->vendor; input_dev->id.product = chip->pci->device; input_dev->dev.parent = &chip->pci->dev; __set_bit(EV_KEY, input_dev->evbit); __set_bit(KEY_MUTE, input_dev->keybit); __set_bit(KEY_VOLUMEDOWN, input_dev->keybit); __set_bit(KEY_VOLUMEUP, input_dev->keybit); err = input_register_device(input_dev); if (err) { input_free_device(input_dev); return err; } chip->input_dev = input_dev; return 0; } #endif /* CONFIG_SND_ES1968_INPUT */ #ifdef CONFIG_SND_ES1968_RADIO #define GPIO_DATA 0x60 #define IO_MASK 4 /* mask register offset from GPIO_DATA bits 1=unmask write to given bit */ #define IO_DIR 8 /* direction register offset from GPIO_DATA bits 0/1=read/write direction */ /* mask bits for GPIO lines */ #define STR_DATA 0x0040 /* GPIO6 */ #define STR_CLK 0x0080 /* GPIO7 */ #define STR_WREN 0x0100 /* GPIO8 */ #define STR_MOST 0x0200 /* GPIO9 */ static void snd_es1968_tea575x_set_pins(struct snd_tea575x *tea, u8 pins) { struct es1968 *chip = tea->private_data; unsigned long io = chip->io_port + GPIO_DATA; u16 val = 0; val |= (pins & TEA575X_DATA) ? STR_DATA : 0; val |= (pins & TEA575X_CLK) ? STR_CLK : 0; val |= (pins & TEA575X_WREN) ? STR_WREN : 0; outw(val, io); } static u8 snd_es1968_tea575x_get_pins(struct snd_tea575x *tea) { struct es1968 *chip = tea->private_data; unsigned long io = chip->io_port + GPIO_DATA; u16 val = inw(io); u8 ret; ret = 0; if (val & STR_DATA) ret |= TEA575X_DATA; if (val & STR_MOST) ret |= TEA575X_MOST; return ret; } static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool output) { struct es1968 *chip = tea->private_data; unsigned long io = chip->io_port + GPIO_DATA; u16 odir = inw(io + IO_DIR); if (output) { outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK); outw(odir | STR_DATA | STR_CLK | STR_WREN, io + IO_DIR); } else { outw(~(STR_CLK | STR_WREN | STR_DATA | STR_MOST), io + IO_MASK); outw((odir & ~(STR_DATA | STR_MOST)) | STR_CLK | STR_WREN, io + IO_DIR); } } static struct snd_tea575x_ops snd_es1968_tea_ops = { .set_pins = snd_es1968_tea575x_set_pins, .get_pins = snd_es1968_tea575x_get_pins, .set_direction = snd_es1968_tea575x_set_direction, }; #endif static int snd_es1968_free(struct es1968 *chip) { cancel_work_sync(&chip->hwvol_work); #ifdef CONFIG_SND_ES1968_INPUT if (chip->input_dev) input_unregister_device(chip->input_dev); #endif if (chip->io_port) { if (chip->irq >= 0) synchronize_irq(chip->irq); outw(1, chip->io_port + 0x04); /* clear WP interrupts */ outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */ } #ifdef CONFIG_SND_ES1968_RADIO snd_tea575x_exit(&chip->tea); v4l2_device_unregister(&chip->v4l2_dev); #endif if (chip->irq >= 0) free_irq(chip->irq, chip); snd_es1968_free_gameport(chip); pci_release_regions(chip->pci); pci_disable_device(chip->pci); kfree(chip); return 0; } static int snd_es1968_dev_free(struct snd_device *device) { struct es1968 *chip = device->device_data; return snd_es1968_free(chip); } struct ess_device_list { unsigned short type; /* chip type */ unsigned short vendor; /* subsystem vendor id */ }; static struct ess_device_list pm_whitelist[] = { { TYPE_MAESTRO2E, 0x0e11 }, /* Compaq Armada */ { TYPE_MAESTRO2E, 0x1028 }, { TYPE_MAESTRO2E, 0x103c }, { TYPE_MAESTRO2E, 0x1179 }, { TYPE_MAESTRO2E, 0x14c0 }, /* HP omnibook 4150 */ { TYPE_MAESTRO2E, 0x1558 }, { TYPE_MAESTRO2E, 0x125d }, /* a PCI card, e.g. Terratec DMX */ { TYPE_MAESTRO2, 0x125d }, /* a PCI card, e.g. SF64-PCE2 */ }; static struct ess_device_list mpu_blacklist[] = { { TYPE_MAESTRO2, 0x125d }, }; static int snd_es1968_create(struct snd_card *card, struct pci_dev *pci, int total_bufsize, int play_streams, int capt_streams, int chip_type, int do_pm, int radio_nr, struct es1968 **chip_ret) { static struct snd_device_ops ops = { .dev_free = snd_es1968_dev_free, }; struct es1968 *chip; int i, err; *chip_ret = NULL; /* enable PCI device */ if ((err = pci_enable_device(pci)) < 0) return err; /* check, if we can restrict PCI DMA transfers to 28 bits */ if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 || pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) { snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n"); pci_disable_device(pci); return -ENXIO; } chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (! chip) { pci_disable_device(pci); return -ENOMEM; } /* Set Vars */ chip->type = chip_type; spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->substream_lock); INIT_LIST_HEAD(&chip->buf_list); INIT_LIST_HEAD(&chip->substream_list); mutex_init(&chip->memory_mutex); INIT_WORK(&chip->hwvol_work, es1968_update_hw_volume); chip->card = card; chip->pci = pci; chip->irq = -1; chip->total_bufsize = total_bufsize; /* in bytes */ chip->playback_streams = play_streams; chip->capture_streams = capt_streams; if ((err = pci_request_regions(pci, "ESS Maestro")) < 0) { kfree(chip); pci_disable_device(pci); return err; } chip->io_port = pci_resource_start(pci, 0); if (request_irq(pci->irq, snd_es1968_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_es1968_free(chip); return -EBUSY; } chip->irq = pci->irq; /* Clear Maestro_map */ for (i = 0; i < 32; i++) chip->maestro_map[i] = 0; /* Clear Apu Map */ for (i = 0; i < NR_APUS; i++) chip->apu[i] = ESM_APU_FREE; /* just to be sure */ pci_set_master(pci); if (do_pm > 1) { /* disable power-management if not on the whitelist */ unsigned short vend; pci_read_config_word(chip->pci, PCI_SUBSYSTEM_VENDOR_ID, &vend); for (i = 0; i < (int)ARRAY_SIZE(pm_whitelist); i++) { if (chip->type == pm_whitelist[i].type && vend == pm_whitelist[i].vendor) { do_pm = 1; break; } } if (do_pm > 1) { /* not matched; disabling pm */ printk(KERN_INFO "es1968: not attempting power management.\n"); do_pm = 0; } } chip->do_pm = do_pm; snd_es1968_chip_init(chip); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_es1968_free(chip); return err; } snd_card_set_dev(card, &pci->dev); #ifdef CONFIG_SND_ES1968_RADIO err = v4l2_device_register(&pci->dev, &chip->v4l2_dev); if (err < 0) { snd_es1968_free(chip); return err; } chip->tea.v4l2_dev = &chip->v4l2_dev; chip->tea.private_data = chip; chip->tea.radio_nr = radio_nr; chip->tea.ops = &snd_es1968_tea_ops; strlcpy(chip->tea.card, "SF64-PCE2", sizeof(chip->tea.card)); sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci)); if (!snd_tea575x_init(&chip->tea, THIS_MODULE)) printk(KERN_INFO "es1968: detected TEA575x radio\n"); #endif *chip_ret = chip; return 0; } /* */ static int snd_es1968_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; struct snd_card *card; struct es1968 *chip; unsigned int i; int err; if (dev >= SNDRV_CARDS) return -ENODEV; if (!enable[dev]) { dev++; return -ENOENT; } err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); if (err < 0) return err; if (total_bufsize[dev] < 128) total_bufsize[dev] = 128; if (total_bufsize[dev] > 4096) total_bufsize[dev] = 4096; if ((err = snd_es1968_create(card, pci, total_bufsize[dev] * 1024, /* in bytes */ pcm_substreams_p[dev], pcm_substreams_c[dev], pci_id->driver_data, use_pm[dev], radio_nr[dev], &chip)) < 0) { snd_card_free(card); return err; } card->private_data = chip; switch (chip->type) { case TYPE_MAESTRO2E: strcpy(card->driver, "ES1978"); strcpy(card->shortname, "ESS ES1978 (Maestro 2E)"); break; case TYPE_MAESTRO2: strcpy(card->driver, "ES1968"); strcpy(card->shortname, "ESS ES1968 (Maestro 2)"); break; case TYPE_MAESTRO: strcpy(card->driver, "ESM1"); strcpy(card->shortname, "ESS Maestro 1"); break; } if ((err = snd_es1968_pcm(chip, 0)) < 0) { snd_card_free(card); return err; } if ((err = snd_es1968_mixer(chip)) < 0) { snd_card_free(card); return err; } if (enable_mpu[dev] == 2) { /* check the black list */ unsigned short vend; pci_read_config_word(chip->pci, PCI_SUBSYSTEM_VENDOR_ID, &vend); for (i = 0; i < ARRAY_SIZE(mpu_blacklist); i++) { if (chip->type == mpu_blacklist[i].type && vend == mpu_blacklist[i].vendor) { enable_mpu[dev] = 0; break; } } } if (enable_mpu[dev]) { if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, chip->io_port + ESM_MPU401_PORT, MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK, -1, &chip->rmidi)) < 0) { printk(KERN_WARNING "es1968: skipping MPU-401 MIDI support..\n"); } } snd_es1968_create_gameport(chip, dev); #ifdef CONFIG_SND_ES1968_INPUT err = snd_es1968_input_register(chip); if (err) snd_printk(KERN_WARNING "Input device registration " "failed with error %i", err); #endif snd_es1968_start_irq(chip); chip->clock = clock[dev]; if (! chip->clock) es1968_measure_clock(chip); sprintf(card->longname, "%s at 0x%lx, irq %i", card->shortname, chip->io_port, chip->irq); if ((err = snd_card_register(card)) < 0) { snd_card_free(card); return err; } pci_set_drvdata(pci, card); dev++; return 0; } static void snd_es1968_remove(struct pci_dev *pci) { snd_card_free(pci_get_drvdata(pci)); pci_set_drvdata(pci, NULL); } static struct pci_driver es1968_driver = { .name = KBUILD_MODNAME, .id_table = snd_es1968_ids, .probe = snd_es1968_probe, .remove = snd_es1968_remove, .driver = { .pm = ES1968_PM_OPS, }, }; module_pci_driver(es1968_driver);
gpl-2.0
TeamMac/android_kernel_lge_msm7x27-3.0.x
drivers/net/zorro8390.c
2748
14235
/* * Amiga Linux/m68k and Linux/PPC Zorro NS8390 Ethernet Driver * * (C) Copyright 1998-2000 by some Elitist 680x0 Users(TM) * * --------------------------------------------------------------------------- * * This program is based on all the other NE2000 drivers for Linux * * --------------------------------------------------------------------------- * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of the Linux * distribution for more details. * * --------------------------------------------------------------------------- * * The Ariadne II and X-Surf are Zorro-II boards containing Realtek RTL8019AS * Ethernet Controllers. */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/delay.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/zorro.h> #include <linux/jiffies.h> #include <asm/system.h> #include <asm/irq.h> #include <asm/amigaints.h> #include <asm/amigahw.h> #define EI_SHIFT(x) (ei_local->reg_offset[x]) #define ei_inb(port) in_8(port) #define ei_outb(val,port) out_8(port,val) #define ei_inb_p(port) in_8(port) #define ei_outb_p(val,port) out_8(port,val) static const char version[] = "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; #include "lib8390.c" #define DRV_NAME "zorro8390" #define NE_BASE (dev->base_addr) #define NE_CMD (0x00*2) #define NE_DATAPORT (0x10*2) /* NatSemi-defined port window offset. */ #define NE_RESET (0x1f*2) /* Issue a read to reset, a write to clear. */ #define NE_IO_EXTENT (0x20*2) #define NE_EN0_ISR (0x07*2) #define NE_EN0_DCFG (0x0e*2) #define NE_EN0_RSARLO (0x08*2) #define NE_EN0_RSARHI (0x09*2) #define NE_EN0_RCNTLO (0x0a*2) #define NE_EN0_RXCR (0x0c*2) #define NE_EN0_TXCR (0x0d*2) #define NE_EN0_RCNTHI (0x0b*2) #define NE_EN0_IMR (0x0f*2) #define NESM_START_PG 0x40 /* First page of TX buffer */ #define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */ #define WORDSWAP(a) ((((a)>>8)&0xff) | ((a)<<8)) static struct card_info { zorro_id id; const char *name; unsigned int offset; } cards[] __devinitdata = { { ZORRO_PROD_VILLAGE_TRONIC_ARIADNE2, "Ariadne II", 0x0600 }, { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, "X-Surf", 0x8600 }, }; static int __devinit zorro8390_init_one(struct zorro_dev *z, const struct zorro_device_id *ent); static int __devinit zorro8390_init(struct net_device *dev, unsigned long board, const char *name, unsigned long ioaddr); static int zorro8390_open(struct net_device *dev); static int zorro8390_close(struct net_device *dev); static void zorro8390_reset_8390(struct net_device *dev); static void zorro8390_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page); static void zorro8390_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset); static void zorro8390_block_output(struct net_device *dev, const int count, const unsigned char *buf, const int start_page); static void __devexit zorro8390_remove_one(struct zorro_dev *z); static struct zorro_device_id zorro8390_zorro_tbl[] __devinitdata = { { ZORRO_PROD_VILLAGE_TRONIC_ARIADNE2, }, { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, }, { 0 } }; MODULE_DEVICE_TABLE(zorro, zorro8390_zorro_tbl); static struct zorro_driver zorro8390_driver = { .name = "zorro8390", .id_table = zorro8390_zorro_tbl, .probe = zorro8390_init_one, .remove = __devexit_p(zorro8390_remove_one), }; static int __devinit zorro8390_init_one(struct zorro_dev *z, const struct zorro_device_id *ent) { struct net_device *dev; unsigned long board, ioaddr; int err, i; for (i = ARRAY_SIZE(cards)-1; i >= 0; i--) if (z->id == cards[i].id) break; if (i < 0) return -ENODEV; board = z->resource.start; ioaddr = board+cards[i].offset; dev = ____alloc_ei_netdev(0); if (!dev) return -ENOMEM; if (!request_mem_region(ioaddr, NE_IO_EXTENT*2, DRV_NAME)) { free_netdev(dev); return -EBUSY; } if ((err = zorro8390_init(dev, board, cards[i].name, ZTWO_VADDR(ioaddr)))) { release_mem_region(ioaddr, NE_IO_EXTENT*2); free_netdev(dev); return err; } zorro_set_drvdata(z, dev); return 0; } static const struct net_device_ops zorro8390_netdev_ops = { .ndo_open = zorro8390_open, .ndo_stop = zorro8390_close, .ndo_start_xmit = __ei_start_xmit, .ndo_tx_timeout = __ei_tx_timeout, .ndo_get_stats = __ei_get_stats, .ndo_set_multicast_list = __ei_set_multicast_list, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = eth_mac_addr, .ndo_change_mtu = eth_change_mtu, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = __ei_poll, #endif }; static int __devinit zorro8390_init(struct net_device *dev, unsigned long board, const char *name, unsigned long ioaddr) { int i; int err; unsigned char SA_prom[32]; int start_page, stop_page; static u32 zorro8390_offsets[16] = { 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, }; /* Reset card. Who knows what dain-bramaged state it was left in. */ { unsigned long reset_start_time = jiffies; z_writeb(z_readb(ioaddr + NE_RESET), ioaddr + NE_RESET); while ((z_readb(ioaddr + NE_EN0_ISR) & ENISR_RESET) == 0) if (time_after(jiffies, reset_start_time + 2*HZ/100)) { printk(KERN_WARNING " not found (no reset ack).\n"); return -ENODEV; } z_writeb(0xff, ioaddr + NE_EN0_ISR); /* Ack all intr. */ } /* Read the 16 bytes of station address PROM. We must first initialize registers, similar to NS8390_init(eifdev, 0). We can't reliably read the SAPROM address without this. (I learned the hard way!). */ { struct { u32 value; u32 offset; } program_seq[] = { {E8390_NODMA+E8390_PAGE0+E8390_STOP, NE_CMD}, /* Select page 0*/ {0x48, NE_EN0_DCFG}, /* Set byte-wide (0x48) access. */ {0x00, NE_EN0_RCNTLO}, /* Clear the count regs. */ {0x00, NE_EN0_RCNTHI}, {0x00, NE_EN0_IMR}, /* Mask completion irq. */ {0xFF, NE_EN0_ISR}, {E8390_RXOFF, NE_EN0_RXCR}, /* 0x20 Set to monitor */ {E8390_TXOFF, NE_EN0_TXCR}, /* 0x02 and loopback mode. */ {32, NE_EN0_RCNTLO}, {0x00, NE_EN0_RCNTHI}, {0x00, NE_EN0_RSARLO}, /* DMA starting at 0x0000. */ {0x00, NE_EN0_RSARHI}, {E8390_RREAD+E8390_START, NE_CMD}, }; for (i = 0; i < ARRAY_SIZE(program_seq); i++) { z_writeb(program_seq[i].value, ioaddr + program_seq[i].offset); } } for (i = 0; i < 16; i++) { SA_prom[i] = z_readb(ioaddr + NE_DATAPORT); (void)z_readb(ioaddr + NE_DATAPORT); } /* We must set the 8390 for word mode. */ z_writeb(0x49, ioaddr + NE_EN0_DCFG); start_page = NESM_START_PG; stop_page = NESM_STOP_PG; dev->base_addr = ioaddr; dev->irq = IRQ_AMIGA_PORTS; /* Install the Interrupt handler */ i = request_irq(IRQ_AMIGA_PORTS, __ei_interrupt, IRQF_SHARED, DRV_NAME, dev); if (i) return i; for(i = 0; i < ETHER_ADDR_LEN; i++) dev->dev_addr[i] = SA_prom[i]; #ifdef DEBUG printk("%pM", dev->dev_addr); #endif ei_status.name = name; ei_status.tx_start_page = start_page; ei_status.stop_page = stop_page; ei_status.word16 = 1; ei_status.rx_start_page = start_page + TX_PAGES; ei_status.reset_8390 = &zorro8390_reset_8390; ei_status.block_input = &zorro8390_block_input; ei_status.block_output = &zorro8390_block_output; ei_status.get_8390_hdr = &zorro8390_get_8390_hdr; ei_status.reg_offset = zorro8390_offsets; dev->netdev_ops = &zorro8390_netdev_ops; __NS8390_init(dev, 0); err = register_netdev(dev); if (err) { free_irq(IRQ_AMIGA_PORTS, dev); return err; } printk(KERN_INFO "%s: %s at 0x%08lx, Ethernet Address %pM\n", dev->name, name, board, dev->dev_addr); return 0; } static int zorro8390_open(struct net_device *dev) { __ei_open(dev); return 0; } static int zorro8390_close(struct net_device *dev) { if (ei_debug > 1) printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); __ei_close(dev); return 0; } /* Hard reset the card. This used to pause for the same period that a 8390 reset command required, but that shouldn't be necessary. */ static void zorro8390_reset_8390(struct net_device *dev) { unsigned long reset_start_time = jiffies; if (ei_debug > 1) printk(KERN_DEBUG "resetting the 8390 t=%ld...\n", jiffies); z_writeb(z_readb(NE_BASE + NE_RESET), NE_BASE + NE_RESET); ei_status.txing = 0; ei_status.dmaing = 0; /* This check _should_not_ be necessary, omit eventually. */ while ((z_readb(NE_BASE+NE_EN0_ISR) & ENISR_RESET) == 0) if (time_after(jiffies, reset_start_time + 2*HZ/100)) { printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", dev->name); break; } z_writeb(ENISR_RESET, NE_BASE + NE_EN0_ISR); /* Ack intr. */ } /* Grab the 8390 specific header. Similar to the block_input routine, but we don't need to be concerned with ring wrap as the header will be at the start of a page, so we optimize accordingly. */ static void zorro8390_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) { int nic_base = dev->base_addr; int cnt; short *ptrs; /* This *shouldn't* happen. If it does, it's the last thing you'll see */ if (ei_status.dmaing) { printk(KERN_ERR "%s: DMAing conflict in ne_get_8390_hdr " "[DMAstat:%d][irqlock:%d].\n", dev->name, ei_status.dmaing, ei_status.irqlock); return; } ei_status.dmaing |= 0x01; z_writeb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); z_writeb(sizeof(struct e8390_pkt_hdr), nic_base + NE_EN0_RCNTLO); z_writeb(0, nic_base + NE_EN0_RCNTHI); z_writeb(0, nic_base + NE_EN0_RSARLO); /* On page boundary */ z_writeb(ring_page, nic_base + NE_EN0_RSARHI); z_writeb(E8390_RREAD+E8390_START, nic_base + NE_CMD); ptrs = (short*)hdr; for (cnt = 0; cnt < (sizeof(struct e8390_pkt_hdr)>>1); cnt++) *ptrs++ = z_readw(NE_BASE + NE_DATAPORT); z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Ack intr. */ hdr->count = WORDSWAP(hdr->count); ei_status.dmaing &= ~0x01; } /* Block input and output, similar to the Crynwr packet driver. If you are porting to a new ethercard, look at the packet driver source for hints. The NEx000 doesn't share the on-board packet memory -- you have to put the packet out through the "remote DMA" dataport using z_writeb. */ static void zorro8390_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) { int nic_base = dev->base_addr; char *buf = skb->data; short *ptrs; int cnt; /* This *shouldn't* happen. If it does, it's the last thing you'll see */ if (ei_status.dmaing) { printk(KERN_ERR "%s: DMAing conflict in ne_block_input " "[DMAstat:%d][irqlock:%d].\n", dev->name, ei_status.dmaing, ei_status.irqlock); return; } ei_status.dmaing |= 0x01; z_writeb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); z_writeb(count & 0xff, nic_base + NE_EN0_RCNTLO); z_writeb(count >> 8, nic_base + NE_EN0_RCNTHI); z_writeb(ring_offset & 0xff, nic_base + NE_EN0_RSARLO); z_writeb(ring_offset >> 8, nic_base + NE_EN0_RSARHI); z_writeb(E8390_RREAD+E8390_START, nic_base + NE_CMD); ptrs = (short*)buf; for (cnt = 0; cnt < (count>>1); cnt++) *ptrs++ = z_readw(NE_BASE + NE_DATAPORT); if (count & 0x01) buf[count-1] = z_readb(NE_BASE + NE_DATAPORT); z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Ack intr. */ ei_status.dmaing &= ~0x01; } static void zorro8390_block_output(struct net_device *dev, int count, const unsigned char *buf, const int start_page) { int nic_base = NE_BASE; unsigned long dma_start; short *ptrs; int cnt; /* Round the count up for word writes. Do we need to do this? What effect will an odd byte count have on the 8390? I should check someday. */ if (count & 0x01) count++; /* This *shouldn't* happen. If it does, it's the last thing you'll see */ if (ei_status.dmaing) { printk(KERN_ERR "%s: DMAing conflict in ne_block_output." "[DMAstat:%d][irqlock:%d]\n", dev->name, ei_status.dmaing, ei_status.irqlock); return; } ei_status.dmaing |= 0x01; /* We should already be in page 0, but to be safe... */ z_writeb(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD); z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Now the normal output. */ z_writeb(count & 0xff, nic_base + NE_EN0_RCNTLO); z_writeb(count >> 8, nic_base + NE_EN0_RCNTHI); z_writeb(0x00, nic_base + NE_EN0_RSARLO); z_writeb(start_page, nic_base + NE_EN0_RSARHI); z_writeb(E8390_RWRITE+E8390_START, nic_base + NE_CMD); ptrs = (short*)buf; for (cnt = 0; cnt < count>>1; cnt++) z_writew(*ptrs++, NE_BASE+NE_DATAPORT); dma_start = jiffies; while ((z_readb(NE_BASE + NE_EN0_ISR) & ENISR_RDC) == 0) if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */ printk(KERN_ERR "%s: timeout waiting for Tx RDC.\n", dev->name); zorro8390_reset_8390(dev); __NS8390_init(dev,1); break; } z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Ack intr. */ ei_status.dmaing &= ~0x01; } static void __devexit zorro8390_remove_one(struct zorro_dev *z) { struct net_device *dev = zorro_get_drvdata(z); unregister_netdev(dev); free_irq(IRQ_AMIGA_PORTS, dev); release_mem_region(ZTWO_PADDR(dev->base_addr), NE_IO_EXTENT*2); free_netdev(dev); } static int __init zorro8390_init_module(void) { return zorro_register_driver(&zorro8390_driver); } static void __exit zorro8390_cleanup_module(void) { zorro_unregister_driver(&zorro8390_driver); } module_init(zorro8390_init_module); module_exit(zorro8390_cleanup_module); MODULE_LICENSE("GPL");
gpl-2.0
IGGYVIP/lge-kernel-e430
drivers/scsi/bnx2i/bnx2i_hwi.c
3260
83763
/* bnx2i_hwi.c: Broadcom NetXtreme II iSCSI driver. * * Copyright (c) 2006 - 2011 Broadcom Corporation * Copyright (c) 2007, 2008 Red Hat, Inc. All rights reserved. * Copyright (c) 2007, 2008 Mike Christie * * 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. * * Written by: Anil Veerabhadrappa (anilgv@broadcom.com) * Maintained by: Eddie Wai (eddie.wai@broadcom.com) */ #include <linux/gfp.h> #include <scsi/scsi_tcq.h> #include <scsi/libiscsi.h> #include "bnx2i.h" DECLARE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu); /** * bnx2i_get_cid_num - get cid from ep * @ep: endpoint pointer * * Only applicable to 57710 family of devices */ static u32 bnx2i_get_cid_num(struct bnx2i_endpoint *ep) { u32 cid; if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) cid = ep->ep_cid; else cid = GET_CID_NUM(ep->ep_cid); return cid; } /** * bnx2i_adjust_qp_size - Adjust SQ/RQ/CQ size for 57710 device type * @hba: Adapter for which adjustments is to be made * * Only applicable to 57710 family of devices */ static void bnx2i_adjust_qp_size(struct bnx2i_hba *hba) { u32 num_elements_per_pg; if (test_bit(BNX2I_NX2_DEV_5706, &hba->cnic_dev_type) || test_bit(BNX2I_NX2_DEV_5708, &hba->cnic_dev_type) || test_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type)) { if (!is_power_of_2(hba->max_sqes)) hba->max_sqes = rounddown_pow_of_two(hba->max_sqes); if (!is_power_of_2(hba->max_rqes)) hba->max_rqes = rounddown_pow_of_two(hba->max_rqes); } /* Adjust each queue size if the user selection does not * yield integral num of page buffers */ /* adjust SQ */ num_elements_per_pg = PAGE_SIZE / BNX2I_SQ_WQE_SIZE; if (hba->max_sqes < num_elements_per_pg) hba->max_sqes = num_elements_per_pg; else if (hba->max_sqes % num_elements_per_pg) hba->max_sqes = (hba->max_sqes + num_elements_per_pg - 1) & ~(num_elements_per_pg - 1); /* adjust CQ */ num_elements_per_pg = PAGE_SIZE / BNX2I_CQE_SIZE; if (hba->max_cqes < num_elements_per_pg) hba->max_cqes = num_elements_per_pg; else if (hba->max_cqes % num_elements_per_pg) hba->max_cqes = (hba->max_cqes + num_elements_per_pg - 1) & ~(num_elements_per_pg - 1); /* adjust RQ */ num_elements_per_pg = PAGE_SIZE / BNX2I_RQ_WQE_SIZE; if (hba->max_rqes < num_elements_per_pg) hba->max_rqes = num_elements_per_pg; else if (hba->max_rqes % num_elements_per_pg) hba->max_rqes = (hba->max_rqes + num_elements_per_pg - 1) & ~(num_elements_per_pg - 1); } /** * bnx2i_get_link_state - get network interface link state * @hba: adapter instance pointer * * updates adapter structure flag based on netdev state */ static void bnx2i_get_link_state(struct bnx2i_hba *hba) { if (test_bit(__LINK_STATE_NOCARRIER, &hba->netdev->state)) set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); else clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); } /** * bnx2i_iscsi_license_error - displays iscsi license related error message * @hba: adapter instance pointer * @error_code: error classification * * Puts out an error log when driver is unable to offload iscsi connection * due to license restrictions */ static void bnx2i_iscsi_license_error(struct bnx2i_hba *hba, u32 error_code) { if (error_code == ISCSI_KCQE_COMPLETION_STATUS_ISCSI_NOT_SUPPORTED) /* iSCSI offload not supported on this device */ printk(KERN_ERR "bnx2i: iSCSI not supported, dev=%s\n", hba->netdev->name); if (error_code == ISCSI_KCQE_COMPLETION_STATUS_LOM_ISCSI_NOT_ENABLED) /* iSCSI offload not supported on this LOM device */ printk(KERN_ERR "bnx2i: LOM is not enable to " "offload iSCSI connections, dev=%s\n", hba->netdev->name); set_bit(ADAPTER_STATE_INIT_FAILED, &hba->adapter_state); } /** * bnx2i_arm_cq_event_coalescing - arms CQ to enable EQ notification * @ep: endpoint (transport indentifier) structure * @action: action, ARM or DISARM. For now only ARM_CQE is used * * Arm'ing CQ will enable chip to generate global EQ events inorder to interrupt * the driver. EQ event is generated CQ index is hit or at least 1 CQ is * outstanding and on chip timer expires */ int bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action) { struct bnx2i_5771x_cq_db *cq_db; u16 cq_index; u16 next_index = 0; u32 num_active_cmds; /* Coalesce CQ entries only on 10G devices */ if (!test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) return 0; /* Do not update CQ DB multiple times before firmware writes * '0xFFFF' to CQDB->SQN field. Deviation may cause spurious * interrupts and other unwanted results */ cq_db = (struct bnx2i_5771x_cq_db *) ep->qp.cq_pgtbl_virt; if (action != CNIC_ARM_CQE_FP) if (cq_db->sqn[0] && cq_db->sqn[0] != 0xFFFF) return 0; if (action == CNIC_ARM_CQE || action == CNIC_ARM_CQE_FP) { num_active_cmds = atomic_read(&ep->num_active_cmds); if (num_active_cmds <= event_coal_min) next_index = 1; else { next_index = num_active_cmds >> ep->ec_shift; if (next_index > num_active_cmds - event_coal_min) next_index = num_active_cmds - event_coal_min; } if (!next_index) next_index = 1; cq_index = ep->qp.cqe_exp_seq_sn + next_index - 1; if (cq_index > ep->qp.cqe_size * 2) cq_index -= ep->qp.cqe_size * 2; if (!cq_index) cq_index = 1; cq_db->sqn[0] = cq_index; } return next_index; } /** * bnx2i_get_rq_buf - copy RQ buffer contents to driver buffer * @conn: iscsi connection on which RQ event occurred * @ptr: driver buffer to which RQ buffer contents is to * be copied * @len: length of valid data inside RQ buf * * Copies RQ buffer contents from shared (DMA'able) memory region to * driver buffer. RQ is used to DMA unsolicitated iscsi pdu's and * scsi sense info */ void bnx2i_get_rq_buf(struct bnx2i_conn *bnx2i_conn, char *ptr, int len) { if (!bnx2i_conn->ep->qp.rqe_left) return; bnx2i_conn->ep->qp.rqe_left--; memcpy(ptr, (u8 *) bnx2i_conn->ep->qp.rq_cons_qe, len); if (bnx2i_conn->ep->qp.rq_cons_qe == bnx2i_conn->ep->qp.rq_last_qe) { bnx2i_conn->ep->qp.rq_cons_qe = bnx2i_conn->ep->qp.rq_first_qe; bnx2i_conn->ep->qp.rq_cons_idx = 0; } else { bnx2i_conn->ep->qp.rq_cons_qe++; bnx2i_conn->ep->qp.rq_cons_idx++; } } static void bnx2i_ring_577xx_doorbell(struct bnx2i_conn *conn) { struct bnx2i_5771x_dbell dbell; u32 msg; memset(&dbell, 0, sizeof(dbell)); dbell.dbell.header = (B577XX_ISCSI_CONNECTION_TYPE << B577XX_DOORBELL_HDR_CONN_TYPE_SHIFT); msg = *((u32 *)&dbell); /* TODO : get doorbell register mapping */ writel(cpu_to_le32(msg), conn->ep->qp.ctx_base); } /** * bnx2i_put_rq_buf - Replenish RQ buffer, if required ring on chip doorbell * @conn: iscsi connection on which event to post * @count: number of RQ buffer being posted to chip * * No need to ring hardware doorbell for 57710 family of devices */ void bnx2i_put_rq_buf(struct bnx2i_conn *bnx2i_conn, int count) { struct bnx2i_5771x_sq_rq_db *rq_db; u16 hi_bit = (bnx2i_conn->ep->qp.rq_prod_idx & 0x8000); struct bnx2i_endpoint *ep = bnx2i_conn->ep; ep->qp.rqe_left += count; ep->qp.rq_prod_idx &= 0x7FFF; ep->qp.rq_prod_idx += count; if (ep->qp.rq_prod_idx > bnx2i_conn->hba->max_rqes) { ep->qp.rq_prod_idx %= bnx2i_conn->hba->max_rqes; if (!hi_bit) ep->qp.rq_prod_idx |= 0x8000; } else ep->qp.rq_prod_idx |= hi_bit; if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) { rq_db = (struct bnx2i_5771x_sq_rq_db *) ep->qp.rq_pgtbl_virt; rq_db->prod_idx = ep->qp.rq_prod_idx; /* no need to ring hardware doorbell for 57710 */ } else { writew(ep->qp.rq_prod_idx, ep->qp.ctx_base + CNIC_RECV_DOORBELL); } mmiowb(); } /** * bnx2i_ring_sq_dbell - Ring SQ doorbell to wake-up the processing engine * @conn: iscsi connection to which new SQ entries belong * @count: number of SQ WQEs to post * * SQ DB is updated in host memory and TX Doorbell is rung for 57710 family * of devices. For 5706/5708/5709 new SQ WQE count is written into the * doorbell register */ static void bnx2i_ring_sq_dbell(struct bnx2i_conn *bnx2i_conn, int count) { struct bnx2i_5771x_sq_rq_db *sq_db; struct bnx2i_endpoint *ep = bnx2i_conn->ep; atomic_inc(&ep->num_active_cmds); wmb(); /* flush SQ WQE memory before the doorbell is rung */ if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) { sq_db = (struct bnx2i_5771x_sq_rq_db *) ep->qp.sq_pgtbl_virt; sq_db->prod_idx = ep->qp.sq_prod_idx; bnx2i_ring_577xx_doorbell(bnx2i_conn); } else writew(count, ep->qp.ctx_base + CNIC_SEND_DOORBELL); mmiowb(); /* flush posted PCI writes */ } /** * bnx2i_ring_dbell_update_sq_params - update SQ driver parameters * @conn: iscsi connection to which new SQ entries belong * @count: number of SQ WQEs to post * * this routine will update SQ driver parameters and ring the doorbell */ static void bnx2i_ring_dbell_update_sq_params(struct bnx2i_conn *bnx2i_conn, int count) { int tmp_cnt; if (count == 1) { if (bnx2i_conn->ep->qp.sq_prod_qe == bnx2i_conn->ep->qp.sq_last_qe) bnx2i_conn->ep->qp.sq_prod_qe = bnx2i_conn->ep->qp.sq_first_qe; else bnx2i_conn->ep->qp.sq_prod_qe++; } else { if ((bnx2i_conn->ep->qp.sq_prod_qe + count) <= bnx2i_conn->ep->qp.sq_last_qe) bnx2i_conn->ep->qp.sq_prod_qe += count; else { tmp_cnt = bnx2i_conn->ep->qp.sq_last_qe - bnx2i_conn->ep->qp.sq_prod_qe; bnx2i_conn->ep->qp.sq_prod_qe = &bnx2i_conn->ep->qp.sq_first_qe[count - (tmp_cnt + 1)]; } } bnx2i_conn->ep->qp.sq_prod_idx += count; /* Ring the doorbell */ bnx2i_ring_sq_dbell(bnx2i_conn, bnx2i_conn->ep->qp.sq_prod_idx); } /** * bnx2i_send_iscsi_login - post iSCSI login request MP WQE to hardware * @conn: iscsi connection * @cmd: driver command structure which is requesting * a WQE to sent to chip for further processing * * prepare and post an iSCSI Login request WQE to CNIC firmware */ int bnx2i_send_iscsi_login(struct bnx2i_conn *bnx2i_conn, struct iscsi_task *task) { struct bnx2i_cmd *bnx2i_cmd; struct bnx2i_login_request *login_wqe; struct iscsi_login_req *login_hdr; u32 dword; bnx2i_cmd = (struct bnx2i_cmd *)task->dd_data; login_hdr = (struct iscsi_login_req *)task->hdr; login_wqe = (struct bnx2i_login_request *) bnx2i_conn->ep->qp.sq_prod_qe; login_wqe->op_code = login_hdr->opcode; login_wqe->op_attr = login_hdr->flags; login_wqe->version_max = login_hdr->max_version; login_wqe->version_min = login_hdr->min_version; login_wqe->data_length = ntoh24(login_hdr->dlength); login_wqe->isid_lo = *((u32 *) login_hdr->isid); login_wqe->isid_hi = *((u16 *) login_hdr->isid + 2); login_wqe->tsih = login_hdr->tsih; login_wqe->itt = task->itt | (ISCSI_TASK_TYPE_MPATH << ISCSI_LOGIN_REQUEST_TYPE_SHIFT); login_wqe->cid = login_hdr->cid; login_wqe->cmd_sn = be32_to_cpu(login_hdr->cmdsn); login_wqe->exp_stat_sn = be32_to_cpu(login_hdr->exp_statsn); login_wqe->flags = ISCSI_LOGIN_REQUEST_UPDATE_EXP_STAT_SN; login_wqe->resp_bd_list_addr_lo = (u32) bnx2i_conn->gen_pdu.resp_bd_dma; login_wqe->resp_bd_list_addr_hi = (u32) ((u64) bnx2i_conn->gen_pdu.resp_bd_dma >> 32); dword = ((1 << ISCSI_LOGIN_REQUEST_NUM_RESP_BDS_SHIFT) | (bnx2i_conn->gen_pdu.resp_buf_size << ISCSI_LOGIN_REQUEST_RESP_BUFFER_LENGTH_SHIFT)); login_wqe->resp_buffer = dword; login_wqe->bd_list_addr_lo = (u32) bnx2i_conn->gen_pdu.req_bd_dma; login_wqe->bd_list_addr_hi = (u32) ((u64) bnx2i_conn->gen_pdu.req_bd_dma >> 32); login_wqe->num_bds = 1; login_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1); return 0; } /** * bnx2i_send_iscsi_tmf - post iSCSI task management request MP WQE to hardware * @conn: iscsi connection * @mtask: driver command structure which is requesting * a WQE to sent to chip for further processing * * prepare and post an iSCSI Login request WQE to CNIC firmware */ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn, struct iscsi_task *mtask) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct iscsi_tm *tmfabort_hdr; struct scsi_cmnd *ref_sc; struct iscsi_task *ctask; struct bnx2i_cmd *bnx2i_cmd; struct bnx2i_tmf_request *tmfabort_wqe; u32 dword; u32 scsi_lun[2]; bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data; tmfabort_hdr = (struct iscsi_tm *)mtask->hdr; tmfabort_wqe = (struct bnx2i_tmf_request *) bnx2i_conn->ep->qp.sq_prod_qe; tmfabort_wqe->op_code = tmfabort_hdr->opcode; tmfabort_wqe->op_attr = tmfabort_hdr->flags; tmfabort_wqe->itt = (mtask->itt | (ISCSI_TASK_TYPE_MPATH << 14)); tmfabort_wqe->reserved2 = 0; tmfabort_wqe->cmd_sn = be32_to_cpu(tmfabort_hdr->cmdsn); switch (tmfabort_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) { case ISCSI_TM_FUNC_ABORT_TASK: case ISCSI_TM_FUNC_TASK_REASSIGN: ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt); if (!ctask || !ctask->sc) /* * the iscsi layer must have completed the cmd while * was starting up. * * Note: In the case of a SCSI cmd timeout, the task's * sc is still active; hence ctask->sc != 0 * In this case, the task must be aborted */ return 0; ref_sc = ctask->sc; if (ref_sc->sc_data_direction == DMA_TO_DEVICE) dword = (ISCSI_TASK_TYPE_WRITE << ISCSI_CMD_REQUEST_TYPE_SHIFT); else dword = (ISCSI_TASK_TYPE_READ << ISCSI_CMD_REQUEST_TYPE_SHIFT); tmfabort_wqe->ref_itt = (dword | (tmfabort_hdr->rtt & ISCSI_ITT_MASK)); break; default: tmfabort_wqe->ref_itt = RESERVED_ITT; } memcpy(scsi_lun, &tmfabort_hdr->lun, sizeof(struct scsi_lun)); tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]); tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]); tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn); tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma; tmfabort_wqe->bd_list_addr_hi = (u32) ((u64) bnx2i_conn->hba->mp_bd_dma >> 32); tmfabort_wqe->num_bds = 1; tmfabort_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1); return 0; } /** * bnx2i_send_iscsi_text - post iSCSI text WQE to hardware * @conn: iscsi connection * @mtask: driver command structure which is requesting * a WQE to sent to chip for further processing * * prepare and post an iSCSI Text request WQE to CNIC firmware */ int bnx2i_send_iscsi_text(struct bnx2i_conn *bnx2i_conn, struct iscsi_task *mtask) { struct bnx2i_cmd *bnx2i_cmd; struct bnx2i_text_request *text_wqe; struct iscsi_text *text_hdr; u32 dword; bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data; text_hdr = (struct iscsi_text *)mtask->hdr; text_wqe = (struct bnx2i_text_request *) bnx2i_conn->ep->qp.sq_prod_qe; memset(text_wqe, 0, sizeof(struct bnx2i_text_request)); text_wqe->op_code = text_hdr->opcode; text_wqe->op_attr = text_hdr->flags; text_wqe->data_length = ntoh24(text_hdr->dlength); text_wqe->itt = mtask->itt | (ISCSI_TASK_TYPE_MPATH << ISCSI_TEXT_REQUEST_TYPE_SHIFT); text_wqe->ttt = be32_to_cpu(text_hdr->ttt); text_wqe->cmd_sn = be32_to_cpu(text_hdr->cmdsn); text_wqe->resp_bd_list_addr_lo = (u32) bnx2i_conn->gen_pdu.resp_bd_dma; text_wqe->resp_bd_list_addr_hi = (u32) ((u64) bnx2i_conn->gen_pdu.resp_bd_dma >> 32); dword = ((1 << ISCSI_TEXT_REQUEST_NUM_RESP_BDS_SHIFT) | (bnx2i_conn->gen_pdu.resp_buf_size << ISCSI_TEXT_REQUEST_RESP_BUFFER_LENGTH_SHIFT)); text_wqe->resp_buffer = dword; text_wqe->bd_list_addr_lo = (u32) bnx2i_conn->gen_pdu.req_bd_dma; text_wqe->bd_list_addr_hi = (u32) ((u64) bnx2i_conn->gen_pdu.req_bd_dma >> 32); text_wqe->num_bds = 1; text_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1); return 0; } /** * bnx2i_send_iscsi_scsicmd - post iSCSI scsicmd request WQE to hardware * @conn: iscsi connection * @cmd: driver command structure which is requesting * a WQE to sent to chip for further processing * * prepare and post an iSCSI SCSI-CMD request WQE to CNIC firmware */ int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *bnx2i_conn, struct bnx2i_cmd *cmd) { struct bnx2i_cmd_request *scsi_cmd_wqe; scsi_cmd_wqe = (struct bnx2i_cmd_request *) bnx2i_conn->ep->qp.sq_prod_qe; memcpy(scsi_cmd_wqe, &cmd->req, sizeof(struct bnx2i_cmd_request)); scsi_cmd_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1); return 0; } /** * bnx2i_send_iscsi_nopout - post iSCSI NOPOUT request WQE to hardware * @conn: iscsi connection * @cmd: driver command structure which is requesting * a WQE to sent to chip for further processing * @datap: payload buffer pointer * @data_len: payload data length * @unsol: indicated whether nopout pdu is unsolicited pdu or * in response to target's NOPIN w/ TTT != FFFFFFFF * * prepare and post a nopout request WQE to CNIC firmware */ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn, struct iscsi_task *task, char *datap, int data_len, int unsol) { struct bnx2i_endpoint *ep = bnx2i_conn->ep; struct bnx2i_cmd *bnx2i_cmd; struct bnx2i_nop_out_request *nopout_wqe; struct iscsi_nopout *nopout_hdr; bnx2i_cmd = (struct bnx2i_cmd *)task->dd_data; nopout_hdr = (struct iscsi_nopout *)task->hdr; nopout_wqe = (struct bnx2i_nop_out_request *)ep->qp.sq_prod_qe; memset(nopout_wqe, 0x00, sizeof(struct bnx2i_nop_out_request)); nopout_wqe->op_code = nopout_hdr->opcode; nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL; memcpy(nopout_wqe->lun, &nopout_hdr->lun, 8); if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) { u32 tmp = nopout_wqe->lun[0]; /* 57710 requires LUN field to be swapped */ nopout_wqe->lun[0] = nopout_wqe->lun[1]; nopout_wqe->lun[1] = tmp; } nopout_wqe->itt = ((u16)task->itt | (ISCSI_TASK_TYPE_MPATH << ISCSI_TMF_REQUEST_TYPE_SHIFT)); nopout_wqe->ttt = be32_to_cpu(nopout_hdr->ttt); nopout_wqe->flags = 0; if (!unsol) nopout_wqe->flags = ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION; else if (nopout_hdr->itt == RESERVED_ITT) nopout_wqe->flags = ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION; nopout_wqe->cmd_sn = be32_to_cpu(nopout_hdr->cmdsn); nopout_wqe->data_length = data_len; if (data_len) { /* handle payload data, not required in first release */ printk(KERN_ALERT "NOPOUT: WARNING!! payload len != 0\n"); } else { nopout_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma; nopout_wqe->bd_list_addr_hi = (u32) ((u64) bnx2i_conn->hba->mp_bd_dma >> 32); nopout_wqe->num_bds = 1; } nopout_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1); return 0; } /** * bnx2i_send_iscsi_logout - post iSCSI logout request WQE to hardware * @conn: iscsi connection * @cmd: driver command structure which is requesting * a WQE to sent to chip for further processing * * prepare and post logout request WQE to CNIC firmware */ int bnx2i_send_iscsi_logout(struct bnx2i_conn *bnx2i_conn, struct iscsi_task *task) { struct bnx2i_cmd *bnx2i_cmd; struct bnx2i_logout_request *logout_wqe; struct iscsi_logout *logout_hdr; bnx2i_cmd = (struct bnx2i_cmd *)task->dd_data; logout_hdr = (struct iscsi_logout *)task->hdr; logout_wqe = (struct bnx2i_logout_request *) bnx2i_conn->ep->qp.sq_prod_qe; memset(logout_wqe, 0x00, sizeof(struct bnx2i_logout_request)); logout_wqe->op_code = logout_hdr->opcode; logout_wqe->cmd_sn = be32_to_cpu(logout_hdr->cmdsn); logout_wqe->op_attr = logout_hdr->flags | ISCSI_LOGOUT_REQUEST_ALWAYS_ONE; logout_wqe->itt = ((u16)task->itt | (ISCSI_TASK_TYPE_MPATH << ISCSI_LOGOUT_REQUEST_TYPE_SHIFT)); logout_wqe->data_length = 0; logout_wqe->cid = 0; logout_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma; logout_wqe->bd_list_addr_hi = (u32) ((u64) bnx2i_conn->hba->mp_bd_dma >> 32); logout_wqe->num_bds = 1; logout_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ bnx2i_conn->ep->state = EP_STATE_LOGOUT_SENT; bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1); return 0; } /** * bnx2i_update_iscsi_conn - post iSCSI logout request WQE to hardware * @conn: iscsi connection which requires iscsi parameter update * * sends down iSCSI Conn Update request to move iSCSI conn to FFP */ void bnx2i_update_iscsi_conn(struct iscsi_conn *conn) { struct bnx2i_conn *bnx2i_conn = conn->dd_data; struct bnx2i_hba *hba = bnx2i_conn->hba; struct kwqe *kwqe_arr[2]; struct iscsi_kwqe_conn_update *update_wqe; struct iscsi_kwqe_conn_update conn_update_kwqe; update_wqe = &conn_update_kwqe; update_wqe->hdr.op_code = ISCSI_KWQE_OPCODE_UPDATE_CONN; update_wqe->hdr.flags = (ISCSI_KWQE_LAYER_CODE << ISCSI_KWQE_HEADER_LAYER_CODE_SHIFT); /* 5771x requires conn context id to be passed as is */ if (test_bit(BNX2I_NX2_DEV_57710, &bnx2i_conn->ep->hba->cnic_dev_type)) update_wqe->context_id = bnx2i_conn->ep->ep_cid; else update_wqe->context_id = (bnx2i_conn->ep->ep_cid >> 7); update_wqe->conn_flags = 0; if (conn->hdrdgst_en) update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_HEADER_DIGEST; if (conn->datadgst_en) update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_DATA_DIGEST; if (conn->session->initial_r2t_en) update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_INITIAL_R2T; if (conn->session->imm_data_en) update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_IMMEDIATE_DATA; update_wqe->max_send_pdu_length = conn->max_xmit_dlength; update_wqe->max_recv_pdu_length = conn->max_recv_dlength; update_wqe->first_burst_length = conn->session->first_burst; update_wqe->max_burst_length = conn->session->max_burst; update_wqe->exp_stat_sn = conn->exp_statsn; update_wqe->max_outstanding_r2ts = conn->session->max_r2t; update_wqe->session_error_recovery_level = conn->session->erl; iscsi_conn_printk(KERN_ALERT, conn, "bnx2i: conn update - MBL 0x%x FBL 0x%x" "MRDSL_I 0x%x MRDSL_T 0x%x \n", update_wqe->max_burst_length, update_wqe->first_burst_length, update_wqe->max_recv_pdu_length, update_wqe->max_send_pdu_length); kwqe_arr[0] = (struct kwqe *) update_wqe; if (hba->cnic && hba->cnic->submit_kwqes) hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 1); } /** * bnx2i_ep_ofld_timer - post iSCSI logout request WQE to hardware * @data: endpoint (transport handle) structure pointer * * routine to handle connection offload/destroy request timeout */ void bnx2i_ep_ofld_timer(unsigned long data) { struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) data; if (ep->state == EP_STATE_OFLD_START) { printk(KERN_ALERT "ofld_timer: CONN_OFLD timeout\n"); ep->state = EP_STATE_OFLD_FAILED; } else if (ep->state == EP_STATE_DISCONN_START) { printk(KERN_ALERT "ofld_timer: CONN_DISCON timeout\n"); ep->state = EP_STATE_DISCONN_TIMEDOUT; } else if (ep->state == EP_STATE_CLEANUP_START) { printk(KERN_ALERT "ofld_timer: CONN_CLEANUP timeout\n"); ep->state = EP_STATE_CLEANUP_FAILED; } wake_up_interruptible(&ep->ofld_wait); } static int bnx2i_power_of2(u32 val) { u32 power = 0; if (val & (val - 1)) return power; val--; while (val) { val = val >> 1; power++; } return power; } /** * bnx2i_send_cmd_cleanup_req - send iscsi cmd context clean-up request * @hba: adapter structure pointer * @cmd: driver command structure which is requesting * a WQE to sent to chip for further processing * * prepares and posts CONN_OFLD_REQ1/2 KWQE */ void bnx2i_send_cmd_cleanup_req(struct bnx2i_hba *hba, struct bnx2i_cmd *cmd) { struct bnx2i_cleanup_request *cmd_cleanup; cmd_cleanup = (struct bnx2i_cleanup_request *)cmd->conn->ep->qp.sq_prod_qe; memset(cmd_cleanup, 0x00, sizeof(struct bnx2i_cleanup_request)); cmd_cleanup->op_code = ISCSI_OPCODE_CLEANUP_REQUEST; cmd_cleanup->itt = cmd->req.itt; cmd_cleanup->cq_index = 0; /* CQ# used for completion, 5771x only */ bnx2i_ring_dbell_update_sq_params(cmd->conn, 1); } /** * bnx2i_send_conn_destroy - initiates iscsi connection teardown process * @hba: adapter structure pointer * @ep: endpoint (transport indentifier) structure * * this routine prepares and posts CONN_OFLD_REQ1/2 KWQE to initiate * iscsi connection context clean-up process */ int bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep) { struct kwqe *kwqe_arr[2]; struct iscsi_kwqe_conn_destroy conn_cleanup; int rc = -EINVAL; memset(&conn_cleanup, 0x00, sizeof(struct iscsi_kwqe_conn_destroy)); conn_cleanup.hdr.op_code = ISCSI_KWQE_OPCODE_DESTROY_CONN; conn_cleanup.hdr.flags = (ISCSI_KWQE_LAYER_CODE << ISCSI_KWQE_HEADER_LAYER_CODE_SHIFT); /* 5771x requires conn context id to be passed as is */ if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) conn_cleanup.context_id = ep->ep_cid; else conn_cleanup.context_id = (ep->ep_cid >> 7); conn_cleanup.reserved0 = (u16)ep->ep_iscsi_cid; kwqe_arr[0] = (struct kwqe *) &conn_cleanup; if (hba->cnic && hba->cnic->submit_kwqes) rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 1); return rc; } /** * bnx2i_570x_send_conn_ofld_req - initiates iscsi conn context setup process * @hba: adapter structure pointer * @ep: endpoint (transport indentifier) structure * * 5706/5708/5709 specific - prepares and posts CONN_OFLD_REQ1/2 KWQE */ static int bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep) { struct kwqe *kwqe_arr[2]; struct iscsi_kwqe_conn_offload1 ofld_req1; struct iscsi_kwqe_conn_offload2 ofld_req2; dma_addr_t dma_addr; int num_kwqes = 2; u32 *ptbl; int rc = -EINVAL; ofld_req1.hdr.op_code = ISCSI_KWQE_OPCODE_OFFLOAD_CONN1; ofld_req1.hdr.flags = (ISCSI_KWQE_LAYER_CODE << ISCSI_KWQE_HEADER_LAYER_CODE_SHIFT); ofld_req1.iscsi_conn_id = (u16) ep->ep_iscsi_cid; dma_addr = ep->qp.sq_pgtbl_phys; ofld_req1.sq_page_table_addr_lo = (u32) dma_addr; ofld_req1.sq_page_table_addr_hi = (u32) ((u64) dma_addr >> 32); dma_addr = ep->qp.cq_pgtbl_phys; ofld_req1.cq_page_table_addr_lo = (u32) dma_addr; ofld_req1.cq_page_table_addr_hi = (u32) ((u64) dma_addr >> 32); ofld_req2.hdr.op_code = ISCSI_KWQE_OPCODE_OFFLOAD_CONN2; ofld_req2.hdr.flags = (ISCSI_KWQE_LAYER_CODE << ISCSI_KWQE_HEADER_LAYER_CODE_SHIFT); dma_addr = ep->qp.rq_pgtbl_phys; ofld_req2.rq_page_table_addr_lo = (u32) dma_addr; ofld_req2.rq_page_table_addr_hi = (u32) ((u64) dma_addr >> 32); ptbl = (u32 *) ep->qp.sq_pgtbl_virt; ofld_req2.sq_first_pte.hi = *ptbl++; ofld_req2.sq_first_pte.lo = *ptbl; ptbl = (u32 *) ep->qp.cq_pgtbl_virt; ofld_req2.cq_first_pte.hi = *ptbl++; ofld_req2.cq_first_pte.lo = *ptbl; kwqe_arr[0] = (struct kwqe *) &ofld_req1; kwqe_arr[1] = (struct kwqe *) &ofld_req2; ofld_req2.num_additional_wqes = 0; if (hba->cnic && hba->cnic->submit_kwqes) rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); return rc; } /** * bnx2i_5771x_send_conn_ofld_req - initiates iscsi connection context creation * @hba: adapter structure pointer * @ep: endpoint (transport indentifier) structure * * 57710 specific - prepares and posts CONN_OFLD_REQ1/2 KWQE */ static int bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep) { struct kwqe *kwqe_arr[5]; struct iscsi_kwqe_conn_offload1 ofld_req1; struct iscsi_kwqe_conn_offload2 ofld_req2; struct iscsi_kwqe_conn_offload3 ofld_req3[1]; dma_addr_t dma_addr; int num_kwqes = 2; u32 *ptbl; int rc = -EINVAL; ofld_req1.hdr.op_code = ISCSI_KWQE_OPCODE_OFFLOAD_CONN1; ofld_req1.hdr.flags = (ISCSI_KWQE_LAYER_CODE << ISCSI_KWQE_HEADER_LAYER_CODE_SHIFT); ofld_req1.iscsi_conn_id = (u16) ep->ep_iscsi_cid; dma_addr = ep->qp.sq_pgtbl_phys + ISCSI_SQ_DB_SIZE; ofld_req1.sq_page_table_addr_lo = (u32) dma_addr; ofld_req1.sq_page_table_addr_hi = (u32) ((u64) dma_addr >> 32); dma_addr = ep->qp.cq_pgtbl_phys + ISCSI_CQ_DB_SIZE; ofld_req1.cq_page_table_addr_lo = (u32) dma_addr; ofld_req1.cq_page_table_addr_hi = (u32) ((u64) dma_addr >> 32); ofld_req2.hdr.op_code = ISCSI_KWQE_OPCODE_OFFLOAD_CONN2; ofld_req2.hdr.flags = (ISCSI_KWQE_LAYER_CODE << ISCSI_KWQE_HEADER_LAYER_CODE_SHIFT); dma_addr = ep->qp.rq_pgtbl_phys + ISCSI_RQ_DB_SIZE; ofld_req2.rq_page_table_addr_lo = (u32) dma_addr; ofld_req2.rq_page_table_addr_hi = (u32) ((u64) dma_addr >> 32); ptbl = (u32 *)((u8 *)ep->qp.sq_pgtbl_virt + ISCSI_SQ_DB_SIZE); ofld_req2.sq_first_pte.hi = *ptbl++; ofld_req2.sq_first_pte.lo = *ptbl; ptbl = (u32 *)((u8 *)ep->qp.cq_pgtbl_virt + ISCSI_CQ_DB_SIZE); ofld_req2.cq_first_pte.hi = *ptbl++; ofld_req2.cq_first_pte.lo = *ptbl; kwqe_arr[0] = (struct kwqe *) &ofld_req1; kwqe_arr[1] = (struct kwqe *) &ofld_req2; ofld_req2.num_additional_wqes = 1; memset(ofld_req3, 0x00, sizeof(ofld_req3[0])); ptbl = (u32 *)((u8 *)ep->qp.rq_pgtbl_virt + ISCSI_RQ_DB_SIZE); ofld_req3[0].qp_first_pte[0].hi = *ptbl++; ofld_req3[0].qp_first_pte[0].lo = *ptbl; kwqe_arr[2] = (struct kwqe *) ofld_req3; /* need if we decide to go with multiple KCQE's per conn */ num_kwqes += 1; if (hba->cnic && hba->cnic->submit_kwqes) rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); return rc; } /** * bnx2i_send_conn_ofld_req - initiates iscsi connection context setup process * * @hba: adapter structure pointer * @ep: endpoint (transport indentifier) structure * * this routine prepares and posts CONN_OFLD_REQ1/2 KWQE */ int bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep) { int rc; if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type)) rc = bnx2i_5771x_send_conn_ofld_req(hba, ep); else rc = bnx2i_570x_send_conn_ofld_req(hba, ep); return rc; } /** * setup_qp_page_tables - iscsi QP page table setup function * @ep: endpoint (transport indentifier) structure * * Sets up page tables for SQ/RQ/CQ, 1G/sec (5706/5708/5709) devices requires * 64-bit address in big endian format. Whereas 10G/sec (57710) requires * PT in little endian format */ static void setup_qp_page_tables(struct bnx2i_endpoint *ep) { int num_pages; u32 *ptbl; dma_addr_t page; int cnic_dev_10g; if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) cnic_dev_10g = 1; else cnic_dev_10g = 0; /* SQ page table */ memset(ep->qp.sq_pgtbl_virt, 0, ep->qp.sq_pgtbl_size); num_pages = ep->qp.sq_mem_size / PAGE_SIZE; page = ep->qp.sq_phys; if (cnic_dev_10g) ptbl = (u32 *)((u8 *)ep->qp.sq_pgtbl_virt + ISCSI_SQ_DB_SIZE); else ptbl = (u32 *) ep->qp.sq_pgtbl_virt; while (num_pages--) { if (cnic_dev_10g) { /* PTE is written in little endian format for 57710 */ *ptbl = (u32) page; ptbl++; *ptbl = (u32) ((u64) page >> 32); ptbl++; page += PAGE_SIZE; } else { /* PTE is written in big endian format for * 5706/5708/5709 devices */ *ptbl = (u32) ((u64) page >> 32); ptbl++; *ptbl = (u32) page; ptbl++; page += PAGE_SIZE; } } /* RQ page table */ memset(ep->qp.rq_pgtbl_virt, 0, ep->qp.rq_pgtbl_size); num_pages = ep->qp.rq_mem_size / PAGE_SIZE; page = ep->qp.rq_phys; if (cnic_dev_10g) ptbl = (u32 *)((u8 *)ep->qp.rq_pgtbl_virt + ISCSI_RQ_DB_SIZE); else ptbl = (u32 *) ep->qp.rq_pgtbl_virt; while (num_pages--) { if (cnic_dev_10g) { /* PTE is written in little endian format for 57710 */ *ptbl = (u32) page; ptbl++; *ptbl = (u32) ((u64) page >> 32); ptbl++; page += PAGE_SIZE; } else { /* PTE is written in big endian format for * 5706/5708/5709 devices */ *ptbl = (u32) ((u64) page >> 32); ptbl++; *ptbl = (u32) page; ptbl++; page += PAGE_SIZE; } } /* CQ page table */ memset(ep->qp.cq_pgtbl_virt, 0, ep->qp.cq_pgtbl_size); num_pages = ep->qp.cq_mem_size / PAGE_SIZE; page = ep->qp.cq_phys; if (cnic_dev_10g) ptbl = (u32 *)((u8 *)ep->qp.cq_pgtbl_virt + ISCSI_CQ_DB_SIZE); else ptbl = (u32 *) ep->qp.cq_pgtbl_virt; while (num_pages--) { if (cnic_dev_10g) { /* PTE is written in little endian format for 57710 */ *ptbl = (u32) page; ptbl++; *ptbl = (u32) ((u64) page >> 32); ptbl++; page += PAGE_SIZE; } else { /* PTE is written in big endian format for * 5706/5708/5709 devices */ *ptbl = (u32) ((u64) page >> 32); ptbl++; *ptbl = (u32) page; ptbl++; page += PAGE_SIZE; } } } /** * bnx2i_alloc_qp_resc - allocates required resources for QP. * @hba: adapter structure pointer * @ep: endpoint (transport indentifier) structure * * Allocate QP (transport layer for iSCSI connection) resources, DMA'able * memory for SQ/RQ/CQ and page tables. EP structure elements such * as producer/consumer indexes/pointers, queue sizes and page table * contents are setup */ int bnx2i_alloc_qp_resc(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep) { struct bnx2i_5771x_cq_db *cq_db; ep->hba = hba; ep->conn = NULL; ep->ep_cid = ep->ep_iscsi_cid = ep->ep_pg_cid = 0; /* Allocate page table memory for SQ which is page aligned */ ep->qp.sq_mem_size = hba->max_sqes * BNX2I_SQ_WQE_SIZE; ep->qp.sq_mem_size = (ep->qp.sq_mem_size + (PAGE_SIZE - 1)) & PAGE_MASK; ep->qp.sq_pgtbl_size = (ep->qp.sq_mem_size / PAGE_SIZE) * sizeof(void *); ep->qp.sq_pgtbl_size = (ep->qp.sq_pgtbl_size + (PAGE_SIZE - 1)) & PAGE_MASK; ep->qp.sq_pgtbl_virt = dma_alloc_coherent(&hba->pcidev->dev, ep->qp.sq_pgtbl_size, &ep->qp.sq_pgtbl_phys, GFP_KERNEL); if (!ep->qp.sq_pgtbl_virt) { printk(KERN_ALERT "bnx2i: unable to alloc SQ PT mem (%d)\n", ep->qp.sq_pgtbl_size); goto mem_alloc_err; } /* Allocate memory area for actual SQ element */ ep->qp.sq_virt = dma_alloc_coherent(&hba->pcidev->dev, ep->qp.sq_mem_size, &ep->qp.sq_phys, GFP_KERNEL); if (!ep->qp.sq_virt) { printk(KERN_ALERT "bnx2i: unable to alloc SQ BD memory %d\n", ep->qp.sq_mem_size); goto mem_alloc_err; } memset(ep->qp.sq_virt, 0x00, ep->qp.sq_mem_size); ep->qp.sq_first_qe = ep->qp.sq_virt; ep->qp.sq_prod_qe = ep->qp.sq_first_qe; ep->qp.sq_cons_qe = ep->qp.sq_first_qe; ep->qp.sq_last_qe = &ep->qp.sq_first_qe[hba->max_sqes - 1]; ep->qp.sq_prod_idx = 0; ep->qp.sq_cons_idx = 0; ep->qp.sqe_left = hba->max_sqes; /* Allocate page table memory for CQ which is page aligned */ ep->qp.cq_mem_size = hba->max_cqes * BNX2I_CQE_SIZE; ep->qp.cq_mem_size = (ep->qp.cq_mem_size + (PAGE_SIZE - 1)) & PAGE_MASK; ep->qp.cq_pgtbl_size = (ep->qp.cq_mem_size / PAGE_SIZE) * sizeof(void *); ep->qp.cq_pgtbl_size = (ep->qp.cq_pgtbl_size + (PAGE_SIZE - 1)) & PAGE_MASK; ep->qp.cq_pgtbl_virt = dma_alloc_coherent(&hba->pcidev->dev, ep->qp.cq_pgtbl_size, &ep->qp.cq_pgtbl_phys, GFP_KERNEL); if (!ep->qp.cq_pgtbl_virt) { printk(KERN_ALERT "bnx2i: unable to alloc CQ PT memory %d\n", ep->qp.cq_pgtbl_size); goto mem_alloc_err; } /* Allocate memory area for actual CQ element */ ep->qp.cq_virt = dma_alloc_coherent(&hba->pcidev->dev, ep->qp.cq_mem_size, &ep->qp.cq_phys, GFP_KERNEL); if (!ep->qp.cq_virt) { printk(KERN_ALERT "bnx2i: unable to alloc CQ BD memory %d\n", ep->qp.cq_mem_size); goto mem_alloc_err; } memset(ep->qp.cq_virt, 0x00, ep->qp.cq_mem_size); ep->qp.cq_first_qe = ep->qp.cq_virt; ep->qp.cq_prod_qe = ep->qp.cq_first_qe; ep->qp.cq_cons_qe = ep->qp.cq_first_qe; ep->qp.cq_last_qe = &ep->qp.cq_first_qe[hba->max_cqes - 1]; ep->qp.cq_prod_idx = 0; ep->qp.cq_cons_idx = 0; ep->qp.cqe_left = hba->max_cqes; ep->qp.cqe_exp_seq_sn = ISCSI_INITIAL_SN; ep->qp.cqe_size = hba->max_cqes; /* Invalidate all EQ CQE index, req only for 57710 */ cq_db = (struct bnx2i_5771x_cq_db *) ep->qp.cq_pgtbl_virt; memset(cq_db->sqn, 0xFF, sizeof(cq_db->sqn[0]) * BNX2X_MAX_CQS); /* Allocate page table memory for RQ which is page aligned */ ep->qp.rq_mem_size = hba->max_rqes * BNX2I_RQ_WQE_SIZE; ep->qp.rq_mem_size = (ep->qp.rq_mem_size + (PAGE_SIZE - 1)) & PAGE_MASK; ep->qp.rq_pgtbl_size = (ep->qp.rq_mem_size / PAGE_SIZE) * sizeof(void *); ep->qp.rq_pgtbl_size = (ep->qp.rq_pgtbl_size + (PAGE_SIZE - 1)) & PAGE_MASK; ep->qp.rq_pgtbl_virt = dma_alloc_coherent(&hba->pcidev->dev, ep->qp.rq_pgtbl_size, &ep->qp.rq_pgtbl_phys, GFP_KERNEL); if (!ep->qp.rq_pgtbl_virt) { printk(KERN_ALERT "bnx2i: unable to alloc RQ PT mem %d\n", ep->qp.rq_pgtbl_size); goto mem_alloc_err; } /* Allocate memory area for actual RQ element */ ep->qp.rq_virt = dma_alloc_coherent(&hba->pcidev->dev, ep->qp.rq_mem_size, &ep->qp.rq_phys, GFP_KERNEL); if (!ep->qp.rq_virt) { printk(KERN_ALERT "bnx2i: unable to alloc RQ BD memory %d\n", ep->qp.rq_mem_size); goto mem_alloc_err; } ep->qp.rq_first_qe = ep->qp.rq_virt; ep->qp.rq_prod_qe = ep->qp.rq_first_qe; ep->qp.rq_cons_qe = ep->qp.rq_first_qe; ep->qp.rq_last_qe = &ep->qp.rq_first_qe[hba->max_rqes - 1]; ep->qp.rq_prod_idx = 0x8000; ep->qp.rq_cons_idx = 0; ep->qp.rqe_left = hba->max_rqes; setup_qp_page_tables(ep); return 0; mem_alloc_err: bnx2i_free_qp_resc(hba, ep); return -ENOMEM; } /** * bnx2i_free_qp_resc - free memory resources held by QP * @hba: adapter structure pointer * @ep: endpoint (transport indentifier) structure * * Free QP resources - SQ/RQ/CQ memory and page tables. */ void bnx2i_free_qp_resc(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep) { if (ep->qp.ctx_base) { iounmap(ep->qp.ctx_base); ep->qp.ctx_base = NULL; } /* Free SQ mem */ if (ep->qp.sq_pgtbl_virt) { dma_free_coherent(&hba->pcidev->dev, ep->qp.sq_pgtbl_size, ep->qp.sq_pgtbl_virt, ep->qp.sq_pgtbl_phys); ep->qp.sq_pgtbl_virt = NULL; ep->qp.sq_pgtbl_phys = 0; } if (ep->qp.sq_virt) { dma_free_coherent(&hba->pcidev->dev, ep->qp.sq_mem_size, ep->qp.sq_virt, ep->qp.sq_phys); ep->qp.sq_virt = NULL; ep->qp.sq_phys = 0; } /* Free RQ mem */ if (ep->qp.rq_pgtbl_virt) { dma_free_coherent(&hba->pcidev->dev, ep->qp.rq_pgtbl_size, ep->qp.rq_pgtbl_virt, ep->qp.rq_pgtbl_phys); ep->qp.rq_pgtbl_virt = NULL; ep->qp.rq_pgtbl_phys = 0; } if (ep->qp.rq_virt) { dma_free_coherent(&hba->pcidev->dev, ep->qp.rq_mem_size, ep->qp.rq_virt, ep->qp.rq_phys); ep->qp.rq_virt = NULL; ep->qp.rq_phys = 0; } /* Free CQ mem */ if (ep->qp.cq_pgtbl_virt) { dma_free_coherent(&hba->pcidev->dev, ep->qp.cq_pgtbl_size, ep->qp.cq_pgtbl_virt, ep->qp.cq_pgtbl_phys); ep->qp.cq_pgtbl_virt = NULL; ep->qp.cq_pgtbl_phys = 0; } if (ep->qp.cq_virt) { dma_free_coherent(&hba->pcidev->dev, ep->qp.cq_mem_size, ep->qp.cq_virt, ep->qp.cq_phys); ep->qp.cq_virt = NULL; ep->qp.cq_phys = 0; } } /** * bnx2i_send_fw_iscsi_init_msg - initiates initial handshake with iscsi f/w * @hba: adapter structure pointer * * Send down iscsi_init KWQEs which initiates the initial handshake with the f/w * This results in iSCSi support validation and on-chip context manager * initialization. Firmware completes this handshake with a CQE carrying * the result of iscsi support validation. Parameter carried by * iscsi init request determines the number of offloaded connection and * tolerance level for iscsi protocol violation this hba/chip can support */ int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba) { struct kwqe *kwqe_arr[3]; struct iscsi_kwqe_init1 iscsi_init; struct iscsi_kwqe_init2 iscsi_init2; int rc = 0; u64 mask64; bnx2i_adjust_qp_size(hba); iscsi_init.flags = ISCSI_PAGE_SIZE_4K << ISCSI_KWQE_INIT1_PAGE_SIZE_SHIFT; if (en_tcp_dack) iscsi_init.flags |= ISCSI_KWQE_INIT1_DELAYED_ACK_ENABLE; iscsi_init.reserved0 = 0; iscsi_init.num_cqs = 1; iscsi_init.hdr.op_code = ISCSI_KWQE_OPCODE_INIT1; iscsi_init.hdr.flags = (ISCSI_KWQE_LAYER_CODE << ISCSI_KWQE_HEADER_LAYER_CODE_SHIFT); iscsi_init.dummy_buffer_addr_lo = (u32) hba->dummy_buf_dma; iscsi_init.dummy_buffer_addr_hi = (u32) ((u64) hba->dummy_buf_dma >> 32); hba->num_ccell = hba->max_sqes >> 1; hba->ctx_ccell_tasks = ((hba->num_ccell & 0xFFFF) | (hba->max_sqes << 16)); iscsi_init.num_ccells_per_conn = hba->num_ccell; iscsi_init.num_tasks_per_conn = hba->max_sqes; iscsi_init.sq_wqes_per_page = PAGE_SIZE / BNX2I_SQ_WQE_SIZE; iscsi_init.sq_num_wqes = hba->max_sqes; iscsi_init.cq_log_wqes_per_page = (u8) bnx2i_power_of2(PAGE_SIZE / BNX2I_CQE_SIZE); iscsi_init.cq_num_wqes = hba->max_cqes; iscsi_init.cq_num_pages = (hba->max_cqes * BNX2I_CQE_SIZE + (PAGE_SIZE - 1)) / PAGE_SIZE; iscsi_init.sq_num_pages = (hba->max_sqes * BNX2I_SQ_WQE_SIZE + (PAGE_SIZE - 1)) / PAGE_SIZE; iscsi_init.rq_buffer_size = BNX2I_RQ_WQE_SIZE; iscsi_init.rq_num_wqes = hba->max_rqes; iscsi_init2.hdr.op_code = ISCSI_KWQE_OPCODE_INIT2; iscsi_init2.hdr.flags = (ISCSI_KWQE_LAYER_CODE << ISCSI_KWQE_HEADER_LAYER_CODE_SHIFT); iscsi_init2.max_cq_sqn = hba->max_cqes * 2 + 1; mask64 = 0x0ULL; mask64 |= ( /* CISCO MDS */ (1UL << ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_TTT_NOT_RSRV) | /* HP MSA1510i */ (1UL << ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_EXP_DATASN) | /* EMC */ (1ULL << ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_LUN)); if (error_mask1) { iscsi_init2.error_bit_map[0] = error_mask1; mask64 &= (u32)(~mask64); mask64 |= error_mask1; } else iscsi_init2.error_bit_map[0] = (u32) mask64; if (error_mask2) { iscsi_init2.error_bit_map[1] = error_mask2; mask64 &= 0xffffffff; mask64 |= ((u64)error_mask2 << 32); } else iscsi_init2.error_bit_map[1] = (u32) (mask64 >> 32); iscsi_error_mask = mask64; kwqe_arr[0] = (struct kwqe *) &iscsi_init; kwqe_arr[1] = (struct kwqe *) &iscsi_init2; if (hba->cnic && hba->cnic->submit_kwqes) rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 2); return rc; } /** * bnx2i_process_scsi_cmd_resp - this function handles scsi cmd completion. * @session: iscsi session * @bnx2i_conn: bnx2i connection * @cqe: pointer to newly DMA'ed CQE entry for processing * * process SCSI CMD Response CQE & complete the request to SCSI-ML */ int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct cqe *cqe) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct bnx2i_cmd_response *resp_cqe; struct bnx2i_cmd *bnx2i_cmd; struct iscsi_task *task; struct iscsi_scsi_rsp *hdr; u32 datalen = 0; resp_cqe = (struct bnx2i_cmd_response *)cqe; spin_lock_bh(&session->lock); task = iscsi_itt_to_task(conn, resp_cqe->itt & ISCSI_CMD_RESPONSE_INDEX); if (!task) goto fail; bnx2i_cmd = task->dd_data; if (bnx2i_cmd->req.op_attr & ISCSI_CMD_REQUEST_READ) { conn->datain_pdus_cnt += resp_cqe->task_stat.read_stat.num_data_outs; conn->rxdata_octets += bnx2i_cmd->req.total_data_transfer_length; } else { conn->dataout_pdus_cnt += resp_cqe->task_stat.read_stat.num_data_outs; conn->r2t_pdus_cnt += resp_cqe->task_stat.read_stat.num_r2ts; conn->txdata_octets += bnx2i_cmd->req.total_data_transfer_length; } bnx2i_iscsi_unmap_sg_list(bnx2i_cmd); hdr = (struct iscsi_scsi_rsp *)task->hdr; resp_cqe = (struct bnx2i_cmd_response *)cqe; hdr->opcode = resp_cqe->op_code; hdr->max_cmdsn = cpu_to_be32(resp_cqe->max_cmd_sn); hdr->exp_cmdsn = cpu_to_be32(resp_cqe->exp_cmd_sn); hdr->response = resp_cqe->response; hdr->cmd_status = resp_cqe->status; hdr->flags = resp_cqe->response_flags; hdr->residual_count = cpu_to_be32(resp_cqe->residual_count); if (resp_cqe->op_code == ISCSI_OP_SCSI_DATA_IN) goto done; if (resp_cqe->status == SAM_STAT_CHECK_CONDITION) { datalen = resp_cqe->data_length; if (datalen < 2) goto done; if (datalen > BNX2I_RQ_WQE_SIZE) { iscsi_conn_printk(KERN_ERR, conn, "sense data len %d > RQ sz\n", datalen); datalen = BNX2I_RQ_WQE_SIZE; } else if (datalen > ISCSI_DEF_MAX_RECV_SEG_LEN) { iscsi_conn_printk(KERN_ERR, conn, "sense data len %d > conn data\n", datalen); datalen = ISCSI_DEF_MAX_RECV_SEG_LEN; } bnx2i_get_rq_buf(bnx2i_cmd->conn, conn->data, datalen); bnx2i_put_rq_buf(bnx2i_cmd->conn, 1); } done: __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, conn->data, datalen); fail: spin_unlock_bh(&session->lock); return 0; } /** * bnx2i_process_login_resp - this function handles iscsi login response * @session: iscsi session pointer * @bnx2i_conn: iscsi connection pointer * @cqe: pointer to newly DMA'ed CQE entry for processing * * process Login Response CQE & complete it to open-iscsi user daemon */ static int bnx2i_process_login_resp(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct cqe *cqe) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct iscsi_task *task; struct bnx2i_login_response *login; struct iscsi_login_rsp *resp_hdr; int pld_len; int pad_len; login = (struct bnx2i_login_response *) cqe; spin_lock(&session->lock); task = iscsi_itt_to_task(conn, login->itt & ISCSI_LOGIN_RESPONSE_INDEX); if (!task) goto done; resp_hdr = (struct iscsi_login_rsp *) &bnx2i_conn->gen_pdu.resp_hdr; memset(resp_hdr, 0, sizeof(struct iscsi_hdr)); resp_hdr->opcode = login->op_code; resp_hdr->flags = login->response_flags; resp_hdr->max_version = login->version_max; resp_hdr->active_version = login->version_active; resp_hdr->hlength = 0; hton24(resp_hdr->dlength, login->data_length); memcpy(resp_hdr->isid, &login->isid_lo, 6); resp_hdr->tsih = cpu_to_be16(login->tsih); resp_hdr->itt = task->hdr->itt; resp_hdr->statsn = cpu_to_be32(login->stat_sn); resp_hdr->exp_cmdsn = cpu_to_be32(login->exp_cmd_sn); resp_hdr->max_cmdsn = cpu_to_be32(login->max_cmd_sn); resp_hdr->status_class = login->status_class; resp_hdr->status_detail = login->status_detail; pld_len = login->data_length; bnx2i_conn->gen_pdu.resp_wr_ptr = bnx2i_conn->gen_pdu.resp_buf + pld_len; pad_len = 0; if (pld_len & 0x3) pad_len = 4 - (pld_len % 4); if (pad_len) { int i = 0; for (i = 0; i < pad_len; i++) { bnx2i_conn->gen_pdu.resp_wr_ptr[0] = 0; bnx2i_conn->gen_pdu.resp_wr_ptr++; } } __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, bnx2i_conn->gen_pdu.resp_buf, bnx2i_conn->gen_pdu.resp_wr_ptr - bnx2i_conn->gen_pdu.resp_buf); done: spin_unlock(&session->lock); return 0; } /** * bnx2i_process_text_resp - this function handles iscsi text response * @session: iscsi session pointer * @bnx2i_conn: iscsi connection pointer * @cqe: pointer to newly DMA'ed CQE entry for processing * * process iSCSI Text Response CQE& complete it to open-iscsi user daemon */ static int bnx2i_process_text_resp(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct cqe *cqe) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct iscsi_task *task; struct bnx2i_text_response *text; struct iscsi_text_rsp *resp_hdr; int pld_len; int pad_len; text = (struct bnx2i_text_response *) cqe; spin_lock(&session->lock); task = iscsi_itt_to_task(conn, text->itt & ISCSI_LOGIN_RESPONSE_INDEX); if (!task) goto done; resp_hdr = (struct iscsi_text_rsp *)&bnx2i_conn->gen_pdu.resp_hdr; memset(resp_hdr, 0, sizeof(struct iscsi_hdr)); resp_hdr->opcode = text->op_code; resp_hdr->flags = text->response_flags; resp_hdr->hlength = 0; hton24(resp_hdr->dlength, text->data_length); resp_hdr->itt = task->hdr->itt; resp_hdr->ttt = cpu_to_be32(text->ttt); resp_hdr->statsn = task->hdr->exp_statsn; resp_hdr->exp_cmdsn = cpu_to_be32(text->exp_cmd_sn); resp_hdr->max_cmdsn = cpu_to_be32(text->max_cmd_sn); pld_len = text->data_length; bnx2i_conn->gen_pdu.resp_wr_ptr = bnx2i_conn->gen_pdu.resp_buf + pld_len; pad_len = 0; if (pld_len & 0x3) pad_len = 4 - (pld_len % 4); if (pad_len) { int i = 0; for (i = 0; i < pad_len; i++) { bnx2i_conn->gen_pdu.resp_wr_ptr[0] = 0; bnx2i_conn->gen_pdu.resp_wr_ptr++; } } __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, bnx2i_conn->gen_pdu.resp_buf, bnx2i_conn->gen_pdu.resp_wr_ptr - bnx2i_conn->gen_pdu.resp_buf); done: spin_unlock(&session->lock); return 0; } /** * bnx2i_process_tmf_resp - this function handles iscsi TMF response * @session: iscsi session pointer * @bnx2i_conn: iscsi connection pointer * @cqe: pointer to newly DMA'ed CQE entry for processing * * process iSCSI TMF Response CQE and wake up the driver eh thread. */ static int bnx2i_process_tmf_resp(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct cqe *cqe) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct iscsi_task *task; struct bnx2i_tmf_response *tmf_cqe; struct iscsi_tm_rsp *resp_hdr; tmf_cqe = (struct bnx2i_tmf_response *)cqe; spin_lock(&session->lock); task = iscsi_itt_to_task(conn, tmf_cqe->itt & ISCSI_TMF_RESPONSE_INDEX); if (!task) goto done; resp_hdr = (struct iscsi_tm_rsp *) &bnx2i_conn->gen_pdu.resp_hdr; memset(resp_hdr, 0, sizeof(struct iscsi_hdr)); resp_hdr->opcode = tmf_cqe->op_code; resp_hdr->max_cmdsn = cpu_to_be32(tmf_cqe->max_cmd_sn); resp_hdr->exp_cmdsn = cpu_to_be32(tmf_cqe->exp_cmd_sn); resp_hdr->itt = task->hdr->itt; resp_hdr->response = tmf_cqe->response; __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); done: spin_unlock(&session->lock); return 0; } /** * bnx2i_process_logout_resp - this function handles iscsi logout response * @session: iscsi session pointer * @bnx2i_conn: iscsi connection pointer * @cqe: pointer to newly DMA'ed CQE entry for processing * * process iSCSI Logout Response CQE & make function call to * notify the user daemon. */ static int bnx2i_process_logout_resp(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct cqe *cqe) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct iscsi_task *task; struct bnx2i_logout_response *logout; struct iscsi_logout_rsp *resp_hdr; logout = (struct bnx2i_logout_response *) cqe; spin_lock(&session->lock); task = iscsi_itt_to_task(conn, logout->itt & ISCSI_LOGOUT_RESPONSE_INDEX); if (!task) goto done; resp_hdr = (struct iscsi_logout_rsp *) &bnx2i_conn->gen_pdu.resp_hdr; memset(resp_hdr, 0, sizeof(struct iscsi_hdr)); resp_hdr->opcode = logout->op_code; resp_hdr->flags = logout->response; resp_hdr->hlength = 0; resp_hdr->itt = task->hdr->itt; resp_hdr->statsn = task->hdr->exp_statsn; resp_hdr->exp_cmdsn = cpu_to_be32(logout->exp_cmd_sn); resp_hdr->max_cmdsn = cpu_to_be32(logout->max_cmd_sn); resp_hdr->t2wait = cpu_to_be32(logout->time_to_wait); resp_hdr->t2retain = cpu_to_be32(logout->time_to_retain); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); bnx2i_conn->ep->state = EP_STATE_LOGOUT_RESP_RCVD; done: spin_unlock(&session->lock); return 0; } /** * bnx2i_process_nopin_local_cmpl - this function handles iscsi nopin CQE * @session: iscsi session pointer * @bnx2i_conn: iscsi connection pointer * @cqe: pointer to newly DMA'ed CQE entry for processing * * process iSCSI NOPIN local completion CQE, frees IIT and command structures */ static void bnx2i_process_nopin_local_cmpl(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct cqe *cqe) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct bnx2i_nop_in_msg *nop_in; struct iscsi_task *task; nop_in = (struct bnx2i_nop_in_msg *)cqe; spin_lock(&session->lock); task = iscsi_itt_to_task(conn, nop_in->itt & ISCSI_NOP_IN_MSG_INDEX); if (task) __iscsi_put_task(task); spin_unlock(&session->lock); } /** * bnx2i_unsol_pdu_adjust_rq - makes adjustments to RQ after unsol pdu is recvd * @conn: iscsi connection * * Firmware advances RQ producer index for every unsolicited PDU even if * payload data length is '0'. This function makes corresponding * adjustments on the driver side to match this f/w behavior */ static void bnx2i_unsol_pdu_adjust_rq(struct bnx2i_conn *bnx2i_conn) { char dummy_rq_data[2]; bnx2i_get_rq_buf(bnx2i_conn, dummy_rq_data, 1); bnx2i_put_rq_buf(bnx2i_conn, 1); } /** * bnx2i_process_nopin_mesg - this function handles iscsi nopin CQE * @session: iscsi session pointer * @bnx2i_conn: iscsi connection pointer * @cqe: pointer to newly DMA'ed CQE entry for processing * * process iSCSI target's proactive iSCSI NOPIN request */ static int bnx2i_process_nopin_mesg(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct cqe *cqe) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct iscsi_task *task; struct bnx2i_nop_in_msg *nop_in; struct iscsi_nopin *hdr; int tgt_async_nop = 0; nop_in = (struct bnx2i_nop_in_msg *)cqe; spin_lock(&session->lock); hdr = (struct iscsi_nopin *)&bnx2i_conn->gen_pdu.resp_hdr; memset(hdr, 0, sizeof(struct iscsi_hdr)); hdr->opcode = nop_in->op_code; hdr->max_cmdsn = cpu_to_be32(nop_in->max_cmd_sn); hdr->exp_cmdsn = cpu_to_be32(nop_in->exp_cmd_sn); hdr->ttt = cpu_to_be32(nop_in->ttt); if (nop_in->itt == (u16) RESERVED_ITT) { bnx2i_unsol_pdu_adjust_rq(bnx2i_conn); hdr->itt = RESERVED_ITT; tgt_async_nop = 1; goto done; } /* this is a response to one of our nop-outs */ task = iscsi_itt_to_task(conn, (itt_t) (nop_in->itt & ISCSI_NOP_IN_MSG_INDEX)); if (task) { hdr->flags = ISCSI_FLAG_CMD_FINAL; hdr->itt = task->hdr->itt; hdr->ttt = cpu_to_be32(nop_in->ttt); memcpy(&hdr->lun, nop_in->lun, 8); } done: __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); spin_unlock(&session->lock); return tgt_async_nop; } /** * bnx2i_process_async_mesg - this function handles iscsi async message * @session: iscsi session pointer * @bnx2i_conn: iscsi connection pointer * @cqe: pointer to newly DMA'ed CQE entry for processing * * process iSCSI ASYNC Message */ static void bnx2i_process_async_mesg(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct cqe *cqe) { struct bnx2i_async_msg *async_cqe; struct iscsi_async *resp_hdr; u8 async_event; bnx2i_unsol_pdu_adjust_rq(bnx2i_conn); async_cqe = (struct bnx2i_async_msg *)cqe; async_event = async_cqe->async_event; if (async_event == ISCSI_ASYNC_MSG_SCSI_EVENT) { iscsi_conn_printk(KERN_ALERT, bnx2i_conn->cls_conn->dd_data, "async: scsi events not supported\n"); return; } spin_lock(&session->lock); resp_hdr = (struct iscsi_async *) &bnx2i_conn->gen_pdu.resp_hdr; memset(resp_hdr, 0, sizeof(struct iscsi_hdr)); resp_hdr->opcode = async_cqe->op_code; resp_hdr->flags = 0x80; memcpy(&resp_hdr->lun, async_cqe->lun, 8); resp_hdr->exp_cmdsn = cpu_to_be32(async_cqe->exp_cmd_sn); resp_hdr->max_cmdsn = cpu_to_be32(async_cqe->max_cmd_sn); resp_hdr->async_event = async_cqe->async_event; resp_hdr->async_vcode = async_cqe->async_vcode; resp_hdr->param1 = cpu_to_be16(async_cqe->param1); resp_hdr->param2 = cpu_to_be16(async_cqe->param2); resp_hdr->param3 = cpu_to_be16(async_cqe->param3); __iscsi_complete_pdu(bnx2i_conn->cls_conn->dd_data, (struct iscsi_hdr *)resp_hdr, NULL, 0); spin_unlock(&session->lock); } /** * bnx2i_process_reject_mesg - process iscsi reject pdu * @session: iscsi session pointer * @bnx2i_conn: iscsi connection pointer * @cqe: pointer to newly DMA'ed CQE entry for processing * * process iSCSI REJECT message */ static void bnx2i_process_reject_mesg(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct cqe *cqe) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct bnx2i_reject_msg *reject; struct iscsi_reject *hdr; reject = (struct bnx2i_reject_msg *) cqe; if (reject->data_length) { bnx2i_get_rq_buf(bnx2i_conn, conn->data, reject->data_length); bnx2i_put_rq_buf(bnx2i_conn, 1); } else bnx2i_unsol_pdu_adjust_rq(bnx2i_conn); spin_lock(&session->lock); hdr = (struct iscsi_reject *) &bnx2i_conn->gen_pdu.resp_hdr; memset(hdr, 0, sizeof(struct iscsi_hdr)); hdr->opcode = reject->op_code; hdr->reason = reject->reason; hton24(hdr->dlength, reject->data_length); hdr->max_cmdsn = cpu_to_be32(reject->max_cmd_sn); hdr->exp_cmdsn = cpu_to_be32(reject->exp_cmd_sn); hdr->ffffffff = cpu_to_be32(RESERVED_ITT); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, conn->data, reject->data_length); spin_unlock(&session->lock); } /** * bnx2i_process_cmd_cleanup_resp - process scsi command clean-up completion * @session: iscsi session pointer * @bnx2i_conn: iscsi connection pointer * @cqe: pointer to newly DMA'ed CQE entry for processing * * process command cleanup response CQE during conn shutdown or error recovery */ static void bnx2i_process_cmd_cleanup_resp(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct cqe *cqe) { struct bnx2i_cleanup_response *cmd_clean_rsp; struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct iscsi_task *task; cmd_clean_rsp = (struct bnx2i_cleanup_response *)cqe; spin_lock(&session->lock); task = iscsi_itt_to_task(conn, cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX); if (!task) printk(KERN_ALERT "bnx2i: cmd clean ITT %x not active\n", cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX); spin_unlock(&session->lock); complete(&bnx2i_conn->cmd_cleanup_cmpl); } /** * bnx2i_percpu_io_thread - thread per cpu for ios * * @arg: ptr to bnx2i_percpu_info structure */ int bnx2i_percpu_io_thread(void *arg) { struct bnx2i_percpu_s *p = arg; struct bnx2i_work *work, *tmp; LIST_HEAD(work_list); set_user_nice(current, -20); while (!kthread_should_stop()) { spin_lock_bh(&p->p_work_lock); while (!list_empty(&p->work_list)) { list_splice_init(&p->work_list, &work_list); spin_unlock_bh(&p->p_work_lock); list_for_each_entry_safe(work, tmp, &work_list, list) { list_del_init(&work->list); /* work allocated in the bh, freed here */ bnx2i_process_scsi_cmd_resp(work->session, work->bnx2i_conn, &work->cqe); atomic_dec(&work->bnx2i_conn->work_cnt); kfree(work); } spin_lock_bh(&p->p_work_lock); } set_current_state(TASK_INTERRUPTIBLE); spin_unlock_bh(&p->p_work_lock); schedule(); } __set_current_state(TASK_RUNNING); return 0; } /** * bnx2i_queue_scsi_cmd_resp - queue cmd completion to the percpu thread * @bnx2i_conn: bnx2i connection * * this function is called by generic KCQ handler to queue all pending cmd * completion CQEs * * The implementation is to queue the cmd response based on the * last recorded command for the given connection. The * cpu_id gets recorded upon task_xmit. No out-of-order completion! */ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session, struct bnx2i_conn *bnx2i_conn, struct bnx2i_nop_in_msg *cqe) { struct bnx2i_work *bnx2i_work = NULL; struct bnx2i_percpu_s *p = NULL; struct iscsi_task *task; struct scsi_cmnd *sc; int rc = 0; int cpu; spin_lock(&session->lock); task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data, cqe->itt & ISCSI_CMD_RESPONSE_INDEX); if (!task || !task->sc) { spin_unlock(&session->lock); return -EINVAL; } sc = task->sc; if (!blk_rq_cpu_valid(sc->request)) cpu = smp_processor_id(); else cpu = sc->request->cpu; spin_unlock(&session->lock); p = &per_cpu(bnx2i_percpu, cpu); spin_lock(&p->p_work_lock); if (unlikely(!p->iothread)) { rc = -EINVAL; goto err; } /* Alloc and copy to the cqe */ bnx2i_work = kzalloc(sizeof(struct bnx2i_work), GFP_ATOMIC); if (bnx2i_work) { INIT_LIST_HEAD(&bnx2i_work->list); bnx2i_work->session = session; bnx2i_work->bnx2i_conn = bnx2i_conn; memcpy(&bnx2i_work->cqe, cqe, sizeof(struct cqe)); list_add_tail(&bnx2i_work->list, &p->work_list); atomic_inc(&bnx2i_conn->work_cnt); wake_up_process(p->iothread); spin_unlock(&p->p_work_lock); goto done; } else rc = -ENOMEM; err: spin_unlock(&p->p_work_lock); bnx2i_process_scsi_cmd_resp(session, bnx2i_conn, (struct cqe *)cqe); done: return rc; } /** * bnx2i_process_new_cqes - process newly DMA'ed CQE's * @bnx2i_conn: bnx2i connection * * this function is called by generic KCQ handler to process all pending CQE's */ static int bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; struct iscsi_session *session = conn->session; struct qp_info *qp; struct bnx2i_nop_in_msg *nopin; int tgt_async_msg; int cqe_cnt = 0; if (bnx2i_conn->ep == NULL) return 0; qp = &bnx2i_conn->ep->qp; if (!qp->cq_virt) { printk(KERN_ALERT "bnx2i (%s): cq resr freed in bh execution!", bnx2i_conn->hba->netdev->name); goto out; } while (1) { nopin = (struct bnx2i_nop_in_msg *) qp->cq_cons_qe; if (nopin->cq_req_sn != qp->cqe_exp_seq_sn) break; if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx))) { if (nopin->op_code == ISCSI_OP_NOOP_IN && nopin->itt == (u16) RESERVED_ITT) { printk(KERN_ALERT "bnx2i: Unsolicited " "NOP-In detected for suspended " "connection dev=%s!\n", bnx2i_conn->hba->netdev->name); bnx2i_unsol_pdu_adjust_rq(bnx2i_conn); goto cqe_out; } break; } tgt_async_msg = 0; switch (nopin->op_code) { case ISCSI_OP_SCSI_CMD_RSP: case ISCSI_OP_SCSI_DATA_IN: /* Run the kthread engine only for data cmds All other cmds will be completed in this bh! */ bnx2i_queue_scsi_cmd_resp(session, bnx2i_conn, nopin); break; case ISCSI_OP_LOGIN_RSP: bnx2i_process_login_resp(session, bnx2i_conn, qp->cq_cons_qe); break; case ISCSI_OP_SCSI_TMFUNC_RSP: bnx2i_process_tmf_resp(session, bnx2i_conn, qp->cq_cons_qe); break; case ISCSI_OP_TEXT_RSP: bnx2i_process_text_resp(session, bnx2i_conn, qp->cq_cons_qe); break; case ISCSI_OP_LOGOUT_RSP: bnx2i_process_logout_resp(session, bnx2i_conn, qp->cq_cons_qe); break; case ISCSI_OP_NOOP_IN: if (bnx2i_process_nopin_mesg(session, bnx2i_conn, qp->cq_cons_qe)) tgt_async_msg = 1; break; case ISCSI_OPCODE_NOPOUT_LOCAL_COMPLETION: bnx2i_process_nopin_local_cmpl(session, bnx2i_conn, qp->cq_cons_qe); break; case ISCSI_OP_ASYNC_EVENT: bnx2i_process_async_mesg(session, bnx2i_conn, qp->cq_cons_qe); tgt_async_msg = 1; break; case ISCSI_OP_REJECT: bnx2i_process_reject_mesg(session, bnx2i_conn, qp->cq_cons_qe); break; case ISCSI_OPCODE_CLEANUP_RESPONSE: bnx2i_process_cmd_cleanup_resp(session, bnx2i_conn, qp->cq_cons_qe); break; default: printk(KERN_ALERT "bnx2i: unknown opcode 0x%x\n", nopin->op_code); } if (!tgt_async_msg) { if (!atomic_read(&bnx2i_conn->ep->num_active_cmds)) printk(KERN_ALERT "bnx2i (%s): no active cmd! " "op 0x%x\n", bnx2i_conn->hba->netdev->name, nopin->op_code); else atomic_dec(&bnx2i_conn->ep->num_active_cmds); } cqe_out: /* clear out in production version only, till beta keep opcode * field intact, will be helpful in debugging (context dump) * nopin->op_code = 0; */ cqe_cnt++; qp->cqe_exp_seq_sn++; if (qp->cqe_exp_seq_sn == (qp->cqe_size * 2 + 1)) qp->cqe_exp_seq_sn = ISCSI_INITIAL_SN; if (qp->cq_cons_qe == qp->cq_last_qe) { qp->cq_cons_qe = qp->cq_first_qe; qp->cq_cons_idx = 0; } else { qp->cq_cons_qe++; qp->cq_cons_idx++; } } out: return cqe_cnt; } /** * bnx2i_fastpath_notification - process global event queue (KCQ) * @hba: adapter structure pointer * @new_cqe_kcqe: pointer to newly DMA'ed KCQE entry * * Fast path event notification handler, KCQ entry carries context id * of the connection that has 1 or more pending CQ entries */ static void bnx2i_fastpath_notification(struct bnx2i_hba *hba, struct iscsi_kcqe *new_cqe_kcqe) { struct bnx2i_conn *bnx2i_conn; u32 iscsi_cid; int nxt_idx; iscsi_cid = new_cqe_kcqe->iscsi_conn_id; bnx2i_conn = bnx2i_get_conn_from_id(hba, iscsi_cid); if (!bnx2i_conn) { printk(KERN_ALERT "cid #%x not valid\n", iscsi_cid); return; } if (!bnx2i_conn->ep) { printk(KERN_ALERT "cid #%x - ep not bound\n", iscsi_cid); return; } bnx2i_process_new_cqes(bnx2i_conn); nxt_idx = bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE_FP); if (nxt_idx && nxt_idx == bnx2i_process_new_cqes(bnx2i_conn)) bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE_FP); } /** * bnx2i_process_update_conn_cmpl - process iscsi conn update completion KCQE * @hba: adapter structure pointer * @update_kcqe: kcqe pointer * * CONN_UPDATE completion handler, this completes iSCSI connection FFP migration */ static void bnx2i_process_update_conn_cmpl(struct bnx2i_hba *hba, struct iscsi_kcqe *update_kcqe) { struct bnx2i_conn *conn; u32 iscsi_cid; iscsi_cid = update_kcqe->iscsi_conn_id; conn = bnx2i_get_conn_from_id(hba, iscsi_cid); if (!conn) { printk(KERN_ALERT "conn_update: cid %x not valid\n", iscsi_cid); return; } if (!conn->ep) { printk(KERN_ALERT "cid %x does not have ep bound\n", iscsi_cid); return; } if (update_kcqe->completion_status) { printk(KERN_ALERT "request failed cid %x\n", iscsi_cid); conn->ep->state = EP_STATE_ULP_UPDATE_FAILED; } else conn->ep->state = EP_STATE_ULP_UPDATE_COMPL; wake_up_interruptible(&conn->ep->ofld_wait); } /** * bnx2i_recovery_que_add_conn - add connection to recovery queue * @hba: adapter structure pointer * @bnx2i_conn: iscsi connection * * Add connection to recovery queue and schedule adapter eh worker */ static void bnx2i_recovery_que_add_conn(struct bnx2i_hba *hba, struct bnx2i_conn *bnx2i_conn) { iscsi_conn_failure(bnx2i_conn->cls_conn->dd_data, ISCSI_ERR_CONN_FAILED); } /** * bnx2i_process_tcp_error - process error notification on a given connection * * @hba: adapter structure pointer * @tcp_err: tcp error kcqe pointer * * handles tcp level error notifications from FW. */ static void bnx2i_process_tcp_error(struct bnx2i_hba *hba, struct iscsi_kcqe *tcp_err) { struct bnx2i_conn *bnx2i_conn; u32 iscsi_cid; iscsi_cid = tcp_err->iscsi_conn_id; bnx2i_conn = bnx2i_get_conn_from_id(hba, iscsi_cid); if (!bnx2i_conn) { printk(KERN_ALERT "bnx2i - cid 0x%x not valid\n", iscsi_cid); return; } printk(KERN_ALERT "bnx2i - cid 0x%x had TCP errors, error code 0x%x\n", iscsi_cid, tcp_err->completion_status); bnx2i_recovery_que_add_conn(bnx2i_conn->hba, bnx2i_conn); } /** * bnx2i_process_iscsi_error - process error notification on a given connection * @hba: adapter structure pointer * @iscsi_err: iscsi error kcqe pointer * * handles iscsi error notifications from the FW. Firmware based in initial * handshake classifies iscsi protocol / TCP rfc violation into either * warning or error indications. If indication is of "Error" type, driver * will initiate session recovery for that connection/session. For * "Warning" type indication, driver will put out a system log message * (there will be only one message for each type for the life of the * session, this is to avoid un-necessarily overloading the system) */ static void bnx2i_process_iscsi_error(struct bnx2i_hba *hba, struct iscsi_kcqe *iscsi_err) { struct bnx2i_conn *bnx2i_conn; u32 iscsi_cid; char warn_notice[] = "iscsi_warning"; char error_notice[] = "iscsi_error"; char additional_notice[64]; char *message; int need_recovery; u64 err_mask64; iscsi_cid = iscsi_err->iscsi_conn_id; bnx2i_conn = bnx2i_get_conn_from_id(hba, iscsi_cid); if (!bnx2i_conn) { printk(KERN_ALERT "bnx2i - cid 0x%x not valid\n", iscsi_cid); return; } err_mask64 = (0x1ULL << iscsi_err->completion_status); if (err_mask64 & iscsi_error_mask) { need_recovery = 0; message = warn_notice; } else { need_recovery = 1; message = error_notice; } switch (iscsi_err->completion_status) { case ISCSI_KCQE_COMPLETION_STATUS_HDR_DIG_ERR: strcpy(additional_notice, "hdr digest err"); break; case ISCSI_KCQE_COMPLETION_STATUS_DATA_DIG_ERR: strcpy(additional_notice, "data digest err"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_OPCODE: strcpy(additional_notice, "wrong opcode rcvd"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_AHS_LEN: strcpy(additional_notice, "AHS len > 0 rcvd"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_ITT: strcpy(additional_notice, "invalid ITT rcvd"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_STATSN: strcpy(additional_notice, "wrong StatSN rcvd"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_EXP_DATASN: strcpy(additional_notice, "wrong DataSN rcvd"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_PEND_R2T: strcpy(additional_notice, "pend R2T violation"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_0: strcpy(additional_notice, "ERL0, UO"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_1: strcpy(additional_notice, "ERL0, U1"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_2: strcpy(additional_notice, "ERL0, U2"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_3: strcpy(additional_notice, "ERL0, U3"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_4: strcpy(additional_notice, "ERL0, U4"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_5: strcpy(additional_notice, "ERL0, U5"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_6: strcpy(additional_notice, "ERL0, U6"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_REMAIN_RCV_LEN: strcpy(additional_notice, "invalid resi len"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_MAX_RCV_PDU_LEN: strcpy(additional_notice, "MRDSL violation"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_F_BIT_ZERO: strcpy(additional_notice, "F-bit not set"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_TTT_NOT_RSRV: strcpy(additional_notice, "invalid TTT"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DATASN: strcpy(additional_notice, "invalid DataSN"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_REMAIN_BURST_LEN: strcpy(additional_notice, "burst len violation"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_BUFFER_OFF: strcpy(additional_notice, "buf offset violation"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_LUN: strcpy(additional_notice, "invalid LUN field"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_R2TSN: strcpy(additional_notice, "invalid R2TSN field"); break; #define BNX2I_ERR_DESIRED_DATA_TRNS_LEN_0 \ ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DESIRED_DATA_TRNS_LEN_0 case BNX2I_ERR_DESIRED_DATA_TRNS_LEN_0: strcpy(additional_notice, "invalid cmd len1"); break; #define BNX2I_ERR_DESIRED_DATA_TRNS_LEN_1 \ ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DESIRED_DATA_TRNS_LEN_1 case BNX2I_ERR_DESIRED_DATA_TRNS_LEN_1: strcpy(additional_notice, "invalid cmd len2"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_PEND_R2T_EXCEED: strcpy(additional_notice, "pend r2t exceeds MaxOutstandingR2T value"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_TTT_IS_RSRV: strcpy(additional_notice, "TTT is rsvd"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_MAX_BURST_LEN: strcpy(additional_notice, "MBL violation"); break; #define BNX2I_ERR_DATA_SEG_LEN_NOT_ZERO \ ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DATA_SEG_LEN_NOT_ZERO case BNX2I_ERR_DATA_SEG_LEN_NOT_ZERO: strcpy(additional_notice, "data seg len != 0"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_REJECT_PDU_LEN: strcpy(additional_notice, "reject pdu len error"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_ASYNC_PDU_LEN: strcpy(additional_notice, "async pdu len error"); break; case ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_NOPIN_PDU_LEN: strcpy(additional_notice, "nopin pdu len error"); break; #define BNX2_ERR_PEND_R2T_IN_CLEANUP \ ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_PEND_R2T_IN_CLEANUP case BNX2_ERR_PEND_R2T_IN_CLEANUP: strcpy(additional_notice, "pend r2t in cleanup"); break; case ISCI_KCQE_COMPLETION_STATUS_TCP_ERROR_IP_FRAGMENT: strcpy(additional_notice, "IP fragments rcvd"); break; case ISCI_KCQE_COMPLETION_STATUS_TCP_ERROR_IP_OPTIONS: strcpy(additional_notice, "IP options error"); break; case ISCI_KCQE_COMPLETION_STATUS_TCP_ERROR_URGENT_FLAG: strcpy(additional_notice, "urgent flag error"); break; default: printk(KERN_ALERT "iscsi_err - unknown err %x\n", iscsi_err->completion_status); } if (need_recovery) { iscsi_conn_printk(KERN_ALERT, bnx2i_conn->cls_conn->dd_data, "bnx2i: %s - %s\n", message, additional_notice); iscsi_conn_printk(KERN_ALERT, bnx2i_conn->cls_conn->dd_data, "conn_err - hostno %d conn %p, " "iscsi_cid %x cid %x\n", bnx2i_conn->hba->shost->host_no, bnx2i_conn, bnx2i_conn->ep->ep_iscsi_cid, bnx2i_conn->ep->ep_cid); bnx2i_recovery_que_add_conn(bnx2i_conn->hba, bnx2i_conn); } else if (!test_and_set_bit(iscsi_err->completion_status, (void *) &bnx2i_conn->violation_notified)) iscsi_conn_printk(KERN_ALERT, bnx2i_conn->cls_conn->dd_data, "bnx2i: %s - %s\n", message, additional_notice); } /** * bnx2i_process_conn_destroy_cmpl - process iscsi conn destroy completion * @hba: adapter structure pointer * @conn_destroy: conn destroy kcqe pointer * * handles connection destroy completion request. */ static void bnx2i_process_conn_destroy_cmpl(struct bnx2i_hba *hba, struct iscsi_kcqe *conn_destroy) { struct bnx2i_endpoint *ep; ep = bnx2i_find_ep_in_destroy_list(hba, conn_destroy->iscsi_conn_id); if (!ep) { printk(KERN_ALERT "bnx2i_conn_destroy_cmpl: no pending " "offload request, unexpected complection\n"); return; } if (hba != ep->hba) { printk(KERN_ALERT "conn destroy- error hba mis-match\n"); return; } if (conn_destroy->completion_status) { printk(KERN_ALERT "conn_destroy_cmpl: op failed\n"); ep->state = EP_STATE_CLEANUP_FAILED; } else ep->state = EP_STATE_CLEANUP_CMPL; wake_up_interruptible(&ep->ofld_wait); } /** * bnx2i_process_ofld_cmpl - process initial iscsi conn offload completion * @hba: adapter structure pointer * @ofld_kcqe: conn offload kcqe pointer * * handles initial connection offload completion, ep_connect() thread is * woken-up to continue with LLP connect process */ static void bnx2i_process_ofld_cmpl(struct bnx2i_hba *hba, struct iscsi_kcqe *ofld_kcqe) { u32 cid_addr; struct bnx2i_endpoint *ep; u32 cid_num; ep = bnx2i_find_ep_in_ofld_list(hba, ofld_kcqe->iscsi_conn_id); if (!ep) { printk(KERN_ALERT "ofld_cmpl: no pend offload request\n"); return; } if (hba != ep->hba) { printk(KERN_ALERT "ofld_cmpl: error hba mis-match\n"); return; } if (ofld_kcqe->completion_status) { ep->state = EP_STATE_OFLD_FAILED; if (ofld_kcqe->completion_status == ISCSI_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE) printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - unable " "to allocate iSCSI context resources\n", hba->netdev->name); else if (ofld_kcqe->completion_status == ISCSI_KCQE_COMPLETION_STATUS_INVALID_OPCODE) printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid " "opcode\n", hba->netdev->name); else if (ofld_kcqe->completion_status == ISCSI_KCQE_COMPLETION_STATUS_CID_BUSY) /* error status code valid only for 5771x chipset */ ep->state = EP_STATE_OFLD_FAILED_CID_BUSY; else printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid " "error code %d\n", hba->netdev->name, ofld_kcqe->completion_status); } else { ep->state = EP_STATE_OFLD_COMPL; cid_addr = ofld_kcqe->iscsi_conn_context_id; cid_num = bnx2i_get_cid_num(ep); ep->ep_cid = cid_addr; ep->qp.ctx_base = NULL; } wake_up_interruptible(&ep->ofld_wait); } /** * bnx2i_indicate_kcqe - process iscsi conn update completion KCQE * @hba: adapter structure pointer * @update_kcqe: kcqe pointer * * Generic KCQ event handler/dispatcher */ static void bnx2i_indicate_kcqe(void *context, struct kcqe *kcqe[], u32 num_cqe) { struct bnx2i_hba *hba = context; int i = 0; struct iscsi_kcqe *ikcqe = NULL; while (i < num_cqe) { ikcqe = (struct iscsi_kcqe *) kcqe[i++]; if (ikcqe->op_code == ISCSI_KCQE_OPCODE_CQ_EVENT_NOTIFICATION) bnx2i_fastpath_notification(hba, ikcqe); else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_OFFLOAD_CONN) bnx2i_process_ofld_cmpl(hba, ikcqe); else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_UPDATE_CONN) bnx2i_process_update_conn_cmpl(hba, ikcqe); else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_INIT) { if (ikcqe->completion_status != ISCSI_KCQE_COMPLETION_STATUS_SUCCESS) bnx2i_iscsi_license_error(hba, ikcqe->\ completion_status); else { set_bit(ADAPTER_STATE_UP, &hba->adapter_state); bnx2i_get_link_state(hba); printk(KERN_INFO "bnx2i [%.2x:%.2x.%.2x]: " "ISCSI_INIT passed\n", (u8)hba->pcidev->bus->number, hba->pci_devno, (u8)hba->pci_func); } } else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_DESTROY_CONN) bnx2i_process_conn_destroy_cmpl(hba, ikcqe); else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_ISCSI_ERROR) bnx2i_process_iscsi_error(hba, ikcqe); else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_TCP_ERROR) bnx2i_process_tcp_error(hba, ikcqe); else printk(KERN_ALERT "bnx2i: unknown opcode 0x%x\n", ikcqe->op_code); } } /** * bnx2i_indicate_netevent - Generic netdev event handler * @context: adapter structure pointer * @event: event type * @vlan_id: vlans id - associated vlan id with this event * * Handles four netdev events, NETDEV_UP, NETDEV_DOWN, * NETDEV_GOING_DOWN and NETDEV_CHANGE */ static void bnx2i_indicate_netevent(void *context, unsigned long event, u16 vlan_id) { struct bnx2i_hba *hba = context; /* Ignore all netevent coming from vlans */ if (vlan_id != 0) return; switch (event) { case NETDEV_UP: if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) bnx2i_send_fw_iscsi_init_msg(hba); break; case NETDEV_DOWN: clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); break; case NETDEV_GOING_DOWN: set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); iscsi_host_for_each_session(hba->shost, bnx2i_drop_session); break; case NETDEV_CHANGE: bnx2i_get_link_state(hba); break; default: ; } } /** * bnx2i_cm_connect_cmpl - process iscsi conn establishment completion * @cm_sk: cnic sock structure pointer * * function callback exported via bnx2i - cnic driver interface to * indicate completion of option-2 TCP connect request. */ static void bnx2i_cm_connect_cmpl(struct cnic_sock *cm_sk) { struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context; if (test_bit(ADAPTER_STATE_GOING_DOWN, &ep->hba->adapter_state)) ep->state = EP_STATE_CONNECT_FAILED; else if (test_bit(SK_F_OFFLD_COMPLETE, &cm_sk->flags)) ep->state = EP_STATE_CONNECT_COMPL; else ep->state = EP_STATE_CONNECT_FAILED; wake_up_interruptible(&ep->ofld_wait); } /** * bnx2i_cm_close_cmpl - process tcp conn close completion * @cm_sk: cnic sock structure pointer * * function callback exported via bnx2i - cnic driver interface to * indicate completion of option-2 graceful TCP connect shutdown */ static void bnx2i_cm_close_cmpl(struct cnic_sock *cm_sk) { struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context; ep->state = EP_STATE_DISCONN_COMPL; wake_up_interruptible(&ep->ofld_wait); } /** * bnx2i_cm_abort_cmpl - process abortive tcp conn teardown completion * @cm_sk: cnic sock structure pointer * * function callback exported via bnx2i - cnic driver interface to * indicate completion of option-2 abortive TCP connect termination */ static void bnx2i_cm_abort_cmpl(struct cnic_sock *cm_sk) { struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context; ep->state = EP_STATE_DISCONN_COMPL; wake_up_interruptible(&ep->ofld_wait); } /** * bnx2i_cm_remote_close - process received TCP FIN * @hba: adapter structure pointer * @update_kcqe: kcqe pointer * * function callback exported via bnx2i - cnic driver interface to indicate * async TCP events such as FIN */ static void bnx2i_cm_remote_close(struct cnic_sock *cm_sk) { struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context; ep->state = EP_STATE_TCP_FIN_RCVD; if (ep->conn) bnx2i_recovery_que_add_conn(ep->hba, ep->conn); } /** * bnx2i_cm_remote_abort - process TCP RST and start conn cleanup * @hba: adapter structure pointer * @update_kcqe: kcqe pointer * * function callback exported via bnx2i - cnic driver interface to * indicate async TCP events (RST) sent by the peer. */ static void bnx2i_cm_remote_abort(struct cnic_sock *cm_sk) { struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context; u32 old_state = ep->state; ep->state = EP_STATE_TCP_RST_RCVD; if (old_state == EP_STATE_DISCONN_START) wake_up_interruptible(&ep->ofld_wait); else if (ep->conn) bnx2i_recovery_que_add_conn(ep->hba, ep->conn); } static int bnx2i_send_nl_mesg(void *context, u32 msg_type, char *buf, u16 buflen) { struct bnx2i_hba *hba = context; int rc; if (!hba) return -ENODEV; rc = iscsi_offload_mesg(hba->shost, &bnx2i_iscsi_transport, msg_type, buf, buflen); if (rc) printk(KERN_ALERT "bnx2i: private nl message send error\n"); return rc; } /** * bnx2i_cnic_cb - global template of bnx2i - cnic driver interface structure * carrying callback function pointers * */ struct cnic_ulp_ops bnx2i_cnic_cb = { .cnic_init = bnx2i_ulp_init, .cnic_exit = bnx2i_ulp_exit, .cnic_start = bnx2i_start, .cnic_stop = bnx2i_stop, .indicate_kcqes = bnx2i_indicate_kcqe, .indicate_netevent = bnx2i_indicate_netevent, .cm_connect_complete = bnx2i_cm_connect_cmpl, .cm_close_complete = bnx2i_cm_close_cmpl, .cm_abort_complete = bnx2i_cm_abort_cmpl, .cm_remote_close = bnx2i_cm_remote_close, .cm_remote_abort = bnx2i_cm_remote_abort, .iscsi_nl_send_msg = bnx2i_send_nl_mesg, .owner = THIS_MODULE }; /** * bnx2i_map_ep_dbell_regs - map connection doorbell registers * @ep: bnx2i endpoint * * maps connection's SQ and RQ doorbell registers, 5706/5708/5709 hosts these * register in BAR #0. Whereas in 57710 these register are accessed by * mapping BAR #1 */ int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep) { u32 cid_num; u32 reg_off; u32 first_l4l5; u32 ctx_sz; u32 config2; resource_size_t reg_base; cid_num = bnx2i_get_cid_num(ep); if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) { reg_base = pci_resource_start(ep->hba->pcidev, BNX2X_DOORBELL_PCI_BAR); reg_off = BNX2I_5771X_DBELL_PAGE_SIZE * (cid_num & 0x1FFFF) + DPM_TRIGER_TYPE; ep->qp.ctx_base = ioremap_nocache(reg_base + reg_off, 4); goto arm_cq; } reg_base = ep->hba->netdev->base_addr; if ((test_bit(BNX2I_NX2_DEV_5709, &ep->hba->cnic_dev_type)) && (ep->hba->mail_queue_access == BNX2I_MQ_BIN_MODE)) { config2 = REG_RD(ep->hba, BNX2_MQ_CONFIG2); first_l4l5 = config2 & BNX2_MQ_CONFIG2_FIRST_L4L5; ctx_sz = (config2 & BNX2_MQ_CONFIG2_CONT_SZ) >> 3; if (ctx_sz) reg_off = CTX_OFFSET + MAX_CID_CNT * MB_KERNEL_CTX_SIZE + BNX2I_570X_PAGE_SIZE_DEFAULT * (((cid_num - first_l4l5) / ctx_sz) + 256); else reg_off = CTX_OFFSET + (MB_KERNEL_CTX_SIZE * cid_num); } else /* 5709 device in normal node and 5706/5708 devices */ reg_off = CTX_OFFSET + (MB_KERNEL_CTX_SIZE * cid_num); ep->qp.ctx_base = ioremap_nocache(reg_base + reg_off, MB_KERNEL_CTX_SIZE); if (!ep->qp.ctx_base) return -ENOMEM; arm_cq: bnx2i_arm_cq_event_coalescing(ep, CNIC_ARM_CQE); return 0; }
gpl-2.0
gtvhacker/Sony-Kernel
net/irda/irlan/irlan_common.c
3516
31218
/********************************************************************* * * Filename: irlan_common.c * Version: 0.9 * Description: IrDA LAN Access Protocol Implementation * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sun Aug 31 20:14:37 1997 * Modified at: Sun Dec 26 21:53:10 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>, * 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. * * Neither Dag Brattli nor University of Tromsø admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/gfp.h> #include <linux/init.h> #include <linux/errno.h> #include <linux/proc_fs.h> #include <linux/sched.h> #include <linux/seq_file.h> #include <linux/random.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/rtnetlink.h> #include <linux/moduleparam.h> #include <linux/bitops.h> #include <asm/system.h> #include <asm/byteorder.h> #include <net/irda/irda.h> #include <net/irda/irttp.h> #include <net/irda/irlmp.h> #include <net/irda/iriap.h> #include <net/irda/timer.h> #include <net/irda/irlan_common.h> #include <net/irda/irlan_client.h> #include <net/irda/irlan_provider.h> #include <net/irda/irlan_eth.h> #include <net/irda/irlan_filter.h> /* extern char sysctl_devname[]; */ /* * Master structure */ static LIST_HEAD(irlans); static void *ckey; static void *skey; /* Module parameters */ static int eth; /* Use "eth" or "irlan" name for devices */ static int access = ACCESS_PEER; /* PEER, DIRECT or HOSTED */ #ifdef CONFIG_PROC_FS static const char *const irlan_access[] = { "UNKNOWN", "DIRECT", "PEER", "HOSTED" }; static const char *const irlan_media[] = { "UNKNOWN", "802.3", "802.5" }; extern struct proc_dir_entry *proc_irda; static int irlan_seq_open(struct inode *inode, struct file *file); static const struct file_operations irlan_fops = { .owner = THIS_MODULE, .open = irlan_seq_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; extern struct proc_dir_entry *proc_irda; #endif /* CONFIG_PROC_FS */ static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr); static void __irlan_close(struct irlan_cb *self); static int __irlan_insert_param(struct sk_buff *skb, char *param, int type, __u8 value_byte, __u16 value_short, __u8 *value_array, __u16 value_len); static void irlan_open_unicast_addr(struct irlan_cb *self); static void irlan_get_unicast_addr(struct irlan_cb *self); void irlan_close_tsaps(struct irlan_cb *self); /* * Function irlan_init (void) * * Initialize IrLAN layer * */ static int __init irlan_init(void) { struct irlan_cb *new; __u16 hints; IRDA_DEBUG(2, "%s()\n", __func__ ); #ifdef CONFIG_PROC_FS { struct proc_dir_entry *proc; proc = proc_create("irlan", 0, proc_irda, &irlan_fops); if (!proc) { printk(KERN_ERR "irlan_init: can't create /proc entry!\n"); return -ENODEV; } } #endif /* CONFIG_PROC_FS */ IRDA_DEBUG(4, "%s()\n", __func__ ); hints = irlmp_service_to_hint(S_LAN); /* Register with IrLMP as a client */ ckey = irlmp_register_client(hints, &irlan_client_discovery_indication, NULL, NULL); if (!ckey) goto err_ckey; /* Register with IrLMP as a service */ skey = irlmp_register_service(hints); if (!skey) goto err_skey; /* Start the master IrLAN instance (the only one for now) */ new = irlan_open(DEV_ADDR_ANY, DEV_ADDR_ANY); if (!new) goto err_open; /* The master will only open its (listen) control TSAP */ irlan_provider_open_ctrl_tsap(new); /* Do some fast discovery! */ irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS); return 0; err_open: irlmp_unregister_service(skey); err_skey: irlmp_unregister_client(ckey); err_ckey: #ifdef CONFIG_PROC_FS remove_proc_entry("irlan", proc_irda); #endif /* CONFIG_PROC_FS */ return -ENOMEM; } static void __exit irlan_cleanup(void) { struct irlan_cb *self, *next; IRDA_DEBUG(4, "%s()\n", __func__ ); irlmp_unregister_client(ckey); irlmp_unregister_service(skey); #ifdef CONFIG_PROC_FS remove_proc_entry("irlan", proc_irda); #endif /* CONFIG_PROC_FS */ /* Cleanup any leftover network devices */ rtnl_lock(); list_for_each_entry_safe(self, next, &irlans, dev_list) { __irlan_close(self); } rtnl_unlock(); } /* * Function irlan_open (void) * * Open new instance of a client/provider, we should only register the * network device if this instance is ment for a particular client/provider */ static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr) { struct net_device *dev; struct irlan_cb *self; IRDA_DEBUG(2, "%s()\n", __func__ ); /* Create network device with irlan */ dev = alloc_irlandev(eth ? "eth%d" : "irlan%d"); if (!dev) return NULL; self = netdev_priv(dev); self->dev = dev; /* * Initialize local device structure */ self->magic = IRLAN_MAGIC; self->saddr = saddr; self->daddr = daddr; /* Provider access can only be PEER, DIRECT, or HOSTED */ self->provider.access_type = access; if (access == ACCESS_DIRECT) { /* * Since we are emulating an IrLAN sever we will have to * give ourself an ethernet address! */ dev->dev_addr[0] = 0x40; dev->dev_addr[1] = 0x00; dev->dev_addr[2] = 0x00; dev->dev_addr[3] = 0x00; get_random_bytes(dev->dev_addr+4, 1); get_random_bytes(dev->dev_addr+5, 1); } self->media = MEDIA_802_3; self->disconnect_reason = LM_USER_REQUEST; init_timer(&self->watchdog_timer); init_timer(&self->client.kick_timer); init_waitqueue_head(&self->open_wait); skb_queue_head_init(&self->client.txq); irlan_next_client_state(self, IRLAN_IDLE); irlan_next_provider_state(self, IRLAN_IDLE); if (register_netdev(dev)) { IRDA_DEBUG(2, "%s(), register_netdev() failed!\n", __func__ ); self = NULL; free_netdev(dev); } else { rtnl_lock(); list_add_rcu(&self->dev_list, &irlans); rtnl_unlock(); } return self; } /* * Function __irlan_close (self) * * This function closes and deallocates the IrLAN client instances. Be * aware that other functions which calls client_close() must * remove self from irlans list first. */ static void __irlan_close(struct irlan_cb *self) { IRDA_DEBUG(2, "%s()\n", __func__ ); ASSERT_RTNL(); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); del_timer_sync(&self->watchdog_timer); del_timer_sync(&self->client.kick_timer); /* Close all open connections and remove TSAPs */ irlan_close_tsaps(self); if (self->client.iriap) iriap_close(self->client.iriap); /* Remove frames queued on the control channel */ skb_queue_purge(&self->client.txq); /* Unregister and free self via destructor */ unregister_netdevice(self->dev); } /* Find any instance of irlan, used for client discovery wakeup */ struct irlan_cb *irlan_get_any(void) { struct irlan_cb *self; list_for_each_entry_rcu(self, &irlans, dev_list) { return self; } return NULL; } /* * Function irlan_connect_indication (instance, sap, qos, max_sdu_size, skb) * * Here we receive the connect indication for the data channel * */ static void irlan_connect_indication(void *instance, void *sap, struct qos_info *qos, __u32 max_sdu_size, __u8 max_header_size, struct sk_buff *skb) { struct irlan_cb *self; struct tsap_cb *tsap; IRDA_DEBUG(2, "%s()\n", __func__ ); self = (struct irlan_cb *) instance; tsap = (struct tsap_cb *) sap; IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(tsap == self->tsap_data,return;); self->max_sdu_size = max_sdu_size; self->max_header_size = max_header_size; IRDA_DEBUG(0, "%s: We are now connected!\n", __func__); del_timer(&self->watchdog_timer); /* If you want to pass the skb to *both* state machines, you will * need to skb_clone() it, so that you don't free it twice. * As the state machines don't need it, git rid of it here... * Jean II */ if (skb) dev_kfree_skb(skb); irlan_do_provider_event(self, IRLAN_DATA_CONNECT_INDICATION, NULL); irlan_do_client_event(self, IRLAN_DATA_CONNECT_INDICATION, NULL); if (self->provider.access_type == ACCESS_PEER) { /* * Data channel is open, so we are now allowed to * configure the remote filter */ irlan_get_unicast_addr(self); irlan_open_unicast_addr(self); } /* Ready to transfer Ethernet frames (at last) */ netif_start_queue(self->dev); /* Clear reason */ } static void irlan_connect_confirm(void *instance, void *sap, struct qos_info *qos, __u32 max_sdu_size, __u8 max_header_size, struct sk_buff *skb) { struct irlan_cb *self; self = (struct irlan_cb *) instance; IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); self->max_sdu_size = max_sdu_size; self->max_header_size = max_header_size; /* TODO: we could set the MTU depending on the max_sdu_size */ IRDA_DEBUG(0, "%s: We are now connected!\n", __func__); del_timer(&self->watchdog_timer); /* * Data channel is open, so we are now allowed to configure the remote * filter */ irlan_get_unicast_addr(self); irlan_open_unicast_addr(self); /* Open broadcast and multicast filter by default */ irlan_set_broadcast_filter(self, TRUE); irlan_set_multicast_filter(self, TRUE); /* Ready to transfer Ethernet frames */ netif_start_queue(self->dev); self->disconnect_reason = 0; /* Clear reason */ wake_up_interruptible(&self->open_wait); } /* * Function irlan_client_disconnect_indication (handle) * * Callback function for the IrTTP layer. Indicates a disconnection of * the specified connection (handle) */ static void irlan_disconnect_indication(void *instance, void *sap, LM_REASON reason, struct sk_buff *userdata) { struct irlan_cb *self; struct tsap_cb *tsap; IRDA_DEBUG(0, "%s(), reason=%d\n", __func__ , reason); self = (struct irlan_cb *) instance; tsap = (struct tsap_cb *) sap; IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(tsap != NULL, return;); IRDA_ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;); IRDA_ASSERT(tsap == self->tsap_data, return;); IRDA_DEBUG(2, "IrLAN, data channel disconnected by peer!\n"); /* Save reason so we know if we should try to reconnect or not */ self->disconnect_reason = reason; switch (reason) { case LM_USER_REQUEST: /* User request */ IRDA_DEBUG(2, "%s(), User requested\n", __func__ ); break; case LM_LAP_DISCONNECT: /* Unexpected IrLAP disconnect */ IRDA_DEBUG(2, "%s(), Unexpected IrLAP disconnect\n", __func__ ); break; case LM_CONNECT_FAILURE: /* Failed to establish IrLAP connection */ IRDA_DEBUG(2, "%s(), IrLAP connect failed\n", __func__ ); break; case LM_LAP_RESET: /* IrLAP reset */ IRDA_DEBUG(2, "%s(), IrLAP reset\n", __func__ ); break; case LM_INIT_DISCONNECT: IRDA_DEBUG(2, "%s(), IrLMP connect failed\n", __func__ ); break; default: IRDA_ERROR("%s(), Unknown disconnect reason\n", __func__); break; } /* If you want to pass the skb to *both* state machines, you will * need to skb_clone() it, so that you don't free it twice. * As the state machines don't need it, git rid of it here... * Jean II */ if (userdata) dev_kfree_skb(userdata); irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL); irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL); wake_up_interruptible(&self->open_wait); } void irlan_open_data_tsap(struct irlan_cb *self) { struct tsap_cb *tsap; notify_t notify; IRDA_DEBUG(2, "%s()\n", __func__ ); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); /* Check if already open */ if (self->tsap_data) return; irda_notify_init(&notify); notify.data_indication = irlan_eth_receive; notify.udata_indication = irlan_eth_receive; notify.connect_indication = irlan_connect_indication; notify.connect_confirm = irlan_connect_confirm; notify.flow_indication = irlan_eth_flow_indication; notify.disconnect_indication = irlan_disconnect_indication; notify.instance = self; strlcpy(notify.name, "IrLAN data", sizeof(notify.name)); tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT, &notify); if (!tsap) { IRDA_DEBUG(2, "%s(), Got no tsap!\n", __func__ ); return; } self->tsap_data = tsap; /* * This is the data TSAP selector which we will pass to the client * when the client ask for it. */ self->stsap_sel_data = self->tsap_data->stsap_sel; } void irlan_close_tsaps(struct irlan_cb *self) { IRDA_DEBUG(4, "%s()\n", __func__ ); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); /* Disconnect and close all open TSAP connections */ if (self->tsap_data) { irttp_disconnect_request(self->tsap_data, NULL, P_NORMAL); irttp_close_tsap(self->tsap_data); self->tsap_data = NULL; } if (self->client.tsap_ctrl) { irttp_disconnect_request(self->client.tsap_ctrl, NULL, P_NORMAL); irttp_close_tsap(self->client.tsap_ctrl); self->client.tsap_ctrl = NULL; } if (self->provider.tsap_ctrl) { irttp_disconnect_request(self->provider.tsap_ctrl, NULL, P_NORMAL); irttp_close_tsap(self->provider.tsap_ctrl); self->provider.tsap_ctrl = NULL; } self->disconnect_reason = LM_USER_REQUEST; } /* * Function irlan_ias_register (self, tsap_sel) * * Register with LM-IAS * */ void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel) { struct ias_object *obj; struct ias_value *new_value; IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); /* * Check if object has already been registered by a previous provider. * If that is the case, we just change the value of the attribute */ if (!irias_find_object("IrLAN")) { obj = irias_new_object("IrLAN", IAS_IRLAN_ID); irias_add_integer_attrib(obj, "IrDA:TinyTP:LsapSel", tsap_sel, IAS_KERNEL_ATTR); irias_insert_object(obj); } else { new_value = irias_new_integer_value(tsap_sel); irias_object_change_attribute("IrLAN", "IrDA:TinyTP:LsapSel", new_value); } /* Register PnP object only if not registered before */ if (!irias_find_object("PnP")) { obj = irias_new_object("PnP", IAS_PNP_ID); #if 0 irias_add_string_attrib(obj, "Name", sysctl_devname, IAS_KERNEL_ATTR); #else irias_add_string_attrib(obj, "Name", "Linux", IAS_KERNEL_ATTR); #endif irias_add_string_attrib(obj, "DeviceID", "HWP19F0", IAS_KERNEL_ATTR); irias_add_integer_attrib(obj, "CompCnt", 1, IAS_KERNEL_ATTR); if (self->provider.access_type == ACCESS_PEER) irias_add_string_attrib(obj, "Comp#01", "PNP8389", IAS_KERNEL_ATTR); else irias_add_string_attrib(obj, "Comp#01", "PNP8294", IAS_KERNEL_ATTR); irias_add_string_attrib(obj, "Manufacturer", "Linux-IrDA Project", IAS_KERNEL_ATTR); irias_insert_object(obj); } } /* * Function irlan_run_ctrl_tx_queue (self) * * Try to send the next command in the control transmit queue * */ int irlan_run_ctrl_tx_queue(struct irlan_cb *self) { struct sk_buff *skb; IRDA_DEBUG(2, "%s()\n", __func__ ); if (irda_lock(&self->client.tx_busy) == FALSE) return -EBUSY; skb = skb_dequeue(&self->client.txq); if (!skb) { self->client.tx_busy = FALSE; return 0; } /* Check that it's really possible to send commands */ if ((self->client.tsap_ctrl == NULL) || (self->client.state == IRLAN_IDLE)) { self->client.tx_busy = FALSE; dev_kfree_skb(skb); return -1; } IRDA_DEBUG(2, "%s(), sending ...\n", __func__ ); return irttp_data_request(self->client.tsap_ctrl, skb); } /* * Function irlan_ctrl_data_request (self, skb) * * This function makes sure that commands on the control channel is being * sent in a command/response fashion */ static void irlan_ctrl_data_request(struct irlan_cb *self, struct sk_buff *skb) { IRDA_DEBUG(2, "%s()\n", __func__ ); /* Queue command */ skb_queue_tail(&self->client.txq, skb); /* Try to send command */ irlan_run_ctrl_tx_queue(self); } /* * Function irlan_get_provider_info (self) * * Send Get Provider Information command to peer IrLAN layer * */ void irlan_get_provider_info(struct irlan_cb *self) { struct sk_buff *skb; __u8 *frame; IRDA_DEBUG(4, "%s()\n", __func__ ); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER, GFP_ATOMIC); if (!skb) return; /* Reserve space for TTP, LMP, and LAP header */ skb_reserve(skb, self->client.max_header_size); skb_put(skb, 2); frame = skb->data; frame[0] = CMD_GET_PROVIDER_INFO; frame[1] = 0x00; /* Zero parameters */ irlan_ctrl_data_request(self, skb); } /* * Function irlan_open_data_channel (self) * * Send an Open Data Command to provider * */ void irlan_open_data_channel(struct irlan_cb *self) { struct sk_buff *skb; __u8 *frame; IRDA_DEBUG(4, "%s()\n", __func__ ); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3") + IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "DIRECT"), GFP_ATOMIC); if (!skb) return; skb_reserve(skb, self->client.max_header_size); skb_put(skb, 2); frame = skb->data; /* Build frame */ frame[0] = CMD_OPEN_DATA_CHANNEL; frame[1] = 0x02; /* Two parameters */ irlan_insert_string_param(skb, "MEDIA", "802.3"); irlan_insert_string_param(skb, "ACCESS_TYPE", "DIRECT"); /* irlan_insert_string_param(skb, "MODE", "UNRELIABLE"); */ /* self->use_udata = TRUE; */ irlan_ctrl_data_request(self, skb); } void irlan_close_data_channel(struct irlan_cb *self) { struct sk_buff *skb; __u8 *frame; IRDA_DEBUG(4, "%s()\n", __func__ ); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); /* Check if the TSAP is still there */ if (self->client.tsap_ctrl == NULL) return; skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN"), GFP_ATOMIC); if (!skb) return; skb_reserve(skb, self->client.max_header_size); skb_put(skb, 2); frame = skb->data; /* Build frame */ frame[0] = CMD_CLOSE_DATA_CHAN; frame[1] = 0x01; /* One parameter */ irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); irlan_ctrl_data_request(self, skb); } /* * Function irlan_open_unicast_addr (self) * * Make IrLAN provider accept ethernet frames addressed to the unicast * address. * */ static void irlan_open_unicast_addr(struct irlan_cb *self) { struct sk_buff *skb; __u8 *frame; IRDA_DEBUG(4, "%s()\n", __func__ ); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") + IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "FILTER"), GFP_ATOMIC); if (!skb) return; /* Reserve space for TTP, LMP, and LAP header */ skb_reserve(skb, self->max_header_size); skb_put(skb, 2); frame = skb->data; frame[0] = CMD_FILTER_OPERATION; frame[1] = 0x03; /* Three parameters */ irlan_insert_byte_param(skb, "DATA_CHAN" , self->dtsap_sel_data); irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED"); irlan_insert_string_param(skb, "FILTER_MODE", "FILTER"); irlan_ctrl_data_request(self, skb); } /* * Function irlan_set_broadcast_filter (self, status) * * Make IrLAN provider accept ethernet frames addressed to the broadcast * address. Be careful with the use of this one, since there may be a lot * of broadcast traffic out there. We can still function without this * one but then _we_ have to initiate all communication with other * hosts, since ARP request for this host will not be answered. */ void irlan_set_broadcast_filter(struct irlan_cb *self, int status) { struct sk_buff *skb; __u8 *frame; IRDA_DEBUG(2, "%s()\n", __func__ ); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BROADCAST") + /* We may waste one byte here...*/ IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "FILTER"), GFP_ATOMIC); if (!skb) return; /* Reserve space for TTP, LMP, and LAP header */ skb_reserve(skb, self->client.max_header_size); skb_put(skb, 2); frame = skb->data; frame[0] = CMD_FILTER_OPERATION; frame[1] = 0x03; /* Three parameters */ irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); irlan_insert_string_param(skb, "FILTER_TYPE", "BROADCAST"); if (status) irlan_insert_string_param(skb, "FILTER_MODE", "FILTER"); else irlan_insert_string_param(skb, "FILTER_MODE", "NONE"); irlan_ctrl_data_request(self, skb); } /* * Function irlan_set_multicast_filter (self, status) * * Make IrLAN provider accept ethernet frames addressed to the multicast * address. * */ void irlan_set_multicast_filter(struct irlan_cb *self, int status) { struct sk_buff *skb; __u8 *frame; IRDA_DEBUG(2, "%s()\n", __func__ ); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "MULTICAST") + /* We may waste one byte here...*/ IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "NONE"), GFP_ATOMIC); if (!skb) return; /* Reserve space for TTP, LMP, and LAP header */ skb_reserve(skb, self->client.max_header_size); skb_put(skb, 2); frame = skb->data; frame[0] = CMD_FILTER_OPERATION; frame[1] = 0x03; /* Three parameters */ irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); irlan_insert_string_param(skb, "FILTER_TYPE", "MULTICAST"); if (status) irlan_insert_string_param(skb, "FILTER_MODE", "ALL"); else irlan_insert_string_param(skb, "FILTER_MODE", "NONE"); irlan_ctrl_data_request(self, skb); } /* * Function irlan_get_unicast_addr (self) * * Retrieves the unicast address from the IrLAN provider. This address * will be inserted into the devices structure, so the ethernet layer * can construct its packets. * */ static void irlan_get_unicast_addr(struct irlan_cb *self) { struct sk_buff *skb; __u8 *frame; IRDA_DEBUG(2, "%s()\n", __func__ ); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") + IRLAN_STRING_PARAMETER_LEN("FILTER_OPERATION", "DYNAMIC"), GFP_ATOMIC); if (!skb) return; /* Reserve space for TTP, LMP, and LAP header */ skb_reserve(skb, self->client.max_header_size); skb_put(skb, 2); frame = skb->data; frame[0] = CMD_FILTER_OPERATION; frame[1] = 0x03; /* Three parameters */ irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED"); irlan_insert_string_param(skb, "FILTER_OPERATION", "DYNAMIC"); irlan_ctrl_data_request(self, skb); } /* * Function irlan_get_media_char (self) * * * */ void irlan_get_media_char(struct irlan_cb *self) { struct sk_buff *skb; __u8 *frame; IRDA_DEBUG(4, "%s()\n", __func__ ); IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3"), GFP_ATOMIC); if (!skb) return; /* Reserve space for TTP, LMP, and LAP header */ skb_reserve(skb, self->client.max_header_size); skb_put(skb, 2); frame = skb->data; /* Build frame */ frame[0] = CMD_GET_MEDIA_CHAR; frame[1] = 0x01; /* One parameter */ irlan_insert_string_param(skb, "MEDIA", "802.3"); irlan_ctrl_data_request(self, skb); } /* * Function insert_byte_param (skb, param, value) * * Insert byte parameter into frame * */ int irlan_insert_byte_param(struct sk_buff *skb, char *param, __u8 value) { return __irlan_insert_param(skb, param, IRLAN_BYTE, value, 0, NULL, 0); } int irlan_insert_short_param(struct sk_buff *skb, char *param, __u16 value) { return __irlan_insert_param(skb, param, IRLAN_SHORT, 0, value, NULL, 0); } /* * Function insert_string (skb, param, value) * * Insert string parameter into frame * */ int irlan_insert_string_param(struct sk_buff *skb, char *param, char *string) { int string_len = strlen(string); return __irlan_insert_param(skb, param, IRLAN_ARRAY, 0, 0, string, string_len); } /* * Function insert_array_param(skb, param, value, len_value) * * Insert array parameter into frame * */ int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *array, __u16 array_len) { return __irlan_insert_param(skb, name, IRLAN_ARRAY, 0, 0, array, array_len); } /* * Function insert_param (skb, param, value, byte) * * Insert parameter at end of buffer, structure of a parameter is: * * ----------------------------------------------------------------------- * | Name Length[1] | Param Name[1..255] | Val Length[2] | Value[0..1016]| * ----------------------------------------------------------------------- */ static int __irlan_insert_param(struct sk_buff *skb, char *param, int type, __u8 value_byte, __u16 value_short, __u8 *value_array, __u16 value_len) { __u8 *frame; __u8 param_len; __le16 tmp_le; /* Temporary value in little endian format */ int n=0; if (skb == NULL) { IRDA_DEBUG(2, "%s(), Got NULL skb\n", __func__ ); return 0; } param_len = strlen(param); switch (type) { case IRLAN_BYTE: value_len = 1; break; case IRLAN_SHORT: value_len = 2; break; case IRLAN_ARRAY: IRDA_ASSERT(value_array != NULL, return 0;); IRDA_ASSERT(value_len > 0, return 0;); break; default: IRDA_DEBUG(2, "%s(), Unknown parameter type!\n", __func__ ); return 0; break; } /* Insert at end of sk-buffer */ frame = skb_tail_pointer(skb); /* Make space for data */ if (skb_tailroom(skb) < (param_len+value_len+3)) { IRDA_DEBUG(2, "%s(), No more space at end of skb\n", __func__ ); return 0; } skb_put(skb, param_len+value_len+3); /* Insert parameter length */ frame[n++] = param_len; /* Insert parameter */ memcpy(frame+n, param, param_len); n += param_len; /* Insert value length (2 byte little endian format, LSB first) */ tmp_le = cpu_to_le16(value_len); memcpy(frame+n, &tmp_le, 2); n += 2; /* To avoid alignment problems */ /* Insert value */ switch (type) { case IRLAN_BYTE: frame[n++] = value_byte; break; case IRLAN_SHORT: tmp_le = cpu_to_le16(value_short); memcpy(frame+n, &tmp_le, 2); n += 2; break; case IRLAN_ARRAY: memcpy(frame+n, value_array, value_len); n+=value_len; break; default: break; } IRDA_ASSERT(n == (param_len+value_len+3), return 0;); return param_len+value_len+3; } /* * Function irlan_extract_param (buf, name, value, len) * * Extracts a single parameter name/value pair from buffer and updates * the buffer pointer to point to the next name/value pair. */ int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len) { __u8 name_len; __u16 val_len; int n=0; IRDA_DEBUG(4, "%s()\n", __func__ ); /* get length of parameter name (1 byte) */ name_len = buf[n++]; if (name_len > 254) { IRDA_DEBUG(2, "%s(), name_len > 254\n", __func__ ); return -RSP_INVALID_COMMAND_FORMAT; } /* get parameter name */ memcpy(name, buf+n, name_len); name[name_len] = '\0'; n+=name_len; /* * Get length of parameter value (2 bytes in little endian * format) */ memcpy(&val_len, buf+n, 2); /* To avoid alignment problems */ le16_to_cpus(&val_len); n+=2; if (val_len >= 1016) { IRDA_DEBUG(2, "%s(), parameter length to long\n", __func__ ); return -RSP_INVALID_COMMAND_FORMAT; } *len = val_len; /* get parameter value */ memcpy(value, buf+n, val_len); value[val_len] = '\0'; n+=val_len; IRDA_DEBUG(4, "Parameter: %s ", name); IRDA_DEBUG(4, "Value: %s\n", value); return n; } #ifdef CONFIG_PROC_FS /* * Start of reading /proc entries. * Return entry at pos, * or start_token to indicate print header line * or NULL if end of file */ static void *irlan_seq_start(struct seq_file *seq, loff_t *pos) { rcu_read_lock(); return seq_list_start_head(&irlans, *pos); } /* Return entry after v, and increment pos */ static void *irlan_seq_next(struct seq_file *seq, void *v, loff_t *pos) { return seq_list_next(v, &irlans, pos); } /* End of reading /proc file */ static void irlan_seq_stop(struct seq_file *seq, void *v) { rcu_read_unlock(); } /* * Show one entry in /proc file. */ static int irlan_seq_show(struct seq_file *seq, void *v) { if (v == &irlans) seq_puts(seq, "IrLAN instances:\n"); else { struct irlan_cb *self = list_entry(v, struct irlan_cb, dev_list); IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;); seq_printf(seq,"ifname: %s,\n", self->dev->name); seq_printf(seq,"client state: %s, ", irlan_state[ self->client.state]); seq_printf(seq,"provider state: %s,\n", irlan_state[ self->provider.state]); seq_printf(seq,"saddr: %#08x, ", self->saddr); seq_printf(seq,"daddr: %#08x\n", self->daddr); seq_printf(seq,"version: %d.%d,\n", self->version[1], self->version[0]); seq_printf(seq,"access type: %s\n", irlan_access[self->client.access_type]); seq_printf(seq,"media: %s\n", irlan_media[self->media]); seq_printf(seq,"local filter:\n"); seq_printf(seq,"remote filter: "); irlan_print_filter(seq, self->client.filter_type); seq_printf(seq,"tx busy: %s\n", netif_queue_stopped(self->dev) ? "TRUE" : "FALSE"); seq_putc(seq,'\n'); } return 0; } static const struct seq_operations irlan_seq_ops = { .start = irlan_seq_start, .next = irlan_seq_next, .stop = irlan_seq_stop, .show = irlan_seq_show, }; static int irlan_seq_open(struct inode *inode, struct file *file) { return seq_open(file, &irlan_seq_ops); } #endif MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>"); MODULE_DESCRIPTION("The Linux IrDA LAN protocol"); MODULE_LICENSE("GPL"); module_param(eth, bool, 0); MODULE_PARM_DESC(eth, "Name devices ethX (0) or irlanX (1)"); module_param(access, int, 0); MODULE_PARM_DESC(access, "Access type DIRECT=1, PEER=2, HOSTED=3"); module_init(irlan_init); module_exit(irlan_cleanup);
gpl-2.0
vasudev-33/secureModule
drivers/clk/mxs/clk-ref.c
4028
3381
/* * Copyright 2012 Freescale Semiconductor, Inc. * * The code contained herein is licensed under the GNU General Public * License. You may obtain a copy of the GNU General Public License * Version 2 or later at the following locations: * * http://www.opensource.org/licenses/gpl-license.html * http://www.gnu.org/copyleft/gpl.html */ #include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/err.h> #include <linux/io.h> #include <linux/slab.h> #include "clk.h" /** * struct clk_ref - mxs reference clock * @hw: clk_hw for the reference clock * @reg: register address * @idx: the index of the reference clock within the same register * * The mxs reference clock sources from pll. Every 4 reference clocks share * one register space, and @idx is used to identify them. Each reference * clock has a gate control and a fractional * divider. The rate is calculated * as pll rate * (18 / FRAC), where FRAC = 18 ~ 35. */ struct clk_ref { struct clk_hw hw; void __iomem *reg; u8 idx; }; #define to_clk_ref(_hw) container_of(_hw, struct clk_ref, hw) static int clk_ref_enable(struct clk_hw *hw) { struct clk_ref *ref = to_clk_ref(hw); writel_relaxed(1 << ((ref->idx + 1) * 8 - 1), ref->reg + CLR); return 0; } static void clk_ref_disable(struct clk_hw *hw) { struct clk_ref *ref = to_clk_ref(hw); writel_relaxed(1 << ((ref->idx + 1) * 8 - 1), ref->reg + SET); } static unsigned long clk_ref_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { struct clk_ref *ref = to_clk_ref(hw); u64 tmp = parent_rate; u8 frac = (readl_relaxed(ref->reg) >> (ref->idx * 8)) & 0x3f; tmp *= 18; do_div(tmp, frac); return tmp; } static long clk_ref_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *prate) { unsigned long parent_rate = *prate; u64 tmp = parent_rate; u8 frac; tmp = tmp * 18 + rate / 2; do_div(tmp, rate); frac = tmp; if (frac < 18) frac = 18; else if (frac > 35) frac = 35; tmp = parent_rate; tmp *= 18; do_div(tmp, frac); return tmp; } static int clk_ref_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { struct clk_ref *ref = to_clk_ref(hw); unsigned long flags; u64 tmp = parent_rate; u32 val; u8 frac, shift = ref->idx * 8; tmp = tmp * 18 + rate / 2; do_div(tmp, rate); frac = tmp; if (frac < 18) frac = 18; else if (frac > 35) frac = 35; spin_lock_irqsave(&mxs_lock, flags); val = readl_relaxed(ref->reg); val &= ~(0x3f << shift); val |= frac << shift; writel_relaxed(val, ref->reg); spin_unlock_irqrestore(&mxs_lock, flags); return 0; } static const struct clk_ops clk_ref_ops = { .enable = clk_ref_enable, .disable = clk_ref_disable, .recalc_rate = clk_ref_recalc_rate, .round_rate = clk_ref_round_rate, .set_rate = clk_ref_set_rate, }; struct clk *mxs_clk_ref(const char *name, const char *parent_name, void __iomem *reg, u8 idx) { struct clk_ref *ref; struct clk *clk; struct clk_init_data init; ref = kzalloc(sizeof(*ref), GFP_KERNEL); if (!ref) return ERR_PTR(-ENOMEM); init.name = name; init.ops = &clk_ref_ops; init.flags = 0; init.parent_names = (parent_name ? &parent_name: NULL); init.num_parents = (parent_name ? 1 : 0); ref->reg = reg; ref->idx = idx; ref->hw.init = &init; clk = clk_register(NULL, &ref->hw); if (IS_ERR(clk)) kfree(ref); return clk; }
gpl-2.0
sbreen94/Zeus_S4_r3
drivers/staging/media/as102/as102_fw.c
4796
5759
/* * Abilis Systems Single DVB-T Receiver * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com> * Copyright (C) 2010 Devin Heitmueller <dheitmueller@kernellabs.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, 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/errno.h> #include <linux/ctype.h> #include <linux/delay.h> #include <linux/firmware.h> #include "as102_drv.h" #include "as102_fw.h" char as102_st_fw1[] = "as102_data1_st.hex"; char as102_st_fw2[] = "as102_data2_st.hex"; char as102_dt_fw1[] = "as102_data1_dt.hex"; char as102_dt_fw2[] = "as102_data2_dt.hex"; static unsigned char atohx(unsigned char *dst, char *src) { unsigned char value = 0; char msb = tolower(*src) - '0'; char lsb = tolower(*(src + 1)) - '0'; if (msb > 9) msb -= 7; if (lsb > 9) lsb -= 7; *dst = value = ((msb & 0xF) << 4) | (lsb & 0xF); return value; } /* * Parse INTEL HEX firmware file to extract address and data. */ static int parse_hex_line(unsigned char *fw_data, unsigned char *addr, unsigned char *data, int *dataLength, unsigned char *addr_has_changed) { int count = 0; unsigned char *src, dst; if (*fw_data++ != ':') { pr_err("invalid firmware file\n"); return -EFAULT; } /* locate end of line */ for (src = fw_data; *src != '\n'; src += 2) { atohx(&dst, src); /* parse line to split addr / data */ switch (count) { case 0: *dataLength = dst; break; case 1: addr[2] = dst; break; case 2: addr[3] = dst; break; case 3: /* check if data is an address */ if (dst == 0x04) *addr_has_changed = 1; else *addr_has_changed = 0; break; case 4: case 5: if (*addr_has_changed) addr[(count - 4)] = dst; else data[(count - 4)] = dst; break; default: data[(count - 4)] = dst; break; } count++; } /* return read value + ':' + '\n' */ return (count * 2) + 2; } static int as102_firmware_upload(struct as10x_bus_adapter_t *bus_adap, unsigned char *cmd, const struct firmware *firmware) { struct as10x_fw_pkt_t fw_pkt; int total_read_bytes = 0, errno = 0; unsigned char addr_has_changed = 0; ENTER(); for (total_read_bytes = 0; total_read_bytes < firmware->size; ) { int read_bytes = 0, data_len = 0; /* parse intel hex line */ read_bytes = parse_hex_line( (u8 *) (firmware->data + total_read_bytes), fw_pkt.raw.address, fw_pkt.raw.data, &data_len, &addr_has_changed); if (read_bytes <= 0) goto error; /* detect the end of file */ total_read_bytes += read_bytes; if (total_read_bytes == firmware->size) { fw_pkt.u.request[0] = 0x00; fw_pkt.u.request[1] = 0x03; /* send EOF command */ errno = bus_adap->ops->upload_fw_pkt(bus_adap, (uint8_t *) &fw_pkt, 2, 0); if (errno < 0) goto error; } else { if (!addr_has_changed) { /* prepare command to send */ fw_pkt.u.request[0] = 0x00; fw_pkt.u.request[1] = 0x01; data_len += sizeof(fw_pkt.u.request); data_len += sizeof(fw_pkt.raw.address); /* send cmd to device */ errno = bus_adap->ops->upload_fw_pkt(bus_adap, (uint8_t *) &fw_pkt, data_len, 0); if (errno < 0) goto error; } } } error: LEAVE(); return (errno == 0) ? total_read_bytes : errno; } int as102_fw_upload(struct as10x_bus_adapter_t *bus_adap) { int errno = -EFAULT; const struct firmware *firmware = NULL; unsigned char *cmd_buf = NULL; char *fw1, *fw2; struct usb_device *dev = bus_adap->usb_dev; ENTER(); /* select fw file to upload */ if (dual_tuner) { fw1 = as102_dt_fw1; fw2 = as102_dt_fw2; } else { fw1 = as102_st_fw1; fw2 = as102_st_fw2; } /* allocate buffer to store firmware upload command and data */ cmd_buf = kzalloc(MAX_FW_PKT_SIZE, GFP_KERNEL); if (cmd_buf == NULL) { errno = -ENOMEM; goto error; } /* request kernel to locate firmware file: part1 */ errno = request_firmware(&firmware, fw1, &dev->dev); if (errno < 0) { pr_err("%s: unable to locate firmware file: %s\n", DRIVER_NAME, fw1); goto error; } /* initiate firmware upload */ errno = as102_firmware_upload(bus_adap, cmd_buf, firmware); if (errno < 0) { pr_err("%s: error during firmware upload part1\n", DRIVER_NAME); goto error; } pr_info("%s: firmware: %s loaded with success\n", DRIVER_NAME, fw1); release_firmware(firmware); /* wait for boot to complete */ mdelay(100); /* request kernel to locate firmware file: part2 */ errno = request_firmware(&firmware, fw2, &dev->dev); if (errno < 0) { pr_err("%s: unable to locate firmware file: %s\n", DRIVER_NAME, fw2); goto error; } /* initiate firmware upload */ errno = as102_firmware_upload(bus_adap, cmd_buf, firmware); if (errno < 0) { pr_err("%s: error during firmware upload part2\n", DRIVER_NAME); goto error; } pr_info("%s: firmware: %s loaded with success\n", DRIVER_NAME, fw2); error: /* free data buffer */ kfree(cmd_buf); /* release firmware if needed */ if (firmware != NULL) release_firmware(firmware); LEAVE(); return errno; }
gpl-2.0